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

use all gas during estimation #7

Merged
merged 1 commit into from
Dec 12, 2024
Merged
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
46 changes: 34 additions & 12 deletions src/v06/EntryPointCodeOverride.sol
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ contract EntryPointCodeOverride is IEntryPoint, StakeManager, NonceManager, Reen
// ================================================================= //
// ======= START: THIS IS CUSTOM TO THIS SIMULATION CONTRACT ======= //
// ================================================================= //
// note: revert whole tx if CallPhaseReverted is detected.

if (reason.length == 0) revert CallPhaseReverted("");

assembly {
Expand Down Expand Up @@ -266,26 +268,46 @@ contract EntryPointCodeOverride is IEntryPoint, StakeManager, NonceManager, Reen
require(msg.sender == address(this), "AA92 internal call only");
MemoryUserOp memory mUserOp = opInfo.mUserOp;

uint256 callGasLimit = mUserOp.callGasLimit;
unchecked {
// handleOps was called with gas limit too low. abort entire bundle.
if (gasleft() < callGasLimit + mUserOp.verificationGasLimit + 5000) {
assembly {
mstore(0, INNER_OUT_OF_GAS)
revert(0, 32)
}
}
}
// ================================================================= //
// ======= START: THIS IS CUSTOM TO THIS SIMULATION CONTRACT ======= //
// ================================================================= //
// note: ignoring AA95 check

//uint256 callGasLimit = mUserOp.callGasLimit;
//
//unchecked {
// // handleOps was called with gas limit too low. abort entire bundle.
// if (gasleft() < callGasLimit + mUserOp.verificationGasLimit + 5000) {
// assembly {
// mstore(0, INNER_OUT_OF_GAS)
// revert(0, 32)
// }
// }
//}

// ================================================================= //
// ======= END: THIS IS CUSTOM TO THIS SIMULATION CONTRACT ======== //
// ================================================================= //

IPaymaster.PostOpMode mode = IPaymaster.PostOpMode.opSucceeded;
if (callData.length > 0) {
bool success = Exec.call(mUserOp.sender, 0, callData, callGasLimit);
// ================================================================= //
// ======= START: THIS IS CUSTOM TO THIS SIMULATION CONTRACT ======= //
// ================================================================= //
// note: Calling exec with gasleft() to ensure that the call has sufficient gas to execute

bool success = Exec.call(mUserOp.sender, 0, callData, gasleft());

// ================================================================= //
// ======= END: THIS IS CUSTOM TO THIS SIMULATION CONTRACT ======== //
// ================================================================= //
if (!success) {
bytes memory result = Exec.getReturnData(REVERT_REASON_MAX_LEN);

// ================================================================= //
// ======= START: THIS IS CUSTOM TO THIS SIMULATION CONTRACT ======= //
// ================================================================= //
// note: Revert if the call failed (this will be caught higher up)

revert CallPhaseReverted(result);

Expand Down Expand Up @@ -658,8 +680,8 @@ contract EntryPointCodeOverride is IEntryPoint, StakeManager, NonceManager, Reen
// ================================================================= //
// ======= START: THIS IS CUSTOM TO THIS SIMULATION CONTRACT ======= //
// ================================================================= //
// note: Throws postOp revert error if one is thrown.

// Throw postOp revert error if one is thrown.
try IPaymaster(paymaster).postOp{gas: mUserOp.verificationGasLimit}(
mode, context, actualGasCost
) {} catch (bytes memory reason) {
Expand Down
Loading