diff --git a/certora/conf/KintoID_Generic.conf b/certora/conf/KintoID_Generic.conf index f2e855f49..7b1d41740 100644 --- a/certora/conf/KintoID_Generic.conf +++ b/certora/conf/KintoID_Generic.conf @@ -7,7 +7,7 @@ "verify": "KintoIDHarness:certora/spec/Generic.spec", "packages": [ 'node_modules/account-abstraction-0.7.0:@openzeppelin/contracts/=node_modules/openzeppelin-contracts-5.0.1', - '@aa-v7/=node_modules/account-abstraction-0.7.0/contracts/', + '@aa/=node_modules/account-abstraction-0.7.0/contracts/', 'ds-test/=node_modules/forge-std/lib/ds-test/src/', 'forge-std/=node_modules/forge-std/src/', diff --git a/certora/conf/KintoID_Monitor1.conf b/certora/conf/KintoID_Monitor1.conf index 343ccec7c..aca39aa7f 100644 --- a/certora/conf/KintoID_Monitor1.conf +++ b/certora/conf/KintoID_Monitor1.conf @@ -7,7 +7,7 @@ "verify": "KintoIDHarness:certora/spec/KintoID/Monitor.spec", "packages": [ 'node_modules/account-abstraction-0.7.0:@openzeppelin/contracts/=node_modules/openzeppelin-contracts-5.0.1', - '@aa-v7/=node_modules/account-abstraction-0.7.0/contracts/', + '@aa/=node_modules/account-abstraction-0.7.0/contracts/', 'ds-test/=node_modules/forge-std/lib/ds-test/src/', 'forge-std/=node_modules/forge-std/src/', diff --git a/certora/conf/KintoID_Monitor2.conf b/certora/conf/KintoID_Monitor2.conf index 0e9f31ab9..b6c6ecaf3 100644 --- a/certora/conf/KintoID_Monitor2.conf +++ b/certora/conf/KintoID_Monitor2.conf @@ -7,7 +7,7 @@ "verify": "KintoIDHarness:certora/spec/KintoID/Monitor.spec", "packages": [ 'node_modules/account-abstraction-0.7.0:@openzeppelin/contracts/=node_modules/openzeppelin-contracts-5.0.1', - '@aa-v7/=node_modules/account-abstraction-0.7.0/contracts/', + '@aa/=node_modules/account-abstraction-0.7.0/contracts/', 'ds-test/=node_modules/forge-std/lib/ds-test/src/', 'forge-std/=node_modules/forge-std/src/', diff --git a/certora/conf/KintoID_SanctionsTraits.conf b/certora/conf/KintoID_SanctionsTraits.conf index be11505ca..8dba72e24 100644 --- a/certora/conf/KintoID_SanctionsTraits.conf +++ b/certora/conf/KintoID_SanctionsTraits.conf @@ -7,7 +7,7 @@ "verify": "KintoIDHarness:certora/spec/KintoID/SanctionsTraits.spec", "packages": [ 'node_modules/account-abstraction-0.7.0:@openzeppelin/contracts/=node_modules/openzeppelin-contracts-5.0.1', - '@aa-v7/=node_modules/account-abstraction-0.7.0/contracts/', + '@aa/=node_modules/account-abstraction-0.7.0/contracts/', 'ds-test/=node_modules/forge-std/lib/ds-test/src/', 'forge-std/=node_modules/forge-std/src/', diff --git a/certora/conf/KintoID_Viewer.conf b/certora/conf/KintoID_Viewer.conf index 995030f3d..f7ab79ad4 100644 --- a/certora/conf/KintoID_Viewer.conf +++ b/certora/conf/KintoID_Viewer.conf @@ -7,7 +7,7 @@ "verify":"KintoIDHarness:certora/spec/KintoID/Viewer.spec", "packages": [ 'node_modules/account-abstraction-0.7.0:@openzeppelin/contracts/=node_modules/openzeppelin-contracts-5.0.1', - '@aa-v7/=node_modules/account-abstraction-0.7.0/contracts/', + '@aa/=node_modules/account-abstraction-0.7.0/contracts/', 'ds-test/=node_modules/forge-std/lib/ds-test/src/', 'forge-std/=node_modules/forge-std/src/', diff --git a/certora/conf/KintoWallet.conf b/certora/conf/KintoWallet.conf index 3118e6bfa..32b37514b 100644 --- a/certora/conf/KintoWallet.conf +++ b/certora/conf/KintoWallet.conf @@ -13,7 +13,7 @@ ], "packages": [ 'node_modules/account-abstraction-0.7.0:@openzeppelin/contracts/=node_modules/openzeppelin-contracts-5.0.1', - '@aa-v7/=node_modules/account-abstraction-0.7.0/contracts', + '@aa/=node_modules/account-abstraction-0.7.0/contracts', 'ds-test/=node_modules/forge-std/lib/ds-test/src', 'forge-std/=node_modules/forge-std/src', diff --git a/certora/conf/KintoWalletFactory.conf b/certora/conf/KintoWalletFactory.conf index 5ddcf5c6a..c607987f7 100644 --- a/certora/conf/KintoWalletFactory.conf +++ b/certora/conf/KintoWalletFactory.conf @@ -6,7 +6,7 @@ "verify":"KintoWalletFactory:certora/spec/KintoWalletFactory/Factory.spec", "packages": [ 'node_modules/account-abstraction-0.7.0:@openzeppelin/contracts/=node_modules/openzeppelin-contracts-5.0.1', - '@aa-v7/=node_modules/account-abstraction-0.7.0/contracts/', + '@aa/=node_modules/account-abstraction-0.7.0/contracts/', 'ds-test/=node_modules/forge-std/lib/ds-test/src/', 'forge-std/=node_modules/forge-std/src/', diff --git a/certora/conf/SponsorPaymaster.conf b/certora/conf/SponsorPaymaster.conf index 08b7ecbcb..9942d769e 100644 --- a/certora/conf/SponsorPaymaster.conf +++ b/certora/conf/SponsorPaymaster.conf @@ -16,7 +16,7 @@ ], "packages": [ 'node_modules/account-abstraction-0.7.0:@openzeppelin/contracts/=node_modules/openzeppelin-contracts-5.0.1', - '@aa-v7/=node_modules/account-abstraction-0.7.0/contracts/', + '@aa/=node_modules/account-abstraction-0.7.0/contracts/', 'ds-test/=node_modules/forge-std/lib/ds-test/src/', 'forge-std/=node_modules/forge-std/src/', diff --git a/certora/conf/SponsorPaymaster_additional.conf b/certora/conf/SponsorPaymaster_additional.conf index 5d8c8141f..892174b6c 100644 --- a/certora/conf/SponsorPaymaster_additional.conf +++ b/certora/conf/SponsorPaymaster_additional.conf @@ -16,7 +16,7 @@ ], "packages": [ 'node_modules/account-abstraction-0.7.0:@openzeppelin/contracts/=node_modules/openzeppelin-contracts-5.0.1', - '@aa-v7/=node_modules/account-abstraction-0.7.0/contracts/', + '@aa/=node_modules/account-abstraction-0.7.0/contracts/', 'ds-test/=node_modules/forge-std/lib/ds-test/src/', 'forge-std/=node_modules/forge-std/src/', diff --git a/foundry.toml b/foundry.toml index 26717f80d..7bc5c2ac4 100644 --- a/foundry.toml +++ b/foundry.toml @@ -8,10 +8,13 @@ ignored_warnings_from = ["lib/token-bridge-contracts/contracts/tokenbridge/libra "lib/nitro-contracts/test/foundry/AbsInbox.t.sol", "lib/token-bridge-contracts/contracts/tokenbridge/libraries/gateway/GatewayRouter.sol"] match-path = 'test/unit/**/*.sol' ffi = true -solc_version = "0.8.24" +solc_version = "0.8.23" +optimizer = true +optimizer_runs = 200 +viaIR = false remappings = [ 'node_modules/account-abstraction-0.7.0:@openzeppelin/contracts/=node_modules/openzeppelin-contracts-5.0.1', - '@aa-v7/=node_modules/account-abstraction-0.7.0/contracts/', + '@aa/=node_modules/account-abstraction-0.7.0/contracts/', 'ds-test/=node_modules/forge-std/lib/ds-test/src/', 'forge-std/=node_modules/forge-std/src/', @@ -28,7 +31,6 @@ remappings = [ '@openzeppelin/contracts-upgradeable/=node_modules/openzeppelin-contracts-upgradeable/', 'node_modules/account-abstraction:@openzeppelin/contracts/=node_modules/openzeppelin-contracts', - '@aa/=node_modules/account-abstraction/contracts/', '@solady/=node_modules/solady/src/', 'solady/=node_modules/solady/src/', diff --git a/package.json b/package.json index df387525b..60714b1af 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,6 @@ }, "dependencies": { "@pimlico/alto": "^0.0.4", - "account-abstraction": "https://github.com/KintoXYZ/account-abstraction.git#61f677923ad7ed0ed5b87d2c20100a7079dba63a", "account-abstraction-0.7.0": "https://github.com/eth-infinitism/account-abstraction.git#7af70c8993a6f42973f520ae0752386a5032abe7", "forge-std": "https://github.com/foundry-rs/forge-std.git#bb4ceea94d6f10eeb5b41dc2391c6c8bf8e734ef", "nitro-contracts": "npm:@arbitrum/nitro-contracts@1.2.1", diff --git a/script/actions/counter.s.sol b/script/actions/counter.s.sol new file mode 100644 index 000000000..46c339f93 --- /dev/null +++ b/script/actions/counter.s.sol @@ -0,0 +1,59 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.18; + +import {SimpleAccount} from "@aa/samples/SimpleAccount.sol"; +import {EntryPoint} from "@aa/core/EntryPoint.sol"; +import {PackedUserOperation} from "@aa/interfaces/PackedUserOperation.sol"; + +import {Counter} from "../../src/sample/Counter.sol"; +import {IKintoWallet} from "../../src/interfaces/IKintoWallet.sol"; +import {IKintoWalletFactory} from "../../src/interfaces/IKintoWalletFactory.sol"; +import {SponsorPaymaster} from "../../src/paymasters/SponsorPaymaster.sol"; + +import {MigrationHelper} from "@kinto-core-script/utils/MigrationHelper.sol"; + +import "forge-std/console.sol"; +import "forge-std/Script.sol"; + +/// @notice This script executes a user operation that calls the `increment()` function using your smart account. +contract KintoCounterScript is MigrationHelper { + EntryPoint _entryPoint; + + function setUp() public {} + + function run() public override { + uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); + address deployerPublicKey = vm.addr(deployerPrivateKey); + console.log("Deployer is", vm.addr(deployerPrivateKey)); + + Counter counter = Counter(_getChainDeployment("Counter")); + console.log("Before UserOp. Counter:", counter.count()); + + SimpleAccount account = SimpleAccount(payable(0xd1DA7E60F0f4480031C58986272EA8127E1073A9)); + console2.log('account:', address(account)); + + // send a tx to the counter contract through our wallet + uint256 nonce = account.getNonce(); + uint256[] memory privateKeys = new uint256[](1); + privateKeys[0] = deployerPrivateKey; + + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); + + // increment counter + userOps[0] = _createUserOperation( + block.chainid, + address(account), + address(counter), + 0, + nonce, + privateKeys, + abi.encodeWithSignature("increment()"), + address(0) + ); + + vm.broadcast(deployerPrivateKey); + EntryPoint(payable(_getChainDeployment("EntryPoint"))).handleOps(userOps, payable(vm.addr(privateKeys[0]))); + + console.log("After UserOp. Counter:", counter.count()); + } +} diff --git a/script/actions/deploy.s.sol b/script/actions/deploy.s.sol index 2f3db7745..75cfe8867 100644 --- a/script/actions/deploy.s.sol +++ b/script/actions/deploy.s.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; -import "@aa/core/EntryPoint.sol"; +import {EntryPoint} from "@aa/core/EntryPoint.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; @@ -13,8 +13,9 @@ import "@kinto-core/viewers/KYCViewer.sol"; import "@kinto-core/viewers/WalletViewer.sol"; import "@kinto-core/wallet/KintoWallet.sol"; import "@kinto-core/wallet/KintoWalletFactory.sol"; +import {BridgedKinto} from "@kinto-core/tokens/bridged/BridgedKinto.sol"; +import {SponsorPaymaster} from "@kinto-core/paymasters/SponsorPaymaster.sol"; import {RewardsDistributor} from "@kinto-core/liquidity-mining/RewardsDistributor.sol"; -import "@kinto-core/paymasters/SponsorPaymaster.sol"; import "@kinto-core/wallet/KintoWallet.sol"; import "@kinto-core/apps/KintoAppRegistry.sol"; import "@kinto-core/tokens/EngenCredits.sol"; @@ -23,10 +24,10 @@ import "@kinto-core/Faucet.sol"; import "@kinto-core/inflators/KintoInflator.sol"; import "@kinto-core/inflators/BundleBulker.sol"; import "@kinto-core/governance/EngenGovernance.sol"; + import "@kinto-core-test/helpers/Create2Helper.sol"; import "@kinto-core-test/helpers/ArtifactsReader.sol"; import "@kinto-core-test/helpers/UUPSProxy.sol"; -import {BridgedKinto} from "@kinto-core/tokens/bridged/BridgedKinto.sol"; import {DeployerHelper} from "@kinto-core-script/utils/DeployerHelper.sol"; @@ -302,11 +303,6 @@ contract DeployerScript is Create2Helper, DeployerHelper { privateKey > 0 ? vm.broadcast(privateKey) : vm.broadcast(); _walletFactory.initialize(); - - // set wallet factory in EntryPoint - if (log) console.log("Setting wallet factory in entry point to: ", address(_walletFactory)); - privateKey > 0 ? vm.broadcast(privateKey) : vm.broadcast(); - entryPoint.setWalletFactory(address(_walletFactory)); } function deployKintoWallet() public returns (KintoWallet _kintoWallet) { diff --git a/script/actions/fund-faucet.s.sol b/script/actions/fund-faucet.s.sol new file mode 100644 index 000000000..f4d96f677 --- /dev/null +++ b/script/actions/fund-faucet.s.sol @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.18; + +import "@kinto-core/wallet/KintoWalletFactory.sol"; +import "@kinto-core/wallet/KintoWallet.sol"; +import {SponsorPaymaster} from "@kinto-core/paymasters/SponsorPaymaster.sol"; + +import "@kinto-core-test/helpers/Create2Helper.sol"; +import "@kinto-core-test/helpers/ArtifactsReader.sol"; +import "@kinto-core-test/helpers/UUPSProxy.sol"; + +import "forge-std/Script.sol"; +import "forge-std/console.sol"; + +contract FundFaucetScript is Create2Helper, ArtifactsReader { + function setUp() public {} + + // NOTE: this migration must be run from the ledger admin + function run() public { + console.log("RUNNING ON CHAIN WITH ID", vm.toString(block.chainid)); + // Execute this script with the ledger admin but first we use the hot wallet + console.log("Executing with address", msg.sender, vm.envAddress("LEDGER_ADMIN")); + address factoryAddr = _getChainDeployment("KintoWalletFactory"); + if (factoryAddr == address(0)) { + console.log("Need to execute main deploy script first", factoryAddr); + return; + } + // Start admin + vm.startBroadcast(); + uint256 AMOUNT_TO_SEND = 0.1 ether; + KintoWalletFactory(address(factoryAddr)).sendMoneyToAccount{value: AMOUNT_TO_SEND}( + 0xb539019776eF803E89EC062Ad54cA24D1Fdb008a + ); + vm.stopBroadcast(); + require(address(0xb539019776eF803E89EC062Ad54cA24D1Fdb008a).balance >= AMOUNT_TO_SEND, "amount was not sent"); + // writes the addresses to a file + console.log("Faucet amount sent"); + } +} diff --git a/script/actions/send-user-operation.s.sol b/script/actions/send-user-operation.s.sol index 825e5b6eb..2e3de96bd 100644 --- a/script/actions/send-user-operation.s.sol +++ b/script/actions/send-user-operation.s.sol @@ -1,7 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; -import {IEntryPoint, UserOperation} from "@aa/core/BaseAccount.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; +import {PackedUserOperation} from "@aa/interfaces/PackedUserOperation.sol"; import {MigrationHelper} from "@kinto-core-script/utils/MigrationHelper.sol"; @@ -21,25 +22,21 @@ contract SendUserOperationScript is MigrationHelper { uint256 nonce = json.readUint(".inflatedOp.nonce"); bytes memory callData = json.readBytes(".inflatedOp.callData"); bytes memory initCode = json.readBytes(".inflatedOp.initCode "); - uint256 callGasLimit = json.readUint(".inflatedOp.callGasLimit"); - uint256 verificationGasLimit = json.readUint(".inflatedOp.verificationGasLimit"); + bytes32 accountGasLimits = json.readBytes32(".inflatedOp.accountGasLimits"); + bytes32 gasFees = json.readBytes32(".inflatedOp.gasFees"); uint256 preVerificationGas = json.readUint(".inflatedOp.preVerificationGas"); - uint256 maxFeePerGas = json.readUint(".inflatedOp.maxFeePerGas"); - uint256 maxPriorityFeePerGas = json.readUint(".inflatedOp.maxPriorityFeePerGas"); bytes memory paymasterAndData = json.readBytes(".inflatedOp.paymasterAndData"); bytes memory signature = json.readBytes(".inflatedOp.signature"); - UserOperation[] memory userOps = new UserOperation[](1); - userOps[0] = UserOperation({ + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); + userOps[0] = PackedUserOperation({ sender: sender, nonce: nonce, initCode: initCode, callData: callData, - callGasLimit: callGasLimit, - verificationGasLimit: verificationGasLimit, preVerificationGas: preVerificationGas, - maxFeePerGas: maxFeePerGas, - maxPriorityFeePerGas: maxPriorityFeePerGas, + accountGasLimits: accountGasLimits, + gasFees: gasFees, paymasterAndData: paymasterAndData, signature: signature }); diff --git a/script/actions/test.s.sol b/script/actions/test.s.sol index 893d73cb2..1eb88b53f 100644 --- a/script/actions/test.s.sol +++ b/script/actions/test.s.sol @@ -1,17 +1,17 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; +import {EntryPoint} from "@aa/core/EntryPoint.sol"; +import {PackedUserOperation} from "@aa/interfaces/PackedUserOperation.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; -import "@aa/core/EntryPoint.sol"; - import "@kinto-core/KintoID.sol"; import "@kinto-core/interfaces/IKintoID.sol"; import "@kinto-core/sample/Counter.sol"; import "@kinto-core/sample/ETHPriceIsRight.sol"; import "@kinto-core/interfaces/IKintoWallet.sol"; import "@kinto-core/wallet/KintoWalletFactory.sol"; -import "@kinto-core/paymasters/SponsorPaymaster.sol"; +import {SponsorPaymaster} from "@kinto-core/paymasters/SponsorPaymaster.sol"; import "@kinto-core-script/utils/MigrationHelper.sol"; @@ -137,7 +137,7 @@ contract KintoDeployTestCounter is MigrationHelper { uint256[] memory privateKeys = new uint256[](1); privateKeys[0] = deployerPrivateKey; - UserOperation[] memory userOps = new UserOperation[](2); + PackedUserOperation[] memory userOps = new PackedUserOperation[](2); // whitelist counter contract in the wallet address[] memory targets = new address[](1); @@ -235,7 +235,7 @@ contract KintoDeployETHPriceIsRight is MigrationHelper { uint256 nonce = _newWallet.getNonce(); uint256[] memory privateKeys = new uint256[](1); privateKeys[0] = deployerPrivateKey; - UserOperation[] memory userOps = new UserOperation[](2); + PackedUserOperation[] memory userOps = new PackedUserOperation[](2); // whitelist ETHPriceIsRight contract in the wallet address[] memory targets = new address[](1); @@ -307,7 +307,7 @@ contract SendHanldeOps is MigrationHelper { uint256[] memory privateKeys = new uint256[](1); privateKeys[0] = deployerPrivateKey; - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( block.chainid, diff --git a/script/migrations/12-create_engen_app.s.sol b/script/migrations/12-create_engen_app.s.sol index 4fed93f0c..b64ca557e 100644 --- a/script/migrations/12-create_engen_app.s.sol +++ b/script/migrations/12-create_engen_app.s.sol @@ -9,7 +9,7 @@ import "../../src/wallet/KintoWallet.sol"; import "../../src/wallet/KintoWalletFactory.sol"; import "../../src/tokens/EngenCredits.sol"; import "../../src/apps/KintoAppRegistry.sol"; -import "../../src/paymasters/SponsorPaymaster.sol"; +import {SponsorPaymaster} from "@kinto-core/paymasters/SponsorPaymaster.sol"; import "../../test/helpers/ArtifactsReader.sol"; import "../../test/helpers/UUPSProxy.sol"; @@ -64,7 +64,7 @@ contract KintoMigration12DeployScript is ArtifactsReader, UserOp { privateKeys[0] = deployerPrivateKey; uint256 nonce = _kintoWallet.getNonce(); - UserOperation[] memory userOps = new UserOperation[](3); + PackedUserOperation[] memory userOps = new PackedUserOperation[](3); // whitelist Engen Credits & Registry address[] memory apps = new address[](2); diff --git a/script/migrations/121-upgrade_access_protocol.s.sol b/script/migrations/121-upgrade_access_protocol.s.sol index 29822d8a0..b4eb7eec5 100644 --- a/script/migrations/121-upgrade_access_protocol.s.sol +++ b/script/migrations/121-upgrade_access_protocol.s.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; -import {IEntryPoint} from "@aa-v7/interfaces/IEntryPoint.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; import {IBridger} from "@kinto-core/interfaces/bridger/IBridger.sol"; import {UpgradeableBeacon} from "@openzeppelin-5.0.1/contracts/proxy/beacon/UpgradeableBeacon.sol"; diff --git a/script/migrations/126-deploy-cross-chain-swap.s.sol b/script/migrations/126-deploy-cross-chain-swap.s.sol index 3898ff310..258879a35 100644 --- a/script/migrations/126-deploy-cross-chain-swap.s.sol +++ b/script/migrations/126-deploy-cross-chain-swap.s.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; -import {IEntryPoint} from "@aa-v7/interfaces/IEntryPoint.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; import {IBridger} from "@kinto-core/interfaces/bridger/IBridger.sol"; import {UpgradeableBeacon} from "@openzeppelin-5.0.1/contracts/proxy/beacon/UpgradeableBeacon.sol"; diff --git a/script/migrations/137-upgrade_wallet_factory.s.sol b/script/migrations/137-upgrade_wallet_factory.s.sol index bf5657685..c1ceb63b1 100644 --- a/script/migrations/137-upgrade_wallet_factory.s.sol +++ b/script/migrations/137-upgrade_wallet_factory.s.sol @@ -3,6 +3,7 @@ pragma solidity ^0.8.18; import "../../src/wallet/KintoWallet.sol"; import {KintoWalletFactory} from "../../src/wallet/KintoWalletFactory.sol"; +import {RewardsDistributor} from "@kinto-core/liquidity-mining/RewardsDistributor.sol"; import {MigrationHelper} from "@kinto-core-script/utils/MigrationHelper.sol"; diff --git a/script/migrations/145-upgrade_access_protocol.s.sol b/script/migrations/145-upgrade_access_protocol.s.sol index c9b914ae7..f23306f85 100644 --- a/script/migrations/145-upgrade_access_protocol.s.sol +++ b/script/migrations/145-upgrade_access_protocol.s.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; -import {IEntryPoint} from "@aa-v7/interfaces/IEntryPoint.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; import {IBridger} from "@kinto-core/interfaces/bridger/IBridger.sol"; import {UpgradeableBeacon} from "@openzeppelin-5.0.1/contracts/proxy/beacon/UpgradeableBeacon.sol"; diff --git a/script/migrations/148-transfer-access-registry-ownership.s.sol b/script/migrations/148-transfer-access-registry-ownership.s.sol index c3d67f50b..11d007873 100644 --- a/script/migrations/148-transfer-access-registry-ownership.s.sol +++ b/script/migrations/148-transfer-access-registry-ownership.s.sol @@ -8,7 +8,7 @@ import {AccessManager} from "@openzeppelin-5.0.1/contracts/access/manager/Access import {Ownable} from "@openzeppelin-5.0.1/contracts/access/Ownable.sol"; import {UUPSUpgradeable} from "@openzeppelin-5.0.1/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import {IAccessPoint} from "@kinto-core/interfaces/IAccessPoint.sol"; -import {IEntryPoint} from "@aa-v7/interfaces/IEntryPoint.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; import {MigrationHelper} from "@kinto-core-script/utils/MigrationHelper.sol"; diff --git a/script/migrations/26-deploy_paymaster_v7.s.sol b/script/migrations/26-deploy_paymaster_v7.s.sol index 16759457e..3456a73f9 100644 --- a/script/migrations/26-deploy_paymaster_v7.s.sol +++ b/script/migrations/26-deploy_paymaster_v7.s.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; -import "../../src/paymasters/SponsorPaymaster.sol"; +import {SponsorPaymaster} from "@kinto-core/paymasters/SponsorPaymaster.sol"; import {MigrationHelper} from "@kinto-core-script/utils/MigrationHelper.sol"; contract KintoMigration26DeployScript is MigrationHelper { diff --git a/script/migrations/27-deploy_registry-v4.s.sol b/script/migrations/27-deploy_registry-v4.s.sol index 2db5f7c60..554083a00 100644 --- a/script/migrations/27-deploy_registry-v4.s.sol +++ b/script/migrations/27-deploy_registry-v4.s.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; -import "../../src/paymasters/SponsorPaymaster.sol"; +import {IKintoAppRegistry} from "@kinto-core/interfaces/IKintoAppRegistry.sol"; import {MigrationHelper} from "@kinto-core-script/utils/MigrationHelper.sol"; import {KintoAppRegistry} from "@kinto-core/apps/KintoAppRegistry.sol"; diff --git a/script/migrations/29-multiple_upgrade_3.s.sol b/script/migrations/29-multiple_upgrade_3.s.sol index b458312b7..0670fa988 100644 --- a/script/migrations/29-multiple_upgrade_3.s.sol +++ b/script/migrations/29-multiple_upgrade_3.s.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.18; import "../../src/apps/KintoAppRegistry.sol"; -import "../../src/paymasters/SponsorPaymaster.sol"; +import {SponsorPaymaster} from "@kinto-core/paymasters/SponsorPaymaster.sol"; import "../../src/tokens/EngenCredits.sol"; import "../../src/viewers/KYCViewer.sol"; import "../../src/wallet/KintoWallet.sol"; diff --git a/script/migrations/30-deploy_paymaster_v9.s.sol b/script/migrations/30-deploy_paymaster_v9.s.sol index d6a469d40..73bf083f5 100644 --- a/script/migrations/30-deploy_paymaster_v9.s.sol +++ b/script/migrations/30-deploy_paymaster_v9.s.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; -import "../../src/paymasters/SponsorPaymaster.sol"; +import {SponsorPaymaster} from "@kinto-core/paymasters/SponsorPaymaster.sol"; import {MigrationHelper} from "@kinto-core-script/utils/MigrationHelper.sol"; contract KintoMigration30DeployScript is MigrationHelper { diff --git a/script/migrations/62-upgrade-wallet-claim.s.sol b/script/migrations/62-upgrade-wallet-claim.s.sol index 8c98a3cfa..7dc4edba6 100644 --- a/script/migrations/62-upgrade-wallet-claim.s.sol +++ b/script/migrations/62-upgrade-wallet-claim.s.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.18; import "../../src/apps/KintoAppRegistry.sol"; -import "../../src/paymasters/SponsorPaymaster.sol"; +import {SponsorPaymaster} from "@kinto-core/paymasters/SponsorPaymaster.sol"; import "../../src/tokens/EngenCredits.sol"; import "../../src/viewers/KYCViewer.sol"; import "../../src/wallet/KintoWallet.sol"; diff --git a/script/migrations/69-upgrde_paymaster.s.sol b/script/migrations/69-upgrde_paymaster.s.sol index 252d68dcf..f9e9dafb7 100644 --- a/script/migrations/69-upgrde_paymaster.s.sol +++ b/script/migrations/69-upgrde_paymaster.s.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; -import "../../src/paymasters/SponsorPaymaster.sol"; +import {SponsorPaymaster} from "@kinto-core/paymasters/SponsorPaymaster.sol"; import {MigrationHelper} from "@kinto-core-script/utils/MigrationHelper.sol"; contract KintoMigration69DeployScript is MigrationHelper { diff --git a/script/samples/counter.s.sol b/script/samples/counter.s.sol index ce0272556..c4c8ee3b6 100644 --- a/script/samples/counter.s.sol +++ b/script/samples/counter.s.sol @@ -1,12 +1,12 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; -import "@aa/core/EntryPoint.sol"; +import {EntryPoint} from "@aa/core/EntryPoint.sol"; import "../../src/sample/Counter.sol"; import "../../src/interfaces/IKintoWallet.sol"; import "../../src/interfaces/IKintoWalletFactory.sol"; -import "../../src/paymasters/SponsorPaymaster.sol"; +import {SponsorPaymaster} from "../../src/paymasters/SponsorPaymaster.sol"; import "@kinto-core-script/utils/MigrationHelper.sol"; @@ -72,7 +72,7 @@ contract KintoCounterScript is MigrationHelper { uint256[] memory privateKeys = new uint256[](1); privateKeys[0] = deployerPrivateKey; - UserOperation[] memory userOps = new UserOperation[](2); + PackedUserOperation[] memory userOps = new PackedUserOperation[](2); // whitelist counter contract in the wallet address[] memory targets = new address[](1); diff --git a/script/samples/createWallet.s.sol b/script/samples/createWallet.s.sol index ca02af25c..4dbec582d 100644 --- a/script/samples/createWallet.s.sol +++ b/script/samples/createWallet.s.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; -import "@aa/core/EntryPoint.sol"; +import {EntryPoint} from "@aa/core/EntryPoint.sol"; import "../../src/KintoID.sol"; import "@kinto-core-script/utils/MigrationHelper.sol"; diff --git a/script/samples/guesser.s.sol b/script/samples/guesser.s.sol index 6981cf8f0..1f52c7c26 100644 --- a/script/samples/guesser.s.sol +++ b/script/samples/guesser.s.sol @@ -1,11 +1,14 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; -import "@aa/core/EntryPoint.sol"; +import {EntryPoint} from "@aa/core/EntryPoint.sol"; import "../../src/sample/ETHPriceIsRight.sol"; import "../../src/interfaces/IKintoWallet.sol"; -import "../../src/paymasters/SponsorPaymaster.sol"; +import {SponsorPaymaster} from "@kinto-core/paymasters/SponsorPaymaster.sol"; + +import "../../test/helpers/AASetup.sol"; +import "../../test/helpers/UserOp.sol"; import "@kinto-core-script/utils/MigrationHelper.sol"; import "forge-std/console.sol"; @@ -71,7 +74,7 @@ contract KintoGuesserScript is MigrationHelper { uint256 nonce = _newWallet.getNonce(); uint256[] memory privateKeys = new uint256[](1); privateKeys[0] = deployerPrivateKey; - UserOperation[] memory userOps = new UserOperation[](2); + PackedUserOperation[] memory userOps = new PackedUserOperation[](2); // whitelist ETHPriceIsRight contract in the wallet address[] memory targets = new address[](1); diff --git a/script/samples/monitor.s.sol b/script/samples/monitor.s.sol index c41f8c1cd..174bda066 100644 --- a/script/samples/monitor.s.sol +++ b/script/samples/monitor.s.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; -import "@aa/core/EntryPoint.sol"; +import {EntryPoint} from "@aa/core/EntryPoint.sol"; import "../../src/KintoID.sol"; import "@kinto-core-script/utils/MigrationHelper.sol"; diff --git a/script/utils/MigrationHelper.sol b/script/utils/MigrationHelper.sol index 341a677fe..cdff00eb5 100644 --- a/script/utils/MigrationHelper.sol +++ b/script/utils/MigrationHelper.sol @@ -8,10 +8,18 @@ import "@openzeppelin/contracts/access/Ownable.sol"; import {ECDSAUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol"; import {EntryPoint} from "@aa/core/EntryPoint.sol"; import {KintoID} from "@kinto-core/KintoID.sol"; +import {KintoWalletFactory} from "@kinto-core/wallet/KintoWalletFactory.sol"; +import {SponsorPaymaster} from "@kinto-core/paymasters/SponsorPaymaster.sol"; +import {KintoAppRegistry} from "@kinto-core/apps/KintoAppRegistry.sol"; -import "@kinto-core/wallet/KintoWalletFactory.sol"; -import "@kinto-core/paymasters/SponsorPaymaster.sol"; -import "@kinto-core/apps/KintoAppRegistry.sol"; +import {PackedUserOperation} from "@aa/interfaces/PackedUserOperation.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; + +import {ISponsorPaymaster} from "@kinto-core/interfaces/ISponsorPaymaster.sol"; +import {IKintoWallet} from "@kinto-core/interfaces/IKintoWallet.sol"; +import {IKintoID} from "@kinto-core/interfaces/IKintoID.sol"; +import {IKintoAppRegistry} from "@kinto-core/interfaces/IKintoAppRegistry.sol"; +import {KintoWallet} from "@kinto-core/wallet/KintoWallet.sol"; import "@kinto-core/interfaces/ISponsorPaymaster.sol"; import "@kinto-core/interfaces/IKintoWallet.sol"; @@ -287,7 +295,7 @@ contract MigrationHelper is Script, DeployerHelper, SignatureHelper, UserOp, Sal address sponsorPaymaster, uint256[] memory privateKeys ) internal { - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( block.chainid, from, @@ -341,7 +349,7 @@ contract MigrationHelper is Script, DeployerHelper, SignatureHelper, UserOp, Sal uint256[] memory privateKeys = new uint256[](1); privateKeys[0] = signerPk; - UserOperation[] memory userOps = new UserOperation[](selectorAndParams.length); + PackedUserOperation[] memory userOps = new PackedUserOperation[](selectorAndParams.length); uint256 nonce = IKintoWallet(from).getNonce(); for (uint256 i = 0; i < selectorAndParams.length; i++) { userOps[i] = _createUserOperation( @@ -362,7 +370,7 @@ contract MigrationHelper is Script, DeployerHelper, SignatureHelper, UserOp, Sal require(selectorAndParams.length == tos.length, "selectorAndParams and tos mismatch"); address payable from = payable(kintoAdminWallet); - UserOperation[] memory userOps = new UserOperation[](selectorAndParams.length); + PackedUserOperation[] memory userOps = new PackedUserOperation[](selectorAndParams.length); uint256 nonce = IKintoWallet(from).getNonce(); for (uint256 i = 0; i < selectorAndParams.length; i++) { userOps[i] = _createUserOperation( diff --git a/src/access/AccessPoint.sol b/src/access/AccessPoint.sol index 073b6326c..e9e40c7e6 100644 --- a/src/access/AccessPoint.sol +++ b/src/access/AccessPoint.sol @@ -7,12 +7,13 @@ import "@openzeppelin-5.0.1/contracts/utils/cryptography/MessageHashUtils.sol"; import "@openzeppelin-5.0.1/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin-5.0.1/contracts/interfaces/IERC20.sol"; -import {BaseAccount} from "@aa-v7/core/BaseAccount.sol"; -import {UserOperationLib} from "@aa-v7/core/UserOperationLib.sol"; -import {SIG_VALIDATION_FAILED, SIG_VALIDATION_SUCCESS} from "@aa-v7/core/Helpers.sol"; -import {PackedUserOperation} from "@aa-v7/interfaces/PackedUserOperation.sol"; -import {IEntryPoint} from "@aa-v7/interfaces/IEntryPoint.sol"; -import {TokenCallbackHandler} from "@aa-v7/samples/callback/TokenCallbackHandler.sol"; +import {BaseAccount} from "@aa/core/BaseAccount.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; +import {UserOperationLib} from "@aa/core/UserOperationLib.sol"; +import {SIG_VALIDATION_FAILED, SIG_VALIDATION_SUCCESS} from "@aa/core/Helpers.sol"; +import {PackedUserOperation} from "@aa/interfaces/PackedUserOperation.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; +import {TokenCallbackHandler} from "@aa/samples/callback/TokenCallbackHandler.sol"; import {IAccessPoint} from "@kinto-core/interfaces/IAccessPoint.sol"; import {IAccessRegistry} from "@kinto-core/interfaces/IAccessRegistry.sol"; diff --git a/src/access/AccessRegistry.sol b/src/access/AccessRegistry.sol index f982cff21..57cd9bc0c 100644 --- a/src/access/AccessRegistry.sol +++ b/src/access/AccessRegistry.sol @@ -10,8 +10,8 @@ import "@openzeppelin-5.0.1/contracts/interfaces/IERC20.sol"; import "@openzeppelin-5.0.1/contracts/utils/Create2.sol"; import "@openzeppelin-5.0.1/contracts/proxy/beacon/UpgradeableBeacon.sol"; -import {BaseAccount} from "@aa-v7/core/BaseAccount.sol"; -import {TokenCallbackHandler} from "@aa-v7/samples/callback/TokenCallbackHandler.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; +import {TokenCallbackHandler} from "@aa/samples/callback/TokenCallbackHandler.sol"; import {ByteSignature} from "@kinto-core/libraries/ByteSignature.sol"; import {AccessPoint} from "@kinto-core/access/AccessPoint.sol"; diff --git a/src/inflators/BundleBulker.sol b/src/inflators/BundleBulker.sol index ded81525d..bdd7ec1a1 100644 --- a/src/inflators/BundleBulker.sol +++ b/src/inflators/BundleBulker.sol @@ -2,6 +2,8 @@ pragma solidity >=0.8; import "../interfaces/IInflator.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; +import {PackedUserOperation} from "@aa/interfaces/PackedUserOperation.sol"; /** * note: forked from https://github.com/daimo-eth/bulk/blob/master/src/BundleBulker.sol @@ -43,7 +45,7 @@ contract BundleBulker { function inflate(bytes calldata compressed) public view - returns (UserOperation[] memory ops, address payable beneficiary) + returns (PackedUserOperation[] memory ops, address payable beneficiary) { uint32 inflatorID = uint32(bytes4(compressed[0:4])); IInflator inflator = idToInflator[inflatorID]; @@ -52,7 +54,7 @@ contract BundleBulker { } fallback() external { - (UserOperation[] memory ops, address payable beneficiary) = inflate(msg.data); + (PackedUserOperation[] memory ops, address payable beneficiary) = inflate(msg.data); IEntryPoint(entryPoint).handleOps(ops, beneficiary); } } diff --git a/src/inflators/KintoInflator.sol b/src/inflators/KintoInflator.sol index 05a1e4307..eefa1b728 100644 --- a/src/inflators/KintoInflator.sol +++ b/src/inflators/KintoInflator.sol @@ -4,11 +4,15 @@ pragma solidity ^0.8.18; import "../interfaces/IOpInflator.sol"; import "../interfaces/IKintoWallet.sol"; +import {PackedUserOperation} from "@aa/interfaces/PackedUserOperation.sol"; + import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "@solady/utils/LibZip.sol"; +import "forge-std/console2.sol"; + /// @notice Inflator contract for Kinto user operations /// @dev This contract is responsible for inflating and compressing (off-chain) user operations /// For further compression, consider: (1) using assembly for encoding/decoding, @@ -28,7 +32,7 @@ import "@solady/utils/LibZip.sol"; /// 0x04 .. 0x80: number of operations in the batch /// The rest of the flags are not used. -/// All other UserOperation fields are encoded as is. +/// All other PackedUserOperation fields are encoded as is. contract KintoInflator is IOpInflator, OwnableUpgradeable, UUPSUpgradeable { /// @notice Mapping of Kinto contract names to addresses mapping(string => address) public kintoContracts; @@ -64,18 +68,19 @@ contract KintoInflator is IOpInflator, OwnableUpgradeable, UUPSUpgradeable { /* ============ Inflate & Compress ============ */ /** - * @notice Inflates a compressed UserOperation - * @param compressed The compressed UserOperation as bytes - * @return op The inflated UserOperation + * @notice Inflates a compressed PackedUserOperation + * @param compressed The compressed PackedUserOperation as bytes + * @return op The inflated PackedUserOperation */ - function inflate(bytes calldata compressed) external view returns (UserOperation memory op) { + function inflate(bytes calldata compressed) external view returns (PackedUserOperation memory op) { // decompress the data return this._inflate(LibZip.flzDecompress(compressed)); } - function _inflate(bytes calldata decompressed) public view returns (UserOperation memory op) { + function _inflate(bytes calldata decompressed) public view returns (PackedUserOperation memory op) { uint256 cursor = 0; // keep track of the current position in the decompressed data + console2.logBytes(decompressed); // extract flags uint8 flags = uint8(decompressed[cursor]); cursor += 1; @@ -106,53 +111,49 @@ contract KintoInflator is IOpInflator, OwnableUpgradeable, UUPSUpgradeable { op.callData = callData; // extract gas parameters and other values using direct conversions - op.callGasLimit = uint256(bytes32(decompressed[cursor:cursor + 32])); + op.accountGasLimits = bytes32(decompressed[cursor:cursor + 32]); cursor += 32; - op.verificationGasLimit = uint256(bytes32(decompressed[cursor:cursor + 32])); + op.gasFees = bytes32(decompressed[cursor:cursor + 32]); cursor += 32; op.preVerificationGas = uint32(bytes4(decompressed[cursor:cursor + 4])); cursor += 4; - op.maxFeePerGas = uint48(bytes6(decompressed[cursor:cursor + 6])); - cursor += 6; - - op.maxPriorityFeePerGas = uint48(bytes6(decompressed[cursor:cursor + 6])); - cursor += 6; - // Extract paymasterAndData if the flag is set if (flags & 0x02 == 0x02) { - op.paymasterAndData = abi.encodePacked(kintoContracts["SP"]); + op.paymasterAndData = abi.encodePacked(kintoContracts["SP"], decompressed[cursor:cursor + 32]); + cursor += 32; } // Decode signature length and content uint32 signatureLength = uint32(bytes4(decompressed[cursor:cursor + 4])); + console2.log("signatureLength:", signatureLength); cursor += 4; require(cursor + signatureLength <= decompressed.length, "Invalid signature length"); op.signature = decompressed[cursor:cursor + signatureLength]; + console2.logBytes(op.signature); return op; } /** - * @notice Compresses a UserOperation for efficient storage and transmission - * @param op The UserOperation to compress - * @return compressed The compressed UserOperation as bytes + * @notice Compresses a PackedUserOperation for efficient storage and transmission + * @param op The PackedUserOperation to compress + * @return compressed The compressed PackedUserOperation as bytes */ - function compress(UserOperation memory op) external view returns (bytes memory compressed) { - // Initialize a dynamically sized buffer - bytes memory buffer = new bytes(0); - + function compress(PackedUserOperation calldata op) external view returns (bytes memory compressed) { // decode `callData` (selector, target, value, bytesOp) bytes4 selector = bytes4(_slice(op.callData, 0, 4)); bytes memory callData = _slice(op.callData, 4, op.callData.length - 4); // set flags based on conditions - buffer = abi.encodePacked(buffer, bytes1(_flags(selector, op, callData))); + uint8 flags = _flags(selector, op, callData); + bytes memory buffer = abi.encodePacked(flags); // encode `sender`, `nonce` and `initCode` buffer = abi.encodePacked(buffer, op.sender, uint32(op.nonce), uint32(op.initCode.length), op.initCode); + console2.logBytes(buffer); // encode `callData` depending on the selector if (selector == IKintoWallet.execute.selector) { @@ -167,38 +168,41 @@ contract KintoInflator is IOpInflator, OwnableUpgradeable, UUPSUpgradeable { } // encode gas params - buffer = abi.encodePacked( - buffer, - op.callGasLimit, - op.verificationGasLimit, - uint32(op.preVerificationGas), - uint48(op.maxFeePerGas), - uint48(op.maxPriorityFeePerGas) - ); + buffer = abi.encodePacked(buffer, op.accountGasLimits, op.gasFees, uint32(op.preVerificationGas)); + console2.logBytes(buffer); + // if there is a paymaster, then encode it's gas settings + if (flags & 0x02 == 0x02) { + buffer = abi.encodePacked(buffer, op.paymasterAndData[20:52]); + } + + console2.log("op.signature.length:", op.signature.length); + console2.logBytes(op.signature); // encode `signature` content buffer = abi.encodePacked(buffer, uint32(op.signature.length), op.signature); + console2.logBytes(buffer); + return LibZip.flzCompress(buffer); } /* ============ Simple compress/inflate ============ */ /** - * @notice Inflates a UserOperation compressed with the simple algorithm - * @param compressed The compressed UserOperation as bytes - * @return op The inflated UserOperation + * @notice Inflates a PackedUserOperation compressed with the simple algorithm + * @param compressed The compressed PackedUserOperation as bytes + * @return op The inflated PackedUserOperation */ - function inflateSimple(bytes calldata compressed) external pure returns (UserOperation memory op) { - op = abi.decode(LibZip.flzDecompress(compressed), (UserOperation)); + function inflateSimple(bytes calldata compressed) external pure returns (PackedUserOperation memory op) { + op = abi.decode(LibZip.flzDecompress(compressed), (PackedUserOperation)); } /** - * @notice Compresses a UserOperation using a simple compression algorithm - * @param op The UserOperation to compress - * @return compressed The compressed UserOperation as bytes + * @notice Compresses a PackedUserOperation using a simple compression algorithm + * @param op The PackedUserOperation to compress + * @return compressed The compressed PackedUserOperation as bytes */ - function compressSimple(UserOperation memory op) external pure returns (bytes memory compressed) { + function compressSimple(PackedUserOperation memory op) external pure returns (bytes memory compressed) { compressed = LibZip.flzCompress(abi.encode(op)); } @@ -302,13 +306,13 @@ contract KintoInflator is IOpInflator, OwnableUpgradeable, UUPSUpgradeable { /* ============ Compress Helpers ============ */ /** - * @notice Determines the flags for a UserOperation + * @notice Determines the flags for a PackedUserOperation * @param selector The function selector - * @param op The UserOperation + * @param op The PackedUserOperation * @param callData The calldata * @return flags The determined flags */ - function _flags(bytes4 selector, UserOperation memory op, bytes memory callData) + function _flags(bytes4 selector, PackedUserOperation memory op, bytes memory callData) internal view returns (uint8 flags) @@ -332,7 +336,7 @@ contract KintoInflator is IOpInflator, OwnableUpgradeable, UUPSUpgradeable { /** * @notice Encodes the calldata for an execute operation - * @param op The UserOperation + * @param op The PackedUserOperation * @param target The target address * @param value The value to send * @param bytesOp The operation bytes @@ -340,7 +344,7 @@ contract KintoInflator is IOpInflator, OwnableUpgradeable, UUPSUpgradeable { * @return The updated buffer */ function _encodeExecuteCalldata( - UserOperation memory op, + PackedUserOperation memory op, address target, uint256 value, bytes memory bytesOp, diff --git a/src/interfaces/IInflator.sol b/src/interfaces/IInflator.sol index ee8662fbd..b52d00c84 100644 --- a/src/interfaces/IInflator.sol +++ b/src/interfaces/IInflator.sol @@ -1,11 +1,12 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.8; -import "./IKintoEntryPoint.sol"; +import {EntryPoint} from "@aa/core/EntryPoint.sol"; +import {PackedUserOperation} from "@aa/interfaces/PackedUserOperation.sol"; interface IInflator { function inflate(bytes calldata compressed) external view - returns (UserOperation[] memory ops, address payable beneficiary); + returns (PackedUserOperation[] memory ops, address payable beneficiary); } diff --git a/src/interfaces/IKintoEntryPoint.sol b/src/interfaces/IKintoEntryPoint.sol deleted file mode 100644 index 17227450e..000000000 --- a/src/interfaces/IKintoEntryPoint.sol +++ /dev/null @@ -1,11 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.18; - -import "@aa/interfaces/IEntryPoint.sol"; - -interface IKintoEntryPoint is IEntryPoint { - function walletFactory() external view returns (address); - - // Admin - function setWalletFactory(address _walletFactory) external; -} diff --git a/src/interfaces/IKintoWallet.sol b/src/interfaces/IKintoWallet.sol index b2c5ad183..f7b99f9ba 100644 --- a/src/interfaces/IKintoWallet.sol +++ b/src/interfaces/IKintoWallet.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; -import {IEntryPoint} from "@aa/core/BaseAccount.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; import {IKintoWalletFactory} from "./IKintoWalletFactory.sol"; import {IKintoID} from "./IKintoID.sol"; import {IKintoAppRegistry} from "./IKintoAppRegistry.sol"; diff --git a/src/interfaces/IOpInflator.sol b/src/interfaces/IOpInflator.sol index 2b87e5779..b83572b10 100644 --- a/src/interfaces/IOpInflator.sol +++ b/src/interfaces/IOpInflator.sol @@ -2,7 +2,8 @@ pragma solidity >=0.8; import "@aa/interfaces/IEntryPoint.sol"; +import {PackedUserOperation} from "@aa/interfaces/PackedUserOperation.sol"; interface IOpInflator { - function inflate(bytes calldata compressed) external view returns (UserOperation memory op); + function inflate(bytes calldata compressed) external view returns (PackedUserOperation memory op); } diff --git a/src/paymasters/SponsorPaymaster.sol b/src/paymasters/SponsorPaymaster.sol index 7e70def37..492e7b932 100644 --- a/src/paymasters/SponsorPaymaster.sol +++ b/src/paymasters/SponsorPaymaster.sol @@ -1,15 +1,18 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; -import "@openzeppelin/contracts/access/Ownable.sol"; -import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; -import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; -import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; -import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; - -import "@aa/interfaces/IPaymaster.sol"; -import {IEntryPoint} from "@aa/core/BaseAccount.sol"; +import {PackedUserOperation} from "@aa/interfaces/PackedUserOperation.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; +import {IPaymaster} from "@aa/interfaces/IPaymaster.sol"; +import {UserOperationLib} from "@aa/core/UserOperationLib.sol"; + +import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; +import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; +import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol"; +import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; +import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; +import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {ISponsorPaymaster} from "@kinto-core/interfaces/ISponsorPaymaster.sol"; import {IKintoAppRegistry} from "@kinto-core/interfaces/IKintoAppRegistry.sol"; @@ -25,12 +28,26 @@ import {IKintoWalletFactory} from "@kinto-core/interfaces/IKintoWalletFactory.so abstract contract BasePaymaster is IPaymaster, Ownable { IEntryPoint public immutable entryPoint; - constructor(IEntryPoint _entryPoint) { + uint256 internal constant PAYMASTER_VALIDATION_GAS_OFFSET = UserOperationLib.PAYMASTER_VALIDATION_GAS_OFFSET; + uint256 internal constant PAYMASTER_POSTOP_GAS_OFFSET = UserOperationLib.PAYMASTER_POSTOP_GAS_OFFSET; + uint256 internal constant PAYMASTER_DATA_OFFSET = UserOperationLib.PAYMASTER_DATA_OFFSET; + + constructor(IEntryPoint _entryPoint) Ownable() { + _validateEntryPointInterface(_entryPoint); entryPoint = _entryPoint; } + //sanity check: make sure this EntryPoint was compiled against the same + // IEntryPoint of this paymaster + function _validateEntryPointInterface(IEntryPoint _entryPoint) internal virtual { + require( + IERC165(address(_entryPoint)).supportsInterface(type(IEntryPoint).interfaceId), + "IEntryPoint interface mismatch" + ); + } + /// @inheritdoc IPaymaster - function validatePaymasterUserOp(UserOperation calldata userOp, bytes32 userOpHash, uint256 maxCost) + function validatePaymasterUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash, uint256 maxCost) external override returns (bytes memory context, uint256 validationData) @@ -45,15 +62,18 @@ abstract contract BasePaymaster is IPaymaster, Ownable { * @param userOpHash - The hash of the user operation. * @param maxCost - The maximum cost of the user operation. */ - function _validatePaymasterUserOp(UserOperation calldata userOp, bytes32 userOpHash, uint256 maxCost) + function _validatePaymasterUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash, uint256 maxCost) internal virtual returns (bytes memory context, uint256 validationData); /// @inheritdoc IPaymaster - function postOp(PostOpMode mode, bytes calldata context, uint256 actualGasCost) external override { + function postOp(PostOpMode mode, bytes calldata context, uint256 actualGasCost, uint256 actualUserOpFeePerGas) + external + override + { _requireFromEntryPoint(); - _postOp(mode, context, actualGasCost); + _postOp(mode, context, actualGasCost, actualUserOpFeePerGas); } /** @@ -63,14 +83,19 @@ abstract contract BasePaymaster is IPaymaster, Ownable { * it must also implement this method. * @param mode - Enum with the following options: * opSucceeded - User operation succeeded. - * opReverted - User op reverted. still has to pay for gas. - * postOpReverted - User op succeeded, but caused postOp (in mode=opSucceeded) to revert. - * Now this is the 2nd call, after user's op was deliberately reverted. + * opReverted - User op reverted. The paymaster still has to pay for gas. + * postOpReverted - never passed in a call to postOp(). * @param context - The context value returned by validatePaymasterUserOp * @param actualGasCost - Actual gas used so far (without this postOp call). + * @param actualUserOpFeePerGas - the gas price this UserOp pays. This value is based on the UserOp's maxFeePerGas + * and maxPriorityFee (and basefee) + * It is not the same as tx.gasprice, which is what the bundler pays. */ - function _postOp(PostOpMode mode, bytes calldata context, uint256 actualGasCost) internal virtual { - (mode, context, actualGasCost); // unused params + function _postOp(PostOpMode mode, bytes calldata context, uint256 actualGasCost, uint256 actualUserOpFeePerGas) + internal + virtual + { + (mode, context, actualGasCost, actualUserOpFeePerGas); // unused params // subclass must override this method if validatePaymasterUserOp returns a context revert("must override"); } @@ -131,6 +156,7 @@ abstract contract BasePaymaster is IPaymaster, Ownable { */ contract SponsorPaymaster is Initializable, BasePaymaster, UUPSUpgradeable, ReentrancyGuard, ISponsorPaymaster { using SafeERC20 for IERC20; + using UserOperationLib for PackedUserOperation; /* ============ Constants & Immutables ============ */ @@ -324,24 +350,26 @@ contract SponsorPaymaster is Initializable, BasePaymaster, UUPSUpgradeable, Reen * @dev sender should have enough txs and gas left to be gasless. * @dev contract developer funds the contract for its users and rate limits the app. */ - function _validatePaymasterUserOp(UserOperation calldata userOp, bytes32 userOpHash, uint256 maxCost) + function _validatePaymasterUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash, uint256 maxCost) internal view override returns (bytes memory context, uint256 validationData) { (userOpHash); + if (userOp.preVerificationGas > MAX_COST_OF_PREVERIFICATION) revert GasTooHighForVerification(); + if (userOp.paymasterAndData.length != 52) revert PaymasterAndDataLengthInvalid(); + uint256 postOpGasLimit = userOp.unpackPostOpGasLimit(); + uint256 verificationGasLimit = userOp.unpackVerificationGasLimit(); + uint256 maxFeePerGas = userOp.unpackMaxFeePerGas(); // verificationGasLimit is dual-purposed, as gas limit for postOp. make sure it is high enough - if (userOp.verificationGasLimit < COST_OF_POST || userOp.verificationGasLimit > MAX_COST_OF_VERIFICATION) { + if (postOpGasLimit < COST_OF_POST || verificationGasLimit > MAX_COST_OF_VERIFICATION) { revert GasOutsideRangeForPostOp(); } - if (userOp.preVerificationGas > MAX_COST_OF_PREVERIFICATION) revert GasTooHighForVerification(); - if (userOp.paymasterAndData.length != 20) revert PaymasterAndDataLengthInvalid(); // use maxFeePerGas for conservative estimation of gas cost - uint256 gasPriceUserOp = userOp.maxFeePerGas; - uint256 ethMaxCost = (maxCost + COST_OF_POST * gasPriceUserOp); + uint256 ethMaxCost = (maxCost + COST_OF_POST * maxFeePerGas); if (ethMaxCost > userOpMaxCost) revert GasTooHighForUserOp(); address sponsor = appRegistry.getApp(_decodeCallData(userOp.callData)); @@ -354,13 +382,18 @@ contract SponsorPaymaster is Initializable, BasePaymaster, UUPSUpgradeable, Reen // Wallets get auto funded by kinto core app sponsor = appRegistry.getApp(address(walletFactory)); } - return (abi.encode(sponsor, userOp.sender, userOp.maxFeePerGas, userOp.maxPriorityFeePerGas), 0); + return (abi.encode(sponsor, userOp.sender, maxFeePerGas, userOp.unpackMaxPriorityFeePerGas()), 0); } /** * @notice performs the post-operation to charge the sponsor contract for the gas. */ - function _postOp(PostOpMode, /* mode */ bytes calldata context, uint256 actualGasCost) internal override { + function _postOp( + PostOpMode, /* mode */ + bytes calldata context, + uint256 actualGasCost, + uint256 actualUserOpFeePerGas + ) internal override { (address sponsor, address kintoWallet, uint256 maxFeePerGas, uint256 maxPriorityFeePerGas) = abi.decode(context, (address, address, uint256, uint256)); address user = IKintoWallet(kintoWallet).owners(0); // use owner because a person can have many wallets diff --git a/src/wallet/KintoWallet.sol b/src/wallet/KintoWallet.sol index b807e7f52..de25e0642 100644 --- a/src/wallet/KintoWallet.sol +++ b/src/wallet/KintoWallet.sol @@ -1,26 +1,28 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; -import "@openzeppelin/contracts/utils/Address.sol"; -import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; -import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; -import "@openzeppelin/contracts/interfaces/IERC20.sol"; +import {Address} from "@openzeppelin/contracts/utils/Address.sol"; +import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; +import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; +import {IERC20} from "@openzeppelin/contracts/interfaces/IERC20.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; -import "@openzeppelin/contracts/utils/Create2.sol"; +import {Create2} from "@openzeppelin/contracts/utils/Create2.sol"; -import "@aa/core/BaseAccount.sol"; -import "@aa/samples/callback/TokenCallbackHandler.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; +import {PackedUserOperation} from "@aa/interfaces/PackedUserOperation.sol"; +import {SIG_VALIDATION_FAILED, SIG_VALIDATION_SUCCESS} from "@aa/core/Helpers.sol"; +import {BaseAccount} from "@aa/core/BaseAccount.sol"; +import {TokenCallbackHandler} from "@aa/samples/callback/TokenCallbackHandler.sol"; import {Constants} from "@kinto-core/libraries/Const.sol"; - -import "@kinto-core/interfaces/IKintoID.sol"; -import "@kinto-core/interfaces/IKintoEntryPoint.sol"; -import "@kinto-core/interfaces/IKintoWallet.sol"; -import "@kinto-core/interfaces/IEngenCredits.sol"; -import "@kinto-core/interfaces/bridger/IBridgerL2.sol"; -import "@kinto-core/governance/EngenGovernance.sol"; -import "@kinto-core/interfaces/IKintoAppRegistry.sol"; -import "@kinto-core/libraries/ByteSignature.sol"; +import {IKintoWalletFactory} from "../interfaces/IKintoWalletFactory.sol"; +import {IKintoID} from "../interfaces/IKintoID.sol"; +import {IKintoWallet} from "../interfaces/IKintoWallet.sol"; +import {IEngenCredits} from "../interfaces/IEngenCredits.sol"; +import {IBridgerL2} from "../interfaces/bridger/IBridgerL2.sol"; +import {IKintoAppRegistry} from "../interfaces/IKintoAppRegistry.sol"; +import {EngenGovernance} from "../governance/EngenGovernance.sol"; +import {ByteSignature} from "../libraries/ByteSignature.sol"; import "forge-std/console2.sol"; @@ -74,9 +76,6 @@ contract KintoWallet is Initializable, BaseAccount, TokenCallbackHandler, IKinto /// @inheritdoc IKintoWallet uint256 public constant WALLET_TARGET_LIMIT = 5; - /// @dev Constant indicating successful signature validation - uint256 internal constant SIG_VALIDATION_SUCCESS = 0; - /// @dev Address of the Bridger contract on Mainnet address internal constant BRIDGER_MAINNET = 0x0f1b7bd7762662B23486320AA91F30312184f70C; @@ -403,7 +402,7 @@ contract KintoWallet is Initializable, BaseAccount, TokenCallbackHandler, IKinto /// implement template method of BaseAccount /// @dev we don't want to do requires here as it would revert the whole transaction /// @dev this is very similar to SponsorPaymaster._decodeCallData, consider unifying - function _validateSignature(UserOperation calldata userOp, bytes32 userOpHash) + function _validateSignature(PackedUserOperation calldata userOp, bytes32 userOpHash) internal virtual override @@ -497,7 +496,7 @@ contract KintoWallet is Initializable, BaseAccount, TokenCallbackHandler, IKinto if (signer != hashData.recover(signature)) { return SIG_VALIDATION_FAILED; } - return _packValidationData(false, 0, 0); + return SIG_VALIDATION_SUCCESS; } /** @@ -620,7 +619,7 @@ contract KintoWallet is Initializable, BaseAccount, TokenCallbackHandler, IKinto */ function _onlyFactory() internal view { //directly through the factory - if (msg.sender != IKintoEntryPoint(address(_entryPoint)).walletFactory()) revert OnlyFactory(); + if (msg.sender != address(factory)) revert OnlyFactory(); } /** diff --git a/test/SharedSetup.t.sol b/test/SharedSetup.t.sol index 5bea4e300..f79388a29 100644 --- a/test/SharedSetup.t.sol +++ b/test/SharedSetup.t.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; -import "@aa/interfaces/IEntryPoint.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; import "@kinto-core/interfaces/IKintoWallet.sol"; @@ -105,7 +105,7 @@ abstract contract SharedSetup is ForkTest, UserOp, AATestScaffolding, ArtifactsR DeployerScript.DeployedContracts memory contracts = deployer.runAndReturnResults(_ownerPk); // set contracts - _entryPoint = IKintoEntryPoint(address(contracts.entryPoint)); + _entryPoint = IEntryPoint(address(contracts.entryPoint)); _kintoAppRegistry = KintoAppRegistry(contracts.registry); _kintoID = KintoID(contracts.kintoID); _walletFactory = KintoWalletFactory(contracts.factory); @@ -170,7 +170,6 @@ abstract contract SharedSetup is ForkTest, UserOp, AATestScaffolding, ArtifactsR fundSponsorForApp(_owner, address(_kintoWallet)); assertEq(_kintoWallet.owners(0), _owner); - assertEq(_entryPoint.walletFactory(), address(_walletFactory)); assertEq(_kintoWallet.getOwnersCount(), 1); etchEngenCredits(); @@ -187,7 +186,7 @@ abstract contract SharedSetup is ForkTest, UserOp, AATestScaffolding, ArtifactsR vm.deal(_owner, 1e20); // read mainnet contracts from addresses.json - _entryPoint = IKintoEntryPoint(_getChainDeployment("EntryPoint")); + _entryPoint = IEntryPoint(_getChainDeployment("EntryPoint")); _kintoAppRegistry = KintoAppRegistry(_getChainDeployment("KintoAppRegistry")); _kintoID = KintoID(_getChainDeployment("KintoID")); _walletFactory = KintoWalletFactory(_getChainDeployment("KintoWalletFactory")); diff --git a/test/fork/bridger/ArbitrumBridger.t.sol b/test/fork/bridger/ArbitrumBridger.t.sol index 96860ef70..1dd981104 100644 --- a/test/fork/bridger/ArbitrumBridger.t.sol +++ b/test/fork/bridger/ArbitrumBridger.t.sol @@ -19,7 +19,7 @@ import {TransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transpa import "@kinto-core/interfaces/IKintoWallet.sol"; import "@kinto-core/interfaces/IKintoWalletFactory.sol"; -import {SharedSetup, UserOperation} from "@kinto-core-test/SharedSetup.t.sol"; +import {SharedSetup} from "@kinto-core-test/SharedSetup.t.sol"; contract ArbitrumBridgerTest is SharedSetup { L2ArbitrumGateway public l2Gateway; diff --git a/test/fork/wallet/AccessPoint.t.sol b/test/fork/wallet/AccessPoint.t.sol index 609409036..1c6bb3cbb 100644 --- a/test/fork/wallet/AccessPoint.t.sol +++ b/test/fork/wallet/AccessPoint.t.sol @@ -1,7 +1,10 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; + import {stdJson} from "forge-std/StdJson.sol"; + import "@kinto-core/interfaces/bridger/IBridger.sol"; import "@kinto-core/bridger/BridgerL2.sol"; @@ -17,7 +20,7 @@ contract AccessPointTest is SignatureHelper, SharedSetup { // create Kinto fork vm.createSelectFork(vm.rpcUrl("kinto")); - _entryPoint = IKintoEntryPoint(_getChainDeployment("EntryPoint")); + _entryPoint = IEntryPoint(_getChainDeployment("EntryPoint")); _kintoAppRegistry = KintoAppRegistry(_getChainDeployment("KintoAppRegistry")); _kintoID = KintoID(_getChainDeployment("KintoID")); _walletFactory = KintoWalletFactory(_getChainDeployment("KintoWalletFactory")); diff --git a/test/fork/workflows/SwapWorkflow.t.sol b/test/fork/workflows/SwapWorkflow.t.sol index e32deb714..2bb9b22b9 100644 --- a/test/fork/workflows/SwapWorkflow.t.sol +++ b/test/fork/workflows/SwapWorkflow.t.sol @@ -9,7 +9,7 @@ import {IERC20} from "@openzeppelin-5.0.1/contracts/token/ERC20/IERC20.sol"; import {ECDSA} from "@openzeppelin-5.0.1/contracts/utils/cryptography/ECDSA.sol"; import {UpgradeableBeacon} from "@openzeppelin-5.0.1/contracts/proxy/beacon/UpgradeableBeacon.sol"; import {MessageHashUtils} from "@openzeppelin-5.0.1/contracts/utils/cryptography/MessageHashUtils.sol"; -import {IEntryPoint} from "@aa-v7/interfaces/IEntryPoint.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; import {AccessRegistry} from "@kinto-core/access/AccessRegistry.sol"; import {AccessPoint} from "@kinto-core/access/AccessPoint.sol"; diff --git a/test/fork/workflows/WethWorkflow.t.sol b/test/fork/workflows/WethWorkflow.t.sol index c87d8ea61..a2bed8822 100644 --- a/test/fork/workflows/WethWorkflow.t.sol +++ b/test/fork/workflows/WethWorkflow.t.sol @@ -8,7 +8,7 @@ import {IERC20} from "@openzeppelin-5.0.1/contracts/token/ERC20/IERC20.sol"; import {ECDSA} from "@openzeppelin-5.0.1/contracts/utils/cryptography/ECDSA.sol"; import {UpgradeableBeacon} from "@openzeppelin-5.0.1/contracts/proxy/beacon/UpgradeableBeacon.sol"; import {MessageHashUtils} from "@openzeppelin-5.0.1/contracts/utils/cryptography/MessageHashUtils.sol"; -import {IEntryPoint} from "@aa-v7/interfaces/IEntryPoint.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; import {IWETH} from "@kinto-core/interfaces/IWETH.sol"; import {AccessRegistry} from "@kinto-core/access/AccessRegistry.sol"; diff --git a/test/harness/AccessRegistryHarness.sol b/test/harness/AccessRegistryHarness.sol index a5e0a136a..62bdba418 100644 --- a/test/harness/AccessRegistryHarness.sol +++ b/test/harness/AccessRegistryHarness.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.18; import "@openzeppelin-5.0.1/contracts/proxy/beacon/UpgradeableBeacon.sol"; -import "../../src/interfaces/IKintoEntryPoint.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; import "../../src/interfaces/IKintoID.sol"; import "../../src/interfaces/IKintoAppRegistry.sol"; diff --git a/test/harness/KintoAppRegistryHarness.sol b/test/harness/KintoAppRegistryHarness.sol index 8640eab1d..d927e6ba4 100644 --- a/test/harness/KintoAppRegistryHarness.sol +++ b/test/harness/KintoAppRegistryHarness.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; -import "../../src/interfaces/IKintoEntryPoint.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; import "../../src/interfaces/IKintoID.sol"; import "../../src/interfaces/IKintoAppRegistry.sol"; diff --git a/test/harness/KintoWalletHarness.sol b/test/harness/KintoWalletHarness.sol index 797100d8f..fef7c24a7 100644 --- a/test/harness/KintoWalletHarness.sol +++ b/test/harness/KintoWalletHarness.sol @@ -1,7 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; -import "../../src/interfaces/IKintoEntryPoint.sol"; +import {PackedUserOperation} from "@aa/interfaces/PackedUserOperation.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; import "../../src/interfaces/IKintoID.sol"; import "../../src/interfaces/IKintoAppRegistry.sol"; @@ -12,7 +13,7 @@ contract KintoWalletHarness is KintoWallet { KintoWallet(__entryPoint, _kintoID, _kintoApp, _factory) {} - function validateSignature(UserOperation calldata userOp, bytes32 userOpHash) + function validateSignature(PackedUserOperation calldata userOp, bytes32 userOpHash) public returns (uint256 validationData) { diff --git a/test/harness/SponsorPaymasterHarness.sol b/test/harness/SponsorPaymasterHarness.sol index cfb983fe2..2c112eef7 100644 --- a/test/harness/SponsorPaymasterHarness.sol +++ b/test/harness/SponsorPaymasterHarness.sol @@ -1,7 +1,9 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.18; -import "../../src/interfaces/IKintoEntryPoint.sol"; +import {PackedUserOperation} from "@aa/interfaces/PackedUserOperation.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; + import "../../src/interfaces/IKintoID.sol"; import "../../src/interfaces/IKintoAppRegistry.sol"; @@ -12,7 +14,7 @@ import {IKintoWalletFactory} from "@kinto-core/interfaces/IKintoWalletFactory.so contract SponsorPaymasterHarness is SponsorPaymaster { constructor(IEntryPoint entryPoint, IKintoWalletFactory factory) SponsorPaymaster(entryPoint, factory) {} - function exposed_validatePaymasterUserOp(UserOperation calldata userOp, bytes32 userOpHash, uint256 maxCost) + function exposed_validatePaymasterUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash, uint256 maxCost) public view returns (bytes memory context, uint256 validationData) diff --git a/test/helpers/AASetup.sol b/test/helpers/AASetup.sol new file mode 100644 index 000000000..68e800620 --- /dev/null +++ b/test/helpers/AASetup.sol @@ -0,0 +1,57 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.18; + +import "forge-std/console.sol"; + +import {EntryPoint} from "@aa/core/EntryPoint.sol"; + +import "../../src/wallet/KintoWalletFactory.sol"; +import {SponsorPaymaster} from "../../src/paymasters/SponsorPaymaster.sol"; +import "../../src/KintoID.sol"; + +import "./Create2Helper.sol"; +import "./ArtifactsReader.sol"; + +abstract contract AASetup is Create2Helper, ArtifactsReader { + function _checkAccountAbstraction() + internal + returns ( + KintoID _kintoID, + EntryPoint _entryPoint, + KintoWalletFactory _walletFactory, + SponsorPaymaster _sponsorPaymaster + ) + { + // Kinto ID + address kintoProxyAddr = _getChainDeployment("KintoID"); + if (!isContract(kintoProxyAddr)) { + console.log("Kinto ID proxy not deployed at", address(kintoProxyAddr)); + revert("Kinto ID not deployed"); + } + _kintoID = KintoID(address(kintoProxyAddr)); + + // Entry Point + address entryPointAddr = _getChainDeployment("EntryPoint"); + if (!isContract(entryPointAddr)) { + console.log("EntryPoint not deployed at", address(entryPointAddr)); + revert("EntryPoint not deployed"); + } + _entryPoint = EntryPoint(payable(entryPointAddr)); + + // Wallet Factory + address walletFactoryAddr = _getChainDeployment("KintoWalletFactory"); + if (!isContract(walletFactoryAddr)) { + console.log("Wallet factory proxy not deployed at", address(walletFactoryAddr)); + revert("Wallet Factory Proxy not deployed"); + } + _walletFactory = KintoWalletFactory(payable(walletFactoryAddr)); + + // Sponsor Paymaster + address sponsorProxyAddr = _getChainDeployment("SponsorPaymaster"); + if (!isContract(sponsorProxyAddr)) { + console.log("Paymaster proxy not deployed at", address(sponsorProxyAddr)); + revert("Paymaster proxy not deployed"); + } + _sponsorPaymaster = SponsorPaymaster(payable(sponsorProxyAddr)); + } +} diff --git a/test/helpers/AATestScaffolding.sol b/test/helpers/AATestScaffolding.sol index 11191adf6..bb11be797 100644 --- a/test/helpers/AATestScaffolding.sol +++ b/test/helpers/AATestScaffolding.sol @@ -5,27 +5,30 @@ import {StdAssertions} from "forge-std/StdAssertions.sol"; import {StdCheats} from "forge-std/StdCheats.sol"; import {Vm} from "forge-std/Vm.sol"; -import "@aa/core/EntryPoint.sol"; -import "@openzeppelin/contracts/governance/TimelockController.sol"; - -import "@kinto-core/interfaces/IKintoEntryPoint.sol"; - -import "@kinto-core/KintoID.sol"; -import "@kinto-core/apps/KintoAppRegistry.sol"; -import "@kinto-core/tokens/EngenCredits.sol"; -import "@kinto-core/tokens/EngenBadges.sol"; -import "@kinto-core/paymasters/SponsorPaymaster.sol"; -import "@kinto-core/wallet/KintoWallet.sol"; -import "@kinto-core/wallet/KintoWalletFactory.sol"; -import "@kinto-core/viewers/KYCViewer.sol"; -import "@kinto-core/viewers/WalletViewer.sol"; -import "@kinto-core/bridger/BridgerL2.sol"; -import "@kinto-core/Faucet.sol"; -import "@kinto-core/inflators/KintoInflator.sol"; -import "@kinto-core/governance/EngenGovernance.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; +import {TimelockController} from "@openzeppelin/contracts/governance/TimelockController.sol"; + +import {IKintoWallet} from "@kinto-core/interfaces/IKintoWallet.sol"; +import {IKintoID} from "@kinto-core/interfaces/IKintoID.sol"; + +import {RewardsDistributor} from "@kinto-core/liquidity-mining/RewardsDistributor.sol"; +import {KintoID} from "@kinto-core/KintoID.sol"; +import {KintoAppRegistry} from "@kinto-core/apps/KintoAppRegistry.sol"; +import {EngenCredits} from "@kinto-core/tokens/EngenCredits.sol"; +import {EngenBadges} from "@kinto-core/tokens/EngenBadges.sol"; +import {SponsorPaymaster} from "@kinto-core/paymasters/SponsorPaymaster.sol"; +import {KintoWallet} from "@kinto-core/wallet/KintoWallet.sol"; +import {KintoWalletFactory} from "@kinto-core/wallet/KintoWalletFactory.sol"; +import {KYCViewer} from "@kinto-core/viewers/KYCViewer.sol"; +import {WalletViewer} from "@kinto-core/viewers/WalletViewer.sol"; +import {BridgerL2} from "@kinto-core/bridger/BridgerL2.sol"; +import {Faucet} from "@kinto-core/Faucet.sol"; +import {KintoInflator} from "@kinto-core/inflators/KintoInflator.sol"; +import {EngenGovernance} from "@kinto-core/governance/EngenGovernance.sol"; + +import {UUPSProxy} from "@kinto-core-test/helpers/UUPSProxy.sol"; import {BridgedKinto} from "@kinto-core/tokens/bridged/BridgedKinto.sol"; -import "@kinto-core-test/helpers/UUPSProxy.sol"; import {SignatureHelper} from "@kinto-core-test/helpers/SignatureHelper.sol"; import {KintoWalletHarness} from "../harness/KintoWalletHarness.sol"; import {SponsorPaymasterHarness} from "../harness/SponsorPaymasterHarness.sol"; @@ -37,7 +40,7 @@ abstract contract AATestScaffolding is SignatureHelper, StdAssertions, StdCheats uint256 internal constant GAS_LIMIT_PERIOD = 30 days; uint256 internal constant GAS_LIMIT_THRESHOLD = 0.01 ether; - IKintoEntryPoint _entryPoint; + IEntryPoint _entryPoint; // Kinto Registry KintoAppRegistry _kintoAppRegistry; diff --git a/test/helpers/SignerHelper.sol b/test/helpers/SignerHelper.sol index cc315a468..b2bafb67a 100644 --- a/test/helpers/SignerHelper.sol +++ b/test/helpers/SignerHelper.sol @@ -5,7 +5,7 @@ import "forge-std/Test.sol"; import {LibString} from "solady/utils/LibString.sol"; import "@aa/interfaces/IEntryPoint.sol"; -import "@aa/core/EntryPoint.sol"; +import {EntryPoint} from "@aa/core/EntryPoint.sol"; import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol"; import "@kinto-core/wallet/KintoWallet.sol"; diff --git a/test/helpers/UserOp.sol b/test/helpers/UserOp.sol index d6d7c891e..4a41629b4 100644 --- a/test/helpers/UserOp.sol +++ b/test/helpers/UserOp.sol @@ -4,13 +4,17 @@ pragma solidity ^0.8.18; import "forge-std/Test.sol"; import {LibString} from "solady/utils/LibString.sol"; -import "@aa/interfaces/IEntryPoint.sol"; -import "@aa/core/EntryPoint.sol"; -import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol"; +import "@aa/core/Helpers.sol"; +import {UserOperationLib} from "@aa/core/UserOperationLib.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; +import {PackedUserOperation} from "@aa/interfaces/PackedUserOperation.sol"; +import {EntryPoint} from "@aa/core/EntryPoint.sol"; +import {ECDSAUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol"; -import "@kinto-core/wallet/KintoWallet.sol"; -import "@kinto-core/wallet/KintoWalletFactory.sol"; -import "@kinto-core-test/helpers/SignerHelper.sol"; +import {KintoWallet} from "@kinto-core/wallet/KintoWallet.sol"; +import {KintoWalletFactory} from "@kinto-core/wallet/KintoWalletFactory.sol"; + +import {SignerHelper} from "@kinto-core-test/helpers/SignerHelper.sol"; import "forge-std/Vm.sol"; import "forge-std/console2.sol"; @@ -33,6 +37,9 @@ abstract contract UserOp is Test, SignerHelper { uint256 constant MAX_FEE_PER_GAS = 1; uint256 constant MAX_PRIORITY_FEE_PER_GAS = 1e9; + uint256 public constant MAX_COST_OF_VERIFICATION = 530_000; + uint256 public constant COST_OF_POST = 200_000; + struct OperationParamsBatch { address[] targets; uint256[] values; @@ -66,7 +73,7 @@ abstract contract UserOp is Test, SignerHelper { uint256[3] memory gasLimits, bool isBatch, OperationParamsBatch memory opParams - ) internal returns (UserOperation memory op) { + ) internal returns (PackedUserOperation memory op) { bytes memory callData; if (isBatch) { callData = abi.encodeCall(KintoWallet.executeBatch, (opParams.targets, opParams.values, opParams.bytesOps)); @@ -74,19 +81,20 @@ abstract contract UserOp is Test, SignerHelper { callData = abi.encodeCall(KintoWallet.execute, (target, value, bytesOp)); } - op = UserOperation({ + op = PackedUserOperation({ sender: from, nonce: nonce, initCode: bytes(""), callData: callData, - callGasLimit: gasLimits[0], // generate from call simulation - verificationGasLimit: 210_000, // verification gas. will add create2 cost (3200+200*length) if initCode exists preVerificationGas: 21_000, // should also cover calldata cost. - maxFeePerGas: gasLimits[1], // grab from current gas - maxPriorityFeePerGas: gasLimits[2], // grab from current gas - paymasterAndData: abi.encodePacked(paymaster), + accountGasLimits: packAccountGasLimits(210_000, gasLimits[0]), + gasFees: packAccountGasLimits(gasLimits[2], gasLimits[1]), + paymasterAndData: paymaster != address(0) + ? packPaymasterData(paymaster, MAX_COST_OF_VERIFICATION, COST_OF_POST, bytes("")) + : bytes(""), signature: bytes("") }); + op.signature = _signUserOp(op, KintoWallet(payable(from)).entryPoint(), chainID, privateKeyOwners); return op; } @@ -100,7 +108,7 @@ abstract contract UserOp is Test, SignerHelper { uint256 nonce, uint256[] memory privateKeyOwners, bytes memory bytesOp - ) internal returns (UserOperation memory op) { + ) internal returns (PackedUserOperation memory op) { return _createUserOperation( block.chainid, from, @@ -126,7 +134,7 @@ abstract contract UserOp is Test, SignerHelper { uint256[] memory privateKeyOwners, bytes memory bytesOp, address paymaster - ) internal returns (UserOperation memory op) { + ) internal returns (PackedUserOperation memory op) { return _createUserOperation( block.chainid, from, @@ -163,7 +171,7 @@ abstract contract UserOp is Test, SignerHelper { uint256[] memory privateKeyOwners, bytes memory bytesOp, address paymaster - ) internal returns (UserOperation memory op) { + ) internal returns (PackedUserOperation memory op) { return _createUserOperation( chainID, from, @@ -188,7 +196,7 @@ abstract contract UserOp is Test, SignerHelper { uint256[] memory privateKeyOwners, OperationParamsBatch memory opParams, address paymaster - ) internal returns (UserOperation memory op) { + ) internal returns (PackedUserOperation memory op) { return _createUserOperation( block.chainid, from, @@ -204,49 +212,44 @@ abstract contract UserOp is Test, SignerHelper { ); } - // signature helpers + /** + * Pack the user operation data into bytes for hashing. + * @param userOp - The user operation data. + */ + function encodePackedUserOperation(PackedUserOperation memory userOp) internal pure returns (bytes memory ret) { + address sender = userOp.sender; + uint256 nonce = userOp.nonce; + bytes32 hashInitCode = keccak256(userOp.initCode); + bytes32 hashCallData = keccak256(userOp.callData); + bytes32 accountGasLimits = userOp.accountGasLimits; + uint256 preVerificationGas = userOp.preVerificationGas; + bytes32 gasFees = userOp.gasFees; + bytes32 hashPaymasterAndData = keccak256(userOp.paymasterAndData); - function _packUserOp(UserOperation memory op, bool forSig) internal pure returns (bytes memory) { - if (forSig) { - return abi.encode( - op.sender, - op.nonce, - keccak256(op.initCode), - keccak256(op.callData), - op.callGasLimit, - op.verificationGasLimit, - op.preVerificationGas, - op.maxFeePerGas, - op.maxPriorityFeePerGas, - keccak256(op.paymasterAndData) - ); - } return abi.encode( - op.sender, - op.nonce, - op.initCode, - op.callData, - op.callGasLimit, - op.verificationGasLimit, - op.preVerificationGas, - op.maxFeePerGas, - op.maxPriorityFeePerGas, - op.paymasterAndData, - op.signature + sender, + nonce, + hashInitCode, + hashCallData, + accountGasLimits, + preVerificationGas, + gasFees, + hashPaymasterAndData ); } - function _getUserOpHash(UserOperation memory op, IEntryPoint _entryPoint, uint256 chainID) + function _getUserOpHash(PackedUserOperation memory op, IEntryPoint _entryPoint, uint256 chainID) internal pure returns (bytes32) { - bytes32 opHash = keccak256(_packUserOp(op, true)); + bytes32 opHash = keccak256(encodePackedUserOperation(op)); + // TODO: v7 have a different hashing return keccak256(abi.encode(opHash, address(_entryPoint), chainID)); } function _signUserOp( - UserOperation memory op, + PackedUserOperation memory op, IEntryPoint _entryPoint, uint256 chainID, uint256[] memory privateKeys @@ -271,4 +274,32 @@ abstract contract UserOp is Test, SignerHelper { } return signature; } + + function packAccountGasLimits(uint256 limit0, uint256 limit1) public pure returns (bytes32) { + // Ensure the inputs fit into 128 bits each + require(limit0 <= type(uint128).max, "limit0 too large"); + require(limit1 <= type(uint128).max, "limit1 too large"); + + // Pack the values into bytes32 + bytes32 packed = bytes32((uint256(limit0) << 128) | uint256(limit1)); + + return packed; + } + + function packPaymasterData( + address paymaster, + uint256 paymasterVerificationGasLimit, + uint256 postOpGasLimit, + bytes memory paymasterData + ) public pure returns (bytes memory) { + require(paymasterVerificationGasLimit <= type(uint128).max, "VerificationGasLimit too large"); + require(postOpGasLimit <= type(uint128).max, "PostOpGasLimit too large"); + + return bytes.concat( + bytes20(paymaster), // Address is padded to 20 bytes + bytes16(uint128(paymasterVerificationGasLimit)), // Pack verification gas limit (16 bytes) + bytes16(uint128(postOpGasLimit)), // Pack post operation gas limit (16 bytes) + paymasterData // Append additional paymaster data + ); + } } diff --git a/test/unit/EngenCredits.t.sol b/test/unit/EngenCredits.t.sol index 3f2eea97f..89718a12c 100644 --- a/test/unit/EngenCredits.t.sol +++ b/test/unit/EngenCredits.t.sol @@ -229,7 +229,7 @@ contract EngenCreditsTest is SharedSetup { _engenCredits.setCredits(addresses, points); // mint credit - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_engenCredits), @@ -258,7 +258,7 @@ contract EngenCreditsTest is SharedSetup { assertEq(_engenCredits.earnedCredits(address(_kintoWallet)), 10); // mint credits - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_engenCredits), @@ -285,7 +285,7 @@ contract EngenCreditsTest is SharedSetup { _engenCredits.setCredits(addresses, points); // mint creidts - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_engenCredits), @@ -326,7 +326,7 @@ contract EngenCreditsTest is SharedSetup { _engenCredits.setTransfersEnabled(true); // mint credit - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_engenCredits), @@ -352,7 +352,7 @@ contract EngenCreditsTest is SharedSetup { _engenCredits.setBurnsEnabled(true); // mint credit - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_engenCredits), diff --git a/test/unit/KintoEntryPoint.t.sol b/test/unit/KintoEntryPoint.t.sol deleted file mode 100644 index adf4ae4ab..000000000 --- a/test/unit/KintoEntryPoint.t.sol +++ /dev/null @@ -1,20 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity ^0.8.18; - -import "@kinto-core-test/SharedSetup.t.sol"; - -contract KintoEntryPointTest is SharedSetup { - function testUp() public view override { - assertEq(_entryPoint.walletFactory(), address(_walletFactory)); - } - - /* ============ Deployment tests ============ */ - - function testCannotResetWalletFactoryAddress() public { - vm.startPrank(_owner); - vm.expectRevert("AA36 wallet factory already set"); - _entryPoint.setWalletFactory(address(0)); - vm.stopPrank(); - } -} diff --git a/test/unit/KintoWalletFactory.t.sol b/test/unit/KintoWalletFactory.t.sol index 1a8182293..6035fe369 100644 --- a/test/unit/KintoWalletFactory.t.sol +++ b/test/unit/KintoWalletFactory.t.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.18; import "@aa/interfaces/IEntryPoint.sol"; -import "@aa/core/EntryPoint.sol"; +import {EntryPoint} from "@aa/core/EntryPoint.sol"; import {UpgradeableBeacon} from "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol"; import {BridgedKinto} from "@kinto-core/tokens/bridged/BridgedKinto.sol"; @@ -59,7 +59,6 @@ contract KintoWalletFactoryTest is SharedSetup { function testUp() public override { super.testUp(); assertEq(_walletFactory.factoryWalletVersion(), 2); - assertEq(_entryPoint.walletFactory(), address(_walletFactory)); } /* ============ Create Account ============ */ @@ -200,7 +199,7 @@ contract KintoWalletFactoryTest is SharedSetup { bool[] memory flags = new bool[](1); flags[0] = true; - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_kintoWallet), diff --git a/test/unit/SponsorPaymastExploit.t.sol b/test/unit/SponsorPaymastExploit.t.sol deleted file mode 100644 index 11e808f9b..000000000 --- a/test/unit/SponsorPaymastExploit.t.sol +++ /dev/null @@ -1,49 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.18; - -import "forge-std/Test.sol"; -import "forge-std/console.sol"; - -import "@aa/interfaces/IEntryPoint.sol"; -import "@aa/core/EntryPoint.sol"; - -import "@kinto-core/wallet/KintoWallet.sol"; -import "@kinto-core/wallet/KintoWalletFactory.sol"; -import "@kinto-core/paymasters/SponsorPaymaster.sol"; -import "@kinto-core/KintoID.sol"; -import "@kinto-core/sample/Counter.sol"; - -import "@kinto-core-test/SharedSetup.t.sol"; - -contract SponsorPaymasterExploitTest is SharedSetup { - using SignatureChecker for address; - - function testExploit() public { - UserOperation[] memory userOps = new UserOperation[](1); - userOps[0] = _createUserOperation( - address(_kintoWallet), - address(counter), - _kintoWallet.getNonce(), - privateKeys, - abi.encodeWithSignature("increment()"), - address(_paymaster) - ); - userOps[0].callGasLimit = 40000; // generate from call simulation - userOps[0].verificationGasLimit = 150000; // verification gas. will add create2 cost (3200+200*length) if initCode exists - userOps[0].preVerificationGas = 99e18; // should also cover calldata cost. - userOps[0].maxFeePerGas = 1; // grab from current gas - userOps[0].maxPriorityFeePerGas = 1e9; // grab from current gas - userOps[0].signature = _signUserOp( - userOps[0], KintoWallet(payable(address(_kintoWallet))).entryPoint(), block.chainid, privateKeys - ); - - uint256 balanceBefore = _owner.balance; - - vm.expectRevert(); - _entryPoint.handleOps(userOps, payable(_owner)); - - uint256 balanceAfter = _owner.balance; - uint256 dust = 100_000; - assertGt(balanceBefore, balanceAfter - dust, "Hacker's profit is too HIGH"); - } -} diff --git a/test/unit/SponsorPaymaster.t.sol b/test/unit/SponsorPaymaster.t.sol index 1c2ac1572..e105a38b6 100644 --- a/test/unit/SponsorPaymaster.t.sol +++ b/test/unit/SponsorPaymaster.t.sol @@ -5,10 +5,10 @@ import "forge-std/Test.sol"; import "forge-std/console.sol"; import "@aa/interfaces/IEntryPoint.sol"; -import "@aa/core/EntryPoint.sol"; +import {EntryPoint} from "@aa/core/EntryPoint.sol"; import "@kinto-core/apps/KintoAppRegistry.sol"; -import "@kinto-core/paymasters/SponsorPaymaster.sol"; +import {SponsorPaymaster} from "@kinto-core/paymasters/SponsorPaymaster.sol"; import "@kinto-core/sample/Counter.sol"; import "@kinto-core/interfaces/IKintoWallet.sol"; import {IKintoWalletFactory} from "@kinto-core/interfaces/IKintoWalletFactory.sol"; @@ -242,7 +242,7 @@ contract SponsorPaymasterTest is SharedSetup { /* ============ Per-Op: Global Rate limits ============ */ function testValidatePaymasterUserOp() public { - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(_kintoWallet), _kintoWallet.getNonce(), @@ -257,7 +257,7 @@ contract SponsorPaymasterTest is SharedSetup { function testValidatePaymasterUserOp_WhenWalletIsApp() public { address wallet = address(alice); - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( wallet, wallet, 0, privateKeys, abi.encodeWithSignature("increment()"), address(_paymaster) ); @@ -273,7 +273,7 @@ contract SponsorPaymasterTest is SharedSetup { } function testValidatePaymasterUserOp_RevertWhen_GasLimitIsLessThanCostOfPost() public { - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(_kintoWallet), _kintoWallet.getNonce(), @@ -283,7 +283,9 @@ contract SponsorPaymasterTest is SharedSetup { ); // verificationGasLimit is 1 less than COST_OF_POST - userOp.verificationGasLimit = _paymaster.COST_OF_POST() - 1; + userOp.paymasterAndData = packPaymasterData( + address(_paymaster), _paymaster.MAX_COST_OF_VERIFICATION(), _paymaster.COST_OF_POST() - 1, bytes("") + ); vm.prank(address(_entryPoint)); vm.expectRevert(ISponsorPaymaster.GasOutsideRangeForPostOp.selector); @@ -291,7 +293,7 @@ contract SponsorPaymasterTest is SharedSetup { } function testValidatePaymasterUserOp_RevertWhen_GasLimitIsMoreThanCostOfVerification() public { - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(_kintoWallet), _kintoWallet.getNonce(), @@ -301,7 +303,9 @@ contract SponsorPaymasterTest is SharedSetup { ); // verificationGasLimit is 1 more than COST_OF_POST - userOp.verificationGasLimit = _paymaster.MAX_COST_OF_VERIFICATION() + 1; + userOp.paymasterAndData = packPaymasterData( + address(_paymaster), _paymaster.MAX_COST_OF_VERIFICATION(), _paymaster.COST_OF_POST() - 1, bytes("") + ); vm.prank(address(_entryPoint)); vm.expectRevert(ISponsorPaymaster.GasOutsideRangeForPostOp.selector); @@ -309,7 +313,7 @@ contract SponsorPaymasterTest is SharedSetup { } function testValidatePaymasterUserOp_RevertWhen_PreGasLimitIsMoreThanMaxPreVerification() public { - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(_kintoWallet), _kintoWallet.getNonce(), @@ -327,7 +331,7 @@ contract SponsorPaymasterTest is SharedSetup { } function testValidatePaymasterUserOp_RevertWhen_PaymasterAndDataIsNotLength20() public { - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(_kintoWallet), _kintoWallet.getNonce(), @@ -345,7 +349,7 @@ contract SponsorPaymasterTest is SharedSetup { } function testValidatePaymasterUserOp_RevertWhen_GasIsTooHigh() public { - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(_kintoWallet), _kintoWallet.getNonce(), @@ -355,8 +359,7 @@ contract SponsorPaymasterTest is SharedSetup { ); // gas price set to 100 ether - userOp.maxFeePerGas = 100 ether; - userOp.maxPriorityFeePerGas = 100 ether; + userOp.gasFees = packAccountGasLimits(100 ether, 100 ether); vm.prank(address(_entryPoint)); vm.expectRevert(ISponsorPaymaster.GasTooHighForUserOp.selector); @@ -436,7 +439,7 @@ contract SponsorPaymasterTest is SharedSetup { _incrementCounterTxs(_paymaster.RATE_LIMIT_THRESHOLD_TOTAL(), address(counter)); // execute one more op and assert that it reverts - UserOperation[] memory userOps = _incrementCounterOps(1, address(counter)); + PackedUserOperation[] memory userOps = _incrementCounterOps(1, address(counter)); vm.expectEmit(true, true, true, false); uint256 last = userOps.length - 1; emit PostOpRevertReason( @@ -460,7 +463,8 @@ contract SponsorPaymasterTest is SharedSetup { updateMetadata(address(_kintoWallet), "counter", address(counter), appLimits, new address[](0)); // generate ops until reaching the threshold - UserOperation[] memory userOps = _incrementCounterOps(_paymaster.RATE_LIMIT_THRESHOLD_TOTAL(), address(counter)); + PackedUserOperation[] memory userOps = + _incrementCounterOps(_paymaster.RATE_LIMIT_THRESHOLD_TOTAL(), address(counter)); _entryPoint.handleOps(userOps, payable(_owner)); } @@ -477,7 +481,7 @@ contract SponsorPaymasterTest is SharedSetup { updateMetadata(address(_kintoWallet), "counter", address(counter), appLimits, new address[](0)); // generate ops until reaching the threshold and assert that it reverts - UserOperation[] memory userOps = + PackedUserOperation[] memory userOps = _incrementCounterOps(_paymaster.RATE_LIMIT_THRESHOLD_TOTAL() + 1, address(counter)); vm.expectEmit(true, true, true, false); uint256 last = userOps.length - 1; @@ -507,7 +511,7 @@ contract SponsorPaymasterTest is SharedSetup { _incrementCounterTxs(appLimits[1], address(counter)); // execute one more op and assert that it reverts - UserOperation[] memory userOps = _incrementCounterOps(1, address(counter)); + PackedUserOperation[] memory userOps = _incrementCounterOps(1, address(counter)); vm.expectEmit(true, true, true, false); uint256 last = userOps.length - 1; emit PostOpRevertReason( @@ -523,7 +527,7 @@ contract SponsorPaymasterTest is SharedSetup { uint256[4] memory appLimits = _kintoAppRegistry.getContractLimits(address(counter)); // generate ops until reaching the threshold - UserOperation[] memory userOps = _incrementCounterOps(appLimits[1], address(counter)); + PackedUserOperation[] memory userOps = _incrementCounterOps(appLimits[1], address(counter)); _entryPoint.handleOps(userOps, payable(_owner)); } @@ -532,7 +536,7 @@ contract SponsorPaymasterTest is SharedSetup { uint256[4] memory appLimits = _kintoAppRegistry.getContractLimits(address(counter)); // generate ops until reaching the threshold and assert that it reverts - UserOperation[] memory userOps = _incrementCounterOps(appLimits[1] + 1, address(counter)); + PackedUserOperation[] memory userOps = _incrementCounterOps(appLimits[1] + 1, address(counter)); vm.expectEmit(true, true, true, false); uint256 last = userOps.length - 1; emit PostOpRevertReason( @@ -556,7 +560,7 @@ contract SponsorPaymasterTest is SharedSetup { _incrementCounterTxsUntilGasLimit(address(counter)); // execute one more op and assert that it reverts - UserOperation[] memory userOps = _incrementCounterOps(1, address(counter)); + PackedUserOperation[] memory userOps = _incrementCounterOps(1, address(counter)); vm.expectEmit(true, true, true, false); emit PostOpRevertReason(_entryPoint.getUserOpHash(userOps[0]), userOps[0].sender, userOps[0].nonce, bytes("")); vm.recordLogs(); @@ -578,7 +582,7 @@ contract SponsorPaymasterTest is SharedSetup { // fixme: vm.warp(block.timestamp + _kintoAppRegistry.GAS_LIMIT_PERIOD() + 1); // generate `amt` ops until reaching the threshold and assert that it reverts - UserOperation[] memory userOps = _incrementCounterOps(amt, address(counter)); + PackedUserOperation[] memory userOps = _incrementCounterOps(amt, address(counter)); vm.expectEmit(true, true, true, false); uint256 last = userOps.length - 1; emit PostOpRevertReason( @@ -675,9 +679,9 @@ contract SponsorPaymasterTest is SharedSetup { /// @dev if batch is true, then we batch the increment ops // otherwise we do them one by one - function _incrementCounterOps(uint256 amt, address app) internal returns (UserOperation[] memory userOps) { + function _incrementCounterOps(uint256 amt, address app) internal returns (PackedUserOperation[] memory userOps) { uint256 nonce = _kintoWallet.getNonce(); - userOps = new UserOperation[](amt); + userOps = new PackedUserOperation[](amt); // we iterate from 1 because the first op is whitelisting the app for (uint256 i = 0; i < amt; i++) { userOps[i] = _createUserOperation( @@ -694,7 +698,7 @@ contract SponsorPaymasterTest is SharedSetup { /// @dev executes `amt` transactions with only one user op per tx function _incrementCounterTxs(uint256 amt, address app) internal { - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); for (uint256 i = 0; i < amt; i++) { userOps[0] = _incrementCounterOps(amt, app)[0]; _entryPoint.handleOps(userOps, payable(_owner)); @@ -707,7 +711,7 @@ contract SponsorPaymasterTest is SharedSetup { uint256 estimatedGasPerTx = 0; uint256 cumulativeGasUsed = 0; - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); while (cumulativeGasUsed < appLimits[3]) { if (cumulativeGasUsed + estimatedGasPerTx >= appLimits[3]) return amt; userOps[0] = _incrementCounterOps(1, app)[0]; // generate 1 user op diff --git a/test/unit/access/AccessPoint.t.sol b/test/unit/access/AccessPoint.t.sol index eac02f163..273db13e5 100644 --- a/test/unit/access/AccessPoint.t.sol +++ b/test/unit/access/AccessPoint.t.sol @@ -8,8 +8,8 @@ import {ECDSA} from "@openzeppelin-5.0.1/contracts/utils/cryptography/ECDSA.sol" import {UpgradeableBeacon} from "@openzeppelin-5.0.1/contracts/proxy/beacon/UpgradeableBeacon.sol"; import {MessageHashUtils} from "@openzeppelin-5.0.1/contracts/utils/cryptography/MessageHashUtils.sol"; -import {PackedUserOperation} from "@aa-v7/interfaces/PackedUserOperation.sol"; -import {IEntryPoint} from "@aa-v7/interfaces/IEntryPoint.sol"; +import {PackedUserOperation} from "@aa/interfaces/PackedUserOperation.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; import {IBridger} from "@kinto-core/interfaces/bridger/IBridger.sol"; import {AccessRegistry} from "@kinto-core/access/AccessRegistry.sol"; diff --git a/test/unit/access/AccessRegistry.t.sol b/test/unit/access/AccessRegistry.t.sol index dccf8bca9..3b7d08956 100644 --- a/test/unit/access/AccessRegistry.t.sol +++ b/test/unit/access/AccessRegistry.t.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.18; import {ECDSA} from "@openzeppelin-5.0.1/contracts/utils/cryptography/ECDSA.sol"; import {UpgradeableBeacon} from "@openzeppelin-5.0.1/contracts/proxy/beacon/UpgradeableBeacon.sol"; -import {EntryPoint} from "@aa-v7/core/EntryPoint.sol"; +import {EntryPoint} from "@aa/core/EntryPoint.sol"; import {Create2} from "@openzeppelin-5.0.1/contracts/utils/Create2.sol"; import {AccessRegistry} from "@kinto-core/access/AccessRegistry.sol"; diff --git a/test/unit/access/BridgeWorkflow.t.sol b/test/unit/access/BridgeWorkflow.t.sol index e9604530b..5c56cdeed 100644 --- a/test/unit/access/BridgeWorkflow.t.sol +++ b/test/unit/access/BridgeWorkflow.t.sol @@ -8,8 +8,8 @@ import {ECDSA} from "@openzeppelin-5.0.1/contracts/utils/cryptography/ECDSA.sol" import {UpgradeableBeacon} from "@openzeppelin-5.0.1/contracts/proxy/beacon/UpgradeableBeacon.sol"; import {MessageHashUtils} from "@openzeppelin-5.0.1/contracts/utils/cryptography/MessageHashUtils.sol"; -import {PackedUserOperation} from "@aa-v7/interfaces/PackedUserOperation.sol"; -import {IEntryPoint} from "@aa-v7/interfaces/IEntryPoint.sol"; +import {PackedUserOperation} from "@aa/interfaces/PackedUserOperation.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; import {IBridger} from "@kinto-core/interfaces/bridger/IBridger.sol"; import {AccessRegistry} from "@kinto-core/access/AccessRegistry.sol"; diff --git a/test/unit/access/WithdrawWorkflow.t.sol b/test/unit/access/WithdrawWorkflow.t.sol index 2c5731322..0f5e1d9d6 100644 --- a/test/unit/access/WithdrawWorkflow.t.sol +++ b/test/unit/access/WithdrawWorkflow.t.sol @@ -6,8 +6,8 @@ import {ECDSA} from "@openzeppelin-5.0.1/contracts/utils/cryptography/ECDSA.sol" import {UpgradeableBeacon} from "@openzeppelin-5.0.1/contracts/proxy/beacon/UpgradeableBeacon.sol"; import {MessageHashUtils} from "@openzeppelin-5.0.1/contracts/utils/cryptography/MessageHashUtils.sol"; -import {PackedUserOperation} from "@aa-v7/interfaces/PackedUserOperation.sol"; -import {IEntryPoint} from "@aa-v7/interfaces/IEntryPoint.sol"; +import {PackedUserOperation} from "@aa/interfaces/PackedUserOperation.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; import {AccessRegistry} from "@kinto-core/access/AccessRegistry.sol"; import {AccessPoint} from "@kinto-core/access/AccessPoint.sol"; diff --git a/test/unit/bridger/ArbitrumBridger.t.sol b/test/unit/bridger/ArbitrumBridger.t.sol index 63a70c97a..bb60bbbf9 100644 --- a/test/unit/bridger/ArbitrumBridger.t.sol +++ b/test/unit/bridger/ArbitrumBridger.t.sol @@ -19,7 +19,7 @@ import {TransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transpa import "@kinto-core/interfaces/IKintoWallet.sol"; import "@kinto-core/interfaces/IKintoWalletFactory.sol"; -import {SharedSetup, UserOperation} from "@kinto-core-test/SharedSetup.t.sol"; +import {SharedSetup} from "@kinto-core-test/SharedSetup.t.sol"; contract ArbitrumBridgerTest is SharedSetup { L2ArbitrumGateway public l2Gateway; diff --git a/test/unit/governance/EngenGovernance.t.sol b/test/unit/governance/EngenGovernance.t.sol index d996a2453..26b531e0b 100644 --- a/test/unit/governance/EngenGovernance.t.sol +++ b/test/unit/governance/EngenGovernance.t.sol @@ -34,7 +34,7 @@ contract EngenGovernanceTest is SharedSetup { function testCreateProposal() public { assertEq(_engenCredits.balanceOf(address(_kintoWallet)), 0); - (UserOperation[] memory userOps, uint256 hashProposal) = + (PackedUserOperation[] memory userOps, uint256 hashProposal) = mintCreditsAndcreateProposal(5e18, "First ENIP Proposal"); _entryPoint.handleOps(userOps, payable(_owner)); assertEq(_engenCredits.balanceOf(address(_kintoWallet)), 5e18); @@ -44,7 +44,7 @@ contract EngenGovernanceTest is SharedSetup { } function testCreateProposal_RevertWhen_WhenNotENoughCredits() public { - (UserOperation[] memory userOps,) = mintCreditsAndcreateProposal(2e18, "First ENIP Proposal"); + (PackedUserOperation[] memory userOps,) = mintCreditsAndcreateProposal(2e18, "First ENIP Proposal"); vm.expectEmit(true, true, true, false); emit UserOperationRevertReason( _entryPoint.getUserOpHash(userOps[1]), userOps[1].sender, userOps[1].nonce, bytes("") @@ -65,7 +65,7 @@ contract EngenGovernanceTest is SharedSetup { vm.prank(_owner); _engenCredits.setCredits(addresses, points); // We Create the proposal - (UserOperation[] memory userOps, uint256 hashProposal) = + (PackedUserOperation[] memory userOps, uint256 hashProposal) = mintCreditsAndcreateProposal(10e18, "First ENIP Proposal"); _entryPoint.handleOps(userOps, payable(_owner)); vm.warp(block.timestamp + 1 days + 1 seconds); @@ -93,7 +93,7 @@ contract EngenGovernanceTest is SharedSetup { function mintCreditsAndcreateProposal(uint256 credits, string memory proposalDescription) internal - returns (UserOperation[] memory, uint256) + returns (PackedUserOperation[] memory, uint256) { { // set points @@ -106,7 +106,7 @@ contract EngenGovernanceTest is SharedSetup { } // mint credit - UserOperation[] memory userOps = new UserOperation[](2); + PackedUserOperation[] memory userOps = new PackedUserOperation[](2); userOps[0] = _createUserOperation( address(_kintoWallet), address(_engenCredits), diff --git a/test/unit/inflate/Inflator.t.sol b/test/unit/inflate/Inflator.t.sol index 994d57479..40c448e9e 100644 --- a/test/unit/inflate/Inflator.t.sol +++ b/test/unit/inflate/Inflator.t.sol @@ -16,7 +16,7 @@ contract InflatorTest is SharedSetup { function testInflate() public { // 1. create user op - UserOperation memory op = _createUserOperation( + PackedUserOperation memory op = _createUserOperation( block.chainid, address(_kintoWallet), address(counter), @@ -33,25 +33,15 @@ contract InflatorTest is SharedSetup { bytes memory compressed = _inflator.compress(op); // 3. decompress (inflate) user op - UserOperation memory decompressed = _inflator.inflate(compressed); + PackedUserOperation memory decompressed = _inflator.inflate(compressed); // assert that the decompressed user op is the same as the original - assertEq(decompressed.sender, op.sender); - assertEq(decompressed.nonce, op.nonce); - assertEq(decompressed.initCode, op.initCode); - assertEq(decompressed.callData, op.callData); - assertEq(decompressed.callGasLimit, op.callGasLimit); - assertEq(decompressed.verificationGasLimit, op.verificationGasLimit); - assertEq(decompressed.preVerificationGas, op.preVerificationGas); - assertEq(decompressed.maxFeePerGas, op.maxFeePerGas); - assertEq(decompressed.maxPriorityFeePerGas, op.maxPriorityFeePerGas); - assertEq(decompressed.paymasterAndData, op.paymasterAndData); - assertEq(decompressed.signature, op.signature); + assertUserOperation(op, decompressed); } function testInflate_WhenDeployContract() public { // 1. create user op - UserOperation memory op = _createUserOperation( + PackedUserOperation memory op = _createUserOperation( address(_kintoWallet), address(_walletFactory), _kintoWallet.getNonce(), @@ -66,25 +56,15 @@ contract InflatorTest is SharedSetup { bytes memory compressed = _inflator.compress(op); // 3. decompress (inflate) user op - UserOperation memory decompressed = _inflator.inflate(compressed); + PackedUserOperation memory decompressed = _inflator.inflate(compressed); // assert that the decompressed user op is the same as the original - assertEq(decompressed.sender, op.sender); - assertEq(decompressed.nonce, op.nonce); - assertEq(decompressed.initCode, op.initCode); - assertEq(decompressed.callData, op.callData); - assertEq(decompressed.callGasLimit, op.callGasLimit); - assertEq(decompressed.verificationGasLimit, op.verificationGasLimit); - assertEq(decompressed.preVerificationGas, op.preVerificationGas); - assertEq(decompressed.maxFeePerGas, op.maxFeePerGas); - assertEq(decompressed.maxPriorityFeePerGas, op.maxPriorityFeePerGas); - assertEq(decompressed.paymasterAndData, op.paymasterAndData); - assertEq(decompressed.signature, op.signature); + assertUserOperation(op, decompressed); } function testInflate_WhenTargetEqualsSender() public { // 1. create user op - UserOperation memory op = _createUserOperation( + PackedUserOperation memory op = _createUserOperation( address(_kintoWallet), address(_kintoWallet), _kintoWallet.getNonce(), @@ -97,25 +77,15 @@ contract InflatorTest is SharedSetup { bytes memory compressed = _inflator.compress(op); // 3. decompress (inflate) user op - UserOperation memory decompressed = _inflator.inflate(compressed); + PackedUserOperation memory decompressed = _inflator.inflate(compressed); // assert that the decompressed user op is the same as the original - assertEq(decompressed.sender, op.sender); - assertEq(decompressed.nonce, op.nonce); - assertEq(decompressed.initCode, op.initCode); - assertEq(decompressed.callData, op.callData); - assertEq(decompressed.callGasLimit, op.callGasLimit); - assertEq(decompressed.verificationGasLimit, op.verificationGasLimit); - assertEq(decompressed.preVerificationGas, op.preVerificationGas); - assertEq(decompressed.maxFeePerGas, op.maxFeePerGas); - assertEq(decompressed.maxPriorityFeePerGas, op.maxPriorityFeePerGas); - assertEq(decompressed.paymasterAndData, op.paymasterAndData); - assertEq(decompressed.signature, op.signature); + assertUserOperation(op, decompressed); } function testInflate_WhenNoPaymaster() public { // 1. create user op - UserOperation memory op = _createUserOperation( + PackedUserOperation memory op = _createUserOperation( address(_kintoWallet), address(_kintoWallet), _kintoWallet.getNonce(), @@ -128,20 +98,10 @@ contract InflatorTest is SharedSetup { bytes memory compressed = _inflator.compress(op); // 3. decompress (inflate) user op - UserOperation memory decompressed = _inflator.inflate(compressed); + PackedUserOperation memory decompressed = _inflator.inflate(compressed); // assert that the decompressed user op is the same as the original - assertEq(decompressed.sender, op.sender); - assertEq(decompressed.nonce, op.nonce); - assertEq(decompressed.initCode, op.initCode); - assertEq(decompressed.callData, op.callData); - assertEq(decompressed.callGasLimit, op.callGasLimit); - assertEq(decompressed.verificationGasLimit, op.verificationGasLimit); - assertEq(decompressed.preVerificationGas, op.preVerificationGas); - assertEq(decompressed.maxFeePerGas, op.maxFeePerGas); - assertEq(decompressed.maxPriorityFeePerGas, op.maxPriorityFeePerGas); - assertEq(decompressed.paymasterAndData, op.paymasterAndData); - assertEq(decompressed.signature, op.signature); + assertUserOperation(op, decompressed); } function testInflate_WhenTargetIsKintoContract() public { @@ -149,7 +109,7 @@ contract InflatorTest is SharedSetup { _inflator.setKintoContract("KAR", address(_kintoAppRegistry)); // 1. create user op - UserOperation memory op = _createUserOperation( + PackedUserOperation memory op = _createUserOperation( address(_kintoWallet), address(_kintoAppRegistry), _kintoWallet.getNonce(), @@ -162,20 +122,10 @@ contract InflatorTest is SharedSetup { bytes memory compressed = _inflator.compress(op); // 3. decompress (inflate) user op - UserOperation memory decompressed = _inflator.inflate(compressed); + PackedUserOperation memory decompressed = _inflator.inflate(compressed); // assert that the decompressed user op is the same as the original - assertEq(decompressed.sender, op.sender); - assertEq(decompressed.nonce, op.nonce); - assertEq(decompressed.initCode, op.initCode); - assertEq(decompressed.callData, op.callData); - assertEq(decompressed.callGasLimit, op.callGasLimit); - assertEq(decompressed.verificationGasLimit, op.verificationGasLimit); - assertEq(decompressed.preVerificationGas, op.preVerificationGas); - assertEq(decompressed.maxFeePerGas, op.maxFeePerGas); - assertEq(decompressed.maxPriorityFeePerGas, op.maxPriorityFeePerGas); - assertEq(decompressed.paymasterAndData, op.paymasterAndData); - assertEq(decompressed.signature, op.signature); + assertUserOperation(op, decompressed); } function testInflate_WhenExecuteBatch() public { @@ -193,7 +143,7 @@ contract InflatorTest is SharedSetup { calls[1] = abi.encodeWithSignature("increment()"); OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); - UserOperation memory op = _createUserOperation( + PackedUserOperation memory op = _createUserOperation( address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(_paymaster) ); @@ -201,20 +151,10 @@ contract InflatorTest is SharedSetup { bytes memory compressed = _inflator.compress(op); // 3. decompress (inflate) user op - UserOperation memory decompressed = _inflator.inflate(compressed); + PackedUserOperation memory decompressed = _inflator.inflate(compressed); // assert that the decompressed user op is the same as the original - assertEq(decompressed.sender, op.sender); - assertEq(decompressed.nonce, op.nonce); - assertEq(decompressed.initCode, op.initCode); - assertEq(decompressed.callData, op.callData); - assertEq(decompressed.callGasLimit, op.callGasLimit); - assertEq(decompressed.verificationGasLimit, op.verificationGasLimit); - assertEq(decompressed.preVerificationGas, op.preVerificationGas); - assertEq(decompressed.maxFeePerGas, op.maxFeePerGas); - assertEq(decompressed.maxPriorityFeePerGas, op.maxPriorityFeePerGas); - assertEq(decompressed.paymasterAndData, op.paymasterAndData); - assertEq(decompressed.signature, op.signature); + assertUserOperation(op, decompressed); } function testInflate_WhenCustomGasParams() public { @@ -232,38 +172,29 @@ contract InflatorTest is SharedSetup { calls[1] = abi.encodeWithSignature("increment()"); OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); - UserOperation memory op = _createUserOperation( + PackedUserOperation memory op = _createUserOperation( address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(_paymaster) ); - op.callGasLimit = 250_000; - op.verificationGasLimit = 230_000; + + op.accountGasLimits = packAccountGasLimits(230_000, 250_000); + op.gasFees = packAccountGasLimits(690_000, 138_000_000); op.preVerificationGas = 1_500_000; - op.maxFeePerGas = 138_000_000; - op.maxPriorityFeePerGas = 690_000; // 2. compress user op bytes memory compressed = _inflator.compress(op); + console2.logBytes(compressed); // 3. decompress (inflate) user op - UserOperation memory decompressed = _inflator.inflate(compressed); + PackedUserOperation memory decompressed = _inflator.inflate(compressed); + console2.log("decompressed.sender:", decompressed.sender); // assert that the decompressed user op is the same as the original - assertEq(decompressed.sender, op.sender); - assertEq(decompressed.nonce, op.nonce); - assertEq(decompressed.initCode, op.initCode); - assertEq(decompressed.callData, op.callData); - assertEq(decompressed.callGasLimit, op.callGasLimit); - assertEq(decompressed.verificationGasLimit, op.verificationGasLimit); - assertEq(decompressed.preVerificationGas, op.preVerificationGas); - assertEq(decompressed.maxFeePerGas, op.maxFeePerGas); - assertEq(decompressed.maxPriorityFeePerGas, op.maxPriorityFeePerGas); - assertEq(decompressed.paymasterAndData, op.paymasterAndData); - assertEq(decompressed.signature, op.signature); + assertUserOperation(op, decompressed); } function testInflate_WhenSimpleInflate() public { // 1. create user op - UserOperation memory op = _createUserOperation( + PackedUserOperation memory op = _createUserOperation( block.chainid, address(_kintoWallet), address(counter), @@ -279,19 +210,21 @@ contract InflatorTest is SharedSetup { // 2. compress user op bytes memory compressedSimple = _inflator.compressSimple(op); - UserOperation memory decompressedSimple = _inflator.inflateSimple(compressedSimple); + PackedUserOperation memory decompressed = _inflator.inflateSimple(compressedSimple); // assert that the decompressed user op is the same as the original - assertEq(decompressedSimple.sender, op.sender); - assertEq(decompressedSimple.nonce, op.nonce); - assertEq(decompressedSimple.initCode, op.initCode); - assertEq(decompressedSimple.callData, op.callData); - assertEq(decompressedSimple.callGasLimit, op.callGasLimit); - assertEq(decompressedSimple.verificationGasLimit, op.verificationGasLimit); - assertEq(decompressedSimple.preVerificationGas, op.preVerificationGas); - assertEq(decompressedSimple.maxFeePerGas, op.maxFeePerGas); - assertEq(decompressedSimple.maxPriorityFeePerGas, op.maxPriorityFeePerGas); - assertEq(decompressedSimple.paymasterAndData, op.paymasterAndData); - assertEq(decompressedSimple.signature, op.signature); + assertUserOperation(op, decompressed); + } + + function assertUserOperation(PackedUserOperation memory op, PackedUserOperation memory decompressed) internal { + assertEq(decompressed.sender, op.sender, "Invalid sender"); + assertEq(decompressed.nonce, op.nonce, "Invalid nonce"); + assertEq(decompressed.initCode, op.initCode, "Invalid initCode"); + assertEq(decompressed.callData, op.callData, "Invalid callData"); + assertEq(decompressed.accountGasLimits, op.accountGasLimits, "Invalid accountGasLimits"); + assertEq(decompressed.gasFees, op.gasFees, "Invalid gasFees"); + assertEq(decompressed.preVerificationGas, op.preVerificationGas, "Invalid preVerificationGas"); + assertEq(decompressed.paymasterAndData, op.paymasterAndData, "Invalid paymasterAndData"); + assertEq(decompressed.signature, op.signature, "Invalid signature"); } } diff --git a/test/unit/tokens/EngenBadges.t.sol b/test/unit/tokens/EngenBadges.t.sol index 0b40b089c..2ad0d289b 100644 --- a/test/unit/tokens/EngenBadges.t.sol +++ b/test/unit/tokens/EngenBadges.t.sol @@ -23,7 +23,7 @@ contract EngenBadgesTest is SharedSetup { whitelistApp(address(_engenBadges)); - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_engenBadges), @@ -50,7 +50,7 @@ contract EngenBadgesTest is SharedSetup { ids[0] = 1; ids[1] = 2; - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_engenBadges), @@ -92,7 +92,7 @@ contract EngenBadgesTest is SharedSetup { function testMint_RevertWhen_NoIds() public { uint256[] memory ids = new uint256[](0); - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_engenBadges), @@ -122,7 +122,7 @@ contract EngenBadgesTest is SharedSetup { ids[i][1] = 2; } - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_engenBadges), @@ -155,7 +155,7 @@ contract EngenBadgesTest is SharedSetup { ids[i][1] = 2; } - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_engenBadges), @@ -175,7 +175,7 @@ contract EngenBadgesTest is SharedSetup { address[] memory recipients = new address[](elements); uint256[][] memory ids = new uint256[][](elements); - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_engenBadges), @@ -205,7 +205,7 @@ contract EngenBadgesTest is SharedSetup { ids[i][1] = 2; } - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_engenBadges), @@ -350,7 +350,7 @@ contract EngenBadgesTest is SharedSetup { uint256[] memory ids = new uint256[](1); ids[0] = 1; - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_engenBadges), @@ -375,7 +375,7 @@ contract EngenBadgesTest is SharedSetup { ids[0] = 1; ids[1] = 2; - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_engenBadges), diff --git a/test/unit/viewers/KYCViewer.t.sol b/test/unit/viewers/KYCViewer.t.sol index 531d5ba6c..b7c6df237 100644 --- a/test/unit/viewers/KYCViewer.t.sol +++ b/test/unit/viewers/KYCViewer.t.sol @@ -23,7 +23,6 @@ contract KYCViewerTest is SharedSetup { function testUp() public override { super.testUp(); assertEq(_kycViewer.owner(), _owner); - assertEq(address(_entryPoint.walletFactory()), address(_kycViewer.walletFactory())); assertEq(address(_walletFactory.kintoID()), address(_kycViewer.kintoID())); assertEq(address(_engenCredits), address(_kycViewer.engenCredits())); } diff --git a/test/unit/viewers/WalletViewer.t.sol b/test/unit/viewers/WalletViewer.t.sol index 6fb2200b8..34b6d5a4a 100644 --- a/test/unit/viewers/WalletViewer.t.sol +++ b/test/unit/viewers/WalletViewer.t.sol @@ -24,7 +24,6 @@ contract WalletViewerUpgraded is WalletViewer { contract WalletViewerTest is SharedSetup { function testUp() public view override { assertEq(_walletViewer.owner(), _owner); - assertEq(address(_entryPoint.walletFactory()), address(_walletViewer.walletFactory())); assertEq(address(_walletFactory.kintoID()), address(_walletViewer.kintoID())); } diff --git a/test/unit/wallet/AppKey.t.sol b/test/unit/wallet/AppKey.t.sol index 1e5609ef6..8401ce865 100644 --- a/test/unit/wallet/AppKey.t.sol +++ b/test/unit/wallet/AppKey.t.sol @@ -8,7 +8,7 @@ contract AppKeyTest is SharedSetup { /* ============ App Key ============ */ function testSetAppKey() public { - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_kintoWallet), @@ -30,7 +30,7 @@ contract AppKeyTest is SharedSetup { // make sure app is not whitelisted whitelistApp(address(_engenCredits), false); - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_kintoWallet), @@ -54,7 +54,7 @@ contract AppKeyTest is SharedSetup { } function testSetAppKey_RevertWhen_InvalidApp() public { - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_kintoWallet), @@ -77,7 +77,7 @@ contract AppKeyTest is SharedSetup { function testSetAppKey_RevertWhen_InvalidSigner() public { whitelistApp(address(_engenCredits), true); - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(_kintoWallet), diff --git a/test/unit/wallet/Execute.t.sol b/test/unit/wallet/Execute.t.sol index f51d0dbe0..229df5009 100644 --- a/test/unit/wallet/Execute.t.sol +++ b/test/unit/wallet/Execute.t.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.18; import "@kinto-core-test/SharedSetup.t.sol"; -import {IEntryPoint} from "@aa/core/BaseAccount.sol"; +import {IEntryPoint} from "@aa/interfaces/IEntryPoint.sol"; contract ExecuteTest is SharedSetup { address public systemApp; @@ -30,14 +30,14 @@ contract ExecuteTest is SharedSetup { vm.deal(address(_kintoWallet), 0); // send a transaction to the counter contract through our wallet without a paymaster and without prefunding the wallet - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(counter), _kintoWallet.getNonce(), privateKeys, abi.encodeWithSignature("increment()") ); - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = userOp; vm.expectRevert(abi.encodeWithSignature("FailedOp(uint256,string)", 0, "AA21 didn't pay prefund")); @@ -49,7 +49,7 @@ contract ExecuteTest is SharedSetup { vm.deal(address(_kintoWallet), 1 ether); // send op without a paymaster but prefunding the wallet - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(counter), @@ -64,7 +64,7 @@ contract ExecuteTest is SharedSetup { function testExecute_WhenMultipleOps_WhenPaymaster() public { uint256 nonce = _kintoWallet.getNonce(); - UserOperation[] memory userOps = new UserOperation[](2); + PackedUserOperation[] memory userOps = new PackedUserOperation[](2); userOps[0] = _createUserOperation( address(_kintoWallet), address(counter), @@ -93,7 +93,7 @@ contract ExecuteTest is SharedSetup { Counter other = new Counter(); - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), address(other), diff --git a/test/unit/wallet/ExecuteBatch.t.sol b/test/unit/wallet/ExecuteBatch.t.sol index 9d5610e88..8f7f5df61 100644 --- a/test/unit/wallet/ExecuteBatch.t.sol +++ b/test/unit/wallet/ExecuteBatch.t.sol @@ -54,9 +54,9 @@ contract ExecuteBatchTest is SharedSetup { calls[0] = abi.encodeWithSignature("increment()"); OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); - UserOperation memory userOp = + PackedUserOperation memory userOp = _createUserOperation(address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(0)); - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = userOp; vm.expectRevert(abi.encodeWithSignature("FailedOp(uint256,string)", 0, "AA21 didn't pay prefund")); @@ -79,7 +79,7 @@ contract ExecuteBatchTest is SharedSetup { calls[0] = abi.encodeWithSignature("increment()"); OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation(address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(0)); @@ -103,7 +103,7 @@ contract ExecuteBatchTest is SharedSetup { calls[1] = abi.encodeWithSignature("increment()"); OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(_paymaster) ); @@ -155,7 +155,7 @@ contract ExecuteBatchTest is SharedSetup { calls[0] = abi.encodeWithSignature("recoverer()"); OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(_paymaster) ); @@ -186,7 +186,7 @@ contract ExecuteBatchTest is SharedSetup { calls[1] = abi.encodeWithSignature("increment()"); OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(_paymaster) ); diff --git a/test/unit/wallet/Upgrade.t.sol b/test/unit/wallet/Upgrade.t.sol index ffa702cf5..1d2cb5cba 100644 --- a/test/unit/wallet/Upgrade.t.sol +++ b/test/unit/wallet/Upgrade.t.sol @@ -14,7 +14,7 @@ contract UpgradeTest is SharedSetup { KintoWallet _newImplementation = new KintoWallet(_entryPoint, _kintoID, _kintoAppRegistry, _walletFactory); // try calling upgradeTo from _owner wallet to upgrade _owner wallet - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(_kintoWallet), _kintoWallet.getNonce(), @@ -22,7 +22,7 @@ contract UpgradeTest is SharedSetup { abi.encodeWithSignature("upgradeTo(address)", address(_newImplementation)), address(_paymaster) ); - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = userOp; // execute the transaction via the entry point and expect a revert event @@ -47,7 +47,7 @@ contract UpgradeTest is SharedSetup { // try calling upgradeTo from _user wallet to upgrade _owner wallet privateKeys[0] = _userPk; - UserOperation[] memory userOps = new UserOperation[](1); + PackedUserOperation[] memory userOps = new PackedUserOperation[](1); userOps[0] = _createUserOperation( address(userWallet), address(_kintoWallet), diff --git a/test/unit/wallet/ValidateSignature.t.sol b/test/unit/wallet/ValidateSignature.t.sol index d46c59871..751d14f1c 100644 --- a/test/unit/wallet/ValidateSignature.t.sol +++ b/test/unit/wallet/ValidateSignature.t.sol @@ -3,12 +3,9 @@ pragma solidity ^0.8.18; import "@kinto-core-test/SharedSetup.t.sol"; +import {SIG_VALIDATION_FAILED, SIG_VALIDATION_SUCCESS} from "@aa/core/Helpers.sol"; contract ValidateSignatureTest is SharedSetup { - // constants - uint256 constant SIG_VALIDATION_FAILED = 1; - uint256 constant SIG_VALIDATION_SUCCESS = 0; - function setUp() public override { super.setUp(); useHarness(); @@ -17,7 +14,7 @@ contract ValidateSignatureTest is SharedSetup { function testValidateSignature_RevertWhen_OwnerIsNotKYCd() public { revokeKYC(_kycProvider, _owner, _ownerPk); - UserOperation memory userOp; + PackedUserOperation memory userOp; assertEq( SIG_VALIDATION_FAILED, KintoWalletHarness(payable(address(_kintoWallet))).validateSignature( @@ -29,7 +26,7 @@ contract ValidateSignatureTest is SharedSetup { function testValidateSignature_RevertWhen_SignatureLengthMismatch() public { revokeKYC(_kycProvider, _owner, _ownerPk); - UserOperation memory userOp; + PackedUserOperation memory userOp; assertEq( SIG_VALIDATION_FAILED, KintoWalletHarness(payable(address(_kintoWallet))).validateSignature( @@ -41,7 +38,7 @@ contract ValidateSignatureTest is SharedSetup { function testValidateSignature_RevertWhen_UsingAppKey_SignatureLengthMismatch() public { revokeKYC(_kycProvider, _owner, _ownerPk); - UserOperation memory userOp; + PackedUserOperation memory userOp; assertEq( SIG_VALIDATION_FAILED, KintoWalletHarness(payable(address(_kintoWallet))).validateSignature( @@ -66,7 +63,7 @@ contract ValidateSignatureTest is SharedSetup { privateKeys[0] = _ownerPk; // call increment - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(counter), _kintoWallet.getNonce(), @@ -87,7 +84,7 @@ contract ValidateSignatureTest is SharedSetup { // function testValidateSignature_WhenOneSignerPolicy_WhenMultipleOwners_WhenOneSigner() public {} function testValidateSignature_WhenMultipleOwners_When1SignerPolicy() public { - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(counter), _kintoWallet.getNonce(), @@ -119,7 +116,7 @@ contract ValidateSignatureTest is SharedSetup { privateKeys[1] = _userPk; // create increment user op - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(counter), _kintoWallet.getNonce(), @@ -150,7 +147,7 @@ contract ValidateSignatureTest is SharedSetup { privateKeys[1] = _userPk; // create op with wrong private keys - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(counter), _kintoWallet.getNonce() + 1, @@ -175,7 +172,7 @@ contract ValidateSignatureTest is SharedSetup { resetSigners(owners, _kintoWallet.ALL_SIGNERS()); // create op with wrong private keys - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(counter), _kintoWallet.getNonce(), @@ -207,7 +204,7 @@ contract ValidateSignatureTest is SharedSetup { privateKeys[2] = _user2Pk; // create op with wrong private keys - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(counter), _kintoWallet.getNonce() + 1, @@ -245,7 +242,7 @@ contract ValidateSignatureTest is SharedSetup { calls[2] = abi.encodeWithSignature("increment()"); OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(_paymaster) ); @@ -285,7 +282,7 @@ contract ValidateSignatureTest is SharedSetup { calls[2] = abi.encodeWithSignature("increment()"); OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(_paymaster) ); @@ -326,7 +323,7 @@ contract ValidateSignatureTest is SharedSetup { calls[2] = abi.encodeWithSignature("increment()"); OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(_paymaster) ); @@ -376,7 +373,7 @@ contract ValidateSignatureTest is SharedSetup { calls[3] = abi.encodeWithSignature("increment()"); OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(_paymaster) ); @@ -410,7 +407,7 @@ contract ValidateSignatureTest is SharedSetup { calls[2] = abi.encodeWithSignature("increment()"); OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(_paymaster) ); @@ -445,7 +442,7 @@ contract ValidateSignatureTest is SharedSetup { calls[limit + 1] = abi.encodeWithSignature("increment()"); OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(_paymaster) ); @@ -469,7 +466,7 @@ contract ValidateSignatureTest is SharedSetup { // create user op with app key as signer privateKeys[0] = _userPk; - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(counter), _kintoWallet.getNonce(), @@ -502,7 +499,7 @@ contract ValidateSignatureTest is SharedSetup { // create user op with the app key as signer privateKeys[0] = _userPk; - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(counter), _kintoWallet.getNonce(), @@ -530,7 +527,7 @@ contract ValidateSignatureTest is SharedSetup { // create Counter increment transaction privateKeys[0] = _userPk; // we want to make use of the app key - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(_kintoWallet), _kintoWallet.getNonce(), @@ -554,7 +551,7 @@ contract ValidateSignatureTest is SharedSetup { setAppKey(address(counter), _user); // create user op with the owner as signer - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(counter), _kintoWallet.getNonce(), @@ -579,7 +576,7 @@ contract ValidateSignatureTest is SharedSetup { setAppKey(address(counter), _user); // try doing a wallet call and it should work - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(_kintoWallet), _kintoWallet.getNonce(), @@ -615,7 +612,7 @@ contract ValidateSignatureTest is SharedSetup { OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); privateKeys[0] = _userPk; // we want to make use of the app key - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(_paymaster) ); @@ -654,7 +651,7 @@ contract ValidateSignatureTest is SharedSetup { OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); privateKeys[0] = _userPk; // we want to make use of the app key - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(_paymaster) ); @@ -696,7 +693,7 @@ contract ValidateSignatureTest is SharedSetup { } OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); privateKeys[0] = _userPk; // we want to make use of the app key - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(_paymaster) ); @@ -746,7 +743,7 @@ contract ValidateSignatureTest is SharedSetup { values[CALLS_NUMBER - 1] = 0; OperationParamsBatch memory opParams = OperationParamsBatch({targets: targets, values: values, bytesOps: calls}); - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), _kintoWallet.getNonce(), privateKeys, opParams, address(_paymaster) ); @@ -775,7 +772,7 @@ contract ValidateSignatureTest is SharedSetup { privateKeys[0] = _ownerPk; privateKeys[1] = _userPk; - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(counter), _kintoWallet.getNonce(), @@ -826,7 +823,7 @@ contract ValidateSignatureTest is SharedSetup { privateKeys[0] = _userPk; privateKeys[1] = _user2Pk; - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(counter), _kintoWallet.getNonce(), @@ -878,7 +875,7 @@ contract ValidateSignatureTest is SharedSetup { privateKeys = new uint256[](1); privateKeys[0] = _userPk; - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(counter), _kintoWallet.getNonce(), @@ -914,7 +911,7 @@ contract ValidateSignatureTest is SharedSetup { privateKeys[1] = _userPk; privateKeys[2] = _user2Pk; - UserOperation memory userOp = _createUserOperation( + PackedUserOperation memory userOp = _createUserOperation( address(_kintoWallet), address(counter), _kintoWallet.getNonce(), @@ -945,7 +942,7 @@ contract ValidateSignatureTest is SharedSetup { // privateKeys = new uint256[](1); // privateKeys[0] = _userPk; - // UserOperation memory userOp = _createUserOperation( + // PackedUserOperation memory userOp = _createUserOperation( // address(_kintoWallet), // address(counter), // _kintoWallet.getNonce(), diff --git a/yarn.lock b/yarn.lock index ddf24ee6e..20970a464 100644 --- a/yarn.lock +++ b/yarn.lock @@ -428,11 +428,6 @@ fastify-plugin "^4.0.0" ws "^8.0.0" -"@gnosis.pm/safe-contracts@^1.3.0": - version "1.3.0" - resolved "https://registry.yarnpkg.com/@gnosis.pm/safe-contracts/-/safe-contracts-1.3.0.tgz#316741a7690d8751a1f701538cfc9ec80866eedc" - integrity sha512-1p+1HwGvxGUVzVkFjNzglwHrLNA67U/axP0Ct85FzzH8yhGJb4t9jDjPYocVMzLorDoWAfKicGy1akPY9jXRVw== - "@grpc/grpc-js@^1.7.1": version "1.11.1" resolved "https://registry.yarnpkg.com/@grpc/grpc-js/-/grpc-js-1.11.1.tgz#a92f33e98f1959feffcd1b25a33b113d2c977b70" @@ -898,11 +893,6 @@ resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.8.3.tgz#cbef3146bfc570849405f59cba18235da95a252a" integrity sha512-bQHV8R9Me8IaJoJ2vPG4rXcL7seB7YVuskr4f+f5RyOStSZetwzkWtoqDMl5erkBJy0lDRUnIR2WIkPiC0GJlg== -"@openzeppelin/contracts@^4.2.0": - version "4.9.6" - resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.9.6.tgz#2a880a24eb19b4f8b25adc2a5095f2aa27f39677" - integrity sha512-xSmezSupL+y9VkHZJGDoCBpmnB2ogM13ccaYDWqJTfS3dbuHkgjuwDFUmaFauBCboQMGB/S5UqUl2y54X99BmA== - "@openzeppelin/contracts@^5.0.0": version "5.0.2" resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-5.0.2.tgz#b1d03075e49290d06570b2fd42154d76c2a5d210" @@ -1270,25 +1260,6 @@ abstract-logging@^2.0.1: table "^6.8.0" typescript "^4.3.5" -"account-abstraction@https://github.com/KintoXYZ/account-abstraction.git#61f677923ad7ed0ed5b87d2c20100a7079dba63a": - version "0.6.0" - resolved "https://github.com/KintoXYZ/account-abstraction.git#61f677923ad7ed0ed5b87d2c20100a7079dba63a" - dependencies: - "@gnosis.pm/safe-contracts" "^1.3.0" - "@nomiclabs/hardhat-etherscan" "^2.1.6" - "@openzeppelin/contracts" "^4.2.0" - "@thehubbleproject/bls" "^0.5.1" - "@typechain/hardhat" "^2.3.0" - "@types/mocha" "^9.0.0" - ethereumjs-util "^7.1.0" - ethereumjs-wallet "^1.0.1" - hardhat-deploy "^0.11.23" - hardhat-deploy-ethers "^0.3.0-beta.11" - solidity-coverage "^0.8.4" - source-map-support "^0.5.19" - table "^6.8.0" - typescript "^4.3.5" - acorn-import-assertions@^1.9.0: version "1.9.0" resolved "https://registry.yarnpkg.com/acorn-import-assertions/-/acorn-import-assertions-1.9.0.tgz#507276249d684797c84e0734ef84860334cfb1ac"