-
Notifications
You must be signed in to change notification settings - Fork 38
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
fix: ModularAccountBase cleanup, coverage, custom error types #257
Conversation
Summary by OctaneNew Contracts
Updated Contracts
🔗 Commit Hash: 2530de6 |
Contract sizes: | Contract | Size (B) | Margin (B) |
|-------------------------------|----------|------------|
| AccountFactory | 4,814 | 19,762 |
| AllowlistModule | 9,230 | 15,346 |
-| ModularAccount | 25,167 | -591 |
+| ModularAccount | 25,293 | -717 |
| NativeTokenLimitModule | 4,714 | 19,862 |
| PaymasterGuardModule | 1,797 | 22,779 |
-| SemiModularAccountBytecode | 27,775 | -3,199 |
-| SemiModularAccountStorageOnly | 28,293 | -3,717 |
+| SemiModularAccountBytecode | 27,912 | -3,336 |
+| SemiModularAccountStorageOnly | 28,430 | -3,854 |
| SingleSignerValidationModule | 4,300 | 20,276 |
| TimeRangeModule | 2,000 | 22,576 |
| WebAuthnValidationModule | 7,854 | 16,722 | Code coverage:
|
error SignatureValidationInvalid(ModuleEntity validationFunction); | ||
error UserOpValidationInvalid(ModuleEntity validationFunction); | ||
error UnexpectedAggregator(ModuleEntity validationFunction, address aggregator); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are theseModuleEntity
while the execution lib errors below are unpacked?
Also nit: Mind sorting this entire block of errors? (see CreateFailed at the bottom)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last I tested, this was both cheaper and smaller in codesize, but let me re-test to be sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok it is actually ever so slightly less codesize - updated!
This comment was marked as resolved.
This comment was marked as resolved.
uint32 errorSelector; | ||
|
||
assembly ("memory-safe") { | ||
selectorUsed := and(mload(add(buffer, 0x4)), 0xffffffff) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clever way to load the first 4 bytes of 0x20!
// - entity Id | ||
// - revert data | ||
|
||
assembly ("memory-safe") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to do
revert(abi.encodeWithselector(this.error.selector, ...)
If so, are we sure it'd be cheaper to do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do that, then we'd have to call the high-level function collectRevertData
first, and the abi.encode...
expression would copy that memory over to the new memory with the data for the revert. I believe this saves on both gas and codesize due to that added copy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gotcha, lgtm!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small comment, lgtm
e6933ab
to
1987ab5
Compare
test: expand test coverage for MABase refactor: remove duplicate error definitions refactor: simplify error types in MABase feat: custom errors for all module functions feat: change error param to moduleentity fix: reorder errors style: fix import formatting
1987ab5
to
2530de6
Compare
Motivation
Cleanup pass on
ModularAccountBase.sol
.During this pass, discovered that we lack custom errors for UO and Sig validation module functions.
Solution