diff --git a/contracts/core/EntryPoint.sol b/contracts/core/EntryPoint.sol index f619874b..ae0b7cff 100644 --- a/contracts/core/EntryPoint.sol +++ b/contracts/core/EntryPoint.sol @@ -79,12 +79,18 @@ contract EntryPoint is IEntryPoint, StakeManager, NonceManager, ReentrancyGuard, (uint256 collected) { uint256 preGas = gasleft(); bytes memory context = getMemoryBytesFromOffset(opInfo.contextOffset); - - try this.innerHandleOp(userOp.callData, opInfo, context) returns ( - uint256 _actualGasCost - ) { - collected = _actualGasCost; - } catch { + uint saveFreePtr; + assembly { + saveFreePtr := mload(0x40) + } + bytes memory innerCall = abi.encodeCall(this.innerHandleOp,(userOp.callData, opInfo, context)); + bool success; + assembly { + success := call(gas(), address(), 0, add(innerCall, 0x20), mload(innerCall), 0, 32) + collected := mload(0) + mstore(0x40, saveFreePtr) + } + if (!success) { bytes32 innerRevertCode; assembly { let len := returndatasize() diff --git a/contracts/interfaces/IAccountExecute.sol b/contracts/interfaces/IAccountExecute.sol new file mode 100644 index 00000000..2e0fb43c --- /dev/null +++ b/contracts/interfaces/IAccountExecute.sol @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-3.0 +pragma solidity ^0.8.12; + +import "./UserOperation.sol"; + +interface IAccountExecute { + /** + * Account MAY implement this execute method. + * passing this methodSig as callData will cause the entryPoint to pass the full UserOp (and hash) + * to the account. + * @param userOp - The operation that was just validated. + * @param userOpHash - Hash of the user's request data. + */ + function executeUserOp( + UserOperation calldata userOp, + bytes32 userOpHash + ) external; +} diff --git a/reports/gas-checker.txt b/reports/gas-checker.txt index 3fac0df2..f5eb0b8d 100644 --- a/reports/gas-checker.txt +++ b/reports/gas-checker.txt @@ -4,7 +4,7 @@ ╔══════════════════════════╤════════╗ ║ gas estimate "simple" │ 29014 ║ ╟──────────────────────────┼────────╢ -║ gas estimate "big tx 5k" │ 125260 ║ +║ gas estimate "big tx 5k" │ 125248 ║ ╚══════════════════════════╧════════╝ ╔════════════════════════════════╤═══════╤═══════════════╤════════════════╤═════════════════════╗ @@ -12,36 +12,36 @@ ║ │ │ │ (delta for │ (compared to ║ ║ │ │ │ one UserOp) │ account.exec()) ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ simple │ 1 │ 81918 │ │ ║ +║ simple │ 1 │ 81808 │ │ ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ simple - diff from previous │ 2 │ │ 44187 │ 15173 ║ +║ simple - diff from previous │ 2 │ │ 44041 │ 15027 ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ simple │ 10 │ 479730 │ │ ║ +║ simple │ 10 │ 478604 │ │ ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ simple - diff from previous │ 11 │ │ 44247 │ 15233 ║ +║ simple - diff from previous │ 11 │ │ 44096 │ 15082 ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ simple paymaster │ 1 │ 89813 │ │ ║ +║ simple paymaster │ 1 │ 89670 │ │ ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ simple paymaster with diff │ 2 │ │ 44796 │ 15782 ║ +║ simple paymaster with diff │ 2 │ │ 44671 │ 15657 ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ simple paymaster │ 10 │ 493254 │ │ ║ +║ simple paymaster │ 10 │ 491926 │ │ ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ simple paymaster with diff │ 11 │ │ 44820 │ 15806 ║ +║ simple paymaster with diff │ 11 │ │ 44752 │ 15738 ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ big tx 5k │ 1 │ 182975 │ │ ║ +║ big tx 5k │ 1 │ 182841 │ │ ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ big tx - diff from previous │ 2 │ │ 144698 │ 19438 ║ +║ big tx - diff from previous │ 2 │ │ 144576 │ 19328 ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ big tx 5k │ 10 │ 1485374 │ │ ║ +║ big tx 5k │ 10 │ 1484244 │ │ ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ big tx - diff from previous │ 11 │ │ 144759 │ 19499 ║ +║ big tx - diff from previous │ 11 │ │ 144620 │ 19372 ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ token paymaster │ 1 │ 148244 │ │ ║ +║ token paymaster │ 1 │ 148138 │ │ ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ token paymaster with diff │ 2 │ │ 72920 │ 43906 ║ +║ token paymaster with diff │ 2 │ │ 72794 │ 43780 ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ token paymaster │ 10 │ 804795 │ │ ║ +║ token paymaster │ 10 │ 803643 │ │ ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ token paymaster with diff │ 11 │ │ 73015 │ 44001 ║ +║ token paymaster with diff │ 11 │ │ 72922 │ 43908 ║ ╚════════════════════════════════╧═══════╧═══════════════╧════════════════╧═════════════════════╝