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

✧ 1.2.3 #15

Merged
merged 9 commits into from
Jun 26, 2024
Merged
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
130 changes: 66 additions & 64 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,66 +1,68 @@
AccountTest:testCdFallback() (gas: 457611)
AccountTest:testCdFallback2() (gas: 1220775)
AccountTest:testDelegateExecute() (gas: 398258)
AccountTest:testDelegateExecute(uint256) (runs: 257, μ: 385788, ~: 377738)
AccountTest:testDelegateExecuteRevertsIfOwnerSlotValueChanged() (gas: 353412)
AccountTest:testDepositFunctions() (gas: 516452)
AccountTest:testDirectStorage() (gas: 70232)
AccountTest:testDisableInitializerForImplementation() (gas: 1498602)
AccountTest:testCdFallback() (gas: 474764)
AccountTest:testCdFallback2() (gas: 1250652)
AccountTest:testDelegateExecute() (gas: 405036)
AccountTest:testDelegateExecute(uint256) (runs: 256, μ: 395877, ~: 384516)
AccountTest:testDelegateExecuteRevertsIfOwnerSlotValueChanged() (gas: 360183)
AccountTest:testDepositFunctions() (gas: 533677)
AccountTest:testDirectStorage() (gas: 70166)
AccountTest:testDisableInitializerForImplementation() (gas: 1520028)
AccountTest:testETHReceived() (gas: 16591)
AccountTest:testExecute() (gas: 415944)
AccountTest:testExecuteBatch() (gas: 760184)
AccountTest:testInitializer() (gas: 1780591)
AccountTest:testIsValidSignature() (gas: 118508)
AccountTest:testIsValidSignatureViaPlugin() (gas: 98498)
AccountTest:testIsValidSignatureViaRPC() (gas: 8937393460516731457)
AccountTest:testIsValidSignatureWrapped() (gas: 405398)
AccountTest:testOnERC1155BatchReceived() (gas: 1568708)
AccountTest:testOnERC1155Received() (gas: 1566056)
AccountTest:testOnERC721Received() (gas: 1693272)
AccountTest:testOwnerRecovery() (gas: 499836)
AccountTest:testSignaturePluginStorage() (gas: 86875)
AccountTest:testValidateUserOp() (gas: 508825)
AccountTest:test__codesize() (gas: 66755)
AccountsTest:testDeploy() (gas: 1755726)
AccountsTest:test__codesize() (gas: 10105)
JointValidatorTest:testDeploy() (gas: 466677)
JointValidatorTest:testInstall() (gas: 146316)
JointValidatorTest:testJointUserOp() (gas: 208)
KeysTest:testDeploy() (gas: 556657)
KeysTest:testInstall() (gas: 56172)
KeysTest:testKeys() (gas: 69648)
PaymentValidatorTest:testDeploy() (gas: 1148736)
PaymentValidatorTest:testERC20PaymentPlan() (gas: 211939)
PaymentValidatorTest:testERC20PaymentPlanFailInvalidSignature() (gas: 221137)
PaymentValidatorTest:testETHPaymentPlan() (gas: 206791)
PaymentValidatorTest:testETHPaymentPlanFailInvalidSignature() (gas: 215997)
PaymentValidatorTest:testFailERC20PaymentPlanInvalidSelector() (gas: 206378)
PaymentValidatorTest:testFailERC20PaymentPlanInvalidTarget() (gas: 207067)
PaymentValidatorTest:testFailERC20PaymentPlanInvalidValue() (gas: 206779)
PaymentValidatorTest:testFailETHInvalidTarget() (gas: 201615)
PaymentValidatorTest:testFailETHPaymentPlanInvalidValue() (gas: 201606)
PaymentValidatorTest:testFailPaymentPlanInvalidAllowance() (gas: 185387)
PaymentValidatorTest:testInstall() (gas: 170994)
PermitValidatorTest:testAddressPermission(address) (runs: 257, μ: 23863, ~: 23863)
PermitValidatorTest:testBoolPermission(bool) (runs: 257, μ: 22254, ~: 22254)
PermitValidatorTest:testEnumPermission(uint256) (runs: 257, μ: 27310, ~: 27366)
PermitValidatorTest:testInstall() (gas: 207683)
PermitValidatorTest:testTransferPermission(address,uint256,uint256,uint256) (runs: 256, μ: 8481, ~: 3728)
PermitValidatorTest:testUintPermission(uint256,uint256,uint256) (runs: 257, μ: 7365, ~: 3284)
PermitValidatorTest:testValuePermission(uint256,uint256) (runs: 257, μ: 20039, ~: 20043)
PermitValidatorTest:test__codesize() (gas: 47950)
PointsTest:testCheck(uint256) (runs: 257, μ: 31230, ~: 31230)
PointsTest:testDeploy() (gas: 103117)
RecoveryValidatorTest:testDeploy() (gas: 1412574)
RecoveryValidatorTest:testInstall() (gas: 172940)
RecoveryValidatorTest:testSetGuardians() (gas: 173334)
RecoveryValidatorTest:testSocialRecovery() (gas: 181294)
RecoveryValidatorTest:testUninstall() (gas: 144192)
TokenTest:testDeploy() (gas: 344405)
TokenTest:testFailTransferBeyondBalance(address) (runs: 257, μ: 39779, ~: 39779)
TokenTest:testFailUnsafeTransfer(address) (runs: 257, μ: 11389, ~: 11389)
AccountTest:testExecute() (gas: 422663)
AccountTest:testExecuteBatch() (gas: 773653)
AccountTest:testInitializer() (gas: 1801885)
AccountTest:testIsValidSignature() (gas: 118863)
AccountTest:testIsValidSignatureViaPlugin() (gas: 98455)
AccountTest:testIsValidSignatureViaRPC() (gas: 8937393460516731459)
AccountTest:testIsValidSignatureWrapped() (gas: 452766)
AccountTest:testOnERC1155BatchReceived() (gas: 1573496)
AccountTest:testOnERC1155Received() (gas: 1570864)
AccountTest:testOnERC721Received() (gas: 1693476)
AccountTest:testOwnerRecovery() (gas: 516827)
AccountTest:testSignaturePluginStorage() (gas: 86831)
AccountTest:testValidateUserOp() (gas: 525722)
AccountTest:test__codesize() (gas: 67284)
AccountsTest:testDeploy() (gas: 1777174)
AccountsTest:test__codesize() (gas: 10212)
JointValidatorTest:testDeploy() (gas: 466944)
JointValidatorTest:testInstall() (gas: 146205)
JointValidatorTest:testJointUserOp() (gas: 186)
KeysTest:testDeploy() (gas: 568553)
KeysTest:testInstall() (gas: 56269)
KeysTest:testKeys() (gas: 69643)
PaymentValidatorTest:testDeploy() (gas: 1161360)
PaymentValidatorTest:testERC20PaymentPlan() (gas: 211892)
PaymentValidatorTest:testERC20PaymentPlanFailInvalidSignature() (gas: 221024)
PaymentValidatorTest:testETHPaymentPlan() (gas: 206730)
PaymentValidatorTest:testETHPaymentPlanFailInvalidSignature() (gas: 215958)
PaymentValidatorTest:testFailERC20PaymentPlanInvalidSelector() (gas: 206314)
PaymentValidatorTest:testFailERC20PaymentPlanInvalidTarget() (gas: 207035)
PaymentValidatorTest:testFailERC20PaymentPlanInvalidValue() (gas: 206712)
PaymentValidatorTest:testFailETHInvalidTarget() (gas: 201523)
PaymentValidatorTest:testFailETHPaymentPlanInvalidValue() (gas: 201547)
PaymentValidatorTest:testFailPaymentPlanInvalidAllowance() (gas: 185331)
PaymentValidatorTest:testInstall() (gas: 171005)
PermitValidatorTest:testAddressPermission(address) (runs: 256, μ: 23814, ~: 23814)
PermitValidatorTest:testBoolPermission(bool) (runs: 256, μ: 22209, ~: 22209)
PermitValidatorTest:testEnumPermission(uint256) (runs: 256, μ: 27306, ~: 27360)
PermitValidatorTest:testInstall() (gas: 207712)
PermitValidatorTest:testTransferPermission(address,uint256,uint256,uint256) (runs: 256, μ: 8652, ~: 3728)
PermitValidatorTest:testUintPermission(uint256,uint256,uint256) (runs: 256, μ: 7274, ~: 3262)
PermitValidatorTest:testValuePermission(uint256,uint256) (runs: 256, μ: 20022, ~: 20023)
PermitValidatorTest:test__codesize() (gas: 48477)
PointsTest:testCheck(uint256) (runs: 256, μ: 31230, ~: 31230)
PointsTest:testDeploy() (gas: 103095)
RecoveryValidatorTest:testDeploy() (gas: 1433821)
RecoveryValidatorTest:testFailSocialRecoveryWithEOAKey() (gas: 179046)
RecoveryValidatorTest:testFailSocialRecoveryWithZeroKey() (gas: 179021)
RecoveryValidatorTest:testInstall() (gas: 172917)
RecoveryValidatorTest:testSetGuardians() (gas: 173389)
RecoveryValidatorTest:testSocialRecovery() (gas: 179091)
RecoveryValidatorTest:testUninstall() (gas: 144165)
TokenTest:testDeploy() (gas: 344605)
TokenTest:testFailTransferBeyondBalance(address) (runs: 256, μ: 39779, ~: 39779)
TokenTest:testFailUnsafeTransfer(address) (runs: 256, μ: 11389, ~: 11389)
TokenTest:testInitBalance() (gas: 10629)
TokenTest:testNameAndSymbolAndDecimals() (gas: 12391)
TokenTest:testTotalSupply() (gas: 8366)
TokenTest:testTransfer(address,uint96) (runs: 257, μ: 43691, ~: 44310)
TokenTest:testTransferFromOwner(address,uint96) (runs: 257, μ: 43791, ~: 44410)
TokenTest:testNameAndSymbolAndDecimals() (gas: 12365)
TokenTest:testTotalSupply() (gas: 8388)
TokenTest:testTransfer(address,uint96) (runs: 256, μ: 43689, ~: 44310)
TokenTest:testTransferFromOwner(address,uint96) (runs: 256, μ: 43793, ~: 44414)
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[profile.default]
solc_version = "0.8.25"
solc_version = "0.8.26"
evm_version = "cancun"

optimizer = true
Expand Down
2 changes: 1 addition & 1 deletion lib/forge-std
40 changes: 23 additions & 17 deletions src/Account.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ contract Account is ERC4337 {
override(EIP712)
returns (string memory, string memory)
{
return ("NANI", "1.1.1");
return ("NANI", "1.2.3");
}

/// @dev Validates userOp
Expand Down Expand Up @@ -96,35 +96,41 @@ contract Account is ERC4337 {
);
}

/// @dev Keccak function over calldata. This is more efficient than letting solidity do it.
/// @dev Keccak function over calldata. This is more efficient than letting Solidity do it.
function _calldataKeccak(bytes calldata data) internal pure virtual returns (bytes32 hash) {
assembly ("memory-safe") {
let mem := mload(0x40)
let len := data.length
calldatacopy(mem, data.offset, len)
hash := keccak256(mem, len)
let m := mload(0x40)
let l := data.length
calldatacopy(m, data.offset, l)
hash := keccak256(m, l)
}
}

/// @dev Extends ERC4337 userOp validation with stored ERC7582 validator plugins.
/// @dev Extends ERC4337 userOp validation in stored ERC7582 validator plugin.
function _validateUserOp() internal virtual returns (uint256 validationData) {
assembly ("memory-safe") {
let m := mload(0x40)
calldatacopy(0x00, 0x00, calldatasize())
if iszero(
call(
gas(),
/*validator*/
shr(96, sload(shl(64, /*key*/ shr(64, /*nonce*/ calldataload(0x84))))),
0,
0x00,
calldatasize(),
0x00,
0x20
if or(
lt(returndatasize(), 0x20),
iszero(
call(
gas(),
/*validator*/
sload( /*key*/ shr(64, /*nonce*/ calldataload(0x84))),
0,
0x00,
calldatasize(),
0x00,
0x20
)
)
) {
returndatacopy(0x00, 0x00, returndatasize())
revert(0x00, returndatasize())
}
mstore(0x40, m) // Restore the free memory pointer.
z0r0z marked this conversation as resolved.
Show resolved Hide resolved
mstore(0x60, 0) // Restore zero pointer.
validationData := mload(0x00)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Accounts.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity ^0.8.19;

import {ERC4337Factory} from "@solady/src/accounts/ERC4337Factory.sol";

/// @notice Simple extendable smart account factory. ERC1271/ERC4337. Version 1.1.1.
/// @notice Simple extendable smart account factory. ERC1271/ERC4337. Version 1.2.3.
/// @author nani.eth (https://github.com/NaniDAO/accounts/blob/main/src/Accounts.sol)
contract Accounts is ERC4337Factory {
constructor(address Account) payable ERC4337Factory(Account) {}
Expand Down
4 changes: 2 additions & 2 deletions test/Account.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ contract AccountTest is SoladyTest {
"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
),
keccak256("NANI"),
keccak256("1.1.1"),
keccak256("1.2.3"),
block.chainid,
address(account)
)
Expand All @@ -617,7 +617,7 @@ contract AccountTest is SoladyTest {
) internal view returns (bytes32 digest) {
address _account = address(account);
bytes32 nameHash = keccak256(bytes("NANI"));
bytes32 versionHash = keccak256(bytes("1.1.1"));
bytes32 versionHash = keccak256(bytes("1.2.3"));
assembly ("memory-safe") {
let m := mload(0x40) // Load the free memory pointer.
mstore(m, _DOMAIN_TYPEHASH)
Expand Down
Loading
Loading