From cebaee323ceae9845cc06b57753099d78e87d452 Mon Sep 17 00:00:00 2001 From: Eloi Manuel Date: Wed, 31 May 2023 16:47:47 +0200 Subject: [PATCH 1/7] Unifying licenses --- contracts/core/BaseOpenfortAccount.sol | 2 +- contracts/core/managed/ManagedOpenfortAccount.sol | 2 +- contracts/core/managed/ManagedOpenfortFactory.sol | 2 +- contracts/core/managed/OpenfortBeacon.sol | 2 +- contracts/core/static/StaticOpenfortAccount.sol | 2 +- contracts/core/static/StaticOpenfortFactory.sol | 2 +- contracts/core/upgradeable/UpgradeableOpenfortAccount.sol | 2 +- contracts/core/upgradeable/UpgradeableOpenfortFactory.sol | 2 +- contracts/interfaces/IBaseOpenfortFactory.sol | 2 +- contracts/mock/MockedV2ManagedOpenfortAccount.sol | 2 +- script/Utils/GasCalculations.sol | 2 +- test/foundry/4337/Specific4337Tests.t.sol | 2 +- test/foundry/core/managed/ManagedOpenfortAccountTest.t.sol | 2 +- test/foundry/core/static/StaticOpenfortAccountTest.t.sol | 2 +- .../core/upgradeable/UpgradeableOpenfortAccountTest.t.sol | 2 +- test/foundry/paymaster/OpenfortPaymasterTest.t.sol | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/contracts/core/BaseOpenfortAccount.sol b/contracts/core/BaseOpenfortAccount.sol index 0a76605..16e40d6 100644 --- a/contracts/core/BaseOpenfortAccount.sol +++ b/contracts/core/BaseOpenfortAccount.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT pragma solidity ^0.8.12; import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; diff --git a/contracts/core/managed/ManagedOpenfortAccount.sol b/contracts/core/managed/ManagedOpenfortAccount.sol index de24bdb..0414c4c 100644 --- a/contracts/core/managed/ManagedOpenfortAccount.sol +++ b/contracts/core/managed/ManagedOpenfortAccount.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT pragma solidity ^0.8.12; // Base account contract to inherit from diff --git a/contracts/core/managed/ManagedOpenfortFactory.sol b/contracts/core/managed/ManagedOpenfortFactory.sol index 3ab84e2..be1a0af 100644 --- a/contracts/core/managed/ManagedOpenfortFactory.sol +++ b/contracts/core/managed/ManagedOpenfortFactory.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT pragma solidity ^0.8.12; import {BeaconProxy} from "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol"; diff --git a/contracts/core/managed/OpenfortBeacon.sol b/contracts/core/managed/OpenfortBeacon.sol index 9fab26a..381139a 100644 --- a/contracts/core/managed/OpenfortBeacon.sol +++ b/contracts/core/managed/OpenfortBeacon.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT pragma solidity ^0.8.12; import {UpgradeableBeacon} from "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol"; diff --git a/contracts/core/static/StaticOpenfortAccount.sol b/contracts/core/static/StaticOpenfortAccount.sol index add0fb0..1579127 100644 --- a/contracts/core/static/StaticOpenfortAccount.sol +++ b/contracts/core/static/StaticOpenfortAccount.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT pragma solidity ^0.8.12; // Base account contract to inherit from diff --git a/contracts/core/static/StaticOpenfortFactory.sol b/contracts/core/static/StaticOpenfortFactory.sol index 8c54a2e..912b01f 100644 --- a/contracts/core/static/StaticOpenfortFactory.sol +++ b/contracts/core/static/StaticOpenfortFactory.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT pragma solidity ^0.8.12; import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol"; diff --git a/contracts/core/upgradeable/UpgradeableOpenfortAccount.sol b/contracts/core/upgradeable/UpgradeableOpenfortAccount.sol index 51cddbb..9f95c6f 100644 --- a/contracts/core/upgradeable/UpgradeableOpenfortAccount.sol +++ b/contracts/core/upgradeable/UpgradeableOpenfortAccount.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT pragma solidity ^0.8.12; // Base account contract to inherit from diff --git a/contracts/core/upgradeable/UpgradeableOpenfortFactory.sol b/contracts/core/upgradeable/UpgradeableOpenfortFactory.sol index 464d09a..76ea71c 100644 --- a/contracts/core/upgradeable/UpgradeableOpenfortFactory.sol +++ b/contracts/core/upgradeable/UpgradeableOpenfortFactory.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT pragma solidity ^0.8.12; import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; diff --git a/contracts/interfaces/IBaseOpenfortFactory.sol b/contracts/interfaces/IBaseOpenfortFactory.sol index 96afcd9..49daf1a 100644 --- a/contracts/interfaces/IBaseOpenfortFactory.sol +++ b/contracts/interfaces/IBaseOpenfortFactory.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT pragma solidity ^0.8.12; interface IBaseOpenfortFactory { diff --git a/contracts/mock/MockedV2ManagedOpenfortAccount.sol b/contracts/mock/MockedV2ManagedOpenfortAccount.sol index 9e43a5b..8bb6303 100644 --- a/contracts/mock/MockedV2ManagedOpenfortAccount.sol +++ b/contracts/mock/MockedV2ManagedOpenfortAccount.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT pragma solidity ^0.8.12; // Base account contract to inherit from diff --git a/script/Utils/GasCalculations.sol b/script/Utils/GasCalculations.sol index 6a55c7d..0b0ce4c 100644 --- a/script/Utils/GasCalculations.sol +++ b/script/Utils/GasCalculations.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT pragma solidity ^0.8.17; import {UserOperation, UserOperationLib} from "lib/account-abstraction/contracts/interfaces/UserOperation.sol"; diff --git a/test/foundry/4337/Specific4337Tests.t.sol b/test/foundry/4337/Specific4337Tests.t.sol index 0f23c41..94e9409 100644 --- a/test/foundry/4337/Specific4337Tests.t.sol +++ b/test/foundry/4337/Specific4337Tests.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT pragma solidity ^0.8.12; import {Test, console} from "lib/forge-std/src/Test.sol"; diff --git a/test/foundry/core/managed/ManagedOpenfortAccountTest.t.sol b/test/foundry/core/managed/ManagedOpenfortAccountTest.t.sol index 1b0d0e0..a71d98f 100644 --- a/test/foundry/core/managed/ManagedOpenfortAccountTest.t.sol +++ b/test/foundry/core/managed/ManagedOpenfortAccountTest.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; import {Test, console} from "lib/forge-std/src/Test.sol"; diff --git a/test/foundry/core/static/StaticOpenfortAccountTest.t.sol b/test/foundry/core/static/StaticOpenfortAccountTest.t.sol index 47328ef..eca0863 100644 --- a/test/foundry/core/static/StaticOpenfortAccountTest.t.sol +++ b/test/foundry/core/static/StaticOpenfortAccountTest.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; import {Test, console} from "lib/forge-std/src/Test.sol"; diff --git a/test/foundry/core/upgradeable/UpgradeableOpenfortAccountTest.t.sol b/test/foundry/core/upgradeable/UpgradeableOpenfortAccountTest.t.sol index 713336c..de91be2 100644 --- a/test/foundry/core/upgradeable/UpgradeableOpenfortAccountTest.t.sol +++ b/test/foundry/core/upgradeable/UpgradeableOpenfortAccountTest.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; import {Test, console} from "lib/forge-std/src/Test.sol"; diff --git a/test/foundry/paymaster/OpenfortPaymasterTest.t.sol b/test/foundry/paymaster/OpenfortPaymasterTest.t.sol index 5b31b84..66e5d13 100644 --- a/test/foundry/paymaster/OpenfortPaymasterTest.t.sol +++ b/test/foundry/paymaster/OpenfortPaymasterTest.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT pragma solidity ^0.8.12; import {Test, console} from "lib/forge-std/src/Test.sol"; From 029f30426449adf2b668fece62dc0c16dde80dd7 Mon Sep 17 00:00:00 2001 From: Eloi Manuel Date: Wed, 31 May 2023 17:44:15 +0200 Subject: [PATCH 2/7] Improved upgrade tests --- contracts/core/BaseOpenfortAccount.sol | 7 +--- .../core/managed/ManagedOpenfortAccount.sol | 2 +- .../core/static/StaticOpenfortAccount.sol | 2 +- .../UpgradeableOpenfortAccount.sol | 2 +- .../UpgradeableOpenfortFactory.sol | 8 ++--- .../mock/MockedV2ManagedOpenfortAccount.sol | 2 +- .../MockedV2UpgradeableOpenfortAccount.sol | 33 +++++++++++++++++++ .../managed/ManagedOpenfortAccountTest.t.sol | 19 +++++------ .../UpgradeableOpenfortAccountTest.t.sol | 8 ++++- 9 files changed, 58 insertions(+), 25 deletions(-) create mode 100644 contracts/mock/MockedV2UpgradeableOpenfortAccount.sol diff --git a/contracts/core/BaseOpenfortAccount.sol b/contracts/core/BaseOpenfortAccount.sol index 16e40d6..2697b62 100644 --- a/contracts/core/BaseOpenfortAccount.sol +++ b/contracts/core/BaseOpenfortAccount.sol @@ -16,7 +16,7 @@ import "account-abstraction/core/Helpers.sol" as Helpers; * @notice Minimal smart contract wallet with session keys following the ERC-4337 standard. * It inherits from: * - BaseAccount to comply with ERC-4337 - * - Initializable because StaticOpenfortAccounts are meant to be created using StaticOpenfortFactory + * - Initializable because accounts are meant to be created using Factories * - Ownable2StepUpgradeable to have permissions * - IERC1271Upgradeable for Signature Validation * - TokenCallbackHandler to support ERC777, ERC721 and ERC1155 @@ -78,11 +78,6 @@ abstract contract BaseOpenfortAccount is _disableInitializers(); } - /* - * @notice Initialize the smart contract wallet. - */ - function initialize(address _defaultAdmin, address _entrypoint, bytes calldata) public virtual; - /** * @inheritdoc BaseAccount */ diff --git a/contracts/core/managed/ManagedOpenfortAccount.sol b/contracts/core/managed/ManagedOpenfortAccount.sol index 0414c4c..4705097 100644 --- a/contracts/core/managed/ManagedOpenfortAccount.sol +++ b/contracts/core/managed/ManagedOpenfortAccount.sol @@ -15,7 +15,7 @@ contract ManagedOpenfortAccount is BaseOpenfortAccount { /* * @notice Initialize the smart contract wallet. */ - function initialize(address _defaultAdmin, address _entrypoint, bytes calldata) public override initializer { + function initialize(address _defaultAdmin, address _entrypoint, bytes calldata) public initializer { if (_defaultAdmin == address(0) || _entrypoint == address(0)) { revert ZeroAddressNotAllowed(); } diff --git a/contracts/core/static/StaticOpenfortAccount.sol b/contracts/core/static/StaticOpenfortAccount.sol index 1579127..3ce1e44 100644 --- a/contracts/core/static/StaticOpenfortAccount.sol +++ b/contracts/core/static/StaticOpenfortAccount.sol @@ -18,7 +18,7 @@ contract StaticOpenfortAccount is BaseOpenfortAccount { /* * @notice Initialize the smart contract wallet. */ - function initialize(address _defaultAdmin, address _entrypoint, bytes calldata) public override initializer { + function initialize(address _defaultAdmin, address _entrypoint, bytes calldata) public initializer { if (_defaultAdmin == address(0) || _entrypoint == address(0)) { revert ZeroAddressNotAllowed(); } diff --git a/contracts/core/upgradeable/UpgradeableOpenfortAccount.sol b/contracts/core/upgradeable/UpgradeableOpenfortAccount.sol index 9f95c6f..8dd2773 100644 --- a/contracts/core/upgradeable/UpgradeableOpenfortAccount.sol +++ b/contracts/core/upgradeable/UpgradeableOpenfortAccount.sol @@ -17,7 +17,7 @@ contract UpgradeableOpenfortAccount is BaseOpenfortAccount, UUPSUpgradeable { /* * @notice Initialize the smart contract wallet. */ - function initialize(address _defaultAdmin, address _entrypoint, bytes calldata) public override initializer { + function initialize(address _defaultAdmin, address _entrypoint, bytes calldata) public initializer { if (_defaultAdmin == address(0) || _entrypoint == address(0)) { revert ZeroAddressNotAllowed(); } diff --git a/contracts/core/upgradeable/UpgradeableOpenfortFactory.sol b/contracts/core/upgradeable/UpgradeableOpenfortFactory.sol index 76ea71c..18b8e92 100644 --- a/contracts/core/upgradeable/UpgradeableOpenfortFactory.sol +++ b/contracts/core/upgradeable/UpgradeableOpenfortFactory.sol @@ -77,12 +77,12 @@ contract UpgradeableOpenfortFactory is IBaseOpenfortFactory { function getAddress(address _admin) public view returns (address) { bytes32 salt = keccak256(abi.encode(_admin)); return Create2.computeAddress( - bytes32(salt), + salt, keccak256( abi.encodePacked( type(ERC1967Proxy).creationCode, abi.encode( - address(accountImplementation), + accountImplementation, abi.encodeCall(UpgradeableOpenfortAccount.initialize, (_admin, entrypointContract, "")) ) ) @@ -96,12 +96,12 @@ contract UpgradeableOpenfortFactory is IBaseOpenfortFactory { function getAddressWithNonce(address _admin, uint256 nonce) public view returns (address) { bytes32 salt = keccak256(abi.encode(_admin, nonce)); return Create2.computeAddress( - bytes32(salt), + salt, keccak256( abi.encodePacked( type(ERC1967Proxy).creationCode, abi.encode( - address(accountImplementation), + accountImplementation, abi.encodeCall(UpgradeableOpenfortAccount.initialize, (_admin, entrypointContract, "")) ) ) diff --git a/contracts/mock/MockedV2ManagedOpenfortAccount.sol b/contracts/mock/MockedV2ManagedOpenfortAccount.sol index 8bb6303..a118e01 100644 --- a/contracts/mock/MockedV2ManagedOpenfortAccount.sol +++ b/contracts/mock/MockedV2ManagedOpenfortAccount.sol @@ -15,7 +15,7 @@ contract MockedV2ManagedOpenfortAccount is BaseOpenfortAccount { /* * @notice Initialize the smart contract wallet. */ - function initialize(address _defaultAdmin, address _entrypoint, bytes calldata) public override initializer { + function initialize(address _defaultAdmin, address _entrypoint, bytes calldata) public initializer { if (_defaultAdmin == address(0) || _entrypoint == address(0)) { revert ZeroAddressNotAllowed(); } diff --git a/contracts/mock/MockedV2UpgradeableOpenfortAccount.sol b/contracts/mock/MockedV2UpgradeableOpenfortAccount.sol new file mode 100644 index 0000000..0195212 --- /dev/null +++ b/contracts/mock/MockedV2UpgradeableOpenfortAccount.sol @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.12; + +// Base account contract to inherit from +import {BaseOpenfortAccount} from "../core/BaseOpenfortAccount.sol"; +import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; + +/** + * @title MockedV2UpgradeableOpenfortAccount + * @author Eloi + * @notice Minimal smart contract wallet with session keys following the ERC-4337 standard. + * It inherits from: + * - BaseOpenfortAccount + * - UUPSUpgradeable + */ +contract MockedV2UpgradeableOpenfortAccount is BaseOpenfortAccount, UUPSUpgradeable { + /* + * @notice Initialize the smart contract wallet. + */ + function initialize(address _defaultAdmin, address _entrypoint, bytes calldata) public initializer { + if (_defaultAdmin == address(0) || _entrypoint == address(0)) { + revert ZeroAddressNotAllowed(); + } + _transferOwnership(_defaultAdmin); + entrypointContract = _entrypoint; + } + + function _authorizeUpgrade(address) internal override onlyOwner {} + + function version() external pure override returns (uint256) { + return 2; + } +} diff --git a/test/foundry/core/managed/ManagedOpenfortAccountTest.t.sol b/test/foundry/core/managed/ManagedOpenfortAccountTest.t.sol index a71d98f..edb87fb 100644 --- a/test/foundry/core/managed/ManagedOpenfortAccountTest.t.sol +++ b/test/foundry/core/managed/ManagedOpenfortAccountTest.t.sol @@ -1111,17 +1111,13 @@ contract ManagedOpenfortAccountTest is Test { function testUpgradeTo() public { // Create an managed account wallet using the old implementation and get its address address payable account = payable(managedOpenfortFactory.createAccount(accountAdmin, "")); - // BeaconProxy proxyAccount = BeaconProxy(account); ManagedOpenfortAccount managedAccount = ManagedOpenfortAccount(account); - managedAccount.getDeposit(); - managedAccount.version(); + assertEq(managedAccount.version(), 1); + // Deploy the new implementation MockedV2ManagedOpenfortAccount newImplementation = new MockedV2ManagedOpenfortAccount(); address newImplementationAddress = address(newImplementation); - // Deploy a factory using the new EntryPoint - // ManagedOpenfortFactory managedOpenfortFactoryNew = new ManagedOpenfortFactory(payable(newEntryPoint), address(staticOpenfortAccount)); - vm.expectRevert("Ownable: caller is not the owner"); openfortBeacon.upgradeTo(newImplementationAddress); @@ -1130,17 +1126,20 @@ contract ManagedOpenfortAccountTest is Test { assertEq(openfortBeacon.implementation(), newImplementationAddress); - MockedV2ManagedOpenfortAccount newManagedAccount = MockedV2ManagedOpenfortAccount(account); + // Notice that, even though we bind the address to the old implementation, version() now returns 2 + assertEq(managedAccount.version(), 2); - newManagedAccount.getDeposit(); - newManagedAccount.version(); + // Same for new accounts. From now on, they have the new version. + address payable account2 = payable(managedOpenfortFactory.createAccount(accountAdmin, "")); + ManagedOpenfortAccount managedAccount2 = ManagedOpenfortAccount(account2); + managedAccount2.version(); } /* * 1- Deploy a factory using the old EntryPoint to create an account. * 2- Inform the account of the new EntryPoint by calling updateEntryPoint() */ - // function testUpgradeTo() public { + // function testUpgradeEntryPoint() public { // address oldEntryPoint = address(0x0576a174D229E3cFA37253523E645A78A0C91B57); // address newEntryPoint = vm.envAddress("ENTRY_POINT_ADDRESS"); // ManagedOpenfortFactory managedOpenfortFactoryOld = new ManagedOpenfortFactory(payable(oldEntryPoint), address(staticOpenfortAccount)); diff --git a/test/foundry/core/upgradeable/UpgradeableOpenfortAccountTest.t.sol b/test/foundry/core/upgradeable/UpgradeableOpenfortAccountTest.t.sol index de91be2..9da7adf 100644 --- a/test/foundry/core/upgradeable/UpgradeableOpenfortAccountTest.t.sol +++ b/test/foundry/core/upgradeable/UpgradeableOpenfortAccountTest.t.sol @@ -3,11 +3,13 @@ pragma solidity ^0.8.19; import {Test, console} from "lib/forge-std/src/Test.sol"; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; +import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; import {EntryPoint, UserOperation} from "account-abstraction/core/EntryPoint.sol"; import {TestCounter} from "account-abstraction/test/TestCounter.sol"; import {TestToken} from "account-abstraction/test/TestToken.sol"; import {UpgradeableOpenfortAccount} from "contracts/core/upgradeable/UpgradeableOpenfortAccount.sol"; import {UpgradeableOpenfortFactory} from "contracts/core/upgradeable/UpgradeableOpenfortFactory.sol"; +import {MockedV2UpgradeableOpenfortAccount} from "contracts/mock/MockedV2UpgradeableOpenfortAccount.sol"; contract UpgradeableOpenfortAccountTest is Test { using ECDSA for bytes32; @@ -1059,13 +1061,17 @@ contract UpgradeableOpenfortAccountTest is Test { function testUpgradeAccount() public { // Create an static account wallet and get its address address account = upgradeableOpenfortFactory.createAccount(accountAdmin, ""); + assertEq(UpgradeableOpenfortAccount(payable(account)).version(), 1); - UpgradeableOpenfortAccount newAccountImplementation = new UpgradeableOpenfortAccount(); + MockedV2UpgradeableOpenfortAccount newAccountImplementation = new MockedV2UpgradeableOpenfortAccount(); vm.expectRevert("Ownable: caller is not the owner"); UpgradeableOpenfortAccount(payable(account)).upgradeTo(address(newAccountImplementation)); vm.prank(accountAdmin); UpgradeableOpenfortAccount(payable(account)).upgradeTo(address(newAccountImplementation)); + + // Notice that, even though we bind the address to the old implementation, version() now returns 2 + assertEq(UpgradeableOpenfortAccount(payable(account)).version(), 2); } } From dd5372b88c407eac8ed143e0d57edba310df3e07 Mon Sep 17 00:00:00 2001 From: Eloi Manuel Date: Wed, 31 May 2023 17:57:17 +0200 Subject: [PATCH 3/7] Moved EntryPoint --- contracts/core/BaseOpenfortAccount.sol | 9 - .../core/managed/ManagedOpenfortAccount.sol | 15 +- .../core/managed/ManagedOpenfortFactory.sol | 14 +- .../core/static/StaticOpenfortAccount.sol | 11 +- .../UpgradeableOpenfortAccount.sol | 11 +- .../mock/MockedV2ManagedOpenfortAccount.sol | 16 +- .../MockedV2UpgradeableOpenfortAccount.sol | 10 +- gas_reports/2023-05-31_17:51.gas.out | 303 ++++++++++++++++++ gas_reports/2023-05-31_17:51.snap.out | 104 ++++++ script/deployManagedAccounts.sol | 3 +- .../managed/ManagedOpenfortAccountTest.t.sol | 2 +- 11 files changed, 468 insertions(+), 30 deletions(-) create mode 100644 gas_reports/2023-05-31_17:51.gas.out create mode 100644 gas_reports/2023-05-31_17:51.snap.out diff --git a/contracts/core/BaseOpenfortAccount.sol b/contracts/core/BaseOpenfortAccount.sol index 2697b62..8156269 100644 --- a/contracts/core/BaseOpenfortAccount.sol +++ b/contracts/core/BaseOpenfortAccount.sol @@ -38,8 +38,6 @@ abstract contract BaseOpenfortAccount is bytes4 internal constant EXECUTEBATCH_SELECTOR = 0x47e1da2a; uint48 internal constant DEFAULT_LIMIT = 100; - address internal entrypointContract; - /** * Struct like ValidationData (from the EIP-4337) - alpha solution - to keep track of session keys' data * @param validAfter this sessionKey is valid only after this timestamp. @@ -78,13 +76,6 @@ abstract contract BaseOpenfortAccount is _disableInitializers(); } - /** - * @inheritdoc BaseAccount - */ - function entryPoint() public view override returns (IEntryPoint) { - return IEntryPoint(entrypointContract); - } - /** * Require the function call went through EntryPoint or owner */ diff --git a/contracts/core/managed/ManagedOpenfortAccount.sol b/contracts/core/managed/ManagedOpenfortAccount.sol index 4705097..3cbdcd7 100644 --- a/contracts/core/managed/ManagedOpenfortAccount.sol +++ b/contracts/core/managed/ManagedOpenfortAccount.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.12; // Base account contract to inherit from -import {BaseOpenfortAccount} from "../BaseOpenfortAccount.sol"; +import {BaseOpenfortAccount, IEntryPoint} from "../BaseOpenfortAccount.sol"; /** * @title ManagedOpenfortAccount (Upgradeable via Beacon) @@ -12,14 +12,21 @@ import {BaseOpenfortAccount} from "../BaseOpenfortAccount.sol"; * - BaseOpenfortAccount */ contract ManagedOpenfortAccount is BaseOpenfortAccount { + address constant private ENTRYPOINTCONTRACT = 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789; /* * @notice Initialize the smart contract wallet. */ - function initialize(address _defaultAdmin, address _entrypoint, bytes calldata) public initializer { - if (_defaultAdmin == address(0) || _entrypoint == address(0)) { + function initialize(address _defaultAdmin, bytes calldata) public initializer { + if (_defaultAdmin == address(0)) { revert ZeroAddressNotAllowed(); } _transferOwnership(_defaultAdmin); - entrypointContract = _entrypoint; + } + + /** + * Return the current EntryPoint + */ + function entryPoint() public pure override returns (IEntryPoint) { + return IEntryPoint(ENTRYPOINTCONTRACT); } } diff --git a/contracts/core/managed/ManagedOpenfortFactory.sol b/contracts/core/managed/ManagedOpenfortFactory.sol index be1a0af..ae4bda8 100644 --- a/contracts/core/managed/ManagedOpenfortFactory.sol +++ b/contracts/core/managed/ManagedOpenfortFactory.sol @@ -18,14 +18,12 @@ import {IBaseOpenfortFactory} from "../../interfaces/IBaseOpenfortFactory.sol"; * - IBaseOpenfortFactory */ contract ManagedOpenfortFactory is IBaseOpenfortFactory { - address public immutable entrypointContract; address public immutable openfortBeacon; - constructor(address _entrypoint, address _openfortBeacon) { - if (_entrypoint == address(0) || _openfortBeacon == address(0)) { + constructor(address _openfortBeacon) { + if ( _openfortBeacon == address(0)) { revert ZeroAddressNotAllowed(); } - entrypointContract = _entrypoint; openfortBeacon = _openfortBeacon; } @@ -44,7 +42,7 @@ contract ManagedOpenfortFactory is IBaseOpenfortFactory { account = address( new BeaconProxy{salt: salt}( openfortBeacon, - abi.encodeCall(ManagedOpenfortAccount.initialize, (_admin, entrypointContract, _data)) + abi.encodeCall(ManagedOpenfortAccount.initialize, (_admin, _data)) ) ); } @@ -67,7 +65,7 @@ contract ManagedOpenfortFactory is IBaseOpenfortFactory { account = address( new BeaconProxy{salt: salt}( openfortBeacon, - abi.encodeCall(ManagedOpenfortAccount.initialize, (_admin, entrypointContract, _data)) + abi.encodeCall(ManagedOpenfortAccount.initialize, (_admin, _data)) ) ); } @@ -84,7 +82,7 @@ contract ManagedOpenfortFactory is IBaseOpenfortFactory { type(BeaconProxy).creationCode, abi.encode( openfortBeacon, - abi.encodeCall(ManagedOpenfortAccount.initialize, (_admin, entrypointContract, "")) + abi.encodeCall(ManagedOpenfortAccount.initialize, (_admin, "")) ) ) ) @@ -103,7 +101,7 @@ contract ManagedOpenfortFactory is IBaseOpenfortFactory { type(BeaconProxy).creationCode, abi.encode( openfortBeacon, - abi.encodeCall(ManagedOpenfortAccount.initialize, (_admin, entrypointContract, "")) + abi.encodeCall(ManagedOpenfortAccount.initialize, (_admin, "")) ) ) ) diff --git a/contracts/core/static/StaticOpenfortAccount.sol b/contracts/core/static/StaticOpenfortAccount.sol index 3ce1e44..cc00687 100644 --- a/contracts/core/static/StaticOpenfortAccount.sol +++ b/contracts/core/static/StaticOpenfortAccount.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.12; // Base account contract to inherit from -import {BaseOpenfortAccount} from "../BaseOpenfortAccount.sol"; +import {BaseOpenfortAccount, IEntryPoint} from "../BaseOpenfortAccount.sol"; /** * @title StaticOpenfortAccount (Non-upgradeable) @@ -13,6 +13,8 @@ import {BaseOpenfortAccount} from "../BaseOpenfortAccount.sol"; * - BaseOpenfortAccount */ contract StaticOpenfortAccount is BaseOpenfortAccount { + address internal entrypointContract; + event EntryPointUpdated(address oldEntryPoint, address newEntryPoint); /* @@ -27,6 +29,13 @@ contract StaticOpenfortAccount is BaseOpenfortAccount { entrypointContract = _entrypoint; } + /** + * Return the current EntryPoint + */ + function entryPoint() public view override returns (IEntryPoint) { + return IEntryPoint(entrypointContract); + } + /** * Update the EntryPoint address */ diff --git a/contracts/core/upgradeable/UpgradeableOpenfortAccount.sol b/contracts/core/upgradeable/UpgradeableOpenfortAccount.sol index 8dd2773..73514a0 100644 --- a/contracts/core/upgradeable/UpgradeableOpenfortAccount.sol +++ b/contracts/core/upgradeable/UpgradeableOpenfortAccount.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.12; // Base account contract to inherit from -import {BaseOpenfortAccount} from "../BaseOpenfortAccount.sol"; +import {BaseOpenfortAccount, IEntryPoint} from "../BaseOpenfortAccount.sol"; import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; /** @@ -14,6 +14,8 @@ import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/U * - UUPSUpgradeable */ contract UpgradeableOpenfortAccount is BaseOpenfortAccount, UUPSUpgradeable { + address internal entrypointContract; + /* * @notice Initialize the smart contract wallet. */ @@ -26,4 +28,11 @@ contract UpgradeableOpenfortAccount is BaseOpenfortAccount, UUPSUpgradeable { } function _authorizeUpgrade(address) internal override onlyOwner {} + + /** + * Return the current EntryPoint + */ + function entryPoint() public view override returns (IEntryPoint) { + return IEntryPoint(entrypointContract); + } } diff --git a/contracts/mock/MockedV2ManagedOpenfortAccount.sol b/contracts/mock/MockedV2ManagedOpenfortAccount.sol index a118e01..945df6f 100644 --- a/contracts/mock/MockedV2ManagedOpenfortAccount.sol +++ b/contracts/mock/MockedV2ManagedOpenfortAccount.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.12; // Base account contract to inherit from -import {BaseOpenfortAccount} from "../core/BaseOpenfortAccount.sol"; +import {BaseOpenfortAccount, IEntryPoint} from "../core/BaseOpenfortAccount.sol"; /** * @title ManagedOpenfortAccount (Upgradeable via Beacon) @@ -12,18 +12,26 @@ import {BaseOpenfortAccount} from "../core/BaseOpenfortAccount.sol"; * - BaseOpenfortAccount */ contract MockedV2ManagedOpenfortAccount is BaseOpenfortAccount { + address constant private ENTRYPOINTCONTRACT = 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789; + /* * @notice Initialize the smart contract wallet. */ - function initialize(address _defaultAdmin, address _entrypoint, bytes calldata) public initializer { - if (_defaultAdmin == address(0) || _entrypoint == address(0)) { + function initialize(address _defaultAdmin, bytes calldata) public initializer { + if (_defaultAdmin == address(0)) { revert ZeroAddressNotAllowed(); } _transferOwnership(_defaultAdmin); - entrypointContract = _entrypoint; } function version() external pure override returns (uint256) { return 2; } + + /** + * Return the current EntryPoint + */ + function entryPoint() public pure override returns (IEntryPoint) { + return IEntryPoint(ENTRYPOINTCONTRACT); + } } diff --git a/contracts/mock/MockedV2UpgradeableOpenfortAccount.sol b/contracts/mock/MockedV2UpgradeableOpenfortAccount.sol index 0195212..12b823c 100644 --- a/contracts/mock/MockedV2UpgradeableOpenfortAccount.sol +++ b/contracts/mock/MockedV2UpgradeableOpenfortAccount.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.12; // Base account contract to inherit from -import {BaseOpenfortAccount} from "../core/BaseOpenfortAccount.sol"; +import {BaseOpenfortAccount, IEntryPoint} from "../core/BaseOpenfortAccount.sol"; import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; /** @@ -14,6 +14,7 @@ import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/U * - UUPSUpgradeable */ contract MockedV2UpgradeableOpenfortAccount is BaseOpenfortAccount, UUPSUpgradeable { + address internal entrypointContract; /* * @notice Initialize the smart contract wallet. */ @@ -30,4 +31,11 @@ contract MockedV2UpgradeableOpenfortAccount is BaseOpenfortAccount, UUPSUpgradea function version() external pure override returns (uint256) { return 2; } + + /** + * Return the current EntryPoint + */ + function entryPoint() public view override returns (IEntryPoint) { + return IEntryPoint(entrypointContract); + } } diff --git a/gas_reports/2023-05-31_17:51.gas.out b/gas_reports/2023-05-31_17:51.gas.out new file mode 100644 index 0000000..fc12cf7 --- /dev/null +++ b/gas_reports/2023-05-31_17:51.gas.out @@ -0,0 +1,303 @@ + +Running 1 test for test/foundry/4337/Specific4337Tests.t.sol:Specific4337Tests +[PASS] testToken():(address) (gas: 2382) +Test result: ok. 1 passed; 0 failed; finished in 3.34s + +Running 14 tests for test/foundry/paymaster/OpenfortPaymasterTest.t.sol:OpenfortPaymasterTest +[PASS] testEntryPointDepositToPaymaster() (gas: 45021) +[PASS] testFailPaymasterUserOpERC20ValidSigExecBatchInsufficientERC20() (gas: 319856) +[PASS] testFailPaymasterUserOpERC20ValidSigSmallApprove() (gas: 279828) +[PASS] testInitialParameters() (gas: 13782) +[PASS] testParsePaymasterDataERC20() (gas: 35513) +[PASS] testParsePaymasterDataNative() (gas: 33247) +[PASS] testPaymasterAddStake() (gas: 47881) +[PASS] testPaymasterUserOpERC20ValidSig() (gas: 300489) +[PASS] testPaymasterUserOpERC20ValidSigExecBatch() (gas: 341300) +[PASS] testPaymasterUserOpNativeValidSig() (gas: 230754) +[PASS] testPaymasterUserOpNativeValidSigExecBatch() (gas: 273169) +[PASS] testPaymasterUserOpWrongSig() (gas: 133317) +[PASS] testPaymasterUserOpWrongSigLength() (gas: 103571) +[PASS] testToken():(address) (gas: 2383) +Test result: ok. 14 passed; 0 failed; finished in 4.69s + +Running 30 tests for test/foundry/core/managed/ManagedOpenfortAccountTest.t.sol:ManagedOpenfortAccountTest +[PASS] testChangeOwnershipAndCountDirect() (gas: 272461) +[PASS] testChangeOwnershipAndCountEntryPoint() (gas: 422986) +[PASS] testCreateAccountViaEntryPoint() (gas: 335107) +[PASS] testCreateAccountViaFactory() (gas: 247446) +[PASS] testCreateAccountViaFactoryWithNonce() (gas: 448791) +[PASS] testFailAttackRegisterSessionKeyViaEntrypoint2ndKey() (gas: 616186) +[PASS] testFailIncrementCounterViaSessionKeyNotregistered() (gas: 387252) +[PASS] testFailIncrementCounterViaSessionKeyReachLimit() (gas: 522032) +[PASS] testFailIncrementCounterViaSessionKeyReachLimitBatching() (gas: 426519) +[PASS] testFailIncrementCounterViaSessionKeyRevoked() (gas: 267275) +[PASS] testFailIncrementCounterViaSessionKeyWhitelistingBatch() (gas: 484031) +[PASS] testFailIncrementCounterViaSessionKeyWhitelistingBatchWrongAddress() (gas: 449705) +[PASS] testFailIncrementCounterViaSessionKeyWhitelistingTooBig() (gas: 243491) +[PASS] testFailIncrementCounterViaSessionKeyWhitelistingWrongAddress() (gas: 441221) +[PASS] testFailRevokeSessionKeyInvalidUser() (gas: 269819) +[PASS] testIncrementCounterDirect() (gas: 262253) +[PASS] testIncrementCounterViaEntrypoint() (gas: 414647) +[PASS] testIncrementCounterViaEntrypointBatching() (gas: 426911) +[PASS] testIncrementCounterViaSessionKey() (gas: 444818) +[PASS] testIncrementCounterViaSessionKeyExpired() (gas: 414111) +[PASS] testIncrementCounterViaSessionKeyWhitelisting() (gas: 470378) +[PASS] testIncrementCounterViaSessionKeyWhitelistingBatch() (gas: 494406) +[PASS] testMintTokenAccount() (gas: 443668) +[PASS] testReceiveNativeToken() (gas: 238318) +[PASS] testRegisterSessionKeyViaEntrypoint() (gas: 527314) +[PASS] testRegisterSessionKeyViaEntrypoint2ndKey() (gas: 639002) +[PASS] testSimulateValidation() (gas: 339318) +[PASS] testToken():(address) (gas: 2426) +[PASS] testTransferOutNativeToken() (gas: 347945) +[PASS] testUpgradeTo() (gas: 2125052) +Test result: ok. 30 passed; 0 failed; finished in 5.35s + +Running 29 tests for test/foundry/core/upgradeable/UpgradeableOpenfortAccountTest.t.sol:UpgradeableOpenfortAccountTest +[PASS] testChangeOwnershipAndCountDirect() (gas: 231956) +[PASS] testChangeOwnershipAndCountEntryPoint() (gas: 381333) +[PASS] testCreateAccountViaEntryPoint() (gas: 293095) +[PASS] testCreateAccountViaFactory() (gas: 206535) +[PASS] testCreateAccountViaFactoryWithNonce() (gas: 375044) +[PASS] testFailAttackRegisterSessionKeyViaEntrypoint2ndKey() (gas: 572021) +[PASS] testFailIncrementCounterViaSessionKeyNotregistered() (gas: 347624) +[PASS] testFailIncrementCounterViaSessionKeyReachLimit() (gas: 480162) +[PASS] testFailIncrementCounterViaSessionKeyReachLimitBatching() (gas: 386336) +[PASS] testFailIncrementCounterViaSessionKeyRevoked() (gas: 227635) +[PASS] testFailIncrementCounterViaSessionKeyWhitelistingBatchWrongAddress() (gas: 409500) +[PASS] testFailIncrementCounterViaSessionKeyWhitelistingTooBig() (gas: 204418) +[PASS] testFailIncrementCounterViaSessionKeyWhitelistingWrongAddress() (gas: 401016) +[PASS] testFailRevokeSessionKeyInvalidUser() (gas: 230179) +[PASS] testIncrementCounterDirect() (gas: 223174) +[PASS] testIncrementCounterViaEntrypoint() (gas: 374498) +[PASS] testIncrementCounterViaEntrypointBatching() (gas: 386728) +[PASS] testIncrementCounterViaSessionKey() (gas: 404052) +[PASS] testIncrementCounterViaSessionKeyExpired() (gas: 373903) +[PASS] testIncrementCounterViaSessionKeyWhitelisting() (gas: 429618) +[PASS] testIncrementCounterViaSessionKeyWhitelistingBatch() (gas: 452995) +[PASS] testMintTokenAccount() (gas: 403351) +[PASS] testReceiveNativeToken() (gas: 199099) +[PASS] testRegisterSessionKeyViaEntrypoint() (gas: 484886) +[PASS] testRegisterSessionKeyViaEntrypoint2ndKey() (gas: 594351) +[PASS] testSimulateValidation() (gas: 300257) +[PASS] testToken():(address) (gas: 2426) +[PASS] testTransferOutNativeToken() (gas: 307594) +[PASS] testUpgradeAccount() (gas: 2473820) +Test result: ok. 29 passed; 0 failed; finished in 5.36s + +Running 30 tests for test/foundry/core/static/StaticOpenfortAccountTest.t.sol:StaticOpenfortAccountTest +[PASS] testChangeOwnershipAndCountDirect() (gas: 174591) +[PASS] testChangeOwnershipAndCountEntryPoint() (gas: 323573) +[PASS] testCreateAccountViaEntryPoint() (gas: 225651) +[PASS] testCreateAccountViaFactory() (gas: 139646) +[PASS] testCreateAccountViaFactoryWithNonce() (gas: 256326) +[PASS] testFailAttackRegisterSessionKeyViaEntrypoint2ndKey() (gas: 513242) +[PASS] testFailIncrementCounterViaSessionKeyNotregistered() (gas: 290564) +[PASS] testFailIncrementCounterViaSessionKeyReachLimit() (gas: 422239) +[PASS] testFailIncrementCounterViaSessionKeyReachLimitBatching() (gas: 329031) +[PASS] testFailIncrementCounterViaSessionKeyRevoked() (gas: 170541) +[PASS] testFailIncrementCounterViaSessionKeyWhitelistingBatch() (gas: 385559) +[PASS] testFailIncrementCounterViaSessionKeyWhitelistingBatchWrongAddress() (gas: 352129) +[PASS] testFailIncrementCounterViaSessionKeyWhitelistingTooBig() (gas: 147484) +[PASS] testFailIncrementCounterViaSessionKeyWhitelistingWrongAddress() (gas: 343645) +[PASS] testFailRevokeSessionKeyInvalidUser() (gas: 173085) +[PASS] testIncrementCounterDirect() (gas: 166279) +[PASS] testIncrementCounterViaEntrypoint() (gas: 317164) +[PASS] testIncrementCounterViaEntrypointBatching() (gas: 329394) +[PASS] testIncrementCounterViaSessionKey() (gas: 346568) +[PASS] testIncrementCounterViaSessionKeyExpired() (gas: 316620) +[PASS] testIncrementCounterViaSessionKeyWhitelisting() (gas: 372157) +[PASS] testIncrementCounterViaSessionKeyWhitelistingBatch() (gas: 395178) +[PASS] testMintTokenAccount() (gas: 346017) +[PASS] testReceiveNativeToken() (gas: 142185) +[PASS] testRegisterSessionKeyViaEntrypoint() (gas: 426762) +[PASS] testRegisterSessionKeyViaEntrypoint2ndKey() (gas: 535415) +[PASS] testSimulateValidation() (gas: 243391) +[PASS] testToken():(address) (gas: 2404) +[PASS] testTransferOutNativeToken() (gas: 250263) +[PASS] testUpdateEntryPoint() (gas: 538664) +Test result: ok. 30 passed; 0 failed; finished in 5.36s +| EntryPoint contract | | | | | | +|---------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 0 | 0 | | | | | +| Function Name | min | avg | median | max | # calls | +| addStake | 25917 | 25917 | 25917 | 25917 | 1 | +| balanceOf | 594 | 1260 | 594 | 2594 | 3 | +| depositTo | 2606 | 10839 | 5406 | 24506 | 3 | + + +| contracts/core/managed/ManagedOpenfortAccount.sol:ManagedOpenfortAccount contract | | | | | | +|-----------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 1831742 | 9306 | | | | | +| Function Name | min | avg | median | max | # calls | +| acceptOwnership | 1996 | 1996 | 1996 | 1996 | 2 | +| execute | 3568 | 21350 | 21542 | 32768 | 17 | +| executeBatch | 25603 | 25603 | 25603 | 25603 | 2 | +| initialize | 72889 | 72889 | 72889 | 72889 | 30 | +| receive | 55 | 55 | 55 | 55 | 2 | +| registerSessionKey(address,uint48,uint48) | 24617 | 24622 | 24617 | 24629 | 7 | +| registerSessionKey(address,uint48,uint48,uint48) | 24367 | 24371 | 24367 | 24379 | 3 | +| registerSessionKey(address,uint48,uint48,uint48,address[]) | 1288 | 39642 | 47313 | 47313 | 6 | +| revokeSessionKey | 609 | 609 | 609 | 609 | 2 | +| sessionKeys | 810 | 810 | 810 | 810 | 3 | +| transferOwnership | 22375 | 22375 | 22375 | 22375 | 2 | +| validateUserOp | 5005 | 7241 | 6740 | 15510 | 49 | +| version | 259 | 259 | 259 | 259 | 1 | + + +| contracts/core/managed/ManagedOpenfortFactory.sol:ManagedOpenfortFactory contract | | | | | | +|-----------------------------------------------------------------------------------|-----------------|--------|--------|--------|---------| +| Deployment Cost | Deployment Size | | | | | +| 849897 | 4613 | | | | | +| Function Name | min | avg | median | max | # calls | +| createAccount | 7848 | 205688 | 219419 | 219419 | 31 | +| createAccountWithNonce | 212472 | 212472 | 212472 | 212472 | 1 | +| getAddress | 7217 | 7217 | 7217 | 7217 | 4 | + + +| contracts/core/managed/OpenfortBeacon.sol:OpenfortBeacon contract | | | | | | +|-------------------------------------------------------------------|-----------------|------|--------|------|---------| +| Deployment Cost | Deployment Size | | | | | +| 213861 | 1248 | | | | | +| Function Name | min | avg | median | max | # calls | +| implementation | 308 | 672 | 308 | 2308 | 159 | +| upgradeTo | 2510 | 4659 | 4659 | 6809 | 2 | + + +| contracts/core/static/StaticOpenfortAccount.sol:StaticOpenfortAccount contract | | | | | | +|--------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 1877392 | 9534 | | | | | +| Function Name | min | avg | median | max | # calls | +| acceptOwnership | 1944 | 1944 | 1944 | 1944 | 2 | +| entryPoint | 376 | 376 | 376 | 376 | 2 | +| execute | 3708 | 22011 | 21747 | 32908 | 20 | +| executeBatch | 25743 | 40742 | 48408 | 55408 | 5 | +| initialize | 74366 | 74366 | 74366 | 74366 | 44 | +| receive | 55 | 55 | 55 | 55 | 2 | +| registerSessionKey(address,uint48,uint48) | 24757 | 24762 | 24757 | 24769 | 7 | +| registerSessionKey(address,uint48,uint48,uint48) | 24485 | 24489 | 24485 | 24497 | 3 | +| registerSessionKey(address,uint48,uint48,uint48,address[]) | 1340 | 39694 | 47365 | 47365 | 6 | +| revokeSessionKey | 749 | 749 | 749 | 749 | 2 | +| sessionKeys | 832 | 832 | 832 | 832 | 3 | +| transferOwnership | 22375 | 22375 | 22375 | 22375 | 2 | +| updateEntryPoint | 651 | 1483 | 1483 | 2315 | 2 | +| validateUserOp | 5145 | 7629 | 6880 | 15650 | 57 | + + +| contracts/core/static/StaticOpenfortFactory.sol:StaticOpenfortFactory contract | | | | | | +|--------------------------------------------------------------------------------|-----------------|--------|--------|--------|---------| +| Deployment Cost | Deployment Size | | | | | +| 366774 | 2178 | | | | | +| Function Name | min | avg | median | max | # calls | +| createAccount | 1273 | 120553 | 124200 | 124200 | 44 | +| createAccountWithNonce | 121729 | 121729 | 121729 | 121729 | 1 | +| getAddress | 830 | 830 | 830 | 830 | 4 | + + +| contracts/core/upgradeable/UpgradeableOpenfortAccount.sol:UpgradeableOpenfortAccount contract | | | | | | +|-----------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 2237283 | 11381 | | | | | +| Function Name | min | avg | median | max | # calls | +| acceptOwnership | 1962 | 1962 | 1962 | 1962 | 2 | +| execute | 3708 | 21354 | 21682 | 32908 | 17 | +| executeBatch | 25743 | 25743 | 25743 | 25743 | 2 | +| initialize | 72911 | 72911 | 72911 | 72911 | 29 | +| receive | 55 | 55 | 55 | 55 | 2 | +| registerSessionKey(address,uint48,uint48) | 24735 | 24740 | 24735 | 24747 | 7 | +| registerSessionKey(address,uint48,uint48,uint48) | 24485 | 24489 | 24485 | 24497 | 3 | +| registerSessionKey(address,uint48,uint48,uint48,address[]) | 1406 | 38226 | 47431 | 47431 | 5 | +| revokeSessionKey | 771 | 771 | 771 | 771 | 2 | +| sessionKeys | 832 | 832 | 832 | 832 | 2 | +| transferOwnership | 22375 | 22375 | 22375 | 22375 | 2 | +| upgradeTo | 890 | 3226 | 3226 | 5562 | 2 | +| validateUserOp | 5145 | 7029 | 6880 | 12521 | 47 | +| version | 303 | 303 | 303 | 303 | 1 | + + +| contracts/core/upgradeable/UpgradeableOpenfortFactory.sol:UpgradeableOpenfortFactory contract | | | | | | +|-----------------------------------------------------------------------------------------------|-----------------|--------|--------|--------|---------| +| Deployment Cost | Deployment Size | | | | | +| 708540 | 3899 | | | | | +| Function Name | min | avg | median | max | # calls | +| createAccount | 6652 | 174806 | 180901 | 180901 | 29 | +| createAccountWithNonce | 178454 | 178454 | 178454 | 178454 | 1 | +| getAddress | 6022 | 6022 | 6022 | 6022 | 4 | + + +| contracts/mock/MockedV2ManagedOpenfortAccount.sol:MockedV2ManagedOpenfortAccount contract | | | | | | +|-------------------------------------------------------------------------------------------|-----------------|-----|--------|-----|---------| +| Deployment Cost | Deployment Size | | | | | +| 1831742 | 9306 | | | | | +| Function Name | min | avg | median | max | # calls | +| version | 259 | 259 | 259 | 259 | 2 | + + +| contracts/mock/MockedV2UpgradeableOpenfortAccount.sol:MockedV2UpgradeableOpenfortAccount contract | | | | | | +|---------------------------------------------------------------------------------------------------|-----------------|-----|--------|-----|---------| +| Deployment Cost | Deployment Size | | | | | +| 2237283 | 11381 | | | | | +| Function Name | min | avg | median | max | # calls | +| proxiableUUID | 374 | 374 | 374 | 374 | 1 | +| version | 303 | 303 | 303 | 303 | 1 | + + +| contracts/paymaster/OpenfortPaymaster.sol:OpenfortPaymaster contract | | | | | | +|----------------------------------------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 1215863 | 6347 | | | | | +| Function Name | min | avg | median | max | # calls | +| addStake | 520 | 30701 | 33420 | 33420 | 16 | +| deposit | 9845 | 32618 | 34245 | 34245 | 15 | +| entryPoint | 261 | 261 | 261 | 261 | 1 | +| getDeposit | 1181 | 2104 | 1181 | 3181 | 13 | +| getHash | 3462 | 5053 | 4998 | 6535 | 12 | +| owner | 2365 | 2365 | 2365 | 2365 | 7 | +| parsePaymasterAndData | 1516 | 1516 | 1516 | 1516 | 2 | +| postOp | 1433 | 12421 | 5583 | 30248 | 6 | +| validatePaymasterUserOp | 1694 | 26885 | 30289 | 31112 | 8 | + + +| node_modules/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol:ERC1967Proxy contract | | | | | | +|-------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 136587 | 1505 | | | | | +| Function Name | min | avg | median | max | # calls | +| acceptOwnership | 2276 | 2276 | 2276 | 2276 | 2 | +| execute | 4118 | 21774 | 22098 | 33318 | 17 | +| executeBatch | 26255 | 26255 | 26255 | 26255 | 2 | +| receive | 454 | 454 | 454 | 454 | 2 | +| registerSessionKey(address,uint48,uint48) | 25139 | 25144 | 25139 | 25151 | 7 | +| registerSessionKey(address,uint48,uint48,uint48) | 24895 | 24899 | 24895 | 24907 | 3 | +| registerSessionKey(address,uint48,uint48,uint48,address[]) | 1907 | 38668 | 47859 | 47859 | 5 | +| revokeSessionKey | 1170 | 1170 | 1170 | 1170 | 2 | +| sessionKeys | 1248 | 1248 | 1248 | 1248 | 2 | +| transferOwnership | 22770 | 22770 | 22770 | 22770 | 2 | +| upgradeTo | 1301 | 3629 | 3629 | 5957 | 2 | +| validateUserOp | 5691 | 7603 | 7432 | 13171 | 47 | +| version | 698 | 698 | 698 | 698 | 2 | + + +| node_modules/@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol:BeaconProxy contract | | | | | | +|----------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 173708 | 1996 | | | | | +| Function Name | min | avg | median | max | # calls | +| acceptOwnership | 2871 | 2871 | 2871 | 2871 | 2 | +| execute | 4673 | 22466 | 22653 | 33873 | 17 | +| executeBatch | 26810 | 26810 | 26810 | 26810 | 2 | +| receive | 1155 | 1155 | 1155 | 1155 | 2 | +| registerSessionKey(address,uint48,uint48) | 25719 | 25724 | 25719 | 25731 | 7 | +| registerSessionKey(address,uint48,uint48,uint48) | 25472 | 25476 | 25472 | 25484 | 3 | +| registerSessionKey(address,uint48,uint48,uint48,address[]) | 2484 | 40777 | 48436 | 48436 | 6 | +| revokeSessionKey | 1709 | 1709 | 1709 | 1709 | 2 | +| sessionKeys | 1921 | 1921 | 1921 | 1921 | 3 | +| transferOwnership | 23471 | 23471 | 23471 | 23471 | 2 | +| validateUserOp | 6246 | 8523 | 7987 | 17105 | 49 | +| version | 1355 | 1355 | 1355 | 1355 | 3 | + + + diff --git a/gas_reports/2023-05-31_17:51.snap.out b/gas_reports/2023-05-31_17:51.snap.out new file mode 100644 index 0000000..3c8f10d --- /dev/null +++ b/gas_reports/2023-05-31_17:51.snap.out @@ -0,0 +1,104 @@ +ManagedOpenfortAccountTest:testChangeOwnershipAndCountDirect() (gas: 272461) +ManagedOpenfortAccountTest:testChangeOwnershipAndCountEntryPoint() (gas: 422986) +ManagedOpenfortAccountTest:testCreateAccountViaEntryPoint() (gas: 335107) +ManagedOpenfortAccountTest:testCreateAccountViaFactory() (gas: 247446) +ManagedOpenfortAccountTest:testCreateAccountViaFactoryWithNonce() (gas: 448791) +ManagedOpenfortAccountTest:testFailAttackRegisterSessionKeyViaEntrypoint2ndKey() (gas: 616186) +ManagedOpenfortAccountTest:testFailIncrementCounterViaSessionKeyNotregistered() (gas: 387252) +ManagedOpenfortAccountTest:testFailIncrementCounterViaSessionKeyReachLimit() (gas: 522032) +ManagedOpenfortAccountTest:testFailIncrementCounterViaSessionKeyReachLimitBatching() (gas: 426519) +ManagedOpenfortAccountTest:testFailIncrementCounterViaSessionKeyRevoked() (gas: 267275) +ManagedOpenfortAccountTest:testFailIncrementCounterViaSessionKeyWhitelistingBatch() (gas: 484031) +ManagedOpenfortAccountTest:testFailIncrementCounterViaSessionKeyWhitelistingBatchWrongAddress() (gas: 449705) +ManagedOpenfortAccountTest:testFailIncrementCounterViaSessionKeyWhitelistingTooBig() (gas: 243491) +ManagedOpenfortAccountTest:testFailIncrementCounterViaSessionKeyWhitelistingWrongAddress() (gas: 441221) +ManagedOpenfortAccountTest:testFailRevokeSessionKeyInvalidUser() (gas: 269819) +ManagedOpenfortAccountTest:testIncrementCounterDirect() (gas: 262253) +ManagedOpenfortAccountTest:testIncrementCounterViaEntrypoint() (gas: 414647) +ManagedOpenfortAccountTest:testIncrementCounterViaEntrypointBatching() (gas: 426911) +ManagedOpenfortAccountTest:testIncrementCounterViaSessionKey() (gas: 444818) +ManagedOpenfortAccountTest:testIncrementCounterViaSessionKeyExpired() (gas: 414111) +ManagedOpenfortAccountTest:testIncrementCounterViaSessionKeyWhitelisting() (gas: 470378) +ManagedOpenfortAccountTest:testIncrementCounterViaSessionKeyWhitelistingBatch() (gas: 494406) +ManagedOpenfortAccountTest:testMintTokenAccount() (gas: 443668) +ManagedOpenfortAccountTest:testReceiveNativeToken() (gas: 238318) +ManagedOpenfortAccountTest:testRegisterSessionKeyViaEntrypoint() (gas: 527314) +ManagedOpenfortAccountTest:testRegisterSessionKeyViaEntrypoint2ndKey() (gas: 639002) +ManagedOpenfortAccountTest:testSimulateValidation() (gas: 339318) +ManagedOpenfortAccountTest:testToken():(address) (gas: 2426) +ManagedOpenfortAccountTest:testTransferOutNativeToken() (gas: 347945) +ManagedOpenfortAccountTest:testUpgradeTo() (gas: 2125052) +OpenfortPaymasterTest:testEntryPointDepositToPaymaster() (gas: 45021) +OpenfortPaymasterTest:testFailPaymasterUserOpERC20ValidSigExecBatchInsufficientERC20() (gas: 319856) +OpenfortPaymasterTest:testFailPaymasterUserOpERC20ValidSigSmallApprove() (gas: 279828) +OpenfortPaymasterTest:testInitialParameters() (gas: 13782) +OpenfortPaymasterTest:testParsePaymasterDataERC20() (gas: 35513) +OpenfortPaymasterTest:testParsePaymasterDataNative() (gas: 33247) +OpenfortPaymasterTest:testPaymasterAddStake() (gas: 47881) +OpenfortPaymasterTest:testPaymasterUserOpERC20ValidSig() (gas: 300489) +OpenfortPaymasterTest:testPaymasterUserOpERC20ValidSigExecBatch() (gas: 341300) +OpenfortPaymasterTest:testPaymasterUserOpNativeValidSig() (gas: 230754) +OpenfortPaymasterTest:testPaymasterUserOpNativeValidSigExecBatch() (gas: 273169) +OpenfortPaymasterTest:testPaymasterUserOpWrongSig() (gas: 133317) +OpenfortPaymasterTest:testPaymasterUserOpWrongSigLength() (gas: 103571) +OpenfortPaymasterTest:testToken():(address) (gas: 2383) +Specific4337Tests:testToken():(address) (gas: 2382) +StaticOpenfortAccountTest:testChangeOwnershipAndCountDirect() (gas: 174591) +StaticOpenfortAccountTest:testChangeOwnershipAndCountEntryPoint() (gas: 323573) +StaticOpenfortAccountTest:testCreateAccountViaEntryPoint() (gas: 225651) +StaticOpenfortAccountTest:testCreateAccountViaFactory() (gas: 139646) +StaticOpenfortAccountTest:testCreateAccountViaFactoryWithNonce() (gas: 256326) +StaticOpenfortAccountTest:testFailAttackRegisterSessionKeyViaEntrypoint2ndKey() (gas: 513242) +StaticOpenfortAccountTest:testFailIncrementCounterViaSessionKeyNotregistered() (gas: 290564) +StaticOpenfortAccountTest:testFailIncrementCounterViaSessionKeyReachLimit() (gas: 422239) +StaticOpenfortAccountTest:testFailIncrementCounterViaSessionKeyReachLimitBatching() (gas: 329031) +StaticOpenfortAccountTest:testFailIncrementCounterViaSessionKeyRevoked() (gas: 170541) +StaticOpenfortAccountTest:testFailIncrementCounterViaSessionKeyWhitelistingBatch() (gas: 385559) +StaticOpenfortAccountTest:testFailIncrementCounterViaSessionKeyWhitelistingBatchWrongAddress() (gas: 352129) +StaticOpenfortAccountTest:testFailIncrementCounterViaSessionKeyWhitelistingTooBig() (gas: 147484) +StaticOpenfortAccountTest:testFailIncrementCounterViaSessionKeyWhitelistingWrongAddress() (gas: 343645) +StaticOpenfortAccountTest:testFailRevokeSessionKeyInvalidUser() (gas: 173085) +StaticOpenfortAccountTest:testIncrementCounterDirect() (gas: 166279) +StaticOpenfortAccountTest:testIncrementCounterViaEntrypoint() (gas: 317164) +StaticOpenfortAccountTest:testIncrementCounterViaEntrypointBatching() (gas: 329394) +StaticOpenfortAccountTest:testIncrementCounterViaSessionKey() (gas: 346568) +StaticOpenfortAccountTest:testIncrementCounterViaSessionKeyExpired() (gas: 316620) +StaticOpenfortAccountTest:testIncrementCounterViaSessionKeyWhitelisting() (gas: 372157) +StaticOpenfortAccountTest:testIncrementCounterViaSessionKeyWhitelistingBatch() (gas: 395178) +StaticOpenfortAccountTest:testMintTokenAccount() (gas: 346017) +StaticOpenfortAccountTest:testReceiveNativeToken() (gas: 142185) +StaticOpenfortAccountTest:testRegisterSessionKeyViaEntrypoint() (gas: 426762) +StaticOpenfortAccountTest:testRegisterSessionKeyViaEntrypoint2ndKey() (gas: 535415) +StaticOpenfortAccountTest:testSimulateValidation() (gas: 243391) +StaticOpenfortAccountTest:testToken():(address) (gas: 2404) +StaticOpenfortAccountTest:testTransferOutNativeToken() (gas: 250263) +StaticOpenfortAccountTest:testUpdateEntryPoint() (gas: 538664) +UpgradeableOpenfortAccountTest:testChangeOwnershipAndCountDirect() (gas: 231956) +UpgradeableOpenfortAccountTest:testChangeOwnershipAndCountEntryPoint() (gas: 381333) +UpgradeableOpenfortAccountTest:testCreateAccountViaEntryPoint() (gas: 293095) +UpgradeableOpenfortAccountTest:testCreateAccountViaFactory() (gas: 206535) +UpgradeableOpenfortAccountTest:testCreateAccountViaFactoryWithNonce() (gas: 375044) +UpgradeableOpenfortAccountTest:testFailAttackRegisterSessionKeyViaEntrypoint2ndKey() (gas: 572021) +UpgradeableOpenfortAccountTest:testFailIncrementCounterViaSessionKeyNotregistered() (gas: 347624) +UpgradeableOpenfortAccountTest:testFailIncrementCounterViaSessionKeyReachLimit() (gas: 480162) +UpgradeableOpenfortAccountTest:testFailIncrementCounterViaSessionKeyReachLimitBatching() (gas: 386336) +UpgradeableOpenfortAccountTest:testFailIncrementCounterViaSessionKeyRevoked() (gas: 227635) +UpgradeableOpenfortAccountTest:testFailIncrementCounterViaSessionKeyWhitelistingBatchWrongAddress() (gas: 409500) +UpgradeableOpenfortAccountTest:testFailIncrementCounterViaSessionKeyWhitelistingTooBig() (gas: 204418) +UpgradeableOpenfortAccountTest:testFailIncrementCounterViaSessionKeyWhitelistingWrongAddress() (gas: 401016) +UpgradeableOpenfortAccountTest:testFailRevokeSessionKeyInvalidUser() (gas: 230179) +UpgradeableOpenfortAccountTest:testIncrementCounterDirect() (gas: 223174) +UpgradeableOpenfortAccountTest:testIncrementCounterViaEntrypoint() (gas: 374498) +UpgradeableOpenfortAccountTest:testIncrementCounterViaEntrypointBatching() (gas: 386728) +UpgradeableOpenfortAccountTest:testIncrementCounterViaSessionKey() (gas: 404052) +UpgradeableOpenfortAccountTest:testIncrementCounterViaSessionKeyExpired() (gas: 373903) +UpgradeableOpenfortAccountTest:testIncrementCounterViaSessionKeyWhitelisting() (gas: 429618) +UpgradeableOpenfortAccountTest:testIncrementCounterViaSessionKeyWhitelistingBatch() (gas: 452995) +UpgradeableOpenfortAccountTest:testMintTokenAccount() (gas: 403351) +UpgradeableOpenfortAccountTest:testReceiveNativeToken() (gas: 199099) +UpgradeableOpenfortAccountTest:testRegisterSessionKeyViaEntrypoint() (gas: 484886) +UpgradeableOpenfortAccountTest:testRegisterSessionKeyViaEntrypoint2ndKey() (gas: 594351) +UpgradeableOpenfortAccountTest:testSimulateValidation() (gas: 300257) +UpgradeableOpenfortAccountTest:testToken():(address) (gas: 2426) +UpgradeableOpenfortAccountTest:testTransferOutNativeToken() (gas: 307594) +UpgradeableOpenfortAccountTest:testUpgradeAccount() (gas: 2473820) \ No newline at end of file diff --git a/script/deployManagedAccounts.sol b/script/deployManagedAccounts.sol index 785039d..95b3e69 100644 --- a/script/deployManagedAccounts.sol +++ b/script/deployManagedAccounts.sol @@ -23,7 +23,7 @@ contract ManagedOpenfortDeploy is Script { OpenfortBeacon openfortBeacon = new OpenfortBeacon(address(managedOpenfortAccount)); // Create a factory to deploy cloned accounts - ManagedOpenfortFactory managedOpenfortFactory = new ManagedOpenfortFactory{salt: versionSalt}(address(entryPoint), address(openfortBeacon)); + ManagedOpenfortFactory managedOpenfortFactory = new ManagedOpenfortFactory{salt: versionSalt}(address(openfortBeacon)); // address account1 = managedOpenfortFactory.accountImplementation(); // The first call should create a new account, while the second will just return the corresponding account address @@ -33,6 +33,7 @@ contract ManagedOpenfortDeploy is Script { ); MockedV2ManagedOpenfortAccount mockedOpenfortAccount = new MockedV2ManagedOpenfortAccount{salt: versionSalt}(); + (mockedOpenfortAccount); // assert(account1 != account2); // address account3 = managedOpenfortFactory.createAccountWithNonce(deployAddress, "", 3); diff --git a/test/foundry/core/managed/ManagedOpenfortAccountTest.t.sol b/test/foundry/core/managed/ManagedOpenfortAccountTest.t.sol index edb87fb..2911194 100644 --- a/test/foundry/core/managed/ManagedOpenfortAccountTest.t.sol +++ b/test/foundry/core/managed/ManagedOpenfortAccountTest.t.sol @@ -140,7 +140,7 @@ contract ManagedOpenfortAccountTest is Test { // deploy OpenfortBeacon openfortBeacon = new OpenfortBeacon(address(managedOpenfortAccount)); // deploy account factory - managedOpenfortFactory = new ManagedOpenfortFactory((payable(vm.envAddress("ENTRY_POINT_ADDRESS"))), address(openfortBeacon)); + managedOpenfortFactory = new ManagedOpenfortFactory(address(openfortBeacon)); // deploy a new TestCounter testCounter = new TestCounter(); // deploy a new TestToken (ERC20) From 100f3977f31723e8bb35ea253c7fe893c6235cc0 Mon Sep 17 00:00:00 2001 From: Eloi Manuel Date: Wed, 31 May 2023 18:02:19 +0200 Subject: [PATCH 4/7] adding tests update entryPoint --- .../UpgradeableOpenfortAccount.sol | 13 + gas_reports/2023-05-31_17:59.gas.out | 303 ++++++++++++++++++ gas_reports/2023-05-31_17:59.snap.out | 104 ++++++ .../UpgradeableOpenfortAccountTest.t.sol | 83 +++-- 4 files changed, 473 insertions(+), 30 deletions(-) create mode 100644 gas_reports/2023-05-31_17:59.gas.out create mode 100644 gas_reports/2023-05-31_17:59.snap.out diff --git a/contracts/core/upgradeable/UpgradeableOpenfortAccount.sol b/contracts/core/upgradeable/UpgradeableOpenfortAccount.sol index 73514a0..21ac229 100644 --- a/contracts/core/upgradeable/UpgradeableOpenfortAccount.sol +++ b/contracts/core/upgradeable/UpgradeableOpenfortAccount.sol @@ -16,6 +16,8 @@ import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/U contract UpgradeableOpenfortAccount is BaseOpenfortAccount, UUPSUpgradeable { address internal entrypointContract; + event EntryPointUpdated(address oldEntryPoint, address newEntryPoint); + /* * @notice Initialize the smart contract wallet. */ @@ -35,4 +37,15 @@ contract UpgradeableOpenfortAccount is BaseOpenfortAccount, UUPSUpgradeable { function entryPoint() public view override returns (IEntryPoint) { return IEntryPoint(entrypointContract); } + + /** + * Update the EntryPoint address + */ + function updateEntryPoint(address _newEntrypoint) external onlyOwner { + if (_newEntrypoint == address(0)) { + revert ZeroAddressNotAllowed(); + } + emit EntryPointUpdated(entrypointContract, _newEntrypoint); + entrypointContract = _newEntrypoint; + } } diff --git a/gas_reports/2023-05-31_17:59.gas.out b/gas_reports/2023-05-31_17:59.gas.out new file mode 100644 index 0000000..b699adb --- /dev/null +++ b/gas_reports/2023-05-31_17:59.gas.out @@ -0,0 +1,303 @@ + +Running 1 test for test/foundry/4337/Specific4337Tests.t.sol:Specific4337Tests +[PASS] testToken():(address) (gas: 2382) +Test result: ok. 1 passed; 0 failed; finished in 1.90s + +Running 14 tests for test/foundry/paymaster/OpenfortPaymasterTest.t.sol:OpenfortPaymasterTest +[PASS] testEntryPointDepositToPaymaster() (gas: 45021) +[PASS] testFailPaymasterUserOpERC20ValidSigExecBatchInsufficientERC20() (gas: 319856) +[PASS] testFailPaymasterUserOpERC20ValidSigSmallApprove() (gas: 279828) +[PASS] testInitialParameters() (gas: 13782) +[PASS] testParsePaymasterDataERC20() (gas: 35513) +[PASS] testParsePaymasterDataNative() (gas: 33247) +[PASS] testPaymasterAddStake() (gas: 47881) +[PASS] testPaymasterUserOpERC20ValidSig() (gas: 300489) +[PASS] testPaymasterUserOpERC20ValidSigExecBatch() (gas: 341300) +[PASS] testPaymasterUserOpNativeValidSig() (gas: 230754) +[PASS] testPaymasterUserOpNativeValidSigExecBatch() (gas: 273169) +[PASS] testPaymasterUserOpWrongSig() (gas: 133317) +[PASS] testPaymasterUserOpWrongSigLength() (gas: 103571) +[PASS] testToken():(address) (gas: 2383) +Test result: ok. 14 passed; 0 failed; finished in 2.88s + +Running 29 tests for test/foundry/core/upgradeable/UpgradeableOpenfortAccountTest.t.sol:UpgradeableOpenfortAccountTest +[PASS] testChangeOwnershipAndCountDirect() (gas: 231956) +[PASS] testChangeOwnershipAndCountEntryPoint() (gas: 381333) +[PASS] testCreateAccountViaEntryPoint() (gas: 293095) +[PASS] testCreateAccountViaFactory() (gas: 206535) +[PASS] testCreateAccountViaFactoryWithNonce() (gas: 375044) +[PASS] testFailAttackRegisterSessionKeyViaEntrypoint2ndKey() (gas: 572021) +[PASS] testFailIncrementCounterViaSessionKeyNotregistered() (gas: 347624) +[PASS] testFailIncrementCounterViaSessionKeyReachLimit() (gas: 480162) +[PASS] testFailIncrementCounterViaSessionKeyReachLimitBatching() (gas: 386336) +[PASS] testFailIncrementCounterViaSessionKeyRevoked() (gas: 227635) +[PASS] testFailIncrementCounterViaSessionKeyWhitelistingBatchWrongAddress() (gas: 409500) +[PASS] testFailIncrementCounterViaSessionKeyWhitelistingTooBig() (gas: 204418) +[PASS] testFailIncrementCounterViaSessionKeyWhitelistingWrongAddress() (gas: 401016) +[PASS] testFailRevokeSessionKeyInvalidUser() (gas: 230179) +[PASS] testIncrementCounterDirect() (gas: 223174) +[PASS] testIncrementCounterViaEntrypoint() (gas: 374498) +[PASS] testIncrementCounterViaEntrypointBatching() (gas: 386728) +[PASS] testIncrementCounterViaSessionKey() (gas: 404052) +[PASS] testIncrementCounterViaSessionKeyExpired() (gas: 373903) +[PASS] testIncrementCounterViaSessionKeyWhitelisting() (gas: 429618) +[PASS] testIncrementCounterViaSessionKeyWhitelistingBatch() (gas: 452995) +[PASS] testMintTokenAccount() (gas: 403351) +[PASS] testReceiveNativeToken() (gas: 199099) +[PASS] testRegisterSessionKeyViaEntrypoint() (gas: 484886) +[PASS] testRegisterSessionKeyViaEntrypoint2ndKey() (gas: 594351) +[PASS] testSimulateValidation() (gas: 300257) +[PASS] testToken():(address) (gas: 2426) +[PASS] testTransferOutNativeToken() (gas: 307594) +[PASS] testUpgradeAccount() (gas: 2473820) +Test result: ok. 29 passed; 0 failed; finished in 3.28s + +Running 30 tests for test/foundry/core/static/StaticOpenfortAccountTest.t.sol:StaticOpenfortAccountTest +[PASS] testChangeOwnershipAndCountDirect() (gas: 174591) +[PASS] testChangeOwnershipAndCountEntryPoint() (gas: 323573) +[PASS] testCreateAccountViaEntryPoint() (gas: 225651) +[PASS] testCreateAccountViaFactory() (gas: 139646) +[PASS] testCreateAccountViaFactoryWithNonce() (gas: 256326) +[PASS] testFailAttackRegisterSessionKeyViaEntrypoint2ndKey() (gas: 513242) +[PASS] testFailIncrementCounterViaSessionKeyNotregistered() (gas: 290564) +[PASS] testFailIncrementCounterViaSessionKeyReachLimit() (gas: 422239) +[PASS] testFailIncrementCounterViaSessionKeyReachLimitBatching() (gas: 329031) +[PASS] testFailIncrementCounterViaSessionKeyRevoked() (gas: 170541) +[PASS] testFailIncrementCounterViaSessionKeyWhitelistingBatch() (gas: 385559) +[PASS] testFailIncrementCounterViaSessionKeyWhitelistingBatchWrongAddress() (gas: 352129) +[PASS] testFailIncrementCounterViaSessionKeyWhitelistingTooBig() (gas: 147484) +[PASS] testFailIncrementCounterViaSessionKeyWhitelistingWrongAddress() (gas: 343645) +[PASS] testFailRevokeSessionKeyInvalidUser() (gas: 173085) +[PASS] testIncrementCounterDirect() (gas: 166279) +[PASS] testIncrementCounterViaEntrypoint() (gas: 317164) +[PASS] testIncrementCounterViaEntrypointBatching() (gas: 329394) +[PASS] testIncrementCounterViaSessionKey() (gas: 346568) +[PASS] testIncrementCounterViaSessionKeyExpired() (gas: 316620) +[PASS] testIncrementCounterViaSessionKeyWhitelisting() (gas: 372157) +[PASS] testIncrementCounterViaSessionKeyWhitelistingBatch() (gas: 395178) +[PASS] testMintTokenAccount() (gas: 346017) +[PASS] testReceiveNativeToken() (gas: 142185) +[PASS] testRegisterSessionKeyViaEntrypoint() (gas: 426762) +[PASS] testRegisterSessionKeyViaEntrypoint2ndKey() (gas: 535415) +[PASS] testSimulateValidation() (gas: 243391) +[PASS] testToken():(address) (gas: 2404) +[PASS] testTransferOutNativeToken() (gas: 250263) +[PASS] testUpdateEntryPoint() (gas: 538664) +Test result: ok. 30 passed; 0 failed; finished in 3.56s + +Running 30 tests for test/foundry/core/managed/ManagedOpenfortAccountTest.t.sol:ManagedOpenfortAccountTest +[PASS] testChangeOwnershipAndCountDirect() (gas: 249782) +[PASS] testChangeOwnershipAndCountEntryPoint() (gas: 400307) +[PASS] testCreateAccountViaEntryPoint() (gas: 312124) +[PASS] testCreateAccountViaFactory() (gas: 224463) +[PASS] testCreateAccountViaFactoryWithNonce() (gas: 403280) +[PASS] testFailAttackRegisterSessionKeyViaEntrypoint2ndKey() (gas: 593507) +[PASS] testFailIncrementCounterViaSessionKeyNotregistered() (gas: 364573) +[PASS] testFailIncrementCounterViaSessionKeyReachLimit() (gas: 499353) +[PASS] testFailIncrementCounterViaSessionKeyReachLimitBatching() (gas: 403840) +[PASS] testFailIncrementCounterViaSessionKeyRevoked() (gas: 244596) +[PASS] testFailIncrementCounterViaSessionKeyWhitelistingBatch() (gas: 461352) +[PASS] testFailIncrementCounterViaSessionKeyWhitelistingBatchWrongAddress() (gas: 427026) +[PASS] testFailIncrementCounterViaSessionKeyWhitelistingTooBig() (gas: 220812) +[PASS] testFailIncrementCounterViaSessionKeyWhitelistingWrongAddress() (gas: 418542) +[PASS] testFailRevokeSessionKeyInvalidUser() (gas: 247140) +[PASS] testIncrementCounterDirect() (gas: 239574) +[PASS] testIncrementCounterViaEntrypoint() (gas: 391968) +[PASS] testIncrementCounterViaEntrypointBatching() (gas: 404232) +[PASS] testIncrementCounterViaSessionKey() (gas: 422139) +[PASS] testIncrementCounterViaSessionKeyExpired() (gas: 391432) +[PASS] testIncrementCounterViaSessionKeyWhitelisting() (gas: 447699) +[PASS] testIncrementCounterViaSessionKeyWhitelistingBatch() (gas: 471727) +[PASS] testMintTokenAccount() (gas: 420989) +[PASS] testReceiveNativeToken() (gas: 215639) +[PASS] testRegisterSessionKeyViaEntrypoint() (gas: 504635) +[PASS] testRegisterSessionKeyViaEntrypoint2ndKey() (gas: 616323) +[PASS] testSimulateValidation() (gas: 316639) +[PASS] testToken():(address) (gas: 2426) +[PASS] testTransferOutNativeToken() (gas: 325266) +[PASS] testUpgradeTo() (gas: 2077363) +Test result: ok. 30 passed; 0 failed; finished in 3.56s +| EntryPoint contract | | | | | | +|---------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 0 | 0 | | | | | +| Function Name | min | avg | median | max | # calls | +| addStake | 25917 | 25917 | 25917 | 25917 | 1 | +| balanceOf | 594 | 1260 | 594 | 2594 | 3 | +| depositTo | 2606 | 10839 | 5406 | 24506 | 3 | + + +| contracts/core/managed/ManagedOpenfortAccount.sol:ManagedOpenfortAccount contract | | | | | | +|-----------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 1806914 | 9182 | | | | | +| Function Name | min | avg | median | max | # calls | +| acceptOwnership | 1996 | 1996 | 1996 | 1996 | 2 | +| execute | 3568 | 21350 | 21542 | 32768 | 17 | +| executeBatch | 25603 | 25603 | 25603 | 25603 | 2 | +| initialize | 50619 | 50619 | 50619 | 50619 | 30 | +| receive | 55 | 55 | 55 | 55 | 2 | +| registerSessionKey(address,uint48,uint48) | 24617 | 24622 | 24617 | 24629 | 7 | +| registerSessionKey(address,uint48,uint48,uint48) | 24367 | 24371 | 24367 | 24379 | 3 | +| registerSessionKey(address,uint48,uint48,uint48,address[]) | 1288 | 39642 | 47313 | 47313 | 6 | +| revokeSessionKey | 609 | 609 | 609 | 609 | 2 | +| sessionKeys | 810 | 810 | 810 | 810 | 3 | +| transferOwnership | 22375 | 22375 | 22375 | 22375 | 2 | +| validateUserOp | 5005 | 7241 | 6740 | 15510 | 49 | +| version | 259 | 259 | 259 | 259 | 1 | + + +| contracts/core/managed/ManagedOpenfortFactory.sol:ManagedOpenfortFactory contract | | | | | | +|-----------------------------------------------------------------------------------|-----------------|--------|--------|--------|---------| +| Deployment Cost | Deployment Size | | | | | +| 802970 | 4253 | | | | | +| Function Name | min | avg | median | max | # calls | +| createAccount | 7695 | 184462 | 196740 | 196740 | 31 | +| createAccountWithNonce | 189793 | 189793 | 189793 | 189793 | 1 | +| getAddress | 7065 | 7065 | 7065 | 7065 | 4 | + + +| contracts/core/managed/OpenfortBeacon.sol:OpenfortBeacon contract | | | | | | +|-------------------------------------------------------------------|-----------------|------|--------|------|---------| +| Deployment Cost | Deployment Size | | | | | +| 213861 | 1248 | | | | | +| Function Name | min | avg | median | max | # calls | +| implementation | 308 | 672 | 308 | 2308 | 159 | +| upgradeTo | 2510 | 4659 | 4659 | 6809 | 2 | + + +| contracts/core/static/StaticOpenfortAccount.sol:StaticOpenfortAccount contract | | | | | | +|--------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 1877392 | 9534 | | | | | +| Function Name | min | avg | median | max | # calls | +| acceptOwnership | 1944 | 1944 | 1944 | 1944 | 2 | +| entryPoint | 376 | 376 | 376 | 376 | 2 | +| execute | 3708 | 22011 | 21747 | 32908 | 20 | +| executeBatch | 25743 | 40742 | 48408 | 55408 | 5 | +| initialize | 74366 | 74366 | 74366 | 74366 | 44 | +| receive | 55 | 55 | 55 | 55 | 2 | +| registerSessionKey(address,uint48,uint48) | 24757 | 24762 | 24757 | 24769 | 7 | +| registerSessionKey(address,uint48,uint48,uint48) | 24485 | 24489 | 24485 | 24497 | 3 | +| registerSessionKey(address,uint48,uint48,uint48,address[]) | 1340 | 39694 | 47365 | 47365 | 6 | +| revokeSessionKey | 749 | 749 | 749 | 749 | 2 | +| sessionKeys | 832 | 832 | 832 | 832 | 3 | +| transferOwnership | 22375 | 22375 | 22375 | 22375 | 2 | +| updateEntryPoint | 651 | 1483 | 1483 | 2315 | 2 | +| validateUserOp | 5145 | 7629 | 6880 | 15650 | 57 | + + +| contracts/core/static/StaticOpenfortFactory.sol:StaticOpenfortFactory contract | | | | | | +|--------------------------------------------------------------------------------|-----------------|--------|--------|--------|---------| +| Deployment Cost | Deployment Size | | | | | +| 366774 | 2178 | | | | | +| Function Name | min | avg | median | max | # calls | +| createAccount | 1273 | 120553 | 124200 | 124200 | 44 | +| createAccountWithNonce | 121729 | 121729 | 121729 | 121729 | 1 | +| getAddress | 830 | 830 | 830 | 830 | 4 | + + +| contracts/core/upgradeable/UpgradeableOpenfortAccount.sol:UpgradeableOpenfortAccount contract | | | | | | +|-----------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 2237283 | 11381 | | | | | +| Function Name | min | avg | median | max | # calls | +| acceptOwnership | 1962 | 1962 | 1962 | 1962 | 2 | +| execute | 3708 | 21354 | 21682 | 32908 | 17 | +| executeBatch | 25743 | 25743 | 25743 | 25743 | 2 | +| initialize | 72911 | 72911 | 72911 | 72911 | 29 | +| receive | 55 | 55 | 55 | 55 | 2 | +| registerSessionKey(address,uint48,uint48) | 24735 | 24740 | 24735 | 24747 | 7 | +| registerSessionKey(address,uint48,uint48,uint48) | 24485 | 24489 | 24485 | 24497 | 3 | +| registerSessionKey(address,uint48,uint48,uint48,address[]) | 1406 | 38226 | 47431 | 47431 | 5 | +| revokeSessionKey | 771 | 771 | 771 | 771 | 2 | +| sessionKeys | 832 | 832 | 832 | 832 | 2 | +| transferOwnership | 22375 | 22375 | 22375 | 22375 | 2 | +| upgradeTo | 890 | 3226 | 3226 | 5562 | 2 | +| validateUserOp | 5145 | 7029 | 6880 | 12521 | 47 | +| version | 303 | 303 | 303 | 303 | 1 | + + +| contracts/core/upgradeable/UpgradeableOpenfortFactory.sol:UpgradeableOpenfortFactory contract | | | | | | +|-----------------------------------------------------------------------------------------------|-----------------|--------|--------|--------|---------| +| Deployment Cost | Deployment Size | | | | | +| 708540 | 3899 | | | | | +| Function Name | min | avg | median | max | # calls | +| createAccount | 6652 | 174806 | 180901 | 180901 | 29 | +| createAccountWithNonce | 178454 | 178454 | 178454 | 178454 | 1 | +| getAddress | 6022 | 6022 | 6022 | 6022 | 4 | + + +| contracts/mock/MockedV2ManagedOpenfortAccount.sol:MockedV2ManagedOpenfortAccount contract | | | | | | +|-------------------------------------------------------------------------------------------|-----------------|-----|--------|-----|---------| +| Deployment Cost | Deployment Size | | | | | +| 1806914 | 9182 | | | | | +| Function Name | min | avg | median | max | # calls | +| version | 259 | 259 | 259 | 259 | 2 | + + +| contracts/mock/MockedV2UpgradeableOpenfortAccount.sol:MockedV2UpgradeableOpenfortAccount contract | | | | | | +|---------------------------------------------------------------------------------------------------|-----------------|-----|--------|-----|---------| +| Deployment Cost | Deployment Size | | | | | +| 2237283 | 11381 | | | | | +| Function Name | min | avg | median | max | # calls | +| proxiableUUID | 374 | 374 | 374 | 374 | 1 | +| version | 303 | 303 | 303 | 303 | 1 | + + +| contracts/paymaster/OpenfortPaymaster.sol:OpenfortPaymaster contract | | | | | | +|----------------------------------------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 1215863 | 6347 | | | | | +| Function Name | min | avg | median | max | # calls | +| addStake | 520 | 30701 | 33420 | 33420 | 16 | +| deposit | 9845 | 32618 | 34245 | 34245 | 15 | +| entryPoint | 261 | 261 | 261 | 261 | 1 | +| getDeposit | 1181 | 2104 | 1181 | 3181 | 13 | +| getHash | 3462 | 5053 | 4998 | 6535 | 12 | +| owner | 2365 | 2365 | 2365 | 2365 | 7 | +| parsePaymasterAndData | 1516 | 1516 | 1516 | 1516 | 2 | +| postOp | 1433 | 12421 | 5583 | 30248 | 6 | +| validatePaymasterUserOp | 1694 | 26885 | 30289 | 31112 | 8 | + + +| node_modules/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol:ERC1967Proxy contract | | | | | | +|-------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 136587 | 1505 | | | | | +| Function Name | min | avg | median | max | # calls | +| acceptOwnership | 2276 | 2276 | 2276 | 2276 | 2 | +| execute | 4118 | 21774 | 22098 | 33318 | 17 | +| executeBatch | 26255 | 26255 | 26255 | 26255 | 2 | +| receive | 454 | 454 | 454 | 454 | 2 | +| registerSessionKey(address,uint48,uint48) | 25139 | 25144 | 25139 | 25151 | 7 | +| registerSessionKey(address,uint48,uint48,uint48) | 24895 | 24899 | 24895 | 24907 | 3 | +| registerSessionKey(address,uint48,uint48,uint48,address[]) | 1907 | 38668 | 47859 | 47859 | 5 | +| revokeSessionKey | 1170 | 1170 | 1170 | 1170 | 2 | +| sessionKeys | 1248 | 1248 | 1248 | 1248 | 2 | +| transferOwnership | 22770 | 22770 | 22770 | 22770 | 2 | +| upgradeTo | 1301 | 3629 | 3629 | 5957 | 2 | +| validateUserOp | 5691 | 7603 | 7432 | 13171 | 47 | +| version | 698 | 698 | 698 | 698 | 2 | + + +| node_modules/@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol:BeaconProxy contract | | | | | | +|----------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 151292 | 1964 | | | | | +| Function Name | min | avg | median | max | # calls | +| acceptOwnership | 2871 | 2871 | 2871 | 2871 | 2 | +| execute | 4673 | 22466 | 22653 | 33873 | 17 | +| executeBatch | 26810 | 26810 | 26810 | 26810 | 2 | +| receive | 1155 | 1155 | 1155 | 1155 | 2 | +| registerSessionKey(address,uint48,uint48) | 25719 | 25724 | 25719 | 25731 | 7 | +| registerSessionKey(address,uint48,uint48,uint48) | 25472 | 25476 | 25472 | 25484 | 3 | +| registerSessionKey(address,uint48,uint48,uint48,address[]) | 2484 | 40777 | 48436 | 48436 | 6 | +| revokeSessionKey | 1709 | 1709 | 1709 | 1709 | 2 | +| sessionKeys | 1921 | 1921 | 1921 | 1921 | 3 | +| transferOwnership | 23471 | 23471 | 23471 | 23471 | 2 | +| validateUserOp | 6246 | 8523 | 7987 | 17105 | 49 | +| version | 1355 | 1355 | 1355 | 1355 | 3 | + + + diff --git a/gas_reports/2023-05-31_17:59.snap.out b/gas_reports/2023-05-31_17:59.snap.out new file mode 100644 index 0000000..8a28395 --- /dev/null +++ b/gas_reports/2023-05-31_17:59.snap.out @@ -0,0 +1,104 @@ +ManagedOpenfortAccountTest:testChangeOwnershipAndCountDirect() (gas: 249782) +ManagedOpenfortAccountTest:testChangeOwnershipAndCountEntryPoint() (gas: 400307) +ManagedOpenfortAccountTest:testCreateAccountViaEntryPoint() (gas: 312124) +ManagedOpenfortAccountTest:testCreateAccountViaFactory() (gas: 224463) +ManagedOpenfortAccountTest:testCreateAccountViaFactoryWithNonce() (gas: 403280) +ManagedOpenfortAccountTest:testFailAttackRegisterSessionKeyViaEntrypoint2ndKey() (gas: 593507) +ManagedOpenfortAccountTest:testFailIncrementCounterViaSessionKeyNotregistered() (gas: 364573) +ManagedOpenfortAccountTest:testFailIncrementCounterViaSessionKeyReachLimit() (gas: 499353) +ManagedOpenfortAccountTest:testFailIncrementCounterViaSessionKeyReachLimitBatching() (gas: 403840) +ManagedOpenfortAccountTest:testFailIncrementCounterViaSessionKeyRevoked() (gas: 244596) +ManagedOpenfortAccountTest:testFailIncrementCounterViaSessionKeyWhitelistingBatch() (gas: 461352) +ManagedOpenfortAccountTest:testFailIncrementCounterViaSessionKeyWhitelistingBatchWrongAddress() (gas: 427026) +ManagedOpenfortAccountTest:testFailIncrementCounterViaSessionKeyWhitelistingTooBig() (gas: 220812) +ManagedOpenfortAccountTest:testFailIncrementCounterViaSessionKeyWhitelistingWrongAddress() (gas: 418542) +ManagedOpenfortAccountTest:testFailRevokeSessionKeyInvalidUser() (gas: 247140) +ManagedOpenfortAccountTest:testIncrementCounterDirect() (gas: 239574) +ManagedOpenfortAccountTest:testIncrementCounterViaEntrypoint() (gas: 391968) +ManagedOpenfortAccountTest:testIncrementCounterViaEntrypointBatching() (gas: 404232) +ManagedOpenfortAccountTest:testIncrementCounterViaSessionKey() (gas: 422139) +ManagedOpenfortAccountTest:testIncrementCounterViaSessionKeyExpired() (gas: 391432) +ManagedOpenfortAccountTest:testIncrementCounterViaSessionKeyWhitelisting() (gas: 447699) +ManagedOpenfortAccountTest:testIncrementCounterViaSessionKeyWhitelistingBatch() (gas: 471727) +ManagedOpenfortAccountTest:testMintTokenAccount() (gas: 420989) +ManagedOpenfortAccountTest:testReceiveNativeToken() (gas: 215639) +ManagedOpenfortAccountTest:testRegisterSessionKeyViaEntrypoint() (gas: 504635) +ManagedOpenfortAccountTest:testRegisterSessionKeyViaEntrypoint2ndKey() (gas: 616323) +ManagedOpenfortAccountTest:testSimulateValidation() (gas: 316639) +ManagedOpenfortAccountTest:testToken():(address) (gas: 2426) +ManagedOpenfortAccountTest:testTransferOutNativeToken() (gas: 325266) +ManagedOpenfortAccountTest:testUpgradeTo() (gas: 2077363) +OpenfortPaymasterTest:testEntryPointDepositToPaymaster() (gas: 45021) +OpenfortPaymasterTest:testFailPaymasterUserOpERC20ValidSigExecBatchInsufficientERC20() (gas: 319856) +OpenfortPaymasterTest:testFailPaymasterUserOpERC20ValidSigSmallApprove() (gas: 279828) +OpenfortPaymasterTest:testInitialParameters() (gas: 13782) +OpenfortPaymasterTest:testParsePaymasterDataERC20() (gas: 35513) +OpenfortPaymasterTest:testParsePaymasterDataNative() (gas: 33247) +OpenfortPaymasterTest:testPaymasterAddStake() (gas: 47881) +OpenfortPaymasterTest:testPaymasterUserOpERC20ValidSig() (gas: 300489) +OpenfortPaymasterTest:testPaymasterUserOpERC20ValidSigExecBatch() (gas: 341300) +OpenfortPaymasterTest:testPaymasterUserOpNativeValidSig() (gas: 230754) +OpenfortPaymasterTest:testPaymasterUserOpNativeValidSigExecBatch() (gas: 273169) +OpenfortPaymasterTest:testPaymasterUserOpWrongSig() (gas: 133317) +OpenfortPaymasterTest:testPaymasterUserOpWrongSigLength() (gas: 103571) +OpenfortPaymasterTest:testToken():(address) (gas: 2383) +Specific4337Tests:testToken():(address) (gas: 2382) +StaticOpenfortAccountTest:testChangeOwnershipAndCountDirect() (gas: 174591) +StaticOpenfortAccountTest:testChangeOwnershipAndCountEntryPoint() (gas: 323573) +StaticOpenfortAccountTest:testCreateAccountViaEntryPoint() (gas: 225651) +StaticOpenfortAccountTest:testCreateAccountViaFactory() (gas: 139646) +StaticOpenfortAccountTest:testCreateAccountViaFactoryWithNonce() (gas: 256326) +StaticOpenfortAccountTest:testFailAttackRegisterSessionKeyViaEntrypoint2ndKey() (gas: 513242) +StaticOpenfortAccountTest:testFailIncrementCounterViaSessionKeyNotregistered() (gas: 290564) +StaticOpenfortAccountTest:testFailIncrementCounterViaSessionKeyReachLimit() (gas: 422239) +StaticOpenfortAccountTest:testFailIncrementCounterViaSessionKeyReachLimitBatching() (gas: 329031) +StaticOpenfortAccountTest:testFailIncrementCounterViaSessionKeyRevoked() (gas: 170541) +StaticOpenfortAccountTest:testFailIncrementCounterViaSessionKeyWhitelistingBatch() (gas: 385559) +StaticOpenfortAccountTest:testFailIncrementCounterViaSessionKeyWhitelistingBatchWrongAddress() (gas: 352129) +StaticOpenfortAccountTest:testFailIncrementCounterViaSessionKeyWhitelistingTooBig() (gas: 147484) +StaticOpenfortAccountTest:testFailIncrementCounterViaSessionKeyWhitelistingWrongAddress() (gas: 343645) +StaticOpenfortAccountTest:testFailRevokeSessionKeyInvalidUser() (gas: 173085) +StaticOpenfortAccountTest:testIncrementCounterDirect() (gas: 166279) +StaticOpenfortAccountTest:testIncrementCounterViaEntrypoint() (gas: 317164) +StaticOpenfortAccountTest:testIncrementCounterViaEntrypointBatching() (gas: 329394) +StaticOpenfortAccountTest:testIncrementCounterViaSessionKey() (gas: 346568) +StaticOpenfortAccountTest:testIncrementCounterViaSessionKeyExpired() (gas: 316620) +StaticOpenfortAccountTest:testIncrementCounterViaSessionKeyWhitelisting() (gas: 372157) +StaticOpenfortAccountTest:testIncrementCounterViaSessionKeyWhitelistingBatch() (gas: 395178) +StaticOpenfortAccountTest:testMintTokenAccount() (gas: 346017) +StaticOpenfortAccountTest:testReceiveNativeToken() (gas: 142185) +StaticOpenfortAccountTest:testRegisterSessionKeyViaEntrypoint() (gas: 426762) +StaticOpenfortAccountTest:testRegisterSessionKeyViaEntrypoint2ndKey() (gas: 535415) +StaticOpenfortAccountTest:testSimulateValidation() (gas: 243391) +StaticOpenfortAccountTest:testToken():(address) (gas: 2404) +StaticOpenfortAccountTest:testTransferOutNativeToken() (gas: 250263) +StaticOpenfortAccountTest:testUpdateEntryPoint() (gas: 538664) +UpgradeableOpenfortAccountTest:testChangeOwnershipAndCountDirect() (gas: 231956) +UpgradeableOpenfortAccountTest:testChangeOwnershipAndCountEntryPoint() (gas: 381333) +UpgradeableOpenfortAccountTest:testCreateAccountViaEntryPoint() (gas: 293095) +UpgradeableOpenfortAccountTest:testCreateAccountViaFactory() (gas: 206535) +UpgradeableOpenfortAccountTest:testCreateAccountViaFactoryWithNonce() (gas: 375044) +UpgradeableOpenfortAccountTest:testFailAttackRegisterSessionKeyViaEntrypoint2ndKey() (gas: 572021) +UpgradeableOpenfortAccountTest:testFailIncrementCounterViaSessionKeyNotregistered() (gas: 347624) +UpgradeableOpenfortAccountTest:testFailIncrementCounterViaSessionKeyReachLimit() (gas: 480162) +UpgradeableOpenfortAccountTest:testFailIncrementCounterViaSessionKeyReachLimitBatching() (gas: 386336) +UpgradeableOpenfortAccountTest:testFailIncrementCounterViaSessionKeyRevoked() (gas: 227635) +UpgradeableOpenfortAccountTest:testFailIncrementCounterViaSessionKeyWhitelistingBatchWrongAddress() (gas: 409500) +UpgradeableOpenfortAccountTest:testFailIncrementCounterViaSessionKeyWhitelistingTooBig() (gas: 204418) +UpgradeableOpenfortAccountTest:testFailIncrementCounterViaSessionKeyWhitelistingWrongAddress() (gas: 401016) +UpgradeableOpenfortAccountTest:testFailRevokeSessionKeyInvalidUser() (gas: 230179) +UpgradeableOpenfortAccountTest:testIncrementCounterDirect() (gas: 223174) +UpgradeableOpenfortAccountTest:testIncrementCounterViaEntrypoint() (gas: 374498) +UpgradeableOpenfortAccountTest:testIncrementCounterViaEntrypointBatching() (gas: 386728) +UpgradeableOpenfortAccountTest:testIncrementCounterViaSessionKey() (gas: 404052) +UpgradeableOpenfortAccountTest:testIncrementCounterViaSessionKeyExpired() (gas: 373903) +UpgradeableOpenfortAccountTest:testIncrementCounterViaSessionKeyWhitelisting() (gas: 429618) +UpgradeableOpenfortAccountTest:testIncrementCounterViaSessionKeyWhitelistingBatch() (gas: 452995) +UpgradeableOpenfortAccountTest:testMintTokenAccount() (gas: 403351) +UpgradeableOpenfortAccountTest:testReceiveNativeToken() (gas: 199099) +UpgradeableOpenfortAccountTest:testRegisterSessionKeyViaEntrypoint() (gas: 484886) +UpgradeableOpenfortAccountTest:testRegisterSessionKeyViaEntrypoint2ndKey() (gas: 594351) +UpgradeableOpenfortAccountTest:testSimulateValidation() (gas: 300257) +UpgradeableOpenfortAccountTest:testToken():(address) (gas: 2426) +UpgradeableOpenfortAccountTest:testTransferOutNativeToken() (gas: 307594) +UpgradeableOpenfortAccountTest:testUpgradeAccount() (gas: 2473820) \ No newline at end of file diff --git a/test/foundry/core/upgradeable/UpgradeableOpenfortAccountTest.t.sol b/test/foundry/core/upgradeable/UpgradeableOpenfortAccountTest.t.sol index 9da7adf..75d085c 100644 --- a/test/foundry/core/upgradeable/UpgradeableOpenfortAccountTest.t.sol +++ b/test/foundry/core/upgradeable/UpgradeableOpenfortAccountTest.t.sol @@ -117,7 +117,7 @@ contract UpgradeableOpenfortAccountTest is Test { * @notice Initialize the UpgradeableOpenfortAccount testing contract. * Scenario: * - factoryAdmin is the deployer (and owner) of the UpgradeableOpenfortFactory - * - accountAdmin is the account used to deploy new static accounts + * - accountAdmin is the account used to deploy new upgradeable accounts * - entryPoint is the singleton EntryPoint * - testCounter is the counter used to test userOps */ @@ -155,7 +155,7 @@ contract UpgradeableOpenfortAccountTest is Test { vm.expectEmit(true, true, false, true); emit AccountCreated(account, accountAdmin); - // Deploy a static account to the counterfactual address + // Deploy a upgradeable account to the counterfactual address upgradeableOpenfortFactory.createAccount(accountAdmin, bytes("")); // Make sure the counterfactual address has not been altered @@ -166,7 +166,7 @@ contract UpgradeableOpenfortAccountTest is Test { * Test account creation using nonces using the factory. */ function testCreateAccountViaFactoryWithNonce() public { - // Create an static account wallet and get its address + // Create an upgradeable account wallet and get its address address account = upgradeableOpenfortFactory.createAccount(accountAdmin, ""); address account2 = upgradeableOpenfortFactory.createAccount(accountAdmin, ""); @@ -214,13 +214,13 @@ contract UpgradeableOpenfortAccountTest is Test { * Create an account using the factory and make it call count() directly. */ function testIncrementCounterDirect() public { - // Create an static account wallet and get its address + // Create an upgradeable account wallet and get its address address account = upgradeableOpenfortFactory.createAccount(accountAdmin, ""); // Verifiy that the counter is stil set to 0 assertEq(testCounter.counters(account), 0); - // Make the admin of the static account wallet (deployer) call "count" + // Make the admin of the upgradeable account wallet (deployer) call "count" vm.prank(accountAdmin); UpgradeableOpenfortAccount(payable(account)).execute( address(testCounter), 0, abi.encodeWithSignature("count()") @@ -235,7 +235,7 @@ contract UpgradeableOpenfortAccountTest is Test { * using the execute() function using the EntryPoint (userOp). Leaveraging ERC-4337. */ function testIncrementCounterViaEntrypoint() public { - // Create an static account wallet and get its address + // Create an upgradeable account wallet and get its address address account = upgradeableOpenfortFactory.createAccount(accountAdmin, ""); // Verifiy that the counter is stil set to 0 @@ -259,7 +259,7 @@ contract UpgradeableOpenfortAccountTest is Test { * using the executeBatching() function using the EntryPoint (userOp). Leaveraging ERC-4337. */ function testIncrementCounterViaEntrypointBatching() public { - // Create an static account wallet and get its address + // Create an upgradeable account wallet and get its address address account = upgradeableOpenfortFactory.createAccount(accountAdmin, ""); // Verifiy that the counter is stil set to 0 @@ -292,7 +292,7 @@ contract UpgradeableOpenfortAccountTest is Test { * Should fail, try to use a sessionKey that is not registered. */ function testFailIncrementCounterViaSessionKeyNotregistered() public { - // Create an static account wallet and get its address + // Create an upgradeable account wallet and get its address address account = upgradeableOpenfortFactory.createAccount(accountAdmin, ""); // Verifiy that the counter is stil set to 0 @@ -319,7 +319,7 @@ contract UpgradeableOpenfortAccountTest is Test { * Use a sessionKey that is registered. */ function testIncrementCounterViaSessionKey() public { - // Create an static account wallet and get its address + // Create an upgradeable account wallet and get its address address account = upgradeableOpenfortFactory.createAccount(accountAdmin, ""); // Verifiy that the counter is stil set to 0 @@ -350,7 +350,7 @@ contract UpgradeableOpenfortAccountTest is Test { * using the EntryPoint (userOp). Then use the sessionKey to count */ function testRegisterSessionKeyViaEntrypoint() public { - // Create an static account wallet and get its address + // Create an upgradeable account wallet and get its address address account = upgradeableOpenfortFactory.createAccount(accountAdmin, ""); // Verifiy that the counter is stil set to 0 @@ -395,7 +395,7 @@ contract UpgradeableOpenfortAccountTest is Test { * using the EntryPoint (userOp). Then use that sessionKey to register a second one */ function testRegisterSessionKeyViaEntrypoint2ndKey() public { - // Create an static account wallet and get its address + // Create an upgradeable account wallet and get its address address account = upgradeableOpenfortFactory.createAccount(accountAdmin, ""); // Verifiy that the counter is stil set to 0 @@ -458,7 +458,7 @@ contract UpgradeableOpenfortAccountTest is Test { * using the EntryPoint (userOp). Then use that sessionKey to register a second one */ function testFailAttackRegisterSessionKeyViaEntrypoint2ndKey() public { - // Create an static account wallet and get its address + // Create an upgradeable account wallet and get its address address account = upgradeableOpenfortFactory.createAccount(accountAdmin, ""); // Verifiy that the counter is stil set to 0 @@ -527,7 +527,7 @@ contract UpgradeableOpenfortAccountTest is Test { * Should fail, try to use a sessionKey that is expired. */ function testIncrementCounterViaSessionKeyExpired() public { - // Create an static account wallet and get its address + // Create an upgradeable account wallet and get its address address account = upgradeableOpenfortFactory.createAccount(accountAdmin, ""); // Verifiy that the counter is stil set to 0 @@ -559,7 +559,7 @@ contract UpgradeableOpenfortAccountTest is Test { * Should fail, try to use a sessionKey that is revoked. */ function testFailIncrementCounterViaSessionKeyRevoked() public { - // Create an static account wallet and get its address + // Create an upgradeable account wallet and get its address address account = upgradeableOpenfortFactory.createAccount(accountAdmin, ""); // Verifiy that the counter is stil set to 0 @@ -590,7 +590,7 @@ contract UpgradeableOpenfortAccountTest is Test { * Should fail, try to use a sessionKey that reached its limit. */ function testFailIncrementCounterViaSessionKeyReachLimit() public { - // Create an static account wallet and get its address + // Create an upgradeable account wallet and get its address address account = upgradeableOpenfortFactory.createAccount(accountAdmin, ""); // Verifiy that the counter is stil set to 0 @@ -631,7 +631,7 @@ contract UpgradeableOpenfortAccountTest is Test { * Should fail, try to use a sessionKey that reached its limit. */ function testFailIncrementCounterViaSessionKeyReachLimitBatching() public { - // Create an static account wallet and get its address + // Create an upgradeable account wallet and get its address address account = upgradeableOpenfortFactory.createAccount(accountAdmin, ""); // Verifiy that the counter is stil set to 0 @@ -673,7 +673,7 @@ contract UpgradeableOpenfortAccountTest is Test { * Should fail, try to revoke a sessionKey using a non-privileged user */ function testFailRevokeSessionKeyInvalidUser() public { - // Create an static account wallet and get its address + // Create an upgradeable account wallet and get its address address account = upgradeableOpenfortFactory.createAccount(accountAdmin, ""); // Verifiy that the counter is stil set to 0 @@ -705,7 +705,7 @@ contract UpgradeableOpenfortAccountTest is Test { * Use a sessionKey with whitelisting to call Execute(). */ function testIncrementCounterViaSessionKeyWhitelisting() public { - // Create an static account wallet and get its address + // Create an upgradeable account wallet and get its address address account = upgradeableOpenfortFactory.createAccount(accountAdmin, ""); // Verifiy that the counter is stil set to 0 @@ -737,7 +737,7 @@ contract UpgradeableOpenfortAccountTest is Test { * Should fail, try to register a sessionKey with a large whitelist. */ function testFailIncrementCounterViaSessionKeyWhitelistingTooBig() public { - // Create an static account wallet and get its address + // Create an upgradeable account wallet and get its address address account = upgradeableOpenfortFactory.createAccount(accountAdmin, ""); // Verifiy that the counter is stil set to 0 @@ -768,7 +768,7 @@ contract UpgradeableOpenfortAccountTest is Test { * Use a sessionKey with whitelisting to call ExecuteBatch(). */ function testIncrementCounterViaSessionKeyWhitelistingBatch() public { - // Create an static account wallet and get its address + // Create an upgradeable account wallet and get its address address account = upgradeableOpenfortFactory.createAccount(accountAdmin, ""); // Verifiy that the counter is stil set to 0 @@ -817,7 +817,7 @@ contract UpgradeableOpenfortAccountTest is Test { * Should fail, try to use a sessionKey with invalid whitelisting to call Execute(). */ function testFailIncrementCounterViaSessionKeyWhitelistingWrongAddress() public { - // Create an static account wallet and get its address + // Create an upgradeable account wallet and get its address address account = upgradeableOpenfortFactory.createAccount(accountAdmin, ""); // Verifiy that the counter is stil set to 0 @@ -849,7 +849,7 @@ contract UpgradeableOpenfortAccountTest is Test { * Should fail, try to use a sessionKey with invalid whitelisting to call ExecuteBatch(). */ function testFailIncrementCounterViaSessionKeyWhitelistingBatchWrongAddress() public { - // Create an static account wallet and get its address + // Create an upgradeable account wallet and get its address address account = upgradeableOpenfortFactory.createAccount(accountAdmin, ""); // Verifiy that the counter is stil set to 0 @@ -905,7 +905,7 @@ contract UpgradeableOpenfortAccountTest is Test { * 5- Test that the new owner can directly interact with the account and make it call the testCounter contract. */ function testChangeOwnershipAndCountDirect() public { - // Create an static account wallet and get its address + // Create an upgradeable account wallet and get its address address account = upgradeableOpenfortFactory.createAccount(accountAdmin, ""); address accountAdmin2; @@ -920,7 +920,7 @@ contract UpgradeableOpenfortAccountTest is Test { // Verifiy that the counter is stil set to 0 assertEq(testCounter.counters(account), 0); - // Make the admin of the static account wallet (deployer) call "count" + // Make the admin of the upgradeable account wallet (deployer) call "count" vm.prank(accountAdmin2); UpgradeableOpenfortAccount(payable(account)).execute( address(testCounter), 0, abi.encodeWithSignature("count()") @@ -934,7 +934,7 @@ contract UpgradeableOpenfortAccountTest is Test { * Change the owner of an account and call TestCounter though the Entrypoint */ function testChangeOwnershipAndCountEntryPoint() public { - // Create an static account wallet and get its address + // Create an upgradeable account wallet and get its address address account = upgradeableOpenfortFactory.createAccount(accountAdmin, ""); address accountAdmin2; @@ -966,7 +966,7 @@ contract UpgradeableOpenfortAccountTest is Test { * Test an account with testToken instead of TestCount. */ function testMintTokenAccount() public { - // Create an static account wallet and get its address + // Create an upgradeable account wallet and get its address address account = upgradeableOpenfortFactory.createAccount(accountAdmin, ""); // Verifiy that the totalSupply is stil 0 @@ -998,7 +998,7 @@ contract UpgradeableOpenfortAccountTest is Test { * Test receive native tokens. */ function testReceiveNativeToken() public { - // Create an static account wallet and get its address + // Create an upgradeable account wallet and get its address address account = upgradeableOpenfortFactory.createAccount(accountAdmin, ""); assertEq(address(account).balance, 0); @@ -1013,7 +1013,7 @@ contract UpgradeableOpenfortAccountTest is Test { * Transfer native tokens out of an account. */ function testTransferOutNativeToken() public { - // Create an static account wallet and get its address + // Create an upgradeable account wallet and get its address address account = upgradeableOpenfortFactory.createAccount(accountAdmin, ""); uint256 value = 1000; @@ -1036,7 +1036,7 @@ contract UpgradeableOpenfortAccountTest is Test { * Basic test of simulateValidation() to check that it always reverts. */ function testSimulateValidation() public { - // Create an static account wallet and get its address + // Create an upgradeable account wallet and get its address address account = upgradeableOpenfortFactory.createAccount(accountAdmin, ""); // Verifiy that the counter is stil set to 0 @@ -1059,7 +1059,7 @@ contract UpgradeableOpenfortAccountTest is Test { * Create an account and upgrade its implementation */ function testUpgradeAccount() public { - // Create an static account wallet and get its address + // Create an upgradeable account wallet and get its address address account = upgradeableOpenfortFactory.createAccount(accountAdmin, ""); assertEq(UpgradeableOpenfortAccount(payable(account)).version(), 1); @@ -1074,4 +1074,27 @@ contract UpgradeableOpenfortAccountTest is Test { // Notice that, even though we bind the address to the old implementation, version() now returns 2 assertEq(UpgradeableOpenfortAccount(payable(account)).version(), 2); } + + /* + * 1- Deploy a factory using the old EntryPoint to create an account. + * 2- Inform the account of the new EntryPoint by calling updateEntryPoint() + */ + function testUpdateEntryPoint() public { + address oldEntryPoint = address(0x0576a174D229E3cFA37253523E645A78A0C91B57); + address newEntryPoint = vm.envAddress("ENTRY_POINT_ADDRESS"); + UpgradeableOpenfortFactory upgradeableOpenfortFactoryOld = new UpgradeableOpenfortFactory(payable(oldEntryPoint), address(upgradeableOpenfortAccount)); + + // Create an upgradeable account wallet using the old EntryPoint and get its address + address payable accountOld = payable(upgradeableOpenfortFactoryOld.createAccount(accountAdmin, "")); + UpgradeableOpenfortAccount upgradeableAccount = UpgradeableOpenfortAccount(accountOld); + assertEq(address(upgradeableAccount.entryPoint()), oldEntryPoint); + + vm.expectRevert("Ownable: caller is not the owner"); + upgradeableAccount.updateEntryPoint(newEntryPoint); + + vm.prank(accountAdmin); + upgradeableAccount.updateEntryPoint(newEntryPoint); + + assertEq(address(upgradeableAccount.entryPoint()), newEntryPoint); + } } From 0f673ca8cc1794ac8ee7319b972006b7af644acf Mon Sep 17 00:00:00 2001 From: Eloi Manuel Date: Wed, 31 May 2023 18:16:58 +0200 Subject: [PATCH 5/7] Added EntryPointUpdated event --- contracts/core/upgradeable/UpgradeableOpenfortAccount.sol | 1 + 1 file changed, 1 insertion(+) diff --git a/contracts/core/upgradeable/UpgradeableOpenfortAccount.sol b/contracts/core/upgradeable/UpgradeableOpenfortAccount.sol index 21ac229..00cc96f 100644 --- a/contracts/core/upgradeable/UpgradeableOpenfortAccount.sol +++ b/contracts/core/upgradeable/UpgradeableOpenfortAccount.sol @@ -25,6 +25,7 @@ contract UpgradeableOpenfortAccount is BaseOpenfortAccount, UUPSUpgradeable { if (_defaultAdmin == address(0) || _entrypoint == address(0)) { revert ZeroAddressNotAllowed(); } + emit EntryPointUpdated(entrypointContract, _entrypoint); _transferOwnership(_defaultAdmin); entrypointContract = _entrypoint; } From 8f9e8180ba8b5f3d1a15bc32ab3d0b7f193d0c88 Mon Sep 17 00:00:00 2001 From: Eloi Manuel Date: Wed, 31 May 2023 18:33:57 +0200 Subject: [PATCH 6/7] Upgraded pragma --- contracts/core/BaseOpenfortAccount.sol | 2 +- contracts/core/managed/ManagedOpenfortAccount.sol | 2 +- contracts/core/managed/ManagedOpenfortFactory.sol | 2 +- contracts/core/managed/OpenfortBeacon.sol | 2 +- contracts/core/static/StaticOpenfortAccount.sol | 2 +- contracts/core/static/StaticOpenfortFactory.sol | 2 +- contracts/core/upgradeable/UpgradeableOpenfortAccount.sol | 2 +- contracts/core/upgradeable/UpgradeableOpenfortFactory.sol | 2 +- contracts/interfaces/IBaseOpenfortFactory.sol | 2 +- contracts/mock/MockedV2ManagedOpenfortAccount.sol | 2 +- contracts/mock/MockedV2UpgradeableOpenfortAccount.sol | 2 +- contracts/mock/Rewards.sol | 2 +- contracts/mock/USDC.sol | 2 +- script/UserOpTestCounter.sol | 2 +- script/deployBatching.s.sol | 2 +- script/deployManagedAccounts.sol | 2 +- script/deployMock.sol | 2 +- script/deployStaticAccounts.sol | 2 +- script/deployUpgradeableAccounts.sol | 2 +- test/foundry/4337/Specific4337Tests.t.sol | 2 +- test/foundry/paymaster/OpenfortPaymasterTest.t.sol | 2 +- 21 files changed, 21 insertions(+), 21 deletions(-) diff --git a/contracts/core/BaseOpenfortAccount.sol b/contracts/core/BaseOpenfortAccount.sol index 8156269..c780760 100644 --- a/contracts/core/BaseOpenfortAccount.sol +++ b/contracts/core/BaseOpenfortAccount.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.12; +pragma solidity ^0.8.19; import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import {Ownable2StepUpgradeable} from "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; diff --git a/contracts/core/managed/ManagedOpenfortAccount.sol b/contracts/core/managed/ManagedOpenfortAccount.sol index 3cbdcd7..ab17b34 100644 --- a/contracts/core/managed/ManagedOpenfortAccount.sol +++ b/contracts/core/managed/ManagedOpenfortAccount.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.12; +pragma solidity ^0.8.19; // Base account contract to inherit from import {BaseOpenfortAccount, IEntryPoint} from "../BaseOpenfortAccount.sol"; diff --git a/contracts/core/managed/ManagedOpenfortFactory.sol b/contracts/core/managed/ManagedOpenfortFactory.sol index ae4bda8..9a40001 100644 --- a/contracts/core/managed/ManagedOpenfortFactory.sol +++ b/contracts/core/managed/ManagedOpenfortFactory.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.12; +pragma solidity ^0.8.19; import {BeaconProxy} from "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol"; import {Create2} from "@openzeppelin/contracts/utils/Create2.sol"; diff --git a/contracts/core/managed/OpenfortBeacon.sol b/contracts/core/managed/OpenfortBeacon.sol index 381139a..9cf1647 100644 --- a/contracts/core/managed/OpenfortBeacon.sol +++ b/contracts/core/managed/OpenfortBeacon.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.12; +pragma solidity ^0.8.19; import {UpgradeableBeacon} from "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol"; diff --git a/contracts/core/static/StaticOpenfortAccount.sol b/contracts/core/static/StaticOpenfortAccount.sol index cc00687..6b743c0 100644 --- a/contracts/core/static/StaticOpenfortAccount.sol +++ b/contracts/core/static/StaticOpenfortAccount.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.12; +pragma solidity ^0.8.19; // Base account contract to inherit from import {BaseOpenfortAccount, IEntryPoint} from "../BaseOpenfortAccount.sol"; diff --git a/contracts/core/static/StaticOpenfortFactory.sol b/contracts/core/static/StaticOpenfortFactory.sol index 912b01f..728c588 100644 --- a/contracts/core/static/StaticOpenfortFactory.sol +++ b/contracts/core/static/StaticOpenfortFactory.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.12; +pragma solidity ^0.8.19; import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol"; // Smart wallet implementation to use diff --git a/contracts/core/upgradeable/UpgradeableOpenfortAccount.sol b/contracts/core/upgradeable/UpgradeableOpenfortAccount.sol index 00cc96f..edd745b 100644 --- a/contracts/core/upgradeable/UpgradeableOpenfortAccount.sol +++ b/contracts/core/upgradeable/UpgradeableOpenfortAccount.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.12; +pragma solidity ^0.8.19; // Base account contract to inherit from import {BaseOpenfortAccount, IEntryPoint} from "../BaseOpenfortAccount.sol"; diff --git a/contracts/core/upgradeable/UpgradeableOpenfortFactory.sol b/contracts/core/upgradeable/UpgradeableOpenfortFactory.sol index 18b8e92..ab7e5cc 100644 --- a/contracts/core/upgradeable/UpgradeableOpenfortFactory.sol +++ b/contracts/core/upgradeable/UpgradeableOpenfortFactory.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.12; +pragma solidity ^0.8.19; import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; import {Create2} from "@openzeppelin/contracts/utils/Create2.sol"; diff --git a/contracts/interfaces/IBaseOpenfortFactory.sol b/contracts/interfaces/IBaseOpenfortFactory.sol index 49daf1a..5137a22 100644 --- a/contracts/interfaces/IBaseOpenfortFactory.sol +++ b/contracts/interfaces/IBaseOpenfortFactory.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.12; +pragma solidity ^0.8.19; interface IBaseOpenfortFactory { /// @notice Emitted when a new Account is created. diff --git a/contracts/mock/MockedV2ManagedOpenfortAccount.sol b/contracts/mock/MockedV2ManagedOpenfortAccount.sol index 945df6f..0df6d4b 100644 --- a/contracts/mock/MockedV2ManagedOpenfortAccount.sol +++ b/contracts/mock/MockedV2ManagedOpenfortAccount.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.12; +pragma solidity ^0.8.19; // Base account contract to inherit from import {BaseOpenfortAccount, IEntryPoint} from "../core/BaseOpenfortAccount.sol"; diff --git a/contracts/mock/MockedV2UpgradeableOpenfortAccount.sol b/contracts/mock/MockedV2UpgradeableOpenfortAccount.sol index 12b823c..2ee0dd2 100644 --- a/contracts/mock/MockedV2UpgradeableOpenfortAccount.sol +++ b/contracts/mock/MockedV2UpgradeableOpenfortAccount.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.12; +pragma solidity ^0.8.19; // Base account contract to inherit from import {BaseOpenfortAccount, IEntryPoint} from "../core/BaseOpenfortAccount.sol"; diff --git a/contracts/mock/Rewards.sol b/contracts/mock/Rewards.sol index 621eaac..096ef60 100644 --- a/contracts/mock/Rewards.sol +++ b/contracts/mock/Rewards.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity ^0.8.12; +pragma solidity ^0.8.19; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; diff --git a/contracts/mock/USDC.sol b/contracts/mock/USDC.sol index 6cecffc..2a408bb 100644 --- a/contracts/mock/USDC.sol +++ b/contracts/mock/USDC.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity ^0.8.12; +pragma solidity ^0.8.19; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; diff --git a/script/UserOpTestCounter.sol b/script/UserOpTestCounter.sol index 54446a4..24abc05 100644 --- a/script/UserOpTestCounter.sol +++ b/script/UserOpTestCounter.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.12; +pragma solidity ^0.8.19; import {Script, console} from "forge-std/Script.sol"; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; diff --git a/script/deployBatching.s.sol b/script/deployBatching.s.sol index 03afa85..3f96c96 100644 --- a/script/deployBatching.s.sol +++ b/script/deployBatching.s.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.12; +pragma solidity ^0.8.19; import {Script, console} from "forge-std/Script.sol"; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; diff --git a/script/deployManagedAccounts.sol b/script/deployManagedAccounts.sol index 95b3e69..28289b3 100644 --- a/script/deployManagedAccounts.sol +++ b/script/deployManagedAccounts.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.12; +pragma solidity ^0.8.19; import {Script, console} from "forge-std/Script.sol"; import {IEntryPoint} from "lib/account-abstraction/contracts/interfaces/IEntryPoint.sol"; diff --git a/script/deployMock.sol b/script/deployMock.sol index f362b48..0deae01 100644 --- a/script/deployMock.sol +++ b/script/deployMock.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.12; +pragma solidity ^0.8.19; import {Script, console} from "forge-std/Script.sol"; import {IEntryPoint} from "lib/account-abstraction/contracts/interfaces/IEntryPoint.sol"; diff --git a/script/deployStaticAccounts.sol b/script/deployStaticAccounts.sol index 041fc8a..c51d4f2 100644 --- a/script/deployStaticAccounts.sol +++ b/script/deployStaticAccounts.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.12; +pragma solidity ^0.8.19; import {Script, console} from "forge-std/Script.sol"; import {IEntryPoint} from "lib/account-abstraction/contracts/interfaces/IEntryPoint.sol"; diff --git a/script/deployUpgradeableAccounts.sol b/script/deployUpgradeableAccounts.sol index ef9494b..bd731a0 100644 --- a/script/deployUpgradeableAccounts.sol +++ b/script/deployUpgradeableAccounts.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.12; +pragma solidity ^0.8.19; import {Script, console} from "forge-std/Script.sol"; import {IEntryPoint} from "lib/account-abstraction/contracts/interfaces/IEntryPoint.sol"; diff --git a/test/foundry/4337/Specific4337Tests.t.sol b/test/foundry/4337/Specific4337Tests.t.sol index 94e9409..f94064e 100644 --- a/test/foundry/4337/Specific4337Tests.t.sol +++ b/test/foundry/4337/Specific4337Tests.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.12; +pragma solidity ^0.8.19; import {Test, console} from "lib/forge-std/src/Test.sol"; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; diff --git a/test/foundry/paymaster/OpenfortPaymasterTest.t.sol b/test/foundry/paymaster/OpenfortPaymasterTest.t.sol index 66e5d13..568bfb8 100644 --- a/test/foundry/paymaster/OpenfortPaymasterTest.t.sol +++ b/test/foundry/paymaster/OpenfortPaymasterTest.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.12; +pragma solidity ^0.8.19; import {Test, console} from "lib/forge-std/src/Test.sol"; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; From 788fd334a39e27ad075b8b84d071c93256f127e7 Mon Sep 17 00:00:00 2001 From: Eloi Manuel Date: Wed, 31 May 2023 18:46:19 +0200 Subject: [PATCH 7/7] Modified proxy names --- .../core/managed/ManagedOpenfortFactory.sol | 17 +- .../core/managed/OpenfortBeaconProxy.sol | 15 + .../upgradeable/OpenfortUpgradeableProxy.sol | 15 + .../UpgradeableOpenfortFactory.sol | 12 +- gas_reports/2023-05-31_18:35.gas.out | 308 ++++++++++++++++++ gas_reports/2023-05-31_18:35.snap.out | 105 ++++++ .../managed/ManagedOpenfortAccountTest.t.sol | 1 - .../UpgradeableOpenfortAccountTest.t.sol | 1 - 8 files changed, 458 insertions(+), 16 deletions(-) create mode 100644 contracts/core/managed/OpenfortBeaconProxy.sol create mode 100644 contracts/core/upgradeable/OpenfortUpgradeableProxy.sol create mode 100644 gas_reports/2023-05-31_18:35.gas.out create mode 100644 gas_reports/2023-05-31_18:35.snap.out diff --git a/contracts/core/managed/ManagedOpenfortFactory.sol b/contracts/core/managed/ManagedOpenfortFactory.sol index 9a40001..befd5f3 100644 --- a/contracts/core/managed/ManagedOpenfortFactory.sol +++ b/contracts/core/managed/ManagedOpenfortFactory.sol @@ -1,11 +1,12 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.19; -import {BeaconProxy} from "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol"; import {Create2} from "@openzeppelin/contracts/utils/Create2.sol"; // Smart wallet implementation to use import {ManagedOpenfortAccount} from "./ManagedOpenfortAccount.sol"; import {OpenfortBeacon} from "./OpenfortBeacon.sol"; +import {OpenfortBeaconProxy} from "./OpenfortBeaconProxy.sol"; + // Interfaces import {IBaseOpenfortFactory} from "../../interfaces/IBaseOpenfortFactory.sol"; @@ -13,7 +14,7 @@ import {IBaseOpenfortFactory} from "../../interfaces/IBaseOpenfortFactory.sol"; * @title ManagedOpenfortFactory (Non-upgradeable) * @author Eloi * @notice Contract to create an on-chain factory to deploy new ManagedOpenfortAccounts. - * It uses OpenZeppelin's Create2 and BeaconProxy libraries. + * It uses OpenZeppelin's Create2 and OpenfortBeaconProxy libraries. * It inherits from: * - IBaseOpenfortFactory */ @@ -40,7 +41,7 @@ contract ManagedOpenfortFactory is IBaseOpenfortFactory { emit AccountCreated(account, _admin); account = address( - new BeaconProxy{salt: salt}( + new OpenfortBeaconProxy{salt: salt}( openfortBeacon, abi.encodeCall(ManagedOpenfortAccount.initialize, (_admin, _data)) ) @@ -63,7 +64,7 @@ contract ManagedOpenfortFactory is IBaseOpenfortFactory { emit AccountCreated(account, _admin); account = address( - new BeaconProxy{salt: salt}( + new OpenfortBeaconProxy{salt: salt}( openfortBeacon, abi.encodeCall(ManagedOpenfortAccount.initialize, (_admin, _data)) ) @@ -76,10 +77,10 @@ contract ManagedOpenfortFactory is IBaseOpenfortFactory { function getAddress(address _admin) public view returns (address) { bytes32 salt = keccak256(abi.encode(_admin)); return Create2.computeAddress( - bytes32(salt), + salt, keccak256( abi.encodePacked( - type(BeaconProxy).creationCode, + type(OpenfortBeaconProxy).creationCode, abi.encode( openfortBeacon, abi.encodeCall(ManagedOpenfortAccount.initialize, (_admin, "")) @@ -95,10 +96,10 @@ contract ManagedOpenfortFactory is IBaseOpenfortFactory { function getAddressWithNonce(address _admin, uint256 nonce) public view returns (address) { bytes32 salt = keccak256(abi.encode(_admin, nonce)); return Create2.computeAddress( - bytes32(salt), + salt, keccak256( abi.encodePacked( - type(BeaconProxy).creationCode, + type(OpenfortBeaconProxy).creationCode, abi.encode( openfortBeacon, abi.encodeCall(ManagedOpenfortAccount.initialize, (_admin, "")) diff --git a/contracts/core/managed/OpenfortBeaconProxy.sol b/contracts/core/managed/OpenfortBeaconProxy.sol new file mode 100644 index 0000000..8541c53 --- /dev/null +++ b/contracts/core/managed/OpenfortBeaconProxy.sol @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.19; + +import {BeaconProxy} from "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol"; + +/** + * @title OpenfortBeaconProxy (Non-upgradeable) + * @author Eloi + * @notice Contract to create the Beacon to determine implementation contract, which is where they will delegate all function calls. + * It inherits from: + * - BeaconProxy + */ +contract OpenfortBeaconProxy is BeaconProxy { + constructor(address beacon, bytes memory data) BeaconProxy(beacon, data) {} +} diff --git a/contracts/core/upgradeable/OpenfortUpgradeableProxy.sol b/contracts/core/upgradeable/OpenfortUpgradeableProxy.sol new file mode 100644 index 0000000..8040531 --- /dev/null +++ b/contracts/core/upgradeable/OpenfortUpgradeableProxy.sol @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.19; + +import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; + +/** + * @title OpenfortUpgradeableProxy (Non-upgradeable) + * @author Eloi + * @notice Contract to create the proxies + * It inherits from: + * - ERC1967Proxy + */ +contract OpenfortUpgradeableProxy is ERC1967Proxy { + constructor(address _logic, bytes memory _data) ERC1967Proxy(_logic, _data) {} +} diff --git a/contracts/core/upgradeable/UpgradeableOpenfortFactory.sol b/contracts/core/upgradeable/UpgradeableOpenfortFactory.sol index ab7e5cc..7d0e455 100644 --- a/contracts/core/upgradeable/UpgradeableOpenfortFactory.sol +++ b/contracts/core/upgradeable/UpgradeableOpenfortFactory.sol @@ -1,10 +1,10 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.19; -import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; import {Create2} from "@openzeppelin/contracts/utils/Create2.sol"; // Smart wallet implementation to use import {UpgradeableOpenfortAccount} from "./UpgradeableOpenfortAccount.sol"; +import {OpenfortUpgradeableProxy} from "./OpenfortUpgradeableProxy.sol"; // Interfaces import {IBaseOpenfortFactory} from "../../interfaces/IBaseOpenfortFactory.sol"; @@ -12,7 +12,7 @@ import {IBaseOpenfortFactory} from "../../interfaces/IBaseOpenfortFactory.sol"; * @title UpgradeableOpenfortFactory (Non-upgradeable) * @author Eloi * @notice Contract to create an on-chain factory to deploy new UpgradeableOpenfortAccounts. - * It uses OpenZeppelin's Create2 and ERC1967Proxy libraries. + * It uses OpenZeppelin's Create2 and OpenfortUpgradeableProxy libraries. * It inherits from: * - IBaseOpenfortFactory */ @@ -41,7 +41,7 @@ contract UpgradeableOpenfortFactory is IBaseOpenfortFactory { emit AccountCreated(account, _admin); account = address( - new ERC1967Proxy{salt: salt}( + new OpenfortUpgradeableProxy{salt: salt}( accountImplementation, abi.encodeCall(UpgradeableOpenfortAccount.initialize, (_admin, entrypointContract, _data)) ) @@ -64,7 +64,7 @@ contract UpgradeableOpenfortFactory is IBaseOpenfortFactory { emit AccountCreated(account, _admin); account = address( - new ERC1967Proxy{salt: salt}( + new OpenfortUpgradeableProxy{salt: salt}( accountImplementation, abi.encodeCall(UpgradeableOpenfortAccount.initialize, (_admin, entrypointContract, _data)) ) @@ -80,7 +80,7 @@ contract UpgradeableOpenfortFactory is IBaseOpenfortFactory { salt, keccak256( abi.encodePacked( - type(ERC1967Proxy).creationCode, + type(OpenfortUpgradeableProxy).creationCode, abi.encode( accountImplementation, abi.encodeCall(UpgradeableOpenfortAccount.initialize, (_admin, entrypointContract, "")) @@ -99,7 +99,7 @@ contract UpgradeableOpenfortFactory is IBaseOpenfortFactory { salt, keccak256( abi.encodePacked( - type(ERC1967Proxy).creationCode, + type(OpenfortUpgradeableProxy).creationCode, abi.encode( accountImplementation, abi.encodeCall(UpgradeableOpenfortAccount.initialize, (_admin, entrypointContract, "")) diff --git a/gas_reports/2023-05-31_18:35.gas.out b/gas_reports/2023-05-31_18:35.gas.out new file mode 100644 index 0000000..922ec63 --- /dev/null +++ b/gas_reports/2023-05-31_18:35.gas.out @@ -0,0 +1,308 @@ + +Running 1 test for test/foundry/4337/Specific4337Tests.t.sol:Specific4337Tests +[PASS] testToken():(address) (gas: 2382) +Test result: ok. 1 passed; 0 failed; finished in 1.53s + +Running 14 tests for test/foundry/paymaster/OpenfortPaymasterTest.t.sol:OpenfortPaymasterTest +[PASS] testEntryPointDepositToPaymaster() (gas: 45021) +[PASS] testFailPaymasterUserOpERC20ValidSigExecBatchInsufficientERC20() (gas: 319856) +[PASS] testFailPaymasterUserOpERC20ValidSigSmallApprove() (gas: 279828) +[PASS] testInitialParameters() (gas: 13782) +[PASS] testParsePaymasterDataERC20() (gas: 35513) +[PASS] testParsePaymasterDataNative() (gas: 33247) +[PASS] testPaymasterAddStake() (gas: 47881) +[PASS] testPaymasterUserOpERC20ValidSig() (gas: 300489) +[PASS] testPaymasterUserOpERC20ValidSigExecBatch() (gas: 341300) +[PASS] testPaymasterUserOpNativeValidSig() (gas: 230754) +[PASS] testPaymasterUserOpNativeValidSigExecBatch() (gas: 273169) +[PASS] testPaymasterUserOpWrongSig() (gas: 133317) +[PASS] testPaymasterUserOpWrongSigLength() (gas: 103571) +[PASS] testToken():(address) (gas: 2383) +Test result: ok. 14 passed; 0 failed; finished in 2.77s + +Running 30 tests for test/foundry/core/static/StaticOpenfortAccountTest.t.sol:StaticOpenfortAccountTest +[PASS] testChangeOwnershipAndCountDirect() (gas: 174591) +[PASS] testChangeOwnershipAndCountEntryPoint() (gas: 323573) +[PASS] testCreateAccountViaEntryPoint() (gas: 225651) +[PASS] testCreateAccountViaFactory() (gas: 139646) +[PASS] testCreateAccountViaFactoryWithNonce() (gas: 256326) +[PASS] testFailAttackRegisterSessionKeyViaEntrypoint2ndKey() (gas: 513242) +[PASS] testFailIncrementCounterViaSessionKeyNotregistered() (gas: 290564) +[PASS] testFailIncrementCounterViaSessionKeyReachLimit() (gas: 422239) +[PASS] testFailIncrementCounterViaSessionKeyReachLimitBatching() (gas: 329031) +[PASS] testFailIncrementCounterViaSessionKeyRevoked() (gas: 170541) +[PASS] testFailIncrementCounterViaSessionKeyWhitelistingBatch() (gas: 385559) +[PASS] testFailIncrementCounterViaSessionKeyWhitelistingBatchWrongAddress() (gas: 352129) +[PASS] testFailIncrementCounterViaSessionKeyWhitelistingTooBig() (gas: 147484) +[PASS] testFailIncrementCounterViaSessionKeyWhitelistingWrongAddress() (gas: 343645) +[PASS] testFailRevokeSessionKeyInvalidUser() (gas: 173085) +[PASS] testIncrementCounterDirect() (gas: 166279) +[PASS] testIncrementCounterViaEntrypoint() (gas: 317164) +[PASS] testIncrementCounterViaEntrypointBatching() (gas: 329394) +[PASS] testIncrementCounterViaSessionKey() (gas: 346568) +[PASS] testIncrementCounterViaSessionKeyExpired() (gas: 316620) +[PASS] testIncrementCounterViaSessionKeyWhitelisting() (gas: 372157) +[PASS] testIncrementCounterViaSessionKeyWhitelistingBatch() (gas: 395178) +[PASS] testMintTokenAccount() (gas: 346017) +[PASS] testReceiveNativeToken() (gas: 142185) +[PASS] testRegisterSessionKeyViaEntrypoint() (gas: 426762) +[PASS] testRegisterSessionKeyViaEntrypoint2ndKey() (gas: 535415) +[PASS] testSimulateValidation() (gas: 243391) +[PASS] testToken():(address) (gas: 2404) +[PASS] testTransferOutNativeToken() (gas: 250263) +[PASS] testUpdateEntryPoint() (gas: 538664) +Test result: ok. 30 passed; 0 failed; finished in 3.18s + +Running 30 tests for test/foundry/core/upgradeable/UpgradeableOpenfortAccountTest.t.sol:UpgradeableOpenfortAccountTest +[PASS] testChangeOwnershipAndCountDirect() (gas: 233447) +[PASS] testChangeOwnershipAndCountEntryPoint() (gas: 382875) +[PASS] testCreateAccountViaEntryPoint() (gas: 294637) +[PASS] testCreateAccountViaFactory() (gas: 208186) +[PASS] testCreateAccountViaFactoryWithNonce() (gas: 378041) +[PASS] testFailAttackRegisterSessionKeyViaEntrypoint2ndKey() (gas: 573628) +[PASS] testFailIncrementCounterViaSessionKeyNotregistered() (gas: 349166) +[PASS] testFailIncrementCounterViaSessionKeyReachLimit() (gas: 481733) +[PASS] testFailIncrementCounterViaSessionKeyReachLimitBatching() (gas: 387856) +[PASS] testFailIncrementCounterViaSessionKeyRevoked() (gas: 229148) +[PASS] testFailIncrementCounterViaSessionKeyWhitelistingBatchWrongAddress() (gas: 411020) +[PASS] testFailIncrementCounterViaSessionKeyWhitelistingTooBig() (gas: 205931) +[PASS] testFailIncrementCounterViaSessionKeyWhitelistingWrongAddress() (gas: 402536) +[PASS] testFailRevokeSessionKeyInvalidUser() (gas: 231692) +[PASS] testIncrementCounterDirect() (gas: 224658) +[PASS] testIncrementCounterViaEntrypoint() (gas: 375989) +[PASS] testIncrementCounterViaEntrypointBatching() (gas: 388219) +[PASS] testIncrementCounterViaSessionKey() (gas: 405594) +[PASS] testIncrementCounterViaSessionKeyExpired() (gas: 375423) +[PASS] testIncrementCounterViaSessionKeyWhitelisting() (gas: 431271) +[PASS] testIncrementCounterViaSessionKeyWhitelistingBatch() (gas: 454515) +[PASS] testMintTokenAccount() (gas: 404842) +[PASS] testReceiveNativeToken() (gas: 200583) +[PASS] testRegisterSessionKeyViaEntrypoint() (gas: 486457) +[PASS] testRegisterSessionKeyViaEntrypoint2ndKey() (gas: 595980) +[PASS] testSimulateValidation() (gas: 301770) +[PASS] testToken():(address) (gas: 2404) +[PASS] testTransferOutNativeToken() (gas: 309107) +[PASS] testUpdateEntryPoint() (gas: 939790) +[PASS] testUpgradeAccount() (gas: 2475282) +Test result: ok. 30 passed; 0 failed; finished in 3.18s + +Running 30 tests for test/foundry/core/managed/ManagedOpenfortAccountTest.t.sol:ManagedOpenfortAccountTest +[PASS] testChangeOwnershipAndCountDirect() (gas: 249782) +[PASS] testChangeOwnershipAndCountEntryPoint() (gas: 400307) +[PASS] testCreateAccountViaEntryPoint() (gas: 312124) +[PASS] testCreateAccountViaFactory() (gas: 224463) +[PASS] testCreateAccountViaFactoryWithNonce() (gas: 403280) +[PASS] testFailAttackRegisterSessionKeyViaEntrypoint2ndKey() (gas: 593507) +[PASS] testFailIncrementCounterViaSessionKeyNotregistered() (gas: 364573) +[PASS] testFailIncrementCounterViaSessionKeyReachLimit() (gas: 499353) +[PASS] testFailIncrementCounterViaSessionKeyReachLimitBatching() (gas: 403840) +[PASS] testFailIncrementCounterViaSessionKeyRevoked() (gas: 244596) +[PASS] testFailIncrementCounterViaSessionKeyWhitelistingBatch() (gas: 461352) +[PASS] testFailIncrementCounterViaSessionKeyWhitelistingBatchWrongAddress() (gas: 427026) +[PASS] testFailIncrementCounterViaSessionKeyWhitelistingTooBig() (gas: 220812) +[PASS] testFailIncrementCounterViaSessionKeyWhitelistingWrongAddress() (gas: 418542) +[PASS] testFailRevokeSessionKeyInvalidUser() (gas: 247140) +[PASS] testIncrementCounterDirect() (gas: 239574) +[PASS] testIncrementCounterViaEntrypoint() (gas: 391968) +[PASS] testIncrementCounterViaEntrypointBatching() (gas: 404232) +[PASS] testIncrementCounterViaSessionKey() (gas: 422139) +[PASS] testIncrementCounterViaSessionKeyExpired() (gas: 391432) +[PASS] testIncrementCounterViaSessionKeyWhitelisting() (gas: 447699) +[PASS] testIncrementCounterViaSessionKeyWhitelistingBatch() (gas: 471727) +[PASS] testMintTokenAccount() (gas: 420989) +[PASS] testReceiveNativeToken() (gas: 215639) +[PASS] testRegisterSessionKeyViaEntrypoint() (gas: 504635) +[PASS] testRegisterSessionKeyViaEntrypoint2ndKey() (gas: 616323) +[PASS] testSimulateValidation() (gas: 316639) +[PASS] testToken():(address) (gas: 2426) +[PASS] testTransferOutNativeToken() (gas: 325266) +[PASS] testUpgradeTo() (gas: 2077363) +Test result: ok. 30 passed; 0 failed; finished in 3.18s +| EntryPoint contract | | | | | | +|---------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 0 | 0 | | | | | +| Function Name | min | avg | median | max | # calls | +| addStake | 25917 | 25917 | 25917 | 25917 | 1 | +| balanceOf | 594 | 1260 | 594 | 2594 | 3 | +| depositTo | 2606 | 10839 | 5406 | 24506 | 3 | + + +| contracts/core/managed/ManagedOpenfortAccount.sol:ManagedOpenfortAccount contract | | | | | | +|-----------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 1806914 | 9182 | | | | | +| Function Name | min | avg | median | max | # calls | +| acceptOwnership | 1996 | 1996 | 1996 | 1996 | 2 | +| execute | 3568 | 21350 | 21542 | 32768 | 17 | +| executeBatch | 25603 | 25603 | 25603 | 25603 | 2 | +| initialize | 50619 | 50619 | 50619 | 50619 | 30 | +| receive | 55 | 55 | 55 | 55 | 2 | +| registerSessionKey(address,uint48,uint48) | 24617 | 24622 | 24617 | 24629 | 7 | +| registerSessionKey(address,uint48,uint48,uint48) | 24367 | 24371 | 24367 | 24379 | 3 | +| registerSessionKey(address,uint48,uint48,uint48,address[]) | 1288 | 39642 | 47313 | 47313 | 6 | +| revokeSessionKey | 609 | 609 | 609 | 609 | 2 | +| sessionKeys | 810 | 810 | 810 | 810 | 3 | +| transferOwnership | 22375 | 22375 | 22375 | 22375 | 2 | +| validateUserOp | 5005 | 7241 | 6740 | 15510 | 49 | +| version | 259 | 259 | 259 | 259 | 1 | + + +| contracts/core/managed/ManagedOpenfortFactory.sol:ManagedOpenfortFactory contract | | | | | | +|-----------------------------------------------------------------------------------|-----------------|--------|--------|--------|---------| +| Deployment Cost | Deployment Size | | | | | +| 802970 | 4253 | | | | | +| Function Name | min | avg | median | max | # calls | +| createAccount | 7695 | 184462 | 196740 | 196740 | 31 | +| createAccountWithNonce | 189793 | 189793 | 189793 | 189793 | 1 | +| getAddress | 7065 | 7065 | 7065 | 7065 | 4 | + + +| contracts/core/managed/OpenfortBeacon.sol:OpenfortBeacon contract | | | | | | +|-------------------------------------------------------------------|-----------------|------|--------|------|---------| +| Deployment Cost | Deployment Size | | | | | +| 213861 | 1248 | | | | | +| Function Name | min | avg | median | max | # calls | +| implementation | 308 | 672 | 308 | 2308 | 159 | +| upgradeTo | 2510 | 4659 | 4659 | 6809 | 2 | + + +| contracts/core/static/StaticOpenfortAccount.sol:StaticOpenfortAccount contract | | | | | | +|--------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 1877392 | 9534 | | | | | +| Function Name | min | avg | median | max | # calls | +| acceptOwnership | 1944 | 1944 | 1944 | 1944 | 2 | +| entryPoint | 376 | 376 | 376 | 376 | 2 | +| execute | 3708 | 22011 | 21747 | 32908 | 20 | +| executeBatch | 25743 | 40742 | 48408 | 55408 | 5 | +| initialize | 74366 | 74366 | 74366 | 74366 | 44 | +| receive | 55 | 55 | 55 | 55 | 2 | +| registerSessionKey(address,uint48,uint48) | 24757 | 24762 | 24757 | 24769 | 7 | +| registerSessionKey(address,uint48,uint48,uint48) | 24485 | 24489 | 24485 | 24497 | 3 | +| registerSessionKey(address,uint48,uint48,uint48,address[]) | 1340 | 39694 | 47365 | 47365 | 6 | +| revokeSessionKey | 749 | 749 | 749 | 749 | 2 | +| sessionKeys | 832 | 832 | 832 | 832 | 3 | +| transferOwnership | 22375 | 22375 | 22375 | 22375 | 2 | +| updateEntryPoint | 651 | 1483 | 1483 | 2315 | 2 | +| validateUserOp | 5145 | 7629 | 6880 | 15650 | 57 | + + +| contracts/core/static/StaticOpenfortFactory.sol:StaticOpenfortFactory contract | | | | | | +|--------------------------------------------------------------------------------|-----------------|--------|--------|--------|---------| +| Deployment Cost | Deployment Size | | | | | +| 366774 | 2178 | | | | | +| Function Name | min | avg | median | max | # calls | +| createAccount | 1273 | 120553 | 124200 | 124200 | 44 | +| createAccountWithNonce | 121729 | 121729 | 121729 | 121729 | 1 | +| getAddress | 830 | 830 | 830 | 830 | 4 | + + +| contracts/core/upgradeable/UpgradeableOpenfortAccount.sol:UpgradeableOpenfortAccount contract | | | | | | +|-----------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 2290542 | 11647 | | | | | +| Function Name | min | avg | median | max | # calls | +| acceptOwnership | 1962 | 1962 | 1962 | 1962 | 2 | +| entryPoint | 376 | 376 | 376 | 376 | 2 | +| execute | 3708 | 21354 | 21682 | 32908 | 17 | +| executeBatch | 25743 | 25743 | 25743 | 25743 | 2 | +| initialize | 74366 | 74366 | 74366 | 74366 | 30 | +| receive | 55 | 55 | 55 | 55 | 2 | +| registerSessionKey(address,uint48,uint48) | 24735 | 24740 | 24735 | 24747 | 7 | +| registerSessionKey(address,uint48,uint48,uint48) | 24485 | 24489 | 24485 | 24497 | 3 | +| registerSessionKey(address,uint48,uint48,uint48,address[]) | 1406 | 38226 | 47431 | 47431 | 5 | +| revokeSessionKey | 771 | 771 | 771 | 771 | 2 | +| sessionKeys | 832 | 832 | 832 | 832 | 2 | +| transferOwnership | 22375 | 22375 | 22375 | 22375 | 2 | +| updateEntryPoint | 629 | 1461 | 1461 | 2293 | 2 | +| upgradeTo | 890 | 3226 | 3226 | 5562 | 2 | +| validateUserOp | 5145 | 7029 | 6880 | 12521 | 47 | +| version | 303 | 303 | 303 | 303 | 1 | + + +| contracts/core/upgradeable/UpgradeableOpenfortFactory.sol:UpgradeableOpenfortFactory contract | | | | | | +|-----------------------------------------------------------------------------------------------|-----------------|--------|--------|--------|---------| +| Deployment Cost | Deployment Size | | | | | +| 708540 | 3899 | | | | | +| Function Name | min | avg | median | max | # calls | +| createAccount | 6652 | 176415 | 182356 | 182356 | 30 | +| createAccountWithNonce | 179909 | 179909 | 179909 | 179909 | 1 | +| getAddress | 6022 | 6022 | 6022 | 6022 | 4 | + + +| contracts/mock/MockedV2ManagedOpenfortAccount.sol:MockedV2ManagedOpenfortAccount contract | | | | | | +|-------------------------------------------------------------------------------------------|-----------------|-----|--------|-----|---------| +| Deployment Cost | Deployment Size | | | | | +| 1806914 | 9182 | | | | | +| Function Name | min | avg | median | max | # calls | +| version | 259 | 259 | 259 | 259 | 2 | + + +| contracts/mock/MockedV2UpgradeableOpenfortAccount.sol:MockedV2UpgradeableOpenfortAccount contract | | | | | | +|---------------------------------------------------------------------------------------------------|-----------------|-----|--------|-----|---------| +| Deployment Cost | Deployment Size | | | | | +| 2237283 | 11381 | | | | | +| Function Name | min | avg | median | max | # calls | +| proxiableUUID | 374 | 374 | 374 | 374 | 1 | +| version | 303 | 303 | 303 | 303 | 1 | + + +| contracts/paymaster/OpenfortPaymaster.sol:OpenfortPaymaster contract | | | | | | +|----------------------------------------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 1215863 | 6347 | | | | | +| Function Name | min | avg | median | max | # calls | +| addStake | 520 | 30701 | 33420 | 33420 | 16 | +| deposit | 9845 | 32618 | 34245 | 34245 | 15 | +| entryPoint | 261 | 261 | 261 | 261 | 1 | +| getDeposit | 1181 | 2104 | 1181 | 3181 | 13 | +| getHash | 3462 | 5053 | 4998 | 6535 | 12 | +| owner | 2365 | 2365 | 2365 | 2365 | 7 | +| parsePaymasterAndData | 1516 | 1516 | 1516 | 1516 | 2 | +| postOp | 1433 | 12421 | 5583 | 30248 | 6 | +| validatePaymasterUserOp | 1694 | 26885 | 30289 | 31112 | 8 | + + +| node_modules/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol:ERC1967Proxy contract | | | | | | +|-------------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 138042 | 1505 | | | | | +| Function Name | min | avg | median | max | # calls | +| acceptOwnership | 2276 | 2276 | 2276 | 2276 | 2 | +| entryPoint | 771 | 771 | 771 | 771 | 2 | +| execute | 4118 | 21774 | 22098 | 33318 | 17 | +| executeBatch | 26255 | 26255 | 26255 | 26255 | 2 | +| receive | 454 | 454 | 454 | 454 | 2 | +| registerSessionKey(address,uint48,uint48) | 25139 | 25144 | 25139 | 25151 | 7 | +| registerSessionKey(address,uint48,uint48,uint48) | 24895 | 24899 | 24895 | 24907 | 3 | +| registerSessionKey(address,uint48,uint48,uint48,address[]) | 1907 | 38668 | 47859 | 47859 | 5 | +| revokeSessionKey | 1170 | 1170 | 1170 | 1170 | 2 | +| sessionKeys | 1248 | 1248 | 1248 | 1248 | 2 | +| transferOwnership | 22770 | 22770 | 22770 | 22770 | 2 | +| updateEntryPoint | 1040 | 1864 | 1864 | 2688 | 2 | +| upgradeTo | 1301 | 3629 | 3629 | 5957 | 2 | +| validateUserOp | 5691 | 7603 | 7432 | 13171 | 47 | +| version | 698 | 698 | 698 | 698 | 2 | + + +| node_modules/@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol:BeaconProxy contract | | | | | | +|----------------------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 151292 | 1964 | | | | | +| Function Name | min | avg | median | max | # calls | +| acceptOwnership | 2871 | 2871 | 2871 | 2871 | 2 | +| execute | 4673 | 22466 | 22653 | 33873 | 17 | +| executeBatch | 26810 | 26810 | 26810 | 26810 | 2 | +| receive | 1155 | 1155 | 1155 | 1155 | 2 | +| registerSessionKey(address,uint48,uint48) | 25719 | 25724 | 25719 | 25731 | 7 | +| registerSessionKey(address,uint48,uint48,uint48) | 25472 | 25476 | 25472 | 25484 | 3 | +| registerSessionKey(address,uint48,uint48,uint48,address[]) | 2484 | 40777 | 48436 | 48436 | 6 | +| revokeSessionKey | 1709 | 1709 | 1709 | 1709 | 2 | +| sessionKeys | 1921 | 1921 | 1921 | 1921 | 3 | +| transferOwnership | 23471 | 23471 | 23471 | 23471 | 2 | +| validateUserOp | 6246 | 8523 | 7987 | 17105 | 49 | +| version | 1355 | 1355 | 1355 | 1355 | 3 | + + + diff --git a/gas_reports/2023-05-31_18:35.snap.out b/gas_reports/2023-05-31_18:35.snap.out new file mode 100644 index 0000000..2c661a0 --- /dev/null +++ b/gas_reports/2023-05-31_18:35.snap.out @@ -0,0 +1,105 @@ +ManagedOpenfortAccountTest:testChangeOwnershipAndCountDirect() (gas: 249782) +ManagedOpenfortAccountTest:testChangeOwnershipAndCountEntryPoint() (gas: 400307) +ManagedOpenfortAccountTest:testCreateAccountViaEntryPoint() (gas: 312124) +ManagedOpenfortAccountTest:testCreateAccountViaFactory() (gas: 224463) +ManagedOpenfortAccountTest:testCreateAccountViaFactoryWithNonce() (gas: 403280) +ManagedOpenfortAccountTest:testFailAttackRegisterSessionKeyViaEntrypoint2ndKey() (gas: 593507) +ManagedOpenfortAccountTest:testFailIncrementCounterViaSessionKeyNotregistered() (gas: 364573) +ManagedOpenfortAccountTest:testFailIncrementCounterViaSessionKeyReachLimit() (gas: 499353) +ManagedOpenfortAccountTest:testFailIncrementCounterViaSessionKeyReachLimitBatching() (gas: 403840) +ManagedOpenfortAccountTest:testFailIncrementCounterViaSessionKeyRevoked() (gas: 244596) +ManagedOpenfortAccountTest:testFailIncrementCounterViaSessionKeyWhitelistingBatch() (gas: 461352) +ManagedOpenfortAccountTest:testFailIncrementCounterViaSessionKeyWhitelistingBatchWrongAddress() (gas: 427026) +ManagedOpenfortAccountTest:testFailIncrementCounterViaSessionKeyWhitelistingTooBig() (gas: 220812) +ManagedOpenfortAccountTest:testFailIncrementCounterViaSessionKeyWhitelistingWrongAddress() (gas: 418542) +ManagedOpenfortAccountTest:testFailRevokeSessionKeyInvalidUser() (gas: 247140) +ManagedOpenfortAccountTest:testIncrementCounterDirect() (gas: 239574) +ManagedOpenfortAccountTest:testIncrementCounterViaEntrypoint() (gas: 391968) +ManagedOpenfortAccountTest:testIncrementCounterViaEntrypointBatching() (gas: 404232) +ManagedOpenfortAccountTest:testIncrementCounterViaSessionKey() (gas: 422139) +ManagedOpenfortAccountTest:testIncrementCounterViaSessionKeyExpired() (gas: 391432) +ManagedOpenfortAccountTest:testIncrementCounterViaSessionKeyWhitelisting() (gas: 447699) +ManagedOpenfortAccountTest:testIncrementCounterViaSessionKeyWhitelistingBatch() (gas: 471727) +ManagedOpenfortAccountTest:testMintTokenAccount() (gas: 420989) +ManagedOpenfortAccountTest:testReceiveNativeToken() (gas: 215639) +ManagedOpenfortAccountTest:testRegisterSessionKeyViaEntrypoint() (gas: 504635) +ManagedOpenfortAccountTest:testRegisterSessionKeyViaEntrypoint2ndKey() (gas: 616323) +ManagedOpenfortAccountTest:testSimulateValidation() (gas: 316639) +ManagedOpenfortAccountTest:testToken():(address) (gas: 2426) +ManagedOpenfortAccountTest:testTransferOutNativeToken() (gas: 325266) +ManagedOpenfortAccountTest:testUpgradeTo() (gas: 2077363) +OpenfortPaymasterTest:testEntryPointDepositToPaymaster() (gas: 45021) +OpenfortPaymasterTest:testFailPaymasterUserOpERC20ValidSigExecBatchInsufficientERC20() (gas: 319856) +OpenfortPaymasterTest:testFailPaymasterUserOpERC20ValidSigSmallApprove() (gas: 279828) +OpenfortPaymasterTest:testInitialParameters() (gas: 13782) +OpenfortPaymasterTest:testParsePaymasterDataERC20() (gas: 35513) +OpenfortPaymasterTest:testParsePaymasterDataNative() (gas: 33247) +OpenfortPaymasterTest:testPaymasterAddStake() (gas: 47881) +OpenfortPaymasterTest:testPaymasterUserOpERC20ValidSig() (gas: 300489) +OpenfortPaymasterTest:testPaymasterUserOpERC20ValidSigExecBatch() (gas: 341300) +OpenfortPaymasterTest:testPaymasterUserOpNativeValidSig() (gas: 230754) +OpenfortPaymasterTest:testPaymasterUserOpNativeValidSigExecBatch() (gas: 273169) +OpenfortPaymasterTest:testPaymasterUserOpWrongSig() (gas: 133317) +OpenfortPaymasterTest:testPaymasterUserOpWrongSigLength() (gas: 103571) +OpenfortPaymasterTest:testToken():(address) (gas: 2383) +Specific4337Tests:testToken():(address) (gas: 2382) +StaticOpenfortAccountTest:testChangeOwnershipAndCountDirect() (gas: 174591) +StaticOpenfortAccountTest:testChangeOwnershipAndCountEntryPoint() (gas: 323573) +StaticOpenfortAccountTest:testCreateAccountViaEntryPoint() (gas: 225651) +StaticOpenfortAccountTest:testCreateAccountViaFactory() (gas: 139646) +StaticOpenfortAccountTest:testCreateAccountViaFactoryWithNonce() (gas: 256326) +StaticOpenfortAccountTest:testFailAttackRegisterSessionKeyViaEntrypoint2ndKey() (gas: 513242) +StaticOpenfortAccountTest:testFailIncrementCounterViaSessionKeyNotregistered() (gas: 290564) +StaticOpenfortAccountTest:testFailIncrementCounterViaSessionKeyReachLimit() (gas: 422239) +StaticOpenfortAccountTest:testFailIncrementCounterViaSessionKeyReachLimitBatching() (gas: 329031) +StaticOpenfortAccountTest:testFailIncrementCounterViaSessionKeyRevoked() (gas: 170541) +StaticOpenfortAccountTest:testFailIncrementCounterViaSessionKeyWhitelistingBatch() (gas: 385559) +StaticOpenfortAccountTest:testFailIncrementCounterViaSessionKeyWhitelistingBatchWrongAddress() (gas: 352129) +StaticOpenfortAccountTest:testFailIncrementCounterViaSessionKeyWhitelistingTooBig() (gas: 147484) +StaticOpenfortAccountTest:testFailIncrementCounterViaSessionKeyWhitelistingWrongAddress() (gas: 343645) +StaticOpenfortAccountTest:testFailRevokeSessionKeyInvalidUser() (gas: 173085) +StaticOpenfortAccountTest:testIncrementCounterDirect() (gas: 166279) +StaticOpenfortAccountTest:testIncrementCounterViaEntrypoint() (gas: 317164) +StaticOpenfortAccountTest:testIncrementCounterViaEntrypointBatching() (gas: 329394) +StaticOpenfortAccountTest:testIncrementCounterViaSessionKey() (gas: 346568) +StaticOpenfortAccountTest:testIncrementCounterViaSessionKeyExpired() (gas: 316620) +StaticOpenfortAccountTest:testIncrementCounterViaSessionKeyWhitelisting() (gas: 372157) +StaticOpenfortAccountTest:testIncrementCounterViaSessionKeyWhitelistingBatch() (gas: 395178) +StaticOpenfortAccountTest:testMintTokenAccount() (gas: 346017) +StaticOpenfortAccountTest:testReceiveNativeToken() (gas: 142185) +StaticOpenfortAccountTest:testRegisterSessionKeyViaEntrypoint() (gas: 426762) +StaticOpenfortAccountTest:testRegisterSessionKeyViaEntrypoint2ndKey() (gas: 535415) +StaticOpenfortAccountTest:testSimulateValidation() (gas: 243391) +StaticOpenfortAccountTest:testToken():(address) (gas: 2404) +StaticOpenfortAccountTest:testTransferOutNativeToken() (gas: 250263) +StaticOpenfortAccountTest:testUpdateEntryPoint() (gas: 538664) +UpgradeableOpenfortAccountTest:testChangeOwnershipAndCountDirect() (gas: 233447) +UpgradeableOpenfortAccountTest:testChangeOwnershipAndCountEntryPoint() (gas: 382875) +UpgradeableOpenfortAccountTest:testCreateAccountViaEntryPoint() (gas: 294637) +UpgradeableOpenfortAccountTest:testCreateAccountViaFactory() (gas: 208186) +UpgradeableOpenfortAccountTest:testCreateAccountViaFactoryWithNonce() (gas: 378041) +UpgradeableOpenfortAccountTest:testFailAttackRegisterSessionKeyViaEntrypoint2ndKey() (gas: 573628) +UpgradeableOpenfortAccountTest:testFailIncrementCounterViaSessionKeyNotregistered() (gas: 349166) +UpgradeableOpenfortAccountTest:testFailIncrementCounterViaSessionKeyReachLimit() (gas: 481733) +UpgradeableOpenfortAccountTest:testFailIncrementCounterViaSessionKeyReachLimitBatching() (gas: 387856) +UpgradeableOpenfortAccountTest:testFailIncrementCounterViaSessionKeyRevoked() (gas: 229148) +UpgradeableOpenfortAccountTest:testFailIncrementCounterViaSessionKeyWhitelistingBatchWrongAddress() (gas: 411020) +UpgradeableOpenfortAccountTest:testFailIncrementCounterViaSessionKeyWhitelistingTooBig() (gas: 205931) +UpgradeableOpenfortAccountTest:testFailIncrementCounterViaSessionKeyWhitelistingWrongAddress() (gas: 402536) +UpgradeableOpenfortAccountTest:testFailRevokeSessionKeyInvalidUser() (gas: 231692) +UpgradeableOpenfortAccountTest:testIncrementCounterDirect() (gas: 224658) +UpgradeableOpenfortAccountTest:testIncrementCounterViaEntrypoint() (gas: 375989) +UpgradeableOpenfortAccountTest:testIncrementCounterViaEntrypointBatching() (gas: 388219) +UpgradeableOpenfortAccountTest:testIncrementCounterViaSessionKey() (gas: 405594) +UpgradeableOpenfortAccountTest:testIncrementCounterViaSessionKeyExpired() (gas: 375423) +UpgradeableOpenfortAccountTest:testIncrementCounterViaSessionKeyWhitelisting() (gas: 431271) +UpgradeableOpenfortAccountTest:testIncrementCounterViaSessionKeyWhitelistingBatch() (gas: 454515) +UpgradeableOpenfortAccountTest:testMintTokenAccount() (gas: 404842) +UpgradeableOpenfortAccountTest:testReceiveNativeToken() (gas: 200583) +UpgradeableOpenfortAccountTest:testRegisterSessionKeyViaEntrypoint() (gas: 486457) +UpgradeableOpenfortAccountTest:testRegisterSessionKeyViaEntrypoint2ndKey() (gas: 595980) +UpgradeableOpenfortAccountTest:testSimulateValidation() (gas: 301770) +UpgradeableOpenfortAccountTest:testToken():(address) (gas: 2404) +UpgradeableOpenfortAccountTest:testTransferOutNativeToken() (gas: 309107) +UpgradeableOpenfortAccountTest:testUpdateEntryPoint() (gas: 939790) +UpgradeableOpenfortAccountTest:testUpgradeAccount() (gas: 2475282) \ No newline at end of file diff --git a/test/foundry/core/managed/ManagedOpenfortAccountTest.t.sol b/test/foundry/core/managed/ManagedOpenfortAccountTest.t.sol index 2911194..2996feb 100644 --- a/test/foundry/core/managed/ManagedOpenfortAccountTest.t.sol +++ b/test/foundry/core/managed/ManagedOpenfortAccountTest.t.sol @@ -3,7 +3,6 @@ pragma solidity ^0.8.19; import {Test, console} from "lib/forge-std/src/Test.sol"; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; -import {BeaconProxy} from "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol"; import {EntryPoint, UserOperation} from "account-abstraction/core/EntryPoint.sol"; import {TestCounter} from "account-abstraction/test/TestCounter.sol"; import {TestToken} from "account-abstraction/test/TestToken.sol"; diff --git a/test/foundry/core/upgradeable/UpgradeableOpenfortAccountTest.t.sol b/test/foundry/core/upgradeable/UpgradeableOpenfortAccountTest.t.sol index 75d085c..4318c87 100644 --- a/test/foundry/core/upgradeable/UpgradeableOpenfortAccountTest.t.sol +++ b/test/foundry/core/upgradeable/UpgradeableOpenfortAccountTest.t.sol @@ -3,7 +3,6 @@ pragma solidity ^0.8.19; import {Test, console} from "lib/forge-std/src/Test.sol"; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; -import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; import {EntryPoint, UserOperation} from "account-abstraction/core/EntryPoint.sol"; import {TestCounter} from "account-abstraction/test/TestCounter.sol"; import {TestToken} from "account-abstraction/test/TestToken.sol";