From bcf27ccc57374b0eda81aec24e8dcfed732f6dd0 Mon Sep 17 00:00:00 2001 From: JaredBorders Date: Tue, 7 Nov 2023 11:34:54 -0500 Subject: [PATCH 01/17] =?UTF-8?q?=F0=9F=91=B7=F0=9F=8F=BB=E2=80=8D?= =?UTF-8?q?=E2=99=82=EF=B8=8F=20Add=20IERC7412?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/kwenta/smv3/EIP7412.sol | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/kwenta/smv3/EIP7412.sol diff --git a/src/kwenta/smv3/EIP7412.sol b/src/kwenta/smv3/EIP7412.sol new file mode 100644 index 0000000..b95d3f1 --- /dev/null +++ b/src/kwenta/smv3/EIP7412.sol @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +pragma solidity 0.8.18; + +import {IERC7412} from "./IERC7412.sol"; + +/// @title Kwenta Smart Margin v3: EIP-7412 Utility Contract +/// @notice Responsible for fulfilling EIP-7412 oracle queries +/// @author JaredBorders (jaredborders@pm.me) +contract EIP7412 { + /// @notice Fulfill an EIP-7412 oracle query + /// @param EIP7412Implementer The address of the EIP-7412 implementer + /// @param signedOffchainData The data that was returned + /// from the off-chain interface, signed by the oracle + function fulfillOracleQuery( + address EIP7412Implementer, + bytes calldata signedOffchainData + ) external payable { + IERC7412(EIP7412Implementer).fulfillOracleQuery(signedOffchainData); + } +} From 1ae6d7aa94b5217ea163a2ff75f7fad09a2e72a0 Mon Sep 17 00:00:00 2001 From: JaredBorders Date: Tue, 7 Nov 2023 11:35:36 -0500 Subject: [PATCH 02/17] =?UTF-8?q?=F0=9F=91=B7=F0=9F=8F=BB=E2=80=8D?= =?UTF-8?q?=E2=99=82=EF=B8=8F=20Replace=20IERC7412=20with=20EIP7412?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/SMv3SessionValidationModule.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SMv3SessionValidationModule.sol b/src/SMv3SessionValidationModule.sol index 331038f..22cf3bb 100644 --- a/src/SMv3SessionValidationModule.sol +++ b/src/SMv3SessionValidationModule.sol @@ -3,7 +3,7 @@ pragma solidity 0.8.18; import {ECDSA} from "src/openzeppelin/ECDSA.sol"; import {IEngine} from "src/kwenta/smv3/IEngine.sol"; -import {IERC7412} from "src/kwenta/smv3/IERC7412.sol"; +import {EIP7412} from "src/kwenta/smv3/EIP7412.sol"; import { ISessionValidationModule, UserOperation @@ -49,7 +49,7 @@ contract SMv3SessionValidationModule is ISessionValidationModule { funcSelector != IEngine.modifyCollateral.selector && funcSelector != IEngine.commitOrder.selector && funcSelector != IEngine.invalidateUnorderedNonces.selector - && funcSelector != IERC7412.fulfillOracleQuery.selector + && funcSelector != EIP7412.fulfillOracleQuery.selector && funcSelector != IEngine.depositEth.selector && funcSelector != IEngine.withdrawEth.selector ) { @@ -121,7 +121,7 @@ contract SMv3SessionValidationModule is ISessionValidationModule { funcSelector != IEngine.modifyCollateral.selector && funcSelector != IEngine.commitOrder.selector && funcSelector != IEngine.invalidateUnorderedNonces.selector - && funcSelector != IERC7412.fulfillOracleQuery.selector + && funcSelector != EIP7412.fulfillOracleQuery.selector && funcSelector != IEngine.depositEth.selector && funcSelector != IEngine.withdrawEth.selector ) { From 889c6f57137aea0f4f6c8c8fb3daecd9c1d50bf9 Mon Sep 17 00:00:00 2001 From: JaredBorders Date: Tue, 7 Nov 2023 11:35:47 -0500 Subject: [PATCH 03/17] =?UTF-8?q?=E2=9C=85=20Update=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/SMv3SessionValidationModule.t.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/SMv3SessionValidationModule.t.sol b/test/SMv3SessionValidationModule.t.sol index b9a3eb9..2b03976 100644 --- a/test/SMv3SessionValidationModule.t.sol +++ b/test/SMv3SessionValidationModule.t.sol @@ -10,7 +10,7 @@ import { UserOperationLib } from "test/utils/UserOperationSignature.sol"; import {IEngine} from "src/kwenta/smv3/IEngine.sol"; -import {IERC7412} from "src/kwenta/smv3/IERC7412.sol"; +import {EIP7412} from "src/kwenta/smv3/EIP7412.sol"; contract SMv3SessionValidationModuleTest is Bootstrap { address signer; @@ -73,7 +73,7 @@ contract SMv3SessionValidationModuleTest is Bootstrap { validSelectors.push(IEngine.modifyCollateral.selector); validSelectors.push(IEngine.commitOrder.selector); validSelectors.push(IEngine.invalidateUnorderedNonces.selector); - validSelectors.push(IERC7412.fulfillOracleQuery.selector); + validSelectors.push(EIP7412.fulfillOracleQuery.selector); validSelectors.push(IEngine.depositEth.selector); validSelectors.push(IEngine.withdrawEth.selector); } From 523710073b96eb2d5cba2da1472a909faea36859 Mon Sep 17 00:00:00 2001 From: JaredBorders Date: Tue, 7 Nov 2023 11:36:04 -0500 Subject: [PATCH 04/17] =?UTF-8?q?=E2=9A=99=EF=B8=8F=20Update=20package=20s?= =?UTF-8?q?cripts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index e380a82..54dd8df 100644 --- a/package.json +++ b/package.json @@ -5,12 +5,12 @@ "homepage": "https://github.com/Kwenta/scw-contracts#readme", "scripts": { "compile": "forge build", - "test": "forge test --fork-url $(grep OPTIMISM_GOERLI_RPC_URL .env | cut -d '=' -f2) --etherscan-api-key $(grep OPTIMISM_ETHERSCAN_API_KEY .env | cut -d '=' -f2) --gas-report -vvv", + "test": "forge test --gas-report -vvv", "format": "forge fmt", - "coverage": "forge coverage --fork-url $(grep OPTIMISM_GOERLI_RPC_URL .env | cut -d '=' -f2)", - "coverage:generate-lcov": "forge coverage --fork-url $(grep OPTIMISM_GOERLI_RPC_URL .env | cut -d '=' -f2) --report lcov", + "coverage": "forge coverage", + "coverage:generate-lcov": "forge coverage --report lcov", "analysis:slither": "slither .", - "gas-snapshot": "forge snapshot --fork-url $(grep OPTIMISM_GOERLI_RPC_URL .env | cut -d '=' -f2)", + "gas-snapshot": "forge snapshot", "decode-custom-error": "npx @usecannon/cli decode synthetix-perps-market" }, "repository": { From c915eb76ed640e4ad97056493cdaf8afefac5e6d Mon Sep 17 00:00:00 2001 From: JaredBorders Date: Tue, 7 Nov 2023 11:36:20 -0500 Subject: [PATCH 05/17] =?UTF-8?q?=F0=9F=93=B8=20Update=20gas-snapshot/lcov?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gas-snapshot | 20 +++--- lcov.info | 168 ++++++++++++++++++++++++++------------------------ 2 files changed, 98 insertions(+), 90 deletions(-) diff --git a/.gas-snapshot b/.gas-snapshot index ff5f8ed..0a05d3c 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -3,17 +3,17 @@ ValidateSessionParams:test_validateSessionParams() (gas: 76317) ValidateSessionParams:test_validateSessionParams_callValue_invalid(uint256) (runs: 256, μ: 107033, ~: 107033) ValidateSessionParams:test_validateSessionParams_destinationContract_invalid(address) (runs: 256, μ: 30633, ~: 30633) ValidateSessionParams:test_validateSessionParams_destinationContract_invalid(address) (runs: 256, μ: 30641, ~: 30641) -ValidateSessionParams:test_validateSessionParams_funcCallData_invalid(bytes4) (runs: 256, μ: 24502, ~: 24502) -ValidateSessionParams:test_validateSessionParams_funcCallData_invalid(bytes4) (runs: 256, μ: 39815, ~: 39928) +ValidateSessionParams:test_validateSessionParams_funcCallData_invalid() (gas: 24048) +ValidateSessionParams:test_validateSessionParams_funcCallData_invalid() (gas: 37702) ValidateSessionParams:test_validateSessionParams_sessionKeyData_invalid(address,address) (runs: 256, μ: 31495, ~: 31495) ValidateSessionParams:test_validateSessionParams_sessionKeyData_invalid(address,address) (runs: 256, μ: 31633, ~: 31633) ValidateSessionUserOp:test_validateSessionUserOp() (gas: 308778) -ValidateSessionUserOp:test_validateSessionUserOp() (gas: 71829) -ValidateSessionUserOp:test_validateSessionUserOp_op_callData_invalid(bytes4,address,uint256) (runs: 256, μ: 130244, ~: 130244) -ValidateSessionUserOp:test_validateSessionUserOp_op_callData_invalid(bytes4,address,uint256) (runs: 256, μ: 282952, ~: 282231) -ValidateSessionUserOp:test_validateSessionUserOp_sessionKeyData_invalid(address,address) (runs: 256, μ: 93063, ~: 93082) -ValidateSessionUserOp:test_validateSessionUserOp_sessionKeyData_invalid(address,address) (runs: 256, μ: 95222, ~: 95260) -ValidateSessionUserOp:test_validateSessionUserOp_sessionKeySignature_invalid(uint256) (runs: 256, μ: 82854, ~: 82854) -ValidateSessionUserOp:test_validateSessionUserOp_sessionKeySignature_invalid(uint256) (runs: 256, μ: 83024, ~: 83024) -ValidateSessionUserOp:test_validateSessionUserOp_userOpHash_invalid(bytes32) (runs: 256, μ: 74764, ~: 74764) +ValidateSessionUserOp:test_validateSessionUserOp() (gas: 71771) +ValidateSessionUserOp:test_validateSessionUserOp_op_callData_invalid(address) (runs: 256, μ: 114525, ~: 114525) +ValidateSessionUserOp:test_validateSessionUserOp_op_callData_invalid(address,uint256) (runs: 256, μ: 280385, ~: 282121) +ValidateSessionUserOp:test_validateSessionUserOp_sessionKeyData_invalid(address,address) (runs: 256, μ: 93021, ~: 93040) +ValidateSessionUserOp:test_validateSessionUserOp_sessionKeyData_invalid(address,address) (runs: 256, μ: 95216, ~: 95216) +ValidateSessionUserOp:test_validateSessionUserOp_sessionKeySignature_invalid(uint256) (runs: 256, μ: 82818, ~: 82818) +ValidateSessionUserOp:test_validateSessionUserOp_sessionKeySignature_invalid(uint256) (runs: 256, μ: 83046, ~: 83046) +ValidateSessionUserOp:test_validateSessionUserOp_userOpHash_invalid(bytes32) (runs: 256, μ: 74706, ~: 74706) ValidateSessionUserOp:test_validateSessionUserOp_userOpHash_invalid(bytes32) (runs: 256, μ: 74934, ~: 74934) \ No newline at end of file diff --git a/lcov.info b/lcov.info index d47961c..346f42a 100644 --- a/lcov.info +++ b/lcov.info @@ -1,23 +1,23 @@ TN: SF:script/Deploy.s.sol -FN:62,DeployOptimism.run -FNDA:0,DeployOptimism.run -DA:63,0 -DA:64,0 -DA:66,0 -DA:68,0 FN:48,DeployBaseGoerli.run FNDA:0,DeployBaseGoerli.run DA:49,0 DA:50,0 DA:52,0 DA:54,0 -FN:34,DeployBase.run -FNDA:0,DeployBase.run -DA:35,0 -DA:36,0 -DA:38,0 -DA:40,0 +FN:62,DeployOptimism.run +FNDA:0,DeployOptimism.run +DA:63,0 +DA:64,0 +DA:66,0 +DA:68,0 +FN:77,DeployOptimismGoerli.run +FNDA:0,DeployOptimismGoerli.run +DA:78,0 +DA:79,0 +DA:81,0 +DA:83,0 FN:18,Setup.deploySystem FNDA:0,Setup.deploySystem DA:19,0 @@ -25,12 +25,12 @@ DA:20,0 DA:21,0 DA:22,0 DA:23,0 -FN:77,DeployOptimismGoerli.run -FNDA:0,DeployOptimismGoerli.run -DA:78,0 -DA:79,0 -DA:81,0 -DA:83,0 +FN:34,DeployBase.run +FNDA:0,DeployBase.run +DA:35,0 +DA:36,0 +DA:38,0 +DA:40,0 FNF:5 FNH:0 LF:21 @@ -40,74 +40,70 @@ BRH:0 end_of_record TN: SF:src/SMv2SessionValidationModule.sol -FN:29,SMv2SessionValidationModule.validateSessionParams -FNDA:1025,SMv2SessionValidationModule.validateSessionParams -DA:36,1025 -DA:37,1025 -DA:40,1025 -BRDA:40,0,0,512 -BRDA:40,0,1,513 -DA:41,512 -DA:45,513 -BRDA:45,1,0,256 -BRDA:45,1,1,257 -DA:46,256 -DA:49,257 -FN:62,SMv2SessionValidationModule.validateSessionUserOp -FNDA:2049,SMv2SessionValidationModule.validateSessionUserOp -DA:70,2049 -DA:71,256 -BRDA:69,2,0,256 -BRDA:69,2,1,1793 -DA:73,256 -DA:76,1793 -DA:77,1793 -DA:79,1793 -DA:85,1793 -BRDA:85,3,0,512 -BRDA:85,3,1,1281 -DA:86,512 -DA:90,1281 -BRDA:90,4,0,256 -BRDA:90,4,1,1025 -DA:91,256 +FN:28,SMv2SessionValidationModule.validateSessionParams +FNDA:770,SMv2SessionValidationModule.validateSessionParams +DA:35,770 +DA:36,770 +DA:39,770 +BRDA:39,0,0,512 +BRDA:39,0,1,258 +DA:40,512 +DA:44,258 +BRDA:44,1,0,1 +BRDA:44,1,1,257 +DA:45,1 +DA:48,257 +FN:61,SMv2SessionValidationModule.validateSessionUserOp +FNDA:1793,SMv2SessionValidationModule.validateSessionUserOp +DA:69,1793 +DA:70,256 +BRDA:68,2,0,256 +BRDA:68,2,1,1537 +DA:72,256 +DA:75,1537 +DA:76,1537 +DA:78,1537 +DA:84,1537 +BRDA:84,3,0,512 +BRDA:84,3,1,1025 +DA:85,512 +DA:90,1025 +DA:92,1025 +DA:93,1025 +DA:94,1025 DA:96,1025 -DA:98,1025 -DA:99,1025 DA:100,1025 -DA:102,1025 -DA:106,1025 -BRDA:106,5,0,256 -BRDA:106,5,1,769 -DA:107,256 -DA:112,769 +BRDA:100,4,0,256 +BRDA:100,4,1,769 +DA:101,256 +DA:106,769 FNF:2 FNH:2 -LF:25 -LH:25 -BRF:12 -BRH:12 +LF:23 +LH:23 +BRF:10 +BRH:10 end_of_record TN: SF:src/SMv3SessionValidationModule.sol FN:31,SMv3SessionValidationModule.validateSessionParams -FNDA:2566,SMv3SessionValidationModule.validateSessionParams -DA:38,2566 -DA:39,2566 -DA:42,2566 +FNDA:2311,SMv3SessionValidationModule.validateSessionParams +DA:38,2311 +DA:39,2311 +DA:42,2311 BRDA:42,0,0,512 -BRDA:42,0,1,2054 +BRDA:42,0,1,1799 DA:43,512 -DA:47,2054 -DA:49,2054 -DA:50,1541 -DA:51,1284 -DA:52,1027 -DA:53,770 -DA:54,513 -BRDA:48,1,0,256 +DA:47,1799 +DA:49,1799 +DA:50,1286 +DA:51,1029 +DA:52,772 +DA:53,515 +DA:54,258 +BRDA:48,1,0,1 BRDA:48,1,1,1798 -DA:56,256 +DA:56,1 DA:60,1798 BRDA:60,2,0,256 BRDA:60,2,1,1 @@ -202,6 +198,18 @@ BRF:2 BRH:0 end_of_record TN: +SF:src/kwenta/smv3/EIP7412.sol +FN:14,EIP7412.fulfillOracleQuery +FNDA:0,EIP7412.fulfillOracleQuery +DA:18,0 +FNF:1 +FNH:0 +LF:1 +LH:0 +BRF:0 +BRH:0 +end_of_record +TN: SF:src/openzeppelin/ECDSA.sol FN:56,ECDSA.tryRecover FNDA:1543,ECDSA.tryRecover @@ -338,6 +346,11 @@ BRH:0 end_of_record TN: SF:test/utils/Bootstrap.sol +FN:40,BootstrapOptimismGoerli.init +FNDA:0,BootstrapOptimismGoerli.init +DA:41,0 +DA:44,0 +DA:46,0 FN:23,Bootstrap.initializeOptimismGoerli FNDA:0,Bootstrap.initializeOptimismGoerli DA:24,0 @@ -345,11 +358,6 @@ DA:25,0 DA:28,0 DA:30,0 DA:32,0 -FN:40,BootstrapOptimismGoerli.init -FNDA:0,BootstrapOptimismGoerli.init -DA:41,0 -DA:44,0 -DA:46,0 FNF:2 FNH:0 LF:8 From 6ba2c7985e423f848c81130edeebeb81e3f430ed Mon Sep 17 00:00:00 2001 From: JaredBorders Date: Tue, 7 Nov 2023 11:39:45 -0500 Subject: [PATCH 06/17] =?UTF-8?q?=F0=9F=9A=80=20Update=20testnet=20deploym?= =?UTF-8?q?ents?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deployments/BaseGoerli.json | 4 ++-- deployments/Optimism.json | 4 ++-- deployments/OptimismGoerli.json | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/deployments/BaseGoerli.json b/deployments/BaseGoerli.json index 02b3a06..b0ef373 100644 --- a/deployments/BaseGoerli.json +++ b/deployments/BaseGoerli.json @@ -1,4 +1,4 @@ { - "SMv2SessionValidationModule": "0x690ef7a21816A6570d0b500b805bc7ea190E5188", - "SMv3SessionValidationModule": "0xBEc5605040987e52E99c6F97787c7822814b73ca" + "SMv2SessionValidationModule": "0x58F4219F2f73214fC453c4332eC6EB1744f0fd78", + "SMv3SessionValidationModule": "0xf1BC9852e89e0b6ABa81548A10c0afF9ACa95CaA" } \ No newline at end of file diff --git a/deployments/Optimism.json b/deployments/Optimism.json index 6a6ce82..4230fe1 100644 --- a/deployments/Optimism.json +++ b/deployments/Optimism.json @@ -1,4 +1,4 @@ { - "SMv2SessionValidationModule": "0xBB959E12f9cDd7ba5EcEC3662063D9B97f44208a", - "SMv3SessionValidationModule": "0xf349243bDe8b0Aeee0e52Cb3553047Be8F9cE57c" + "SMv2SessionValidationModule": "tbd", + "SMv3SessionValidationModule": "tbd" } \ No newline at end of file diff --git a/deployments/OptimismGoerli.json b/deployments/OptimismGoerli.json index 812077c..8af3b3d 100644 --- a/deployments/OptimismGoerli.json +++ b/deployments/OptimismGoerli.json @@ -1,4 +1,4 @@ { - "SMv2SessionValidationModule": "0x5D283bE42cEA50cC74F6CeD79A9844efa34F8A5D", - "SMv3SessionValidationModule": "0xAE55743B6Df1df7194a708460950851a74910D9F" + "SMv2SessionValidationModule": "0x1eE6c365adcEA067A691E5Dd2c70039fF7F2AcE8", + "SMv3SessionValidationModule": "0x11118Ad5B3A0F19ccc17358873Aa6E96F43F9bD4" } \ No newline at end of file From 530868f1c1e14e8bae601e389f90ea7d6669852f Mon Sep 17 00:00:00 2001 From: JaredBorders Date: Tue, 7 Nov 2023 14:21:53 -0500 Subject: [PATCH 07/17] =?UTF-8?q?=F0=9F=93=9A=20Update=20comments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/SMv2SessionValidationModule.sol | 5 ++++- src/SMv3SessionValidationModule.sol | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/SMv2SessionValidationModule.sol b/src/SMv2SessionValidationModule.sol index ea8624c..05f0810 100644 --- a/src/SMv2SessionValidationModule.sol +++ b/src/SMv2SessionValidationModule.sol @@ -64,7 +64,10 @@ contract SMv2SessionValidationModule is ISessionValidationModule { bytes calldata _sessionKeyData, bytes calldata _sessionKeySignature ) external pure override returns (bool) { - /// @dev ensure function selector is `IAccount.execute` + /// @dev ensure function selector either + /// `execute(address,uint256,bytes)` + /// or + /// `execute_ncC(address,uint256,bytes)` if ( bytes4(_op.callData[0:4]) != EXECUTE_SELECTOR && bytes4(_op.callData[0:4]) != EXECUTE_OPTIMIZED_SELECTOR diff --git a/src/SMv3SessionValidationModule.sol b/src/SMv3SessionValidationModule.sol index 22cf3bb..f8f04bd 100644 --- a/src/SMv3SessionValidationModule.sol +++ b/src/SMv3SessionValidationModule.sol @@ -84,7 +84,10 @@ contract SMv3SessionValidationModule is ISessionValidationModule { bytes calldata _sessionKeyData, bytes calldata _sessionKeySignature ) external pure override returns (bool) { - /// @dev ensure function selector is `IAccount.execute` + /// @dev ensure function selector either + /// `execute(address,uint256,bytes)` + /// or + /// `execute_ncC(address,uint256,bytes)` if ( bytes4(_op.callData[0:4]) != EXECUTE_SELECTOR && bytes4(_op.callData[0:4]) != EXECUTE_OPTIMIZED_SELECTOR From 08afe5caab9525cab403a86f103e97fdc431957b Mon Sep 17 00:00:00 2001 From: JaredBorders Date: Tue, 7 Nov 2023 14:24:51 -0500 Subject: [PATCH 08/17] =?UTF-8?q?=F0=9F=9A=80=20Update=20testnet=20deploym?= =?UTF-8?q?ents?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deployments/BaseGoerli.json | 4 ++-- deployments/OptimismGoerli.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/deployments/BaseGoerli.json b/deployments/BaseGoerli.json index b0ef373..509ec46 100644 --- a/deployments/BaseGoerli.json +++ b/deployments/BaseGoerli.json @@ -1,4 +1,4 @@ { - "SMv2SessionValidationModule": "0x58F4219F2f73214fC453c4332eC6EB1744f0fd78", - "SMv3SessionValidationModule": "0xf1BC9852e89e0b6ABa81548A10c0afF9ACa95CaA" + "SMv2SessionValidationModule": "0x64Db098EDbB149DBe99900c96CC73b6F9A1Af2db", + "SMv3SessionValidationModule": "0x9dc88774AbDFba9EB7B4BB2026C6C250a1ad52CB" } \ No newline at end of file diff --git a/deployments/OptimismGoerli.json b/deployments/OptimismGoerli.json index 8af3b3d..60b8125 100644 --- a/deployments/OptimismGoerli.json +++ b/deployments/OptimismGoerli.json @@ -1,4 +1,4 @@ { - "SMv2SessionValidationModule": "0x1eE6c365adcEA067A691E5Dd2c70039fF7F2AcE8", - "SMv3SessionValidationModule": "0x11118Ad5B3A0F19ccc17358873Aa6E96F43F9bD4" + "SMv2SessionValidationModule": "0xF4243f4d3F8014DE6A085F901d3Fc32339f7A088", + "SMv3SessionValidationModule": "0xF463a18aC17864bc916BDF1d02911601cA5d8d44" } \ No newline at end of file From c10101d59f0d9915ae314416e5f994ad99257f6c Mon Sep 17 00:00:00 2001 From: insuline Date: Fri, 10 Nov 2023 16:10:58 +0300 Subject: [PATCH 09/17] =?UTF-8?q?=E2=9C=A8=20Add=20payable=20param=20for?= =?UTF-8?q?=20fulfillQuery?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/SMv3SessionValidationModule.sol | 72 +++++++++++++++++------------ 1 file changed, 42 insertions(+), 30 deletions(-) diff --git a/src/SMv3SessionValidationModule.sol b/src/SMv3SessionValidationModule.sol index f8f04bd..af5a6e9 100644 --- a/src/SMv3SessionValidationModule.sol +++ b/src/SMv3SessionValidationModule.sol @@ -4,10 +4,7 @@ pragma solidity 0.8.18; import {ECDSA} from "src/openzeppelin/ECDSA.sol"; import {IEngine} from "src/kwenta/smv3/IEngine.sol"; import {EIP7412} from "src/kwenta/smv3/EIP7412.sol"; -import { - ISessionValidationModule, - UserOperation -} from "src/biconomy/interfaces/ISessionValidationModule.sol"; +import {ISessionValidationModule, UserOperation} from "src/biconomy/interfaces/ISessionValidationModule.sol"; /** * @title Kwenta Smart Margin v3 Session Validation Module for Biconomy Smart Accounts @@ -35,8 +32,10 @@ contract SMv3SessionValidationModule is ISessionValidationModule { bytes calldata _sessionKeyData, bytes calldata /*_callSpecificData*/ ) external pure override returns (address) { - (address sessionKey, address smv3Engine) = - abi.decode(_sessionKeyData, (address, address)); + (address sessionKey, address smv3Engine) = abi.decode( + _sessionKeyData, + (address, address) + ); /// @dev ensure destinationContract is the smv3Engine if (destinationContract != smv3Engine) { @@ -46,21 +45,25 @@ contract SMv3SessionValidationModule is ISessionValidationModule { /// @dev ensure the function selector is the a valid IEngine selector bytes4 funcSelector = bytes4(_funcCallData[0:4]); if ( - funcSelector != IEngine.modifyCollateral.selector - && funcSelector != IEngine.commitOrder.selector - && funcSelector != IEngine.invalidateUnorderedNonces.selector - && funcSelector != EIP7412.fulfillOracleQuery.selector - && funcSelector != IEngine.depositEth.selector - && funcSelector != IEngine.withdrawEth.selector + funcSelector != IEngine.modifyCollateral.selector && + funcSelector != IEngine.commitOrder.selector && + funcSelector != IEngine.invalidateUnorderedNonces.selector && + funcSelector != EIP7412.fulfillOracleQuery.selector && + funcSelector != IEngine.depositEth.selector && + funcSelector != IEngine.withdrawEth.selector ) { revert InvalidSMv3Selector(); } - /// @dev ensure call value is zero unless calling IEngine.depositEth + /// @dev ensure call value is zero unless calling IEngine.depositEth or EIP7412.fulfillOracleQuery if (funcSelector == IEngine.depositEth.selector) { if (callValue == 0) { revert InvalidCallValue(); } + } else if (funcSelector == EIP7412.fulfillOracleQuery.selector) { + if (callValue == 0) { + revert InvalidCallValue(); + } } else if (callValue != 0) { revert InvalidCallValue(); } @@ -89,16 +92,18 @@ contract SMv3SessionValidationModule is ISessionValidationModule { /// or /// `execute_ncC(address,uint256,bytes)` if ( - bytes4(_op.callData[0:4]) != EXECUTE_SELECTOR - && bytes4(_op.callData[0:4]) != EXECUTE_OPTIMIZED_SELECTOR + bytes4(_op.callData[0:4]) != EXECUTE_SELECTOR && + bytes4(_op.callData[0:4]) != EXECUTE_OPTIMIZED_SELECTOR ) { revert InvalidSelector(); } - (address sessionKey, address smv3Engine) = - abi.decode(_sessionKeyData, (address, address)); + (address sessionKey, address smv3Engine) = abi.decode( + _sessionKeyData, + (address, address) + ); - (address destinationContract, uint256 callValue,) = abi.decode( + (address destinationContract, uint256 callValue, ) = abi.decode( _op.callData[4:], // skip selector; already checked (address, uint256, bytes) ); @@ -113,37 +118,44 @@ contract SMv3SessionValidationModule is ISessionValidationModule { bytes calldata data; { uint256 offset = uint256(bytes32(_op.callData[4 + 64:4 + 96])); - uint256 length = - uint256(bytes32(_op.callData[4 + offset:4 + offset + 32])); + uint256 length = uint256( + bytes32(_op.callData[4 + offset:4 + offset + 32]) + ); data = _op.callData[4 + offset + 32:4 + offset + 32 + length]; } /// @dev ensure the function selector is the a valid IEngine selector bytes4 funcSelector = bytes4(data[0:4]); if ( - funcSelector != IEngine.modifyCollateral.selector - && funcSelector != IEngine.commitOrder.selector - && funcSelector != IEngine.invalidateUnorderedNonces.selector - && funcSelector != EIP7412.fulfillOracleQuery.selector - && funcSelector != IEngine.depositEth.selector - && funcSelector != IEngine.withdrawEth.selector + funcSelector != IEngine.modifyCollateral.selector && + funcSelector != IEngine.commitOrder.selector && + funcSelector != IEngine.invalidateUnorderedNonces.selector && + funcSelector != EIP7412.fulfillOracleQuery.selector && + funcSelector != IEngine.depositEth.selector && + funcSelector != IEngine.withdrawEth.selector ) { revert InvalidSMv3Selector(); } - /// @dev ensure call value is zero unless calling IEngine.depositEth + /// @dev ensure call value is zero unless calling IEngine.depositEth or EIP7412.fulfillOracleQuery if (funcSelector == IEngine.depositEth.selector) { if (callValue == 0) { revert InvalidCallValue(); } + } else if (funcSelector == EIP7412.fulfillOracleQuery.selector) { + if (callValue == 0) { + revert InvalidCallValue(); + } } else if (callValue != 0) { revert InvalidCallValue(); } /// @dev this method of signature validation is out-of-date /// see https://github.com/OpenZeppelin/openzeppelin-sdk/blob/7d96de7248ae2e7e81a743513ccc617a2e6bba21/packages/lib/contracts/cryptography/ECDSA.sol#L6 - return ECDSA.recover( - ECDSA.toEthSignedMessageHash(_userOpHash), _sessionKeySignature - ) == sessionKey; + return + ECDSA.recover( + ECDSA.toEthSignedMessageHash(_userOpHash), + _sessionKeySignature + ) == sessionKey; } } From 7fc63c734a288f5201c3f2bf84eaec4dac17d971 Mon Sep 17 00:00:00 2001 From: insuline Date: Fri, 10 Nov 2023 16:11:07 +0300 Subject: [PATCH 10/17] =?UTF-8?q?=E2=9C=85=20Update=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/SMv3SessionValidationModule.t.sol | 156 +++++++++++++++++-------- 1 file changed, 108 insertions(+), 48 deletions(-) diff --git a/test/SMv3SessionValidationModule.t.sol b/test/SMv3SessionValidationModule.t.sol index 2b03976..b1a75dc 100644 --- a/test/SMv3SessionValidationModule.t.sol +++ b/test/SMv3SessionValidationModule.t.sol @@ -1,14 +1,8 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.18; -import { - Bootstrap, SMv3SessionValidationModule -} from "test/utils/Bootstrap.sol"; -import { - UserOperationSignature, - UserOperation, - UserOperationLib -} from "test/utils/UserOperationSignature.sol"; +import {Bootstrap, SMv3SessionValidationModule} from "test/utils/Bootstrap.sol"; +import {UserOperationSignature, UserOperation, UserOperationLib} from "test/utils/UserOperationSignature.sol"; import {IEngine} from "src/kwenta/smv3/IEngine.sol"; import {EIP7412} from "src/kwenta/smv3/EIP7412.sol"; @@ -56,18 +50,25 @@ contract SMv3SessionValidationModuleTest is Bootstrap { destinationContract = smv3Engine; callValue = 0; /// @notice a valid selector for IEngine - funcCallData = - abi.encode(IEngine.modifyCollateral.selector, bytes32("")); + funcCallData = abi.encode( + IEngine.modifyCollateral.selector, + bytes32("") + ); sessionKeyData = abi.encode(sessionKey, smv3Engine); callSpecificData = ""; // validateSessionUserOp params op.callData = abi.encodeWithSelector( - EXECUTE_SELECTOR, destinationContract, callValue, funcCallData + EXECUTE_SELECTOR, + destinationContract, + callValue, + funcCallData ); userOpHash = userOpSignature.hashUserOperation(op); - sessionKeySignature = - userOpSignature.getUserOperationSignature(op, signerPrivateKey); + sessionKeySignature = userOpSignature.getUserOperationSignature( + op, + signerPrivateKey + ); // define array of valid selectors validSelectors.push(IEngine.modifyCollateral.selector); @@ -87,18 +88,22 @@ contract ValidateSessionParams is SMv3SessionValidationModuleTest { if (validSelectors[i] == IEngine.depositEth.selector) { callValue = 1; // valid for depositEth + } else if ( + validSelectors[i] == EIP7412.fulfillOracleQuery.selector + ) { + callValue = 1; // valid for fulfillOracleQuery } else { callValue = 0; // invalid for depositEth } address retSessionKey = smv3SessionValidationModule .validateSessionParams( - destinationContract, - callValue, - funcCallData, - sessionKeyData, - callSpecificData - ); + destinationContract, + callValue, + funcCallData, + sessionKeyData, + callSpecificData + ); assertEq(sessionKey, retSessionKey); } @@ -135,6 +140,10 @@ contract ValidateSessionParams is SMv3SessionValidationModuleTest { if (validSelectors[i] == IEngine.depositEth.selector) { callValue = 0; // i.e. invalid for depositEth + } else if ( + validSelectors[i] == EIP7412.fulfillOracleQuery.selector + ) { + callValue = 0; // valid for fulfillOracleQuery } else { callValue = invalid_callValue; } @@ -181,24 +190,28 @@ contract ValidateSessionParams is SMv3SessionValidationModuleTest { ) public { vm.assume(invalid_sessionKey != sessionKey); - bytes memory invalid_sessionKeyData = - abi.encode(invalid_sessionKey, destinationContract); + bytes memory invalid_sessionKeyData = abi.encode( + invalid_sessionKey, + destinationContract + ); address retSessionKey = smv3SessionValidationModule .validateSessionParams( - destinationContract, - callValue, - funcCallData, - invalid_sessionKeyData, - callSpecificData - ); + destinationContract, + callValue, + funcCallData, + invalid_sessionKeyData, + callSpecificData + ); assertFalse(retSessionKey == sessionKey); vm.assume(invalid_destinationContract != destinationContract); - invalid_sessionKeyData = - abi.encode(sessionKey, invalid_destinationContract); + invalid_sessionKeyData = abi.encode( + sessionKey, + invalid_destinationContract + ); vm.expectRevert( abi.encodeWithSelector( @@ -224,21 +237,33 @@ contract ValidateSessionUserOp is SMv3SessionValidationModuleTest { if (validSelectors[i] == IEngine.depositEth.selector) { callValue = 1; // valid for depositEth + } else if ( + validSelectors[i] == EIP7412.fulfillOracleQuery.selector + ) { + callValue = 1; // valid for fulfillOracleQuery } else { callValue = 0; // invalid for depositEth } op.callData = abi.encodeWithSelector( - EXECUTE_SELECTOR, destinationContract, callValue, funcCallData + EXECUTE_SELECTOR, + destinationContract, + callValue, + funcCallData ); userOpHash = userOpSignature.hashUserOperation(op); - sessionKeySignature = - userOpSignature.getUserOperationSignature(op, signerPrivateKey); + sessionKeySignature = userOpSignature.getUserOperationSignature( + op, + signerPrivateKey + ); bool ret = smv3SessionValidationModule.validateSessionUserOp( - op, userOpHash, sessionKeyData, sessionKeySignature + op, + userOpHash, + sessionKeyData, + sessionKeySignature ); assertTrue(ret); @@ -252,7 +277,10 @@ contract ValidateSessionUserOp is SMv3SessionValidationModuleTest { bytes4 invalid_selector = 0x12345678; op.callData = abi.encodeWithSelector( - invalid_selector, destinationContract, 1, funcCallData + invalid_selector, + destinationContract, + 1, + funcCallData ); vm.expectRevert( @@ -262,7 +290,10 @@ contract ValidateSessionUserOp is SMv3SessionValidationModuleTest { ); smv3SessionValidationModule.validateSessionUserOp( - op, userOpHash, sessionKeyData, sessionKeySignature + op, + userOpHash, + sessionKeyData, + sessionKeySignature ); vm.assume(invalid_destinationContract != destinationContract); @@ -281,7 +312,10 @@ contract ValidateSessionUserOp is SMv3SessionValidationModuleTest { ); smv3SessionValidationModule.validateSessionUserOp( - op, userOpHash, sessionKeyData, sessionKeySignature + op, + userOpHash, + sessionKeyData, + sessionKeySignature ); vm.assume(invalid_callValue != callValue); @@ -292,6 +326,10 @@ contract ValidateSessionUserOp is SMv3SessionValidationModuleTest { if (validSelectors[i] == IEngine.depositEth.selector) { callValue = 0; // i.e. invalid for depositEth + } else if ( + validSelectors[i] == EIP7412.fulfillOracleQuery.selector + ) { + callValue = 0; // valid for fulfillOracleQuery } else { callValue = invalid_callValue; } @@ -310,12 +348,17 @@ contract ValidateSessionUserOp is SMv3SessionValidationModuleTest { ); smv3SessionValidationModule.validateSessionUserOp( - op, userOpHash, sessionKeyData, sessionKeySignature + op, + userOpHash, + sessionKeyData, + sessionKeySignature ); } - bytes memory invalid_funcCallData = - abi.encode(invalid_selector, bytes32("")); + bytes memory invalid_funcCallData = abi.encode( + invalid_selector, + bytes32("") + ); op.callData = abi.encodeWithSelector( EXECUTE_SELECTOR, @@ -331,7 +374,10 @@ contract ValidateSessionUserOp is SMv3SessionValidationModuleTest { ); smv3SessionValidationModule.validateSessionUserOp( - op, userOpHash, sessionKeyData, sessionKeySignature + op, + userOpHash, + sessionKeyData, + sessionKeySignature ); } @@ -341,7 +387,10 @@ contract ValidateSessionUserOp is SMv3SessionValidationModuleTest { vm.assume(invalid_userOpHash != userOpHash); bool ret = smv3SessionValidationModule.validateSessionUserOp( - op, invalid_userOpHash, sessionKeyData, sessionKeySignature + op, + invalid_userOpHash, + sessionKeyData, + sessionKeySignature ); assertFalse(ret); @@ -353,11 +402,16 @@ contract ValidateSessionUserOp is SMv3SessionValidationModuleTest { ) public { vm.assume(invalid_sessionKey != sessionKey); - bytes memory invalid_sessionKeyData = - abi.encode(invalid_sessionKey, smv3Engine); + bytes memory invalid_sessionKeyData = abi.encode( + invalid_sessionKey, + smv3Engine + ); bool isValid = smv3SessionValidationModule.validateSessionUserOp( - op, userOpHash, invalid_sessionKeyData, sessionKeySignature + op, + userOpHash, + invalid_sessionKeyData, + sessionKeySignature ); assertFalse(isValid); @@ -373,7 +427,10 @@ contract ValidateSessionUserOp is SMv3SessionValidationModuleTest { ); smv3SessionValidationModule.validateSessionUserOp( - op, userOpHash, sessionKeyData, sessionKeySignature + op, + userOpHash, + sessionKeyData, + sessionKeySignature ); } @@ -387,11 +444,14 @@ contract ValidateSessionUserOp is SMv3SessionValidationModuleTest { // test specific vm.assume(invalid_privateKey != signerPrivateKey); - bytes memory invalidSessionKeySignature = - userOpSignature.getUserOperationSignature(op, invalid_privateKey); + bytes memory invalidSessionKeySignature = userOpSignature + .getUserOperationSignature(op, invalid_privateKey); bool isValid = smv3SessionValidationModule.validateSessionUserOp( - op, userOpHash, sessionKeyData, invalidSessionKeySignature + op, + userOpHash, + sessionKeyData, + invalidSessionKeySignature ); assertFalse(isValid); From 2ac513ace9af41ba21cc3c9b972792d5e6b64505 Mon Sep 17 00:00:00 2001 From: insuline Date: Fri, 10 Nov 2023 16:13:23 +0300 Subject: [PATCH 11/17] =?UTF-8?q?=F0=9F=9A=80=20Update=20SMv3ValidationMod?= =?UTF-8?q?ule=20Base=20Goerli=20deployment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deployments/BaseGoerli.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deployments/BaseGoerli.json b/deployments/BaseGoerli.json index 509ec46..d80156b 100644 --- a/deployments/BaseGoerli.json +++ b/deployments/BaseGoerli.json @@ -1,4 +1,4 @@ { "SMv2SessionValidationModule": "0x64Db098EDbB149DBe99900c96CC73b6F9A1Af2db", - "SMv3SessionValidationModule": "0x9dc88774AbDFba9EB7B4BB2026C6C250a1ad52CB" -} \ No newline at end of file + "SMv3SessionValidationModule": "0x56f5bb804cc5b0b2dd483028be21b5af1bdc4a32" +} From 9f6d4d38795ab91dd7d553a0680a23facea4fa33 Mon Sep 17 00:00:00 2001 From: insuline Date: Fri, 10 Nov 2023 16:31:21 +0300 Subject: [PATCH 12/17] =?UTF-8?q?=F0=9F=8E=A8=20Format=20changes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/SMv3SessionValidationModule.sol | 60 +++++----- test/SMv3SessionValidationModule.t.sol | 160 +++++++++---------------- 2 files changed, 84 insertions(+), 136 deletions(-) diff --git a/src/SMv3SessionValidationModule.sol b/src/SMv3SessionValidationModule.sol index af5a6e9..0d92961 100644 --- a/src/SMv3SessionValidationModule.sol +++ b/src/SMv3SessionValidationModule.sol @@ -4,7 +4,10 @@ pragma solidity 0.8.18; import {ECDSA} from "src/openzeppelin/ECDSA.sol"; import {IEngine} from "src/kwenta/smv3/IEngine.sol"; import {EIP7412} from "src/kwenta/smv3/EIP7412.sol"; -import {ISessionValidationModule, UserOperation} from "src/biconomy/interfaces/ISessionValidationModule.sol"; +import { + ISessionValidationModule, + UserOperation +} from "src/biconomy/interfaces/ISessionValidationModule.sol"; /** * @title Kwenta Smart Margin v3 Session Validation Module for Biconomy Smart Accounts @@ -32,10 +35,8 @@ contract SMv3SessionValidationModule is ISessionValidationModule { bytes calldata _sessionKeyData, bytes calldata /*_callSpecificData*/ ) external pure override returns (address) { - (address sessionKey, address smv3Engine) = abi.decode( - _sessionKeyData, - (address, address) - ); + (address sessionKey, address smv3Engine) = + abi.decode(_sessionKeyData, (address, address)); /// @dev ensure destinationContract is the smv3Engine if (destinationContract != smv3Engine) { @@ -45,12 +46,12 @@ contract SMv3SessionValidationModule is ISessionValidationModule { /// @dev ensure the function selector is the a valid IEngine selector bytes4 funcSelector = bytes4(_funcCallData[0:4]); if ( - funcSelector != IEngine.modifyCollateral.selector && - funcSelector != IEngine.commitOrder.selector && - funcSelector != IEngine.invalidateUnorderedNonces.selector && - funcSelector != EIP7412.fulfillOracleQuery.selector && - funcSelector != IEngine.depositEth.selector && - funcSelector != IEngine.withdrawEth.selector + funcSelector != IEngine.modifyCollateral.selector + && funcSelector != IEngine.commitOrder.selector + && funcSelector != IEngine.invalidateUnorderedNonces.selector + && funcSelector != EIP7412.fulfillOracleQuery.selector + && funcSelector != IEngine.depositEth.selector + && funcSelector != IEngine.withdrawEth.selector ) { revert InvalidSMv3Selector(); } @@ -92,18 +93,16 @@ contract SMv3SessionValidationModule is ISessionValidationModule { /// or /// `execute_ncC(address,uint256,bytes)` if ( - bytes4(_op.callData[0:4]) != EXECUTE_SELECTOR && - bytes4(_op.callData[0:4]) != EXECUTE_OPTIMIZED_SELECTOR + bytes4(_op.callData[0:4]) != EXECUTE_SELECTOR + && bytes4(_op.callData[0:4]) != EXECUTE_OPTIMIZED_SELECTOR ) { revert InvalidSelector(); } - (address sessionKey, address smv3Engine) = abi.decode( - _sessionKeyData, - (address, address) - ); + (address sessionKey, address smv3Engine) = + abi.decode(_sessionKeyData, (address, address)); - (address destinationContract, uint256 callValue, ) = abi.decode( + (address destinationContract, uint256 callValue,) = abi.decode( _op.callData[4:], // skip selector; already checked (address, uint256, bytes) ); @@ -118,21 +117,20 @@ contract SMv3SessionValidationModule is ISessionValidationModule { bytes calldata data; { uint256 offset = uint256(bytes32(_op.callData[4 + 64:4 + 96])); - uint256 length = uint256( - bytes32(_op.callData[4 + offset:4 + offset + 32]) - ); + uint256 length = + uint256(bytes32(_op.callData[4 + offset:4 + offset + 32])); data = _op.callData[4 + offset + 32:4 + offset + 32 + length]; } /// @dev ensure the function selector is the a valid IEngine selector bytes4 funcSelector = bytes4(data[0:4]); if ( - funcSelector != IEngine.modifyCollateral.selector && - funcSelector != IEngine.commitOrder.selector && - funcSelector != IEngine.invalidateUnorderedNonces.selector && - funcSelector != EIP7412.fulfillOracleQuery.selector && - funcSelector != IEngine.depositEth.selector && - funcSelector != IEngine.withdrawEth.selector + funcSelector != IEngine.modifyCollateral.selector + && funcSelector != IEngine.commitOrder.selector + && funcSelector != IEngine.invalidateUnorderedNonces.selector + && funcSelector != EIP7412.fulfillOracleQuery.selector + && funcSelector != IEngine.depositEth.selector + && funcSelector != IEngine.withdrawEth.selector ) { revert InvalidSMv3Selector(); } @@ -152,10 +150,8 @@ contract SMv3SessionValidationModule is ISessionValidationModule { /// @dev this method of signature validation is out-of-date /// see https://github.com/OpenZeppelin/openzeppelin-sdk/blob/7d96de7248ae2e7e81a743513ccc617a2e6bba21/packages/lib/contracts/cryptography/ECDSA.sol#L6 - return - ECDSA.recover( - ECDSA.toEthSignedMessageHash(_userOpHash), - _sessionKeySignature - ) == sessionKey; + return ECDSA.recover( + ECDSA.toEthSignedMessageHash(_userOpHash), _sessionKeySignature + ) == sessionKey; } } diff --git a/test/SMv3SessionValidationModule.t.sol b/test/SMv3SessionValidationModule.t.sol index b1a75dc..be19c1c 100644 --- a/test/SMv3SessionValidationModule.t.sol +++ b/test/SMv3SessionValidationModule.t.sol @@ -1,8 +1,14 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.18; -import {Bootstrap, SMv3SessionValidationModule} from "test/utils/Bootstrap.sol"; -import {UserOperationSignature, UserOperation, UserOperationLib} from "test/utils/UserOperationSignature.sol"; +import { + Bootstrap, SMv3SessionValidationModule +} from "test/utils/Bootstrap.sol"; +import { + UserOperationSignature, + UserOperation, + UserOperationLib +} from "test/utils/UserOperationSignature.sol"; import {IEngine} from "src/kwenta/smv3/IEngine.sol"; import {EIP7412} from "src/kwenta/smv3/EIP7412.sol"; @@ -50,25 +56,18 @@ contract SMv3SessionValidationModuleTest is Bootstrap { destinationContract = smv3Engine; callValue = 0; /// @notice a valid selector for IEngine - funcCallData = abi.encode( - IEngine.modifyCollateral.selector, - bytes32("") - ); + funcCallData = + abi.encode(IEngine.modifyCollateral.selector, bytes32("")); sessionKeyData = abi.encode(sessionKey, smv3Engine); callSpecificData = ""; // validateSessionUserOp params op.callData = abi.encodeWithSelector( - EXECUTE_SELECTOR, - destinationContract, - callValue, - funcCallData + EXECUTE_SELECTOR, destinationContract, callValue, funcCallData ); userOpHash = userOpSignature.hashUserOperation(op); - sessionKeySignature = userOpSignature.getUserOperationSignature( - op, - signerPrivateKey - ); + sessionKeySignature = + userOpSignature.getUserOperationSignature(op, signerPrivateKey); // define array of valid selectors validSelectors.push(IEngine.modifyCollateral.selector); @@ -88,9 +87,8 @@ contract ValidateSessionParams is SMv3SessionValidationModuleTest { if (validSelectors[i] == IEngine.depositEth.selector) { callValue = 1; // valid for depositEth - } else if ( - validSelectors[i] == EIP7412.fulfillOracleQuery.selector - ) { + } else if (validSelectors[i] == EIP7412.fulfillOracleQuery.selector) + { callValue = 1; // valid for fulfillOracleQuery } else { callValue = 0; // invalid for depositEth @@ -98,12 +96,12 @@ contract ValidateSessionParams is SMv3SessionValidationModuleTest { address retSessionKey = smv3SessionValidationModule .validateSessionParams( - destinationContract, - callValue, - funcCallData, - sessionKeyData, - callSpecificData - ); + destinationContract, + callValue, + funcCallData, + sessionKeyData, + callSpecificData + ); assertEq(sessionKey, retSessionKey); } @@ -140,9 +138,8 @@ contract ValidateSessionParams is SMv3SessionValidationModuleTest { if (validSelectors[i] == IEngine.depositEth.selector) { callValue = 0; // i.e. invalid for depositEth - } else if ( - validSelectors[i] == EIP7412.fulfillOracleQuery.selector - ) { + } else if (validSelectors[i] == EIP7412.fulfillOracleQuery.selector) + { callValue = 0; // valid for fulfillOracleQuery } else { callValue = invalid_callValue; @@ -190,28 +187,24 @@ contract ValidateSessionParams is SMv3SessionValidationModuleTest { ) public { vm.assume(invalid_sessionKey != sessionKey); - bytes memory invalid_sessionKeyData = abi.encode( - invalid_sessionKey, - destinationContract - ); + bytes memory invalid_sessionKeyData = + abi.encode(invalid_sessionKey, destinationContract); address retSessionKey = smv3SessionValidationModule .validateSessionParams( - destinationContract, - callValue, - funcCallData, - invalid_sessionKeyData, - callSpecificData - ); + destinationContract, + callValue, + funcCallData, + invalid_sessionKeyData, + callSpecificData + ); assertFalse(retSessionKey == sessionKey); vm.assume(invalid_destinationContract != destinationContract); - invalid_sessionKeyData = abi.encode( - sessionKey, - invalid_destinationContract - ); + invalid_sessionKeyData = + abi.encode(sessionKey, invalid_destinationContract); vm.expectRevert( abi.encodeWithSelector( @@ -237,33 +230,24 @@ contract ValidateSessionUserOp is SMv3SessionValidationModuleTest { if (validSelectors[i] == IEngine.depositEth.selector) { callValue = 1; // valid for depositEth - } else if ( - validSelectors[i] == EIP7412.fulfillOracleQuery.selector - ) { + } else if (validSelectors[i] == EIP7412.fulfillOracleQuery.selector) + { callValue = 1; // valid for fulfillOracleQuery } else { callValue = 0; // invalid for depositEth } op.callData = abi.encodeWithSelector( - EXECUTE_SELECTOR, - destinationContract, - callValue, - funcCallData + EXECUTE_SELECTOR, destinationContract, callValue, funcCallData ); userOpHash = userOpSignature.hashUserOperation(op); - sessionKeySignature = userOpSignature.getUserOperationSignature( - op, - signerPrivateKey - ); + sessionKeySignature = + userOpSignature.getUserOperationSignature(op, signerPrivateKey); bool ret = smv3SessionValidationModule.validateSessionUserOp( - op, - userOpHash, - sessionKeyData, - sessionKeySignature + op, userOpHash, sessionKeyData, sessionKeySignature ); assertTrue(ret); @@ -277,10 +261,7 @@ contract ValidateSessionUserOp is SMv3SessionValidationModuleTest { bytes4 invalid_selector = 0x12345678; op.callData = abi.encodeWithSelector( - invalid_selector, - destinationContract, - 1, - funcCallData + invalid_selector, destinationContract, 1, funcCallData ); vm.expectRevert( @@ -290,10 +271,7 @@ contract ValidateSessionUserOp is SMv3SessionValidationModuleTest { ); smv3SessionValidationModule.validateSessionUserOp( - op, - userOpHash, - sessionKeyData, - sessionKeySignature + op, userOpHash, sessionKeyData, sessionKeySignature ); vm.assume(invalid_destinationContract != destinationContract); @@ -312,10 +290,7 @@ contract ValidateSessionUserOp is SMv3SessionValidationModuleTest { ); smv3SessionValidationModule.validateSessionUserOp( - op, - userOpHash, - sessionKeyData, - sessionKeySignature + op, userOpHash, sessionKeyData, sessionKeySignature ); vm.assume(invalid_callValue != callValue); @@ -326,9 +301,8 @@ contract ValidateSessionUserOp is SMv3SessionValidationModuleTest { if (validSelectors[i] == IEngine.depositEth.selector) { callValue = 0; // i.e. invalid for depositEth - } else if ( - validSelectors[i] == EIP7412.fulfillOracleQuery.selector - ) { + } else if (validSelectors[i] == EIP7412.fulfillOracleQuery.selector) + { callValue = 0; // valid for fulfillOracleQuery } else { callValue = invalid_callValue; @@ -348,17 +322,12 @@ contract ValidateSessionUserOp is SMv3SessionValidationModuleTest { ); smv3SessionValidationModule.validateSessionUserOp( - op, - userOpHash, - sessionKeyData, - sessionKeySignature + op, userOpHash, sessionKeyData, sessionKeySignature ); } - bytes memory invalid_funcCallData = abi.encode( - invalid_selector, - bytes32("") - ); + bytes memory invalid_funcCallData = + abi.encode(invalid_selector, bytes32("")); op.callData = abi.encodeWithSelector( EXECUTE_SELECTOR, @@ -374,10 +343,7 @@ contract ValidateSessionUserOp is SMv3SessionValidationModuleTest { ); smv3SessionValidationModule.validateSessionUserOp( - op, - userOpHash, - sessionKeyData, - sessionKeySignature + op, userOpHash, sessionKeyData, sessionKeySignature ); } @@ -387,10 +353,7 @@ contract ValidateSessionUserOp is SMv3SessionValidationModuleTest { vm.assume(invalid_userOpHash != userOpHash); bool ret = smv3SessionValidationModule.validateSessionUserOp( - op, - invalid_userOpHash, - sessionKeyData, - sessionKeySignature + op, invalid_userOpHash, sessionKeyData, sessionKeySignature ); assertFalse(ret); @@ -402,16 +365,11 @@ contract ValidateSessionUserOp is SMv3SessionValidationModuleTest { ) public { vm.assume(invalid_sessionKey != sessionKey); - bytes memory invalid_sessionKeyData = abi.encode( - invalid_sessionKey, - smv3Engine - ); + bytes memory invalid_sessionKeyData = + abi.encode(invalid_sessionKey, smv3Engine); bool isValid = smv3SessionValidationModule.validateSessionUserOp( - op, - userOpHash, - invalid_sessionKeyData, - sessionKeySignature + op, userOpHash, invalid_sessionKeyData, sessionKeySignature ); assertFalse(isValid); @@ -427,10 +385,7 @@ contract ValidateSessionUserOp is SMv3SessionValidationModuleTest { ); smv3SessionValidationModule.validateSessionUserOp( - op, - userOpHash, - sessionKeyData, - sessionKeySignature + op, userOpHash, sessionKeyData, sessionKeySignature ); } @@ -444,14 +399,11 @@ contract ValidateSessionUserOp is SMv3SessionValidationModuleTest { // test specific vm.assume(invalid_privateKey != signerPrivateKey); - bytes memory invalidSessionKeySignature = userOpSignature - .getUserOperationSignature(op, invalid_privateKey); + bytes memory invalidSessionKeySignature = + userOpSignature.getUserOperationSignature(op, invalid_privateKey); bool isValid = smv3SessionValidationModule.validateSessionUserOp( - op, - userOpHash, - sessionKeyData, - invalidSessionKeySignature + op, userOpHash, sessionKeyData, invalidSessionKeySignature ); assertFalse(isValid); From 6abbeef9dc3b9b886bd14d899531ad2ed090ead8 Mon Sep 17 00:00:00 2001 From: JaredBorders Date: Mon, 13 Nov 2023 19:19:02 -0500 Subject: [PATCH 13/17] =?UTF-8?q?=F0=9F=91=B7=F0=9F=8F=BB=E2=80=8D?= =?UTF-8?q?=E2=99=82=EF=B8=8F=20Clean=20up=20logic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/SMv3SessionValidationModule.t.sol | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/test/SMv3SessionValidationModule.t.sol b/test/SMv3SessionValidationModule.t.sol index be19c1c..307bb5e 100644 --- a/test/SMv3SessionValidationModule.t.sol +++ b/test/SMv3SessionValidationModule.t.sol @@ -85,13 +85,15 @@ contract ValidateSessionParams is SMv3SessionValidationModuleTest { // ensure each valid selector is accepted funcCallData = abi.encode(validSelectors[i], bytes32("")); - if (validSelectors[i] == IEngine.depositEth.selector) { - callValue = 1; // valid for depositEth - } else if (validSelectors[i] == EIP7412.fulfillOracleQuery.selector) - { - callValue = 1; // valid for fulfillOracleQuery + if ( + validSelectors[i] == IEngine.depositEth.selector + || validSelectors[i] == EIP7412.fulfillOracleQuery.selector + ) { + // ONLY non-zero call values are valid when + // calling depositEth() or fulfillOracleQuery() + callValue = 1; } else { - callValue = 0; // invalid for depositEth + callValue = 0; } address retSessionKey = smv3SessionValidationModule From 6d5b7fde2ddfbec527c48e3de51b3534d52ba2f1 Mon Sep 17 00:00:00 2001 From: JaredBorders Date: Mon, 13 Nov 2023 19:19:23 -0500 Subject: [PATCH 14/17] =?UTF-8?q?=F0=9F=91=B7=F0=9F=8F=BB=E2=80=8D?= =?UTF-8?q?=E2=99=82=EF=B8=8F=20Clean=20up=20logic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/SMv3SessionValidationModule.sol | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/SMv3SessionValidationModule.sol b/src/SMv3SessionValidationModule.sol index 0d92961..3ffadbd 100644 --- a/src/SMv3SessionValidationModule.sol +++ b/src/SMv3SessionValidationModule.sol @@ -136,11 +136,10 @@ contract SMv3SessionValidationModule is ISessionValidationModule { } /// @dev ensure call value is zero unless calling IEngine.depositEth or EIP7412.fulfillOracleQuery - if (funcSelector == IEngine.depositEth.selector) { - if (callValue == 0) { - revert InvalidCallValue(); - } - } else if (funcSelector == EIP7412.fulfillOracleQuery.selector) { + if ( + funcSelector == IEngine.depositEth.selector + || funcSelector == EIP7412.fulfillOracleQuery.selector + ) { if (callValue == 0) { revert InvalidCallValue(); } From e2b1f4386f09a6b5274b53ecadfac8d7dcb7612a Mon Sep 17 00:00:00 2001 From: JaredBorders Date: Mon, 13 Nov 2023 19:35:32 -0500 Subject: [PATCH 15/17] =?UTF-8?q?=F0=9F=91=B7=F0=9F=8F=BB=E2=80=8D?= =?UTF-8?q?=E2=99=82=EF=B8=8F=20Refactor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/SMv3SessionValidationModule.sol | 88 ++++++++++++++++------------- 1 file changed, 48 insertions(+), 40 deletions(-) diff --git a/src/SMv3SessionValidationModule.sol b/src/SMv3SessionValidationModule.sol index 3ffadbd..58d4221 100644 --- a/src/SMv3SessionValidationModule.sol +++ b/src/SMv3SessionValidationModule.sol @@ -45,29 +45,14 @@ contract SMv3SessionValidationModule is ISessionValidationModule { /// @dev ensure the function selector is the a valid IEngine selector bytes4 funcSelector = bytes4(_funcCallData[0:4]); - if ( - funcSelector != IEngine.modifyCollateral.selector - && funcSelector != IEngine.commitOrder.selector - && funcSelector != IEngine.invalidateUnorderedNonces.selector - && funcSelector != EIP7412.fulfillOracleQuery.selector - && funcSelector != IEngine.depositEth.selector - && funcSelector != IEngine.withdrawEth.selector - ) { - revert InvalidSMv3Selector(); - } - /// @dev ensure call value is zero unless calling IEngine.depositEth or EIP7412.fulfillOracleQuery - if (funcSelector == IEngine.depositEth.selector) { - if (callValue == 0) { - revert InvalidCallValue(); - } - } else if (funcSelector == EIP7412.fulfillOracleQuery.selector) { - if (callValue == 0) { - revert InvalidCallValue(); - } - } else if (callValue != 0) { - revert InvalidCallValue(); - } + // sanitize the selector; ensure it is a valid selector + // that can be called on the smv3Engine) + _sanitizeSelector(funcSelector); + + // sanitize the call value; ensure it is zero unless calling + // IEngine.depositEth or EIP7412.fulfillOracleQuery + _sanitizeCallValue(funcSelector, callValue); return sessionKey; } @@ -122,35 +107,58 @@ contract SMv3SessionValidationModule is ISessionValidationModule { data = _op.callData[4 + offset + 32:4 + offset + 32 + length]; } - /// @dev ensure the function selector is the a valid IEngine selector + // define the function selector bytes4 funcSelector = bytes4(data[0:4]); + + // sanitize the selector; ensure it is a valid selector + // that can be called on the smv3Engine) + _sanitizeSelector(funcSelector); + + // sanitize the call value; ensure it is zero unless calling + // IEngine.depositEth or EIP7412.fulfillOracleQuery + _sanitizeCallValue(funcSelector, callValue); + + /// @dev this method of signature validation is out-of-date + /// see https://github.com/OpenZeppelin/openzeppelin-sdk/blob/7d96de7248ae2e7e81a743513ccc617a2e6bba21/packages/lib/contracts/cryptography/ECDSA.sol#L6 + return ECDSA.recover( + ECDSA.toEthSignedMessageHash(_userOpHash), _sessionKeySignature + ) == sessionKey; + } + + /// @notice sanitize the selector to ensure it is a + /// valid selector that can be called on the smv3Engine + /// @param _selector the selector to sanitize + /// @dev will revert if the selector is not valid + function _sanitizeSelector(bytes4 _selector) internal pure { if ( - funcSelector != IEngine.modifyCollateral.selector - && funcSelector != IEngine.commitOrder.selector - && funcSelector != IEngine.invalidateUnorderedNonces.selector - && funcSelector != EIP7412.fulfillOracleQuery.selector - && funcSelector != IEngine.depositEth.selector - && funcSelector != IEngine.withdrawEth.selector + _selector != IEngine.modifyCollateral.selector + && _selector != IEngine.commitOrder.selector + && _selector != IEngine.invalidateUnorderedNonces.selector + && _selector != EIP7412.fulfillOracleQuery.selector + && _selector != IEngine.depositEth.selector + && _selector != IEngine.withdrawEth.selector ) { revert InvalidSMv3Selector(); } + } - /// @dev ensure call value is zero unless calling IEngine.depositEth or EIP7412.fulfillOracleQuery + /// @notice sanitize the call value to ensure it is zero unless calling + /// IEngine.depositEth or EIP7412.fulfillOracleQuery + /// @param _selector the selector to sanitize + /// @dev will revert if the call value is not valid + function _sanitizeCallValue(bytes4 _selector, uint256 _callValue) + internal + pure + { if ( - funcSelector == IEngine.depositEth.selector - || funcSelector == EIP7412.fulfillOracleQuery.selector + _selector == IEngine.depositEth.selector + || _selector == EIP7412.fulfillOracleQuery.selector ) { - if (callValue == 0) { + if (_callValue == 0) { revert InvalidCallValue(); } - } else if (callValue != 0) { + } else if (_callValue != 0) { revert InvalidCallValue(); } - - /// @dev this method of signature validation is out-of-date - /// see https://github.com/OpenZeppelin/openzeppelin-sdk/blob/7d96de7248ae2e7e81a743513ccc617a2e6bba21/packages/lib/contracts/cryptography/ECDSA.sol#L6 - return ECDSA.recover( - ECDSA.toEthSignedMessageHash(_userOpHash), _sessionKeySignature - ) == sessionKey; } } From 9f9966edb89bc22acd328297134a34625c7f9ba7 Mon Sep 17 00:00:00 2001 From: JaredBorders Date: Mon, 13 Nov 2023 19:35:50 -0500 Subject: [PATCH 16/17] =?UTF-8?q?=F0=9F=93=B8=20Update=20gas-snapshot/lcov?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gas-snapshot | 20 +++--- lcov.info | 179 +++++++++++++++++++++++--------------------------- 2 files changed, 94 insertions(+), 105 deletions(-) diff --git a/.gas-snapshot b/.gas-snapshot index 0a05d3c..df9efbb 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -1,19 +1,19 @@ ValidateSessionParams:test_validateSessionParams() (gas: 29469) -ValidateSessionParams:test_validateSessionParams() (gas: 76317) -ValidateSessionParams:test_validateSessionParams_callValue_invalid(uint256) (runs: 256, μ: 107033, ~: 107033) +ValidateSessionParams:test_validateSessionParams() (gas: 79125) +ValidateSessionParams:test_validateSessionParams_callValue_invalid(uint256) (runs: 256, μ: 109712, ~: 109712) ValidateSessionParams:test_validateSessionParams_destinationContract_invalid(address) (runs: 256, μ: 30633, ~: 30633) ValidateSessionParams:test_validateSessionParams_destinationContract_invalid(address) (runs: 256, μ: 30641, ~: 30641) ValidateSessionParams:test_validateSessionParams_funcCallData_invalid() (gas: 24048) -ValidateSessionParams:test_validateSessionParams_funcCallData_invalid() (gas: 37702) +ValidateSessionParams:test_validateSessionParams_funcCallData_invalid() (gas: 37720) ValidateSessionParams:test_validateSessionParams_sessionKeyData_invalid(address,address) (runs: 256, μ: 31495, ~: 31495) -ValidateSessionParams:test_validateSessionParams_sessionKeyData_invalid(address,address) (runs: 256, μ: 31633, ~: 31633) -ValidateSessionUserOp:test_validateSessionUserOp() (gas: 308778) +ValidateSessionParams:test_validateSessionParams_sessionKeyData_invalid(address,address) (runs: 256, μ: 31733, ~: 31733) +ValidateSessionUserOp:test_validateSessionUserOp() (gas: 311526) ValidateSessionUserOp:test_validateSessionUserOp() (gas: 71771) ValidateSessionUserOp:test_validateSessionUserOp_op_callData_invalid(address) (runs: 256, μ: 114525, ~: 114525) -ValidateSessionUserOp:test_validateSessionUserOp_op_callData_invalid(address,uint256) (runs: 256, μ: 280385, ~: 282121) -ValidateSessionUserOp:test_validateSessionUserOp_sessionKeyData_invalid(address,address) (runs: 256, μ: 93021, ~: 93040) -ValidateSessionUserOp:test_validateSessionUserOp_sessionKeyData_invalid(address,address) (runs: 256, μ: 95216, ~: 95216) +ValidateSessionUserOp:test_validateSessionUserOp_op_callData_invalid(address,uint256) (runs: 256, μ: 283271, ~: 284818) +ValidateSessionUserOp:test_validateSessionUserOp_sessionKeyData_invalid(address,address) (runs: 256, μ: 93040, ~: 93040) +ValidateSessionUserOp:test_validateSessionUserOp_sessionKeyData_invalid(address,address) (runs: 256, μ: 95241, ~: 95316) ValidateSessionUserOp:test_validateSessionUserOp_sessionKeySignature_invalid(uint256) (runs: 256, μ: 82818, ~: 82818) -ValidateSessionUserOp:test_validateSessionUserOp_sessionKeySignature_invalid(uint256) (runs: 256, μ: 83046, ~: 83046) +ValidateSessionUserOp:test_validateSessionUserOp_sessionKeySignature_invalid(uint256) (runs: 256, μ: 83146, ~: 83146) ValidateSessionUserOp:test_validateSessionUserOp_userOpHash_invalid(bytes32) (runs: 256, μ: 74706, ~: 74706) -ValidateSessionUserOp:test_validateSessionUserOp_userOpHash_invalid(bytes32) (runs: 256, μ: 74934, ~: 74934) \ No newline at end of file +ValidateSessionUserOp:test_validateSessionUserOp_userOpHash_invalid(bytes32) (runs: 256, μ: 75034, ~: 75034) \ No newline at end of file diff --git a/lcov.info b/lcov.info index 346f42a..ee2cd3c 100644 --- a/lcov.info +++ b/lcov.info @@ -6,18 +6,18 @@ DA:49,0 DA:50,0 DA:52,0 DA:54,0 -FN:62,DeployOptimism.run -FNDA:0,DeployOptimism.run -DA:63,0 -DA:64,0 -DA:66,0 -DA:68,0 FN:77,DeployOptimismGoerli.run FNDA:0,DeployOptimismGoerli.run DA:78,0 DA:79,0 DA:81,0 DA:83,0 +FN:62,DeployOptimism.run +FNDA:0,DeployOptimism.run +DA:63,0 +DA:64,0 +DA:66,0 +DA:68,0 FN:18,Setup.deploySystem FNDA:0,Setup.deploySystem DA:19,0 @@ -55,28 +55,28 @@ DA:45,1 DA:48,257 FN:61,SMv2SessionValidationModule.validateSessionUserOp FNDA:1793,SMv2SessionValidationModule.validateSessionUserOp -DA:69,1793 -DA:70,256 -BRDA:68,2,0,256 -BRDA:68,2,1,1537 -DA:72,256 -DA:75,1537 -DA:76,1537 +DA:72,1793 +DA:73,256 +BRDA:71,2,0,256 +BRDA:71,2,1,1537 +DA:75,256 DA:78,1537 -DA:84,1537 -BRDA:84,3,0,512 -BRDA:84,3,1,1025 -DA:85,512 -DA:90,1025 -DA:92,1025 +DA:79,1537 +DA:81,1537 +DA:87,1537 +BRDA:87,3,0,512 +BRDA:87,3,1,1025 +DA:88,512 DA:93,1025 -DA:94,1025 +DA:95,1025 DA:96,1025 -DA:100,1025 -BRDA:100,4,0,256 -BRDA:100,4,1,769 -DA:101,256 -DA:106,769 +DA:97,1025 +DA:99,1025 +DA:103,1025 +BRDA:103,4,0,256 +BRDA:103,4,1,769 +DA:104,256 +DA:109,769 FNF:2 FNH:2 LF:23 @@ -95,74 +95,63 @@ BRDA:42,0,0,512 BRDA:42,0,1,1799 DA:43,512 DA:47,1799 -DA:49,1799 -DA:50,1286 -DA:51,1029 -DA:52,772 -DA:53,515 -DA:54,258 -BRDA:48,1,0,1 -BRDA:48,1,1,1798 -DA:56,1 -DA:60,1798 -BRDA:60,2,0,256 -BRDA:60,2,1,1 -DA:61,257 -BRDA:61,3,0,256 -BRDA:61,3,1,1 -DA:62,256 -DA:64,1541 -BRDA:64,4,0,1280 -BRDA:64,4,1,261 -DA:65,1280 -DA:68,262 -FN:81,SMv3SessionValidationModule.validateSessionUserOp +DA:51,1799 +DA:55,1798 +DA:57,262 +FN:70,SMv3SessionValidationModule.validateSessionUserOp FNDA:3334,SMv3SessionValidationModule.validateSessionUserOp -DA:89,3334 -DA:90,256 -BRDA:88,5,0,256 -BRDA:88,5,1,3078 -DA:92,256 -DA:95,3078 +DA:81,3334 +DA:82,256 +BRDA:80,1,0,256 +BRDA:80,1,1,3078 +DA:84,256 +DA:87,3078 +DA:88,3078 +DA:90,3078 DA:96,3078 -DA:98,3078 -DA:104,3078 -BRDA:104,6,0,512 -BRDA:104,6,1,2566 -DA:105,512 -DA:110,2566 -DA:112,2566 -DA:113,2566 -DA:114,2566 +BRDA:96,2,0,512 +BRDA:96,2,1,2566 +DA:97,512 +DA:102,2566 +DA:104,2566 +DA:105,2566 +DA:106,2566 +DA:107,2566 +DA:111,2566 DA:115,2566 -DA:119,2566 -DA:121,2566 -DA:122,1541 -DA:123,1284 -DA:124,1027 -DA:125,770 -DA:126,513 -BRDA:120,7,0,256 -BRDA:120,7,1,2310 -DA:128,256 -DA:132,2310 -BRDA:132,8,0,256 -BRDA:132,8,1,1 -DA:133,257 -BRDA:133,9,0,256 -BRDA:133,9,1,1 -DA:134,256 -DA:136,2053 -BRDA:136,10,0,1280 -BRDA:136,10,1,773 -DA:137,1280 -DA:142,774 -FNF:2 -FNH:2 -LF:45 -LH:45 -BRF:22 -BRH:22 +DA:119,2310 +DA:123,774 +FN:132,SMv3SessionValidationModule._sanitizeSelector +FNDA:4365,SMv3SessionValidationModule._sanitizeSelector +DA:134,4365 +DA:135,2827 +DA:136,2313 +DA:137,1799 +DA:138,1285 +DA:139,771 +BRDA:133,3,0,257 +BRDA:133,3,1,4108 +DA:141,257 +FN:149,SMv3SessionValidationModule._sanitizeCallValue +FNDA:4108,SMv3SessionValidationModule._sanitizeCallValue +DA:154,4108 +DA:155,3594 +BRDA:153,4,0,1024 +BRDA:153,4,1,4 +DA:157,1028 +BRDA:157,5,0,1024 +BRDA:157,5,1,4 +DA:158,1024 +DA:160,3080 +BRDA:160,6,0,2048 +BRDA:160,6,1,1032 +DA:161,2048 +FNF:4 +FNH:4 +LF:38 +LH:38 +BRF:14 +BRH:14 end_of_record TN: SF:src/biconomy/interfaces/UserOperation.sol @@ -346,11 +335,6 @@ BRH:0 end_of_record TN: SF:test/utils/Bootstrap.sol -FN:40,BootstrapOptimismGoerli.init -FNDA:0,BootstrapOptimismGoerli.init -DA:41,0 -DA:44,0 -DA:46,0 FN:23,Bootstrap.initializeOptimismGoerli FNDA:0,Bootstrap.initializeOptimismGoerli DA:24,0 @@ -358,6 +342,11 @@ DA:25,0 DA:28,0 DA:30,0 DA:32,0 +FN:40,BootstrapOptimismGoerli.init +FNDA:0,BootstrapOptimismGoerli.init +DA:41,0 +DA:44,0 +DA:46,0 FNF:2 FNH:0 LF:8 From 0b6bc82463f239f7ca4707fc65f37a3af8dc5726 Mon Sep 17 00:00:00 2001 From: JaredBorders Date: Mon, 13 Nov 2023 19:38:41 -0500 Subject: [PATCH 17/17] =?UTF-8?q?=F0=9F=9A=80=20Update=20testnet=20deploym?= =?UTF-8?q?ents?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deployments/BaseGoerli.json | 2 +- deployments/OptimismGoerli.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/deployments/BaseGoerli.json b/deployments/BaseGoerli.json index d80156b..281ee38 100644 --- a/deployments/BaseGoerli.json +++ b/deployments/BaseGoerli.json @@ -1,4 +1,4 @@ { "SMv2SessionValidationModule": "0x64Db098EDbB149DBe99900c96CC73b6F9A1Af2db", - "SMv3SessionValidationModule": "0x56f5bb804cc5b0b2dd483028be21b5af1bdc4a32" + "SMv3SessionValidationModule": "0x3026c03EEA11204b8dC77969fa36E546f8DC82C9" } diff --git a/deployments/OptimismGoerli.json b/deployments/OptimismGoerli.json index 60b8125..f71e2c2 100644 --- a/deployments/OptimismGoerli.json +++ b/deployments/OptimismGoerli.json @@ -1,4 +1,4 @@ { "SMv2SessionValidationModule": "0xF4243f4d3F8014DE6A085F901d3Fc32339f7A088", - "SMv3SessionValidationModule": "0xF463a18aC17864bc916BDF1d02911601cA5d8d44" + "SMv3SessionValidationModule": "0x25EBde897bA211885982b5e74E8F65F3CDdAfA17" } \ No newline at end of file