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

detect postOp reverts #6

Merged
merged 1 commit into from
Oct 23, 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
23 changes: 22 additions & 1 deletion src/v06/EntryPointCodeOverride.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ contract EntryPointCodeOverride is IEntryPoint, StakeManager, NonceManager, Reen
*/
uint256 public constant SIG_VALIDATION_FAILED = 1;

// ================================================================= //
// ======= START: THIS IS CUSTOM TO THIS SIMULATION CONTRACT ======= //
// ================================================================= //
error CallPhaseReverted(bytes reason);
error FailedOpWithRevert(uint256 opIndex, string reason, bytes inner);
// ================================================================= //
// ======= END: THIS IS CUSTOM TO THIS SIMULATION CONTRACT ========= //
// ================================================================= //

/**
* compensate the caller's beneficiary address with the collected fees of all UserOperations.
Expand Down Expand Up @@ -648,7 +655,21 @@ contract EntryPointCodeOverride is IEntryPoint, StakeManager, NonceManager, Reen
if (context.length > 0) {
actualGasCost = actualGas * gasPrice;
if (mode != IPaymaster.PostOpMode.postOpReverted) {
IPaymaster(paymaster).postOp{gas: mUserOp.verificationGasLimit}(mode, context, actualGasCost);
// ================================================================= //
// ======= START: THIS IS CUSTOM TO THIS SIMULATION CONTRACT ======= //
// ================================================================= //

// Throw postOp revert error if one is thrown.
try IPaymaster(paymaster).postOp{gas: mUserOp.verificationGasLimit}(
mode, context, actualGasCost
) {} catch (bytes memory reason) {
if (reason.length == 0) revert FailedOp(opIndex, "AA50 postOp revert");
revert FailedOpWithRevert(opIndex, "AA50 postOp reverted", reason);
}

// ================================================================= //
// ======= END: THIS IS CUSTOM TO THIS SIMULATION CONTRACT ========= //
// ================================================================= //
} else {
// solhint-disable-next-line no-empty-blocks
try IPaymaster(paymaster).postOp{gas: mUserOp.verificationGasLimit}(
Expand Down
Loading