Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove getNonce call to entryPoint
Browse files Browse the repository at this point in the history
plusminushalf committed Sep 21, 2024
1 parent 9401c29 commit c4ab973
Showing 1 changed file with 18 additions and 37 deletions.
55 changes: 18 additions & 37 deletions src/rpc/rpcHandler.ts
Original file line number Diff line number Diff line change
@@ -378,46 +378,27 @@ export class RpcHandler implements IRpcEndpoint {
// Check if the nonce is valid
// If the nonce is less than the current nonce, the user operation has already been executed
// If the nonce is greater than the current nonce, we may have missing user operations in the mempool
const currentNonceValue = await this.getNonceValue(
userOperation,
entryPoint
)
const [, userOperationNonceValue] = getNonceKeyAndValue(
userOperation.nonce
)
const [userOperationNonceKey, userOperationNonceValue] =
getNonceKeyAndValue(userOperation.nonce)

let queuedUserOperations: UserOperation[] = []
if (userOperationNonceValue < currentNonceValue) {
throw new RpcError(
"UserOperation reverted during simulation with reason: AA25 invalid account nonce",
ValidationErrors.InvalidFields
)
}
if (userOperationNonceValue > currentNonceValue) {
// Nonce queues are supported only for v7 user operations
if (isVersion06(userOperation)) {
throw new RpcError(
"UserOperation reverted during simulation with reason: AA25 invalid account nonce",
ValidationErrors.InvalidFields
)
}

queuedUserOperations = await this.mempool.getQueuedUserOperations(
userOperation,
entryPoint,
currentNonceValue
const queuedUserOperations: UserOperation[] = this.mempool
.dumpOutstanding()
.map((userOpInfo) =>
deriveUserOperation(userOpInfo.mempoolUserOperation)
)

if (
userOperationNonceValue >
currentNonceValue + BigInt(queuedUserOperations.length)
) {
throw new RpcError(
"UserOperation reverted during simulation with reason: AA25 invalid account nonce",
ValidationErrors.InvalidFields
.filter((uo) => {
const [opNonceKey, opNonceValue] = getNonceKeyAndValue(uo.nonce)

return (
uo.sender === userOperation.sender &&
opNonceKey === userOperationNonceKey &&
// on chain nonce - 12
// in mempool nonce - 11, 13, 15, 18
// current user operation nonce - 16
// need to pick 11, 13, 14, 15
opNonceValue < userOperationNonceValue
)
}
}
})

const executionResult = await this.validator.getExecutionResult(
userOperation,

0 comments on commit c4ab973

Please sign in to comment.