Skip to content

Commit c5499f2

Browse files
authored
Merge branch 'dev' into feat/v3.1-rc3
2 parents a38a8fb + a807c8e commit c5499f2

File tree

12 files changed

+181
-265
lines changed

12 files changed

+181
-265
lines changed
Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
{
22
"transactions": [
33
{
4-
"hash": "0x9803b4ddc4b3ef54acc03d828a762ab711f0c1764134b5692f66dd22bb249b9f",
4+
"hash": "0x8562ad26e46f807af71418ec082c720698f553e8eba477999545a42408ffa4a4",
55
"transactionType": "CREATE2",
66
"contractName": "ECDSAValidator",
7-
"contractAddress": "0x845adb2c711129d4f3966735ed98a9f09fc4ce57",
7+
"contractAddress": "0x8104e3ad430ea6d354d013a6789fdfc71e671c43",
88
"function": null,
99
"arguments": null,
1010
"transaction": {
1111
"from": "0x9775137314fe595c943712b0b336327dfa80ae8a",
1212
"to": "0x4e59b44847b379578588920ca78fbf26c0b4956c",
13-
"gas": "0x9fafe",
13+
"gas": "0xa28d7",
1414
"value": "0x0",
15-
"input": "0x00000000000000000000000000000000000000000000000000000000000000006080806040523460155761071b908161001b8239f35b600080fdfe608060408181526004918236101561001657600080fd5b600090813560e01c908163173bf7da1461043a57816320709efc14610403575080636d61fe701461034a5780638a91b0e3146102d4578063970032031461028e578063d60b347f14610240578063d68f602514610124578063ecd05961146100e55763f551e2ee1461008757600080fd5b346100e25760603660031901126100e2576100a061049e565b506044359067ffffffffffffffff82116100e257506100c76020936100d09236910161046b565b906024356105e5565b90516001600160e01b03199091168152f35b80fd5b50919034610120576020366003190112610120576020925081359160018314928315610116575b5050519015158152f35b149150388061010c565b8280fd5b509160603660031901126101205761013a61049e565b9267ffffffffffffffff6044358181116101205761015b903690850161046b565b505033825260208281528483205490956001600160a01b039182169116036101f157835192858401918211848310176101de575083949291945283815282519382859384528251928382860152825b8481106101c857505050828201840152601f01601f19168101030190f35b81810183015188820188015287955082016101aa565b634e487b7160e01b835260419052602482fd5b835162461bcd60e51b8152808401869052602360248201527f454344534156616c696461746f723a2073656e646572206973206e6f74206f776044820152623732b960e91b6064820152608490fd5b50903461028a57602036600319011261028a5760209061028161026161049e565b6001600160a01b0390811660009081526020819052604090205416151590565b90519015158152f35b5080fd5b506003199082823601126100e25783359167ffffffffffffffff831161028a576101209083360301126100e257506020926102cd91602435910161051d565b9051908152f35b5091602036600319011261012057803567ffffffffffffffff811161034657610300903690830161046b565b5050336000908152602081905260409020546001600160a01b031615610330575081903382528160205281205580f35b602491519063f91bd6f160e01b82523390820152fd5b8380fd5b5091602036600319011261012057803567ffffffffffffffff811161034657610376903690830161046b565b33600090815260208190526040902054919290916001600160a01b03166103ec5750601411610120573560601c90338352826020528220816bffffffffffffffffffffffff60a01b825416179055337fa5e1f8b4009110f5525798d04ae2125421a12d0590aa52c13682ff1bd3c492ca8380a380f35b6024908451906393360fbf60e01b82523390820152fd5b90508234610120576020366003190112610120576020926001600160a01b0391908261042d61049e565b1681528085522054168152f35b8285602036600319011261028a5780359067ffffffffffffffff8211610120576104669136910161046b565b505080f35b9181601f840112156104995782359167ffffffffffffffff8311610499576020838186019501011161049957565b600080fd5b600435906001600160a01b038216820361049957565b92919267ffffffffffffffff918281116105075760405192601f8201601f19908116603f011684019081118482101761050757604052829481845281830111610499578281602093846000960137010152565b634e487b7160e01b600052604160045260246000fd5b3360009081526020819052604081205490926001600160a01b03918216926101008101359036819003601e19018212156105e1570180359067ffffffffffffffff82116105e1576020019181360383136105e157836105866105803685876104b4565b8361067d565b1685146105d9576105ca926105c4916020527b19457468657265756d205369676e6564204d6573736167653a0a33328752603c6004209236916104b4565b9061067d565b16036105d35790565b50600190565b505050505090565b8580fd5b919033600052600060205260018060a01b0391826040600020541693836106106105803685876104b4565b16851461066c5761064f926105c4916020527b19457468657265756d205369676e6564204d6573736167653a0a3332600052603c6004209236916104b4565b160361066057630b135d3f60e11b90565b6001600160e01b031990565b50630b135d3f60e11b949350505050565b919091602060016080600082948390604080998151986106bb575b5050505afa51923d156106ad57600060605252565b638baa579f6000526004601cfd5b8492835287808201518352828251146106fb5760418251146106e4575050509050388881610698565b60609384830151901a905201519052388881610698565b9250015190601b8260ff1c019052848060ff1b031660605238888161069856",
16-
"nonce": "0x45",
17-
"chainId": "0xaa36a7"
15+
"input": "0x00000000000000000000000000000000000000000000000000000000000000006080806040523461001657610740908161001c8239f35b600080fdfe608060408181526004918236101561001657600080fd5b600090813560e01c90816320709efc14610459575080636d61fe70146103a05780638a91b0e31461032e57806397003203146102e8578063aacbd72a1461028e578063d60b347f14610240578063d68f602514610124578063ecd05961146100e55763f551e2ee1461008757600080fd5b346100e25760603660031901126100e2576100a0610490565b506044359067ffffffffffffffff82116100e257506100c76020936100d0923691016104ab565b9060243561060a565b90516001600160e01b03199091168152f35b80fd5b50919034610120576020366003190112610120576020925081359160018314928315610116575b5050519015158152f35b149150388061010c565b8280fd5b509160603660031901126101205761013a610490565b9267ffffffffffffffff6044358181116101205761015b90369085016104ab565b505033825260208281528483205490956001600160a01b039182169116036101f157835192858401918211848310176101de575083949291945283815282519382859384528251928382860152825b8481106101c857505050828201840152601f01601f19168101030190f35b81810183015188820188015287955082016101aa565b634e487b7160e01b835260419052602482fd5b835162461bcd60e51b8152808401869052602360248201527f454344534156616c696461746f723a2073656e646572206973206e6f74206f776044820152623732b960e91b6064820152608490fd5b50903461028a57602036600319011261028a57602090610281610261610490565b6001600160a01b0390811660009081526020819052604090205416151590565b90519015158152f35b5080fd5b5082606036600319011261028a5767ffffffffffffffff9080358281116102e4576102bc90369083016104ab565b50506024358015150361012057604435918211610120576102df913691016104ab565b505080f35b8380fd5b506003199082823601126100e25783359167ffffffffffffffff831161028a576101209083360301126100e25750602092610327916024359101610542565b9051908152f35b5091602036600319011261012057803567ffffffffffffffff81116102e45761035a90369083016104ab565b5050336000908152602081905260409020546001600160a01b03161561038a575081903382528160205281205580f35b602491519063f91bd6f160e01b82523390820152fd5b5091602036600319011261012057803567ffffffffffffffff81116102e4576103cc90369083016104ab565b33600090815260208190526040902054919290916001600160a01b03166104425750601411610120573560601c90338352826020528220816bffffffffffffffffffffffff60a01b825416179055337fa5e1f8b4009110f5525798d04ae2125421a12d0590aa52c13682ff1bd3c492ca8380a380f35b6024908451906393360fbf60e01b82523390820152fd5b90508234610120576020366003190112610120576020926001600160a01b03919082610483610490565b1681528085522054168152f35b600435906001600160a01b03821682036104a657565b600080fd5b9181601f840112156104a65782359167ffffffffffffffff83116104a657602083818601950101116104a657565b92919267ffffffffffffffff9182811161052c5760405192601f8201601f19908116603f011684019081118482101761052c576040528294818452818301116104a6578281602093846000960137010152565b634e487b7160e01b600052604160045260246000fd5b3360009081526020819052604081205490926001600160a01b03918216926101008101359036819003601e1901821215610606570180359067ffffffffffffffff82116106065760200191813603831361060657836105ab6105a53685876104d9565b836106a2565b1685146105fe576105ef926105e9916020527b19457468657265756d205369676e6564204d6573736167653a0a33328752603c6004209236916104d9565b906106a2565b16036105f85790565b50600190565b505050505090565b8580fd5b919033600052600060205260018060a01b0391826040600020541693836106356105a53685876104d9565b16851461069157610674926105e9916020527b19457468657265756d205369676e6564204d6573736167653a0a3332600052603c6004209236916104d9565b160361068557630b135d3f60e11b90565b6001600160e01b031990565b50630b135d3f60e11b949350505050565b919091602060016080600082948390604080998151986106e0575b5050505afa51923d156106d257600060605252565b638baa579f6000526004601cfd5b8492835287808201518352828251146107205760418251146107095750505090503888816106bd565b60609384830151901a9052015190523888816106bd565b9250015190601b8260ff1c019052848060ff1b03166060523888816106bd56",
16+
"nonce": "0x3e",
17+
"chainId": "0xaa36a7",
18+
"accessList": null,
19+
"type": null
1820
},
1921
"additionalContracts": [],
2022
"isFixedGasLimit": false
@@ -23,25 +25,25 @@
2325
"receipts": [
2426
{
2527
"status": "0x1",
26-
"cumulativeGasUsed": "0xb578d9",
28+
"cumulativeGasUsed": "0xaf2a76",
2729
"logs": [],
2830
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
2931
"type": "0x2",
30-
"transactionHash": "0x9803b4ddc4b3ef54acc03d828a762ab711f0c1764134b5692f66dd22bb249b9f",
31-
"transactionIndex": "0x51",
32-
"blockHash": "0xb4650a875f62666e5c1d1525cbb634af43376ea7ed4a8cf9994547f472ea1e4c",
33-
"blockNumber": "0x58db5c",
34-
"gasUsed": "0x6d375",
35-
"effectiveGasPrice": "0x836fb6b6f",
32+
"transactionHash": "0x8562ad26e46f807af71418ec082c720698f553e8eba477999545a42408ffa4a4",
33+
"transactionIndex": "0x42",
34+
"blockHash": "0x05be0f541009e1f0df7b4c62fdfe876fb76559f2d962acd90cb8f1afb24bfefe",
35+
"blockNumber": "0x569a7d",
36+
"gasUsed": "0x6f2d1",
37+
"effectiveGasPrice": "0x66b60fa8",
3638
"from": "0x9775137314fe595c943712b0b336327dfa80ae8a",
3739
"to": "0x4e59b44847b379578588920ca78fbf26c0b4956c",
38-
"contractAddress": "0x845adb2c711129d4f3966735ed98a9f09fc4ce57"
40+
"contractAddress": "0x8104e3ad430ea6d354d013a6789fdfc71e671c43"
3941
}
4042
],
4143
"libraries": [],
4244
"pending": [],
4345
"returns": {},
44-
"timestamp": 1714676307,
46+
"timestamp": 1712847787,
4547
"chain": 11155111,
46-
"commit": "8f7fd99"
48+
"commit": "f8be0c5"
4749
}

broadcast/DeployKernel.s.sol/11155111/run-latest.json

Lines changed: 101 additions & 63 deletions
Large diffs are not rendered by default.

src/Kernel.sol

Lines changed: 7 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ contract Kernel is IAccount, IAccountExecute, IERC7579Account, ValidationManager
8484
if (validator.isModuleType(4)) {
8585
bytes memory ret = IHook(address(validator)).preCheck(msg.sender, msg.value, msg.data);
8686
_;
87-
IHook(address(validator)).postCheck(ret);
87+
IHook(address(validator)).postCheck(ret, true, hex""); // TODO don't support try catch hook here
8888
} else {
8989
revert InvalidCaller();
9090
}
@@ -121,28 +121,6 @@ contract Kernel is IAccount, IAccountExecute, IERC7579Account, ValidationManager
121121
}
122122
}
123123

124-
function changeRootValidator(
125-
ValidationId _rootValidator,
126-
IHook hook,
127-
bytes calldata validatorData,
128-
bytes calldata hookData
129-
) external payable onlyEntryPointOrSelfOrRoot {
130-
ValidationStorage storage vs = _validationStorage();
131-
if (ValidationId.unwrap(_rootValidator) == bytes21(0)) {
132-
revert InvalidValidator();
133-
}
134-
ValidationType vType = ValidatorLib.getType(_rootValidator);
135-
if (vType != VALIDATION_TYPE_VALIDATOR && vType != VALIDATION_TYPE_PERMISSION) {
136-
revert InvalidValidationType();
137-
}
138-
_setRootValidator(_rootValidator);
139-
if (_validationStorage().validationConfig[_rootValidator].hook == IHook(address(0))) {
140-
// when new rootValidator is not installed yet
141-
ValidationConfig memory config = ValidationConfig({nonce: uint32(vs.currentNonce), hook: hook});
142-
_installValidation(_rootValidator, config, validatorData, hookData);
143-
}
144-
}
145-
146124
function upgradeTo(address _newImplementation) external payable onlyEntryPointOrSelfOrRoot {
147125
assembly {
148126
sstore(ERC1967_IMPLEMENTATION_SLOT, _newImplementation)
@@ -184,16 +162,8 @@ contract Kernel is IAccount, IAccountExecute, IERC7579Account, ValidationManager
184162
} else {
185163
// action installed
186164
bytes memory context;
187-
if (
188-
address(config.hook) != address(1) && address(config.hook) != 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF
189-
) {
165+
if (address(config.hook) != address(1)) {
190166
context = _doPreHook(config.hook, msg.value, msg.data);
191-
} else if (address(config.hook) == 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF) {
192-
// for selector manager, address(0) for the hook will default to type(address).max,
193-
// and this will only allow entrypoints to interact
194-
if (msg.sender != address(entrypoint)) {
195-
revert InvalidCaller();
196-
}
197167
}
198168
// execute action
199169
if (config.callType == CALLTYPE_SINGLE) {
@@ -203,10 +173,8 @@ contract Kernel is IAccount, IAccountExecute, IERC7579Account, ValidationManager
203173
} else {
204174
revert NotSupportedCallType();
205175
}
206-
if (
207-
address(config.hook) != address(1) && address(config.hook) != 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF
208-
) {
209-
_doPostHook(config.hook, context);
176+
if (address(config.hook) != address(1)) {
177+
_doPostHook(config.hook, context, success, result);
210178
}
211179
}
212180
if (!success) {
@@ -290,7 +258,7 @@ contract Kernel is IAccount, IAccountExecute, IERC7579Account, ValidationManager
290258
}
291259
(bool success, bytes memory ret) = ExecLib.executeDelegatecall(address(this), userOp.callData[4:]);
292260
if (address(hook) != address(1)) {
293-
_doPostHook(hook, context);
261+
_doPostHook(hook, context, success, ret);
294262
} else if (!success) {
295263
revert ExecutionReverted();
296264
}
@@ -312,7 +280,7 @@ contract Kernel is IAccount, IAccountExecute, IERC7579Account, ValidationManager
312280
}
313281
returnData = ExecLib.execute(execMode, executionCalldata);
314282
if (address(hook) != address(1)) {
315-
_doPostHook(hook, context);
283+
_doPostHook(hook, context, true, abi.encode(returnData));
316284
}
317285
}
318286

@@ -361,14 +329,11 @@ contract Kernel is IAccount, IAccountExecute, IERC7579Account, ValidationManager
361329
ValidationConfig({nonce: vs.currentNonce, hook: IHook(address(bytes20(initData[0:20])))});
362330
bytes calldata validatorData;
363331
bytes calldata hookData;
364-
bytes calldata selectorData;
365332
assembly {
366333
validatorData.offset := add(add(initData.offset, 52), calldataload(add(initData.offset, 20)))
367334
validatorData.length := calldataload(sub(validatorData.offset, 32))
368335
hookData.offset := add(add(initData.offset, 52), calldataload(add(initData.offset, 52)))
369336
hookData.length := calldataload(sub(hookData.offset, 32))
370-
selectorData.offset := add(add(initData.offset, 52), calldataload(add(initData.offset, 84)))
371-
selectorData.length := calldataload(sub(selectorData.offset, 32))
372337
}
373338
_installValidation(vId, config, validatorData, hookData);
374339
if (selectorData.length == 4) {
@@ -525,7 +490,7 @@ contract Kernel is IAccount, IAccountExecute, IERC7579Account, ValidationManager
525490
}
526491

527492
function accountId() external pure override returns (string memory accountImplementationId) {
528-
return "kernel.advanced.v0.3.1";
493+
return "kernel.advanced.v0.3.0-beta";
529494
}
530495

531496
function supportsExecutionMode(ExecMode mode) external pure override returns (bool) {

src/core/HookManager.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ abstract contract HookManager {
1717
context = hook.preCheck(msg.sender, value, callData);
1818
}
1919

20-
function _doPostHook(IHook hook, bytes memory context) internal {
20+
function _doPostHook(IHook hook, bytes memory context, bool success, bytes memory result) internal {
2121
// bool success,
2222
// bytes memory result
23-
hook.postCheck(context);
23+
hook.postCheck(context, success, result);
2424
}
2525

2626
// @notice if hook is not initialized before, kernel will call hook.onInstall no matter what flag it shows, with hookData[1:]

src/core/SelectorManager.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ abstract contract SelectorManager {
3737

3838
function _installSelector(bytes4 selector, address target, IHook hook, bytes calldata selectorData) internal {
3939
if (address(hook) == address(0)) {
40-
hook = IHook(address(0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF));
40+
hook = IHook(address(1));
4141
}
4242
SelectorConfig storage ss = _selectorConfig(selector);
4343
// we are going to install only through call/delegatecall

src/interfaces/IERC7579Modules.sol

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,30 @@ interface IValidator is IModule {
6969
interface IExecutor is IModule {}
7070

7171
interface IHook is IModule {
72-
function preCheck(address msgSender, uint256 msgValue, bytes calldata msgData)
72+
/**
73+
* @dev Called by the smart account before execution
74+
* @param msgSender the address that called the smart account
75+
* @param value the value that was sent to the smart account
76+
* @param msgData the data that was sent to the smart account
77+
*
78+
* MAY return arbitrary data in the `hookData` return value
79+
*/
80+
function preCheck(address msgSender, uint256 value, bytes calldata msgData)
7381
external
7482
payable
7583
returns (bytes memory hookData);
7684

77-
function postCheck(bytes calldata hookData) external payable;
85+
/**
86+
* @dev Called by the smart account after execution
87+
* @param hookData the data that was returned by the `preCheck` function
88+
* @param executionSuccess whether the execution(s) was (were) successful
89+
* @param executionReturn the return/revert data of the execution(s)
90+
*
91+
* MAY validate the `hookData` to validate transaction context of the `preCheck` function
92+
*/
93+
function postCheck(bytes calldata hookData, bool executionSuccess, bytes calldata executionReturn)
94+
external
95+
payable;
7896
}
7997

8098
interface IFallback is IModule {}

src/mock/MockHook.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ contract MockHook is IHook {
3434
return data[msg.sender];
3535
}
3636

37-
function postCheck(bytes calldata hookData) external payable override {
37+
function postCheck(bytes calldata hookData, bool success, bytes memory res) external payable override {
3838
postHookData[msg.sender] = hookData;
3939
}
4040
}

src/mock/MockValidator.sol

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ contract MockValidator is IValidator, IHook {
7373
return hex"";
7474
}
7575

76-
function postCheck(bytes calldata hookData) external payable {
76+
function postCheck(bytes calldata hookData, bool executionSuccess, bytes calldata executionReturn)
77+
external
78+
payable
79+
{
7780
return;
7881
}
7982
}

0 commit comments

Comments
 (0)