Skip to content

Commit

Permalink
optimize getting function selector
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsoncusack committed Apr 19, 2024
1 parent ceb82f2 commit ad4309c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
34 changes: 17 additions & 17 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ CoinbaseSmartWalletFactoryTest:test_implementation_returnsExpectedAddress() (gas
CoinbaseSmartWalletFactoryTest:test_initCodeHash() (gas: 7890)
CoinbaseSmartWalletFactoryTest:test_revertsIfNoOwners() (gas: 29214)
ERC1271Test:test_returnsExpectedDomainHashWhenProxy() (gas: 29198)
ERC1271Test:test_static() (gas: 3243921)
ERC1271Test:test_static() (gas: 3229650)
MultiOwnableInitializeTest:testRevertsIfLength32ButLargerThanAddress() (gas: 81111)
MultiOwnableInitializeTest:testRevertsIfLength32NotAddress() (gas: 81092)
MultiOwnableInitializeTest:testRevertsIfLengthNot32Or64() (gas: 103395)
Expand All @@ -40,33 +40,33 @@ RemoveOwnerAtIndexTest:test_revert_whenCalledByNonOwner(address) (runs: 256, μ:
RemoveOwnerAtIndexTest:test_revert_whenNoOwnerAtIndex() (gas: 33372)
RemoveOwnerAtIndexTest:test_revert_whenWrongOwnerAtIndex() (gas: 36694)
RemoveOwnerAtIndexTest:test_reverts_ifIsLastOwner() (gas: 7471805)
TestCanSkipChainIdValidation:test_approvedSelectorsReturnTrue() (gas: 15845)
TestCanSkipChainIdValidation:test_otherSelectorsReturnFalse() (gas: 12469)
TestCanSkipChainIdValidation:test_approvedSelectorsReturnTrue() (gas: 17781)
TestCanSkipChainIdValidation:test_otherSelectorsReturnFalse() (gas: 12579)
TestExecuteWithoutChainIdValidation:testExecute() (gas: 424837)
TestExecuteWithoutChainIdValidation:testExecuteBatch() (gas: 728897)
TestExecuteWithoutChainIdValidation:testExecuteBatch(uint256) (runs: 256, μ: 3612753, ~: 3472828)
TestExecuteWithoutChainIdValidation:test__codesize() (gas: 49960)
TestExecuteWithoutChainIdValidation:test__codesize() (gas: 50195)
TestExecuteWithoutChainIdValidation:test_revertsWithReservedNonce() (gas: 82347)
TestExecuteWithoutChainIdValidation:testExecuteBatch(uint256) (runs: 256, μ: 3597261, ~: 3458766)
TestExecuteWithoutChainIdValidation:test__codesize() (gas: 49890)
TestExecuteWithoutChainIdValidation:test__codesize() (gas: 50125)
TestExecuteWithoutChainIdValidation:test_revertsWithReservedNonce() (gas: 81983)
TestExecuteWithoutChainIdValidation:test_reverts_whenCallerNotEntryPoint() (gas: 11053)
TestExecuteWithoutChainIdValidation:test_reverts_whenOneCallReverts() (gas: 467906)
TestExecuteWithoutChainIdValidation:test_reverts_whenOneSelectorNotApproved() (gas: 179678)
TestExecuteWithoutChainIdValidation:test_reverts_whenSelectorNotApproved() (gas: 106769)
TestExecuteWithoutChainIdValidation:test_succeeds_whenSelectorAllowed() (gas: 424367)
TestExecuteWithoutChainIdValidation:test_reverts_whenOneCallReverts() (gas: 467715)
TestExecuteWithoutChainIdValidation:test_reverts_whenOneSelectorNotApproved() (gas: 179684)
TestExecuteWithoutChainIdValidation:test_reverts_whenSelectorNotApproved() (gas: 106758)
TestExecuteWithoutChainIdValidation:test_succeeds_whenSelectorAllowed() (gas: 423916)
TestImplementation:testImplementation() (gas: 12623)
TestInitialize:testInitialize() (gas: 21034)
TestInitialize:test_cannotInitImplementation() (gas: 2899105)
TestInitialize:test_cannotInitImplementation() (gas: 2885066)
TestIsValidSignature:testReturnsInvalidIfPasskeySigButWrongOwnerLength() (gas: 40187)
TestIsValidSignature:testRevertsIfEthereumSignatureButWrongOwnerLength() (gas: 24040)
TestIsValidSignature:testRevertsIfOwnerIsInvalidEthereumAddress() (gas: 22021)
TestIsValidSignature:testSmartWalletSigner() (gas: 3174740)
TestIsValidSignature:testSmartWalletSigner() (gas: 3160701)
TestIsValidSignature:testValidateSignatureWithEOASigner() (gas: 24922)
TestIsValidSignature:testValidateSignatureWithEOASignerFailsWithWrongSigner() (gas: 23877)
TestIsValidSignature:testValidateSignatureWithPasskeySigner() (gas: 423238)
TestIsValidSignature:testValidateSignatureWithPasskeySignerFailsBadOwnerIndex() (gas: 35664)
TestIsValidSignature:testValidateSignatureWithPasskeySignerFailsWithWrongBadSignature() (gas: 430704)
TestUpgradeToAndCall:testUpgradeToAndCall() (gas: 25477)
TestValidateUserOp:test_reverts_whenReplayableNonceKeyInvalidForSelector() (gas: 14551)
TestValidateUserOp:test_reverts_whenSelectorInvalidForReplayableNonceKey() (gas: 14816)
TestValidateUserOp:test_succeedsWithEOASigner() (gas: 447664)
TestValidateUserOp:test_succeedsWithPasskeySigner() (gas: 785032)
TestValidateUserOp:test_reverts_whenReplayableNonceKeyInvalidForSelector() (gas: 14187)
TestValidateUserOp:test_reverts_whenSelectorInvalidForReplayableNonceKey() (gas: 14452)
TestValidateUserOp:test_succeedsWithEOASigner() (gas: 447938)
TestValidateUserOp:test_succeedsWithPasskeySigner() (gas: 785169)
4 changes: 2 additions & 2 deletions src/CoinbaseSmartWallet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ contract CoinbaseSmartWallet is MultiOwnable, UUPSUpgradeable, Receiver, ERC1271
uint256 key = userOp.nonce >> 64;

if (
userOp.callData.length >= 4 && bytes4(userOp.callData[0:4]) == this.executeWithoutChainIdValidation.selector
bytes4(userOp.callData) == this.executeWithoutChainIdValidation.selector
) {
userOpHash = getUserOpHashWithoutChainId(userOp);
if (key != REPLAYABLE_NONCE_KEY) {
Expand Down Expand Up @@ -181,7 +181,7 @@ contract CoinbaseSmartWallet is MultiOwnable, UUPSUpgradeable, Receiver, ERC1271
function executeWithoutChainIdValidation(bytes[] calldata calls) public payable virtual onlyEntryPoint {
for (uint256 i; i < calls.length; i++) {
bytes calldata call = calls[i];
bytes4 selector = bytes4(call[0:4]);
bytes4 selector = bytes4(call);
if (!canSkipChainIdValidation(selector)) {
revert SelectorNotAllowed(selector);
}
Expand Down

0 comments on commit ad4309c

Please sign in to comment.