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
remove AA40 - global verification gas check #447
Changes from all commits
40a4af2
3caa62e
e9164de
277e9db
eb29f85
4126ec5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -441,7 +441,8 @@ contract EntryPoint is IEntryPoint, StakeManager, NonceManager, ReentrancyGuard, | |
uint256 opIndex, | ||
PackedUserOperation calldata op, | ||
UserOpInfo memory opInfo, | ||
uint256 requiredPrefund | ||
uint256 requiredPrefund, | ||
uint256 verificationGasLimit | ||
) | ||
internal | ||
returns ( | ||
|
@@ -462,7 +463,7 @@ contract EntryPoint is IEntryPoint, StakeManager, NonceManager, ReentrancyGuard, | |
} | ||
try | ||
IAccount(sender).validateUserOp{ | ||
gas: mUserOp.verificationGasLimit | ||
gas: verificationGasLimit | ||
}(op, opInfo.userOpHash, missingAccountFunds) | ||
returns (uint256 _validationData) { | ||
validationData = _validationData; | ||
|
@@ -498,6 +499,7 @@ contract EntryPoint is IEntryPoint, StakeManager, NonceManager, ReentrancyGuard, | |
uint256 requiredPreFund | ||
) internal returns (bytes memory context, uint256 validationData) { | ||
unchecked { | ||
uint256 preGas = gasleft(); | ||
MemoryUserOp memory mUserOp = opInfo.mUserOp; | ||
address paymaster = mUserOp.paymaster; | ||
DepositInfo storage paymasterInfo = deposits[paymaster]; | ||
|
@@ -506,8 +508,9 @@ contract EntryPoint is IEntryPoint, StakeManager, NonceManager, ReentrancyGuard, | |
revert FailedOp(opIndex, "AA31 paymaster deposit too low"); | ||
} | ||
paymasterInfo.deposit = deposit - requiredPreFund; | ||
uint256 pmVerificationGasLimit = mUserOp.paymasterVerificationGasLimit; | ||
try | ||
IPaymaster(paymaster).validatePaymasterUserOp{gas: mUserOp.paymasterVerificationGasLimit}( | ||
IPaymaster(paymaster).validatePaymasterUserOp{gas: pmVerificationGasLimit}( | ||
op, | ||
opInfo.userOpHash, | ||
requiredPreFund | ||
|
@@ -518,6 +521,9 @@ contract EntryPoint is IEntryPoint, StakeManager, NonceManager, ReentrancyGuard, | |
} catch { | ||
revert FailedOpWithRevert(opIndex, "AA33 reverted", Exec.getReturnData(REVERT_REASON_MAX_LEN)); | ||
} | ||
if (preGas - gasleft() > pmVerificationGasLimit) { | ||
revert FailedOp(opIndex, "AA36 over paymasterVerificationGasLimit"); | ||
} | ||
} | ||
} | ||
|
||
|
@@ -597,8 +603,9 @@ contract EntryPoint is IEntryPoint, StakeManager, NonceManager, ReentrancyGuard, | |
|
||
// Validate all numeric values in userOp are well below 128 bit, so they can safely be added | ||
// and multiplied without causing overflow. | ||
uint256 verificationGasLimit = mUserOp.verificationGasLimit; | ||
uint256 maxGasValues = mUserOp.preVerificationGas | | ||
mUserOp.verificationGasLimit | | ||
verificationGasLimit | | ||
mUserOp.callGasLimit | | ||
mUserOp.paymasterVerificationGasLimit | | ||
mUserOp.paymasterPostOpGasLimit | | ||
|
@@ -611,13 +618,20 @@ contract EntryPoint is IEntryPoint, StakeManager, NonceManager, ReentrancyGuard, | |
opIndex, | ||
userOp, | ||
outOpInfo, | ||
requiredPreFund | ||
requiredPreFund, | ||
verificationGasLimit | ||
); | ||
|
||
if (!_validateAndUpdateNonce(mUserOp.sender, mUserOp.nonce)) { | ||
revert FailedOp(opIndex, "AA25 invalid account nonce"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a minor issue, why not incorporate the Nonce verification into _validateAccountPrepayment? It seems that doing so would make the responsibilities of each method clearer. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the method names declare their responsibilities:
|
||
} | ||
|
||
unchecked { | ||
if (preGas - gasleft() > verificationGasLimit) { | ||
revert FailedOp(opIndex, "AA26 over verificationGasLimit"); | ||
} | ||
} | ||
|
||
bytes memory context; | ||
if (mUserOp.paymaster != address(0)) { | ||
(context, paymasterValidationData) = _validatePaymasterPrepayment( | ||
|
@@ -628,11 +642,6 @@ contract EntryPoint is IEntryPoint, StakeManager, NonceManager, ReentrancyGuard, | |
); | ||
} | ||
unchecked { | ||
uint256 gasUsed = preGas - gasleft(); | ||
|
||
if (mUserOp.verificationGasLimit + mUserOp.paymasterVerificationGasLimit < gasUsed) { | ||
revert FailedOp(opIndex, "AA40 over verificationGasLimit"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We removed this since we now check each of the limits separately. Is it guaranteed that this can no longer happen even with EntryPoint overhead? I assume it is, just checking. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you're right. we didn't cover some validations. Now account validation gas limit would cover also nonce check and copy |
||
} | ||
outOpInfo.prefund = requiredPreFund; | ||
outOpInfo.contextOffset = getOffsetOfMemoryBytes(context); | ||
outOpInfo.preOpGas = preGas - gasleft() + userOp.preVerificationGas; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious why this variable makes things more efficient than accessing
mUserOp.paymasterVerificationGasLimit
directly below.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use it twice in this method. so it saves (a little..) to keep the memory var on the stack.