diff --git a/contracts/core/EntryPoint.sol b/contracts/core/EntryPoint.sol index 6cd04392b..a3962eb4a 100644 --- a/contracts/core/EntryPoint.sol +++ b/contracts/core/EntryPoint.sol @@ -33,6 +33,10 @@ contract EntryPoint is IEntryPoint, StakeManager, NonceManager, ReentrancyGuard, return _senderCreator; } + //compensate for innerHandleOps' emit message and deposit refund. + // allow some slack for future gas price changes. + uint private constant INNER_GAS_OVERHEAD = 10000; + // Marker for inner call revert on out of gas bytes32 private constant INNER_OUT_OF_GAS = hex"deaddead"; @@ -296,10 +300,10 @@ contract EntryPoint is IEntryPoint, StakeManager, NonceManager, ReentrancyGuard, unchecked { // handleOps was called with gas limit too low. abort entire bundle. if ( - gasleft() < + gasleft() * 63 / 64 < callGasLimit + mUserOp.paymasterPostOpGasLimit + - 5000 + INNER_GAS_OVERHEAD ) { assembly { mstore(0, INNER_OUT_OF_GAS) diff --git a/reports/gas-checker.txt b/reports/gas-checker.txt index 2a6551a6f..c71d2e386 100644 --- a/reports/gas-checker.txt +++ b/reports/gas-checker.txt @@ -12,44 +12,44 @@ ║ │ │ │ (delta for │ (compared to ║ ║ │ │ │ one UserOp) │ account.exec()) ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ simple │ 1 │ 81580 │ │ ║ +║ simple │ 1 │ 81609 │ │ ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ simple - diff from previous │ 2 │ │ 43741 │ 14762 ║ +║ simple - diff from previous │ 2 │ │ 43794 │ 14815 ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ simple │ 10 │ 475536 │ │ ║ +║ simple │ 10 │ 475874 │ │ ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ simple - diff from previous │ 11 │ │ 43798 │ 14819 ║ +║ simple - diff from previous │ 11 │ │ 43791 │ 14812 ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ simple paymaster │ 1 │ 87871 │ │ ║ +║ simple paymaster │ 1 │ 87924 │ │ ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ simple paymaster with diff │ 2 │ │ 42757 │ 13778 ║ +║ simple paymaster with diff │ 2 │ │ 42810 │ 13831 ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ simple paymaster │ 10 │ 473045 │ │ ║ +║ simple paymaster │ 10 │ 473311 │ │ ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ simple paymaster with diff │ 11 │ │ 42835 │ 13856 ║ +║ simple paymaster with diff │ 11 │ │ 42876 │ 13897 ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ big tx 5k │ 1 │ 182638 │ │ ║ +║ big tx 5k │ 1 │ 182667 │ │ ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ big tx - diff from previous │ 2 │ │ 144264 │ 19040 ║ +║ big tx - diff from previous │ 2 │ │ 144293 │ 19069 ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ big tx 5k │ 10 │ 1481207 │ │ ║ +║ big tx 5k │ 10 │ 1481461 │ │ ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ big tx - diff from previous │ 11 │ │ 144345 │ 19121 ║ +║ big tx - diff from previous │ 11 │ │ 144350 │ 19126 ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ paymaster+postOp │ 1 │ 89675 │ │ ║ +║ paymaster+postOp │ 1 │ 89704 │ │ ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ paymaster+postOp with diff │ 2 │ │ 44536 │ 15557 ║ +║ paymaster+postOp with diff │ 2 │ │ 44589 │ 15610 ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ paymaster+postOp │ 10 │ 490829 │ │ ║ +║ paymaster+postOp │ 10 │ 491155 │ │ ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ paymaster+postOp with diff │ 11 │ │ 44609 │ 15630 ║ +║ paymaster+postOp with diff │ 11 │ │ 44638 │ 15659 ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ token paymaster │ 1 │ 130350 │ │ ║ +║ token paymaster │ 1 │ 130379 │ │ ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ token paymaster with diff │ 2 │ │ 67932 │ 38953 ║ +║ token paymaster with diff │ 2 │ │ 67961 │ 38982 ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ token paymaster │ 10 │ 741961 │ │ ║ +║ token paymaster │ 10 │ 742299 │ │ ║ ╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢ -║ token paymaster with diff │ 11 │ │ 68051 │ 39072 ║ +║ token paymaster with diff │ 11 │ │ 68032 │ 39053 ║ ╚════════════════════════════════╧═══════╧═══════════════╧════════════════╧═════════════════════╝ diff --git a/test/entrypoint.test.ts b/test/entrypoint.test.ts index 11c5e1fcd..bb7965454 100644 --- a/test/entrypoint.test.ts +++ b/test/entrypoint.test.ts @@ -530,7 +530,7 @@ describe('EntryPoint', function () { sender: account.address, callData: accountExec.data, verificationGasLimit: 1e5, - callGasLimit: 11.5e5 + callGasLimit: 11e5 }, accountOwner, entryPoint) const inititalAccountBalance = await getBalance(account.address) const beneficiaryAddress = createAddress()