Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

👷🏻‍♂️ EIP7412 Fix #2

Merged
merged 17 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -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(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: 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)
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_userOpHash_invalid(bytes32) (runs: 256, μ: 74934, ~: 74934)
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, μ: 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, μ: 83146, ~: 83146)
ValidateSessionUserOp:test_validateSessionUserOp_userOpHash_invalid(bytes32) (runs: 256, μ: 74706, ~: 74706)
ValidateSessionUserOp:test_validateSessionUserOp_userOpHash_invalid(bytes32) (runs: 256, μ: 75034, ~: 75034)
6 changes: 3 additions & 3 deletions deployments/BaseGoerli.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"SMv2SessionValidationModule": "0x690ef7a21816A6570d0b500b805bc7ea190E5188",
"SMv3SessionValidationModule": "0xBEc5605040987e52E99c6F97787c7822814b73ca"
}
"SMv2SessionValidationModule": "0x64Db098EDbB149DBe99900c96CC73b6F9A1Af2db",
"SMv3SessionValidationModule": "0x3026c03EEA11204b8dC77969fa36E546f8DC82C9"
}
4 changes: 2 additions & 2 deletions deployments/Optimism.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"SMv2SessionValidationModule": "0xBB959E12f9cDd7ba5EcEC3662063D9B97f44208a",
"SMv3SessionValidationModule": "0xf349243bDe8b0Aeee0e52Cb3553047Be8F9cE57c"
"SMv2SessionValidationModule": "tbd",
"SMv3SessionValidationModule": "tbd"
}
4 changes: 2 additions & 2 deletions deployments/OptimismGoerli.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"SMv2SessionValidationModule": "0x5D283bE42cEA50cC74F6CeD79A9844efa34F8A5D",
"SMv3SessionValidationModule": "0xAE55743B6Df1df7194a708460950851a74910D9F"
"SMv2SessionValidationModule": "0xF4243f4d3F8014DE6A085F901d3Fc32339f7A088",
"SMv3SessionValidationModule": "0x25EBde897bA211885982b5e74E8F65F3CDdAfA17"
}
259 changes: 128 additions & 131 deletions lcov.info
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
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: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
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
Expand All @@ -40,133 +40,118 @@ 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
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:72,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
BRDA:71,2,0,256
BRDA:71,2,1,1537
DA:75,256
DA:78,1537
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:95,1025
DA:96,1025
DA:98,1025
DA:97,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
DA:103,1025
BRDA:103,4,0,256
BRDA:103,4,1,769
DA:104,256
DA:109,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
BRDA:48,1,1,1798
DA:56,256
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:47,1799
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
Expand Down Expand Up @@ -202,6 +187,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
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
5 changes: 4 additions & 1 deletion src/SMv2SessionValidationModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading