Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: deferred install gas benchmarks #188

Merged
merged 10 commits into from
Sep 26, 2024

Conversation

Zer0dot
Copy link
Contributor

@Zer0dot Zer0dot commented Sep 24, 2024

Motivation

Installing deferred validations will likely be a fairly high volume action. Benchmarking gas use for a simple case deferred validation grants us insights into gas consumption for this pretty common action.

Solution

Simply copy and lightly modify the standard test file (DeferredValidation.t.sol) internal functions for deferred validation into the base benchmark gas contract (ModularAccountBenchmarkBase.sol.

Then, add the gas tests for deferred validation for both the standard MA and the SMA with bytecode.

Copy link

octane-security-app-dev bot commented Sep 24, 2024

Summary by Octane

New Contracts

No new contracts were added in this PR.

Updated Contracts

  • ModularAccountBenchmarkBase.sol: Added ValidationConfigLib to enhance validation configurations in smart contracts and streamlined the code for better modularity and organization.
  • ModuleSignatureUtils.sol: Enhanced modular account validation by introducing deferred validation and expanded signature encoding functionalities.

🔗 Commit Hash: 469cc79

Copy link

octane-security-app-dev bot commented Sep 24, 2024

Overview

Octane AI analysis has finished. No vulnerabilities were found. Cheers! 🎉🎉🎉


🔗 Commit Hash: 1467bb5

Copy link

github-actions bot commented Sep 24, 2024

Contract sizes:

| Contract                     | Size (B) | Margin (B) |
|------------------------------|----------|------------|
| AccountFactory               |    4,169 |     20,407 |
| AllowlistModule              |    5,817 |     18,759 |
| ERC20TokenLimitModule        |    4,138 |     20,438 |
| ModularAccount               |   25,983 |     -1,407 |
| SemiModularAccount           |   26,487 |     -1,911 |
| SingleSignerValidationModule |    3,444 |     21,132 |
| TimeRangeModule              |    1,870 |     22,706 |
| TokenReceiverModule          |    2,189 |     22,387 |

Code coverage:

File % Lines % Statements % Branches % Funcs
src/account/AccountExecutor.sol 100.00% (4/4) 100.00% (4/4) 100.00% (1/1) 100.00% (1/1)
src/account/AccountStorageInitializable.sol 84.21% (16/19) 84.62% (22/26) 60.00% (3/5) 100.00% (2/2)
src/account/BaseAccount.sol 83.33% (5/6) 80.00% (4/5) 50.00% (1/2) 100.00% (2/2)
src/account/ModularAccount.sol 92.92% (223/240) 93.46% (300/321) 82.50% (33/40) 97.44% (38/39)
src/account/ModularAccountView.sol 96.55% (28/29) 95.24% (40/42) 100.00% (2/2) 100.00% (2/2)
src/account/ModuleManagerInternals.sol 88.10% (111/126) 88.17% (149/169) 42.86% (6/14) 100.00% (11/11)
src/account/SemiModularAccount.sol 0.00% (0/50) 0.00% (0/66) 0.00% (0/9) 0.00% (0/17)
src/factory/AccountFactory.sol 34.48% (10/29) 35.00% (14/40) 50.00% (1/2) 18.18% (2/11)
src/libraries/HookConfigLib.sol 47.06% (8/17) 65.62% (21/32) 100.00% (0/0) 66.67% (8/12)
src/libraries/KnownSelectorsLib.sol 100.00% (27/27) 100.00% (60/60) 100.00% (0/0) 100.00% (3/3)
src/libraries/ModuleEntityLib.sol 62.50% (5/8) 45.00% (9/20) 100.00% (0/0) 50.00% (3/6)
src/libraries/SparseCalldataSegmentLib.sol 100.00% (23/23) 100.00% (29/29) 100.00% (5/5) 100.00% (6/6)
src/libraries/ValidationConfigLib.sol 44.44% (8/18) 52.63% (20/38) 100.00% (0/0) 61.54% (8/13)
src/modules/BaseModule.sol 100.00% (11/11) 100.00% (15/15) 100.00% (1/1) 100.00% (2/2)
src/modules/ERC20TokenLimitModule.sol 70.27% (26/37) 76.92% (40/52) 70.00% (7/10) 55.56% (5/9)
src/modules/ModuleEIP712.sol 100.00% (1/1) 100.00% (2/2) 100.00% (0/0) 100.00% (1/1)
src/modules/ReplaySafeWrapper.sol 100.00% (6/6) 100.00% (7/7) 100.00% (0/0) 100.00% (2/2)
src/modules/TokenReceiverModule.sol 70.00% (7/10) 69.23% (9/13) 100.00% (0/0) 28.57% (2/7)
src/modules/permissions/AllowlistModule.sol 76.19% (32/42) 75.00% (42/56) 77.78% (7/9) 41.67% (5/12)
src/modules/permissions/TimeRangeModule.sol 100.00% (12/12) 100.00% (20/20) 100.00% (1/1) 75.00% (6/8)
src/modules/validation/SingleSignerValidationModule.sol 88.89% (16/18) 91.30% (21/23) 100.00% (3/3) 88.89% (8/9)
Total 78.99% (579/733) 79.62% (828/1040) 68.27% (71/104) 66.86% (117/175)

Copy link
Contributor

@adamegyed adamegyed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Had some comments.

gas/modular-account/ModularAccountBenchmarkBase.sol Outdated Show resolved Hide resolved
gas/modular-account/ModularAccountBenchmarkBase.sol Outdated Show resolved Hide resolved
gas/modular-account/ModularAccountBenchmarkBase.sol Outdated Show resolved Hide resolved
@Zer0dot Zer0dot force-pushed the zer0dot/deferred-install-benchmark branch from 68dffc5 to 50b7c06 Compare September 26, 2024 01:15
Copy link
Contributor

@adamegyed adamegyed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just some small style nits

Comment on lines 12 to 17

import {ValidationConfig, ValidationConfigLib} from "../../src/libraries/ValidationConfigLib.sol";
import {SingleSignerValidationModule} from "../../src/modules/validation/SingleSignerValidationModule.sol";

import {ModuleSignatureUtils} from "../../test/utils/ModuleSignatureUtils.sol";
import {BenchmarkBase} from "..//BenchmarkBase.sol";

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: forge fmt likes to randomly insert newlines when sorting imports, could we remove these? The fmt checker passes after removing these lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Wonder why the formatter does that..

@@ -3,10 +3,12 @@ pragma solidity ^0.8.26;

import {PackedUserOperation} from "@eth-infinitism/account-abstraction/interfaces/PackedUserOperation.sol";
import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also here

import {PackedUserOperation} from "@eth-infinitism/account-abstraction/interfaces/PackedUserOperation.sol";
import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";

import {ModuleEntity, ModuleEntityLib} from "../../src/libraries/ModuleEntityLib.sol";
import {ValidationConfig, ValidationConfigLib} from "../../src/libraries/ValidationConfigLib.sol";

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

@Zer0dot Zer0dot force-pushed the zer0dot/deferred-install-benchmark branch from 1467bb5 to e5850ff Compare September 26, 2024 18:40
@Zer0dot Zer0dot merged commit 82d7fe7 into develop Sep 26, 2024
6 checks passed
@Zer0dot Zer0dot deleted the zer0dot/deferred-install-benchmark branch September 26, 2024 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants