Skip to content

Commit

Permalink
don't revert the estimation if earlier in the queue reverts
Browse files Browse the repository at this point in the history
  • Loading branch information
plusminushalf committed Sep 21, 2024
1 parent 3682d55 commit 8b41b05
Showing 1 changed file with 34 additions and 5 deletions.
39 changes: 34 additions & 5 deletions src/EntryPointSimulations.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ contract EntryPointSimulations is EntryPoint, IEntryPointSimulations {
_simulationOnlyValidations(userOp);
(
uint256 validationData,
uint256 paymasterValidationData,
// uint256 paymasterVerificationGasLimit
uint256 paymasterValidationData, // uint256 paymasterVerificationGasLimit

) = _validatePrepayment(0, userOp, outOpInfo);

_validateAccountAndPaymasterValidationData(
Expand Down Expand Up @@ -118,7 +118,9 @@ contract EntryPointSimulations is EntryPoint, IEntryPointSimulations {
function simulateValidationBulk(
PackedUserOperation[] calldata userOps
) public returns (ValidationResult[] memory) {
ValidationResult[] memory results = new ValidationResult[](userOps.length);
ValidationResult[] memory results = new ValidationResult[](
userOps.length
);

for (uint256 i = 0; i < userOps.length; i++) {
ValidationResult memory result = simulateValidation(userOps[i]);
Expand Down Expand Up @@ -227,9 +229,36 @@ contract EntryPointSimulations is EntryPoint, IEntryPointSimulations {
ExecutionResult[] memory results = new ExecutionResult[](ops.length);

for (uint256 i = 0; i < ops.length; i++) {
ExecutionResult memory result = simulateHandleOp(ops[i]);
(bool success, bytes memory returnData) = address(this).call(
abi.encodeWithSignature(
"simulateHandleOp((address,uint256,bytes,bytes,uint256,uint256,uint256,uint256,uint256,address,address,bytes))",
ops[i]
)
);

results[i] = result;
if (success) {
ExecutionResult memory execResult = abi.decode(
returnData,
(ExecutionResult)
);
results.push(execResult);
}

// revert only at last as we are estimating only the last call
if (i == ops.length - 1) {
if (returnData.length > 0) {
assembly {
// Revert using the original error data, propagating the exact revert reason
revert(add(returnData, 0x20), mload(returnData))
}
} else {
// If there's no revert reason, we can use a generic message
revert("simulateHandleOp failed without a revert reason");
}
}

// ExecutionResult memory result = simulateHandleOp(ops[i]);
// results[i] = result;
}

return results;
Expand Down

0 comments on commit 8b41b05

Please sign in to comment.