Skip to content

Commit

Permalink
Merge pull request #6 from pimlicolabs/feat/detect-v06-postop-reverts
Browse files Browse the repository at this point in the history
detect postOp reverts
  • Loading branch information
mouseless0x authored Oct 23, 2024
2 parents abc151f + 6e6c60e commit e333fab
Showing 1 changed file with 22 additions and 1 deletion.
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

0 comments on commit e333fab

Please sign in to comment.