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

remove getNonce call to entryPoint #298

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
55 changes: 18 additions & 37 deletions src/rpc/rpcHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading