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

use immutable for entryPoint in SmartWallet #31

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,25 @@ RemoveOwnerAtIndexTest:testRevertsIfCalledByNonOwner() (gas: 11308)
RemoveOwnerAtIndexTest:testRevertsIfNoOwnerAtIndex() (gas: 16624)
TestCanSkipChainIdValidation:test_approvedSelectorsReturnTrue() (gas: 15933)
TestCanSkipChainIdValidation:test_otherSelectorsReturnFalse() (gas: 12513)
TestExecuteWithoutChainIdValidation:testExecute() (gas: 424907)
TestExecuteWithoutChainIdValidation:testExecuteBatch() (gas: 729143)
TestExecuteWithoutChainIdValidation:testExecuteBatch(uint256) (runs: 256, μ: 3450733, ~: 3582947)
TestExecuteWithoutChainIdValidation:test__codesize() (gas: 49053)
TestExecuteWithoutChainIdValidation:test__codesize() (gas: 49288)
TestExecuteWithoutChainIdValidation:test_canChangeOwnerWithoutChainId() (gas: 287727)
TestExecuteWithoutChainIdValidation:test_cannotCallExec() (gas: 220025)
TestExecuteWithoutChainIdValidation:test_revertsIfCallerNotEntryPoint() (gas: 8598)
TestExecuteWithoutChainIdValidation:test_revertsIfWrongNonceKey() (gas: 62275)
TestExecuteWithoutChainIdValidation:test_revertsWithReservedNonce() (gas: 82324)
TestExecuteWithoutChainIdValidation:testExecute() (gas: 424961)
TestExecuteWithoutChainIdValidation:testExecuteBatch() (gas: 729179)
TestExecuteWithoutChainIdValidation:testExecuteBatch(uint256) (runs: 256, μ: 3464532, ~: 3316512)
TestExecuteWithoutChainIdValidation:test__codesize() (gas: 49268)
TestExecuteWithoutChainIdValidation:test__codesize() (gas: 49503)
TestExecuteWithoutChainIdValidation:test_canChangeOwnerWithoutChainId() (gas: 287799)
TestExecuteWithoutChainIdValidation:test_cannotCallExec() (gas: 220097)
TestExecuteWithoutChainIdValidation:test_revertsIfCallerNotEntryPoint() (gas: 8616)
TestExecuteWithoutChainIdValidation:test_revertsIfWrongNonceKey() (gas: 62329)
TestExecuteWithoutChainIdValidation:test_revertsWithReservedNonce() (gas: 82342)
TestInitialize:testInitialize() (gas: 21034)
TestInitialize:test_cannotInitImplementation() (gas: 2714468)
TestInitialize:test_cannotInitImplementation() (gas: 2738240)
TestIsValidSignature:testReturnsInvalidIfPasskeySigButWrongOwnerLength() (gas: 39469)
TestIsValidSignature:testRevertsIfEthereumSignatureButWrongOwnerLength() (gas: 24040)
TestIsValidSignature:testSmartWalletSigner() (gas: 2990421)
TestIsValidSignature:testSmartWalletSigner() (gas: 3018423)
TestIsValidSignature:testValidateSignatureWithEOASigner() (gas: 24922)
TestIsValidSignature:testValidateSignatureWithEOASignerFailsWithWrongSigner() (gas: 23877)
TestIsValidSignature:testValidateSignatureWithPasskeySigner() (gas: 421256)
TestIsValidSignature:testValidateSignatureWithPasskeySignerFailsBadOwnerIndex() (gas: 34958)
TestIsValidSignature:testValidateSignatureWithPasskeySignerFailsWithWrongBadSignature() (gas: 428722)
TestUpgradeToAndCall:testUpgradeToAndCall() (gas: 25477)
TestValidateUserOp:testValidateUserOp() (gas: 447275)
TestValidateUserOp:testValidateUserOp() (gas: 447335)
16 changes: 6 additions & 10 deletions src/CoinbaseSmartWallet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ contract CoinbaseSmartWallet is MultiOwnable, UUPSUpgradeable, Receiver, ERC1271

/// @notice Reverts if the caller is not the EntryPoint.
modifier onlyEntryPoint() virtual {
if (msg.sender != entryPoint()) {
if (msg.sender != entryPoint) {
revert Unauthorized();
}

Expand All @@ -72,7 +72,7 @@ contract CoinbaseSmartWallet is MultiOwnable, UUPSUpgradeable, Receiver, ERC1271

/// @notice Reverts if the caller is neither the EntryPoint, the owner, nor the account itself.
modifier onlyEntryPointOrOwner() virtual {
if (msg.sender != entryPoint()) {
if (msg.sender != entryPoint) {
_checkOwner();
}

Expand All @@ -99,6 +99,9 @@ contract CoinbaseSmartWallet is MultiOwnable, UUPSUpgradeable, Receiver, ERC1271
}
}

/// @notice The address of the v0.6 EntryPoint contract.
address public immutable entryPoint = 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789;

constructor() {
// Implementation should not be initializable (does not affect proxies which use their own storage).
bytes[] memory owners = new bytes[](1);
Expand Down Expand Up @@ -211,13 +214,6 @@ contract CoinbaseSmartWallet is MultiOwnable, UUPSUpgradeable, Receiver, ERC1271
}
}

/// @notice Returns the address of the EntryPoint v0.6.
///
/// @return The address of the EntryPoint v0.6
function entryPoint() public view virtual returns (address) {
return 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789;
}

/// @notice Computes the hash of the `UserOperation` in the same way as EntryPoint v0.6, but
/// leaves out the chain ID.
///
Expand All @@ -232,7 +228,7 @@ contract CoinbaseSmartWallet is MultiOwnable, UUPSUpgradeable, Receiver, ERC1271
virtual
returns (bytes32 userOpHash)
{
return keccak256(abi.encode(UserOperationLib.hash(userOp), entryPoint()));
return keccak256(abi.encode(UserOperationLib.hash(userOp), entryPoint));
}

/// @notice Returns the implementation of the ERC1967 proxy.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ contract TestExecuteWithoutChainIdValidation is SmartWalletTestBase {
UserOperation memory userOp = _getUserOpWithSignature();
vm.expectEmit(true, true, true, true);
emit IEntryPoint.UserOperationEvent(
entryPoint.getUserOpHash(userOp), userOp.sender, address(0), userOp.nonce, false, 0, 48005
entryPoint.getUserOpHash(userOp), userOp.sender, address(0), userOp.nonce, false, 0, 48059
);
_sendUserOperation(userOp);
}
Expand Down