mirror of
https://github.com/getwax/zk-account-abstraction.git
synced 2026-01-08 20:18:05 -05:00
fix SimpleWallet slot allocations (#226)
Fit nonce and owner into the same slot, to save unneeded SLOAD during validation (They used to be in the same slot, and got "unaligned" when added a proxy, since using "Initializeable" uses the first 2 bytes in the storage.
This commit is contained in:
@@ -20,6 +20,10 @@ import "../core/BaseAccount.sol";
|
||||
contract SimpleAccount is BaseAccount, UUPSUpgradeable, Initializable {
|
||||
using ECDSA for bytes32;
|
||||
|
||||
//filler member, to push the nonce and owner to the same slot
|
||||
// the "Initializeble" class takes 2 bytes in the first slot
|
||||
bytes28 private _filler;
|
||||
|
||||
//explicit sizes of nonce, to fit a single storage cell with "owner"
|
||||
uint96 private _nonce;
|
||||
address public owner;
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
== gas estimate of direct calling the account's "execFromEntryPoint" method
|
||||
the destination is "account.nonce()", which is known to be "hot" address used by this account
|
||||
it little higher than EOA call: its an exec from entrypoint (or account owner) into account contract, verifying msg.sender and exec to target)
|
||||
- gas estimate "simple" - 31045
|
||||
- gas estimate "big tx 5k" - 127295
|
||||
- gas estimate "simple" - 31033
|
||||
- gas estimate "big tx 5k" - 127284
|
||||
╔════════════════════════════════╤═══════╤═══════════════╤════════════════╤═════════════════════╗
|
||||
║ handleOps description │ count │ total gasUsed │ per UserOp gas │ per UserOp overhead ║
|
||||
║ │ │ │ (delta for │ (compared to ║
|
||||
║ │ │ │ one UserOp) │ account.exec()) ║
|
||||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
|
||||
║ simple │ 1 │ 78018 │ │ ║
|
||||
║ simple │ 1 │ 75948 │ │ ║
|
||||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
|
||||
║ simple - diff from previous │ 2 │ │ 43447 │ 12402 ║
|
||||
║ simple - diff from previous │ 2 │ │ 41449 │ 10416 ║
|
||||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
|
||||
║ simple │ 10 │ 469609 │ │ ║
|
||||
║ simple │ 10 │ 449053 │ │ ║
|
||||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
|
||||
║ simple - diff from previous │ 11 │ │ 43630 │ 12585 ║
|
||||
║ simple - diff from previous │ 11 │ │ 41560 │ 10527 ║
|
||||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
|
||||
║ simple paymaster │ 1 │ 84303 │ │ ║
|
||||
║ simple paymaster │ 1 │ 82245 │ │ ║
|
||||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
|
||||
║ simple paymaster with diff │ 2 │ │ 42490 │ 11445 ║
|
||||
║ simple paymaster with diff │ 2 │ │ 40408 │ 9375 ║
|
||||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
|
||||
║ simple paymaster │ 10 │ 466934 │ │ ║
|
||||
║ simple paymaster │ 10 │ 446306 │ │ ║
|
||||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
|
||||
║ simple paymaster with diff │ 11 │ │ 42602 │ 11557 ║
|
||||
║ simple paymaster with diff │ 11 │ │ 40604 │ 9571 ║
|
||||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
|
||||
║ big tx 5k │ 1 │ 179739 │ │ ║
|
||||
║ big tx 5k │ 1 │ 177693 │ │ ║
|
||||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
|
||||
║ big tx - diff from previous │ 2 │ │ 144794 │ 17499 ║
|
||||
║ big tx - diff from previous │ 2 │ │ 142772 │ 15488 ║
|
||||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
|
||||
║ big tx 5k │ 10 │ 1488695 │ │ ║
|
||||
║ big tx 5k │ 10 │ 1468115 │ │ ║
|
||||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
|
||||
║ big tx - diff from previous │ 11 │ │ 146324 │ 19029 ║
|
||||
║ big tx - diff from previous │ 11 │ │ 144290 │ 17006 ║
|
||||
╚════════════════════════════════╧═══════╧═══════════════╧════════════════╧═════════════════════╝
|
||||
|
||||
|
||||
Reference in New Issue
Block a user