Skip to content

Commit

Permalink
Merge pull request #406 from pimlicolabs/fix/arb
Browse files Browse the repository at this point in the history
revert is gas limit > maxGasPerBundle
  • Loading branch information
plusminushalf authored Jan 17, 2025
2 parents 0e8118b + fbbb72b commit 20bcf51
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/cli/config/bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export const bundlerArgsSchema = z.object({
"max-gas-per-bundle": z
.string()
.transform((val) => BigInt(val))
.default("5000000"),
.default("20000000"),
"rpc-methods": z
.string()
.nullable()
Expand Down
2 changes: 1 addition & 1 deletion src/cli/config/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export const bundlerOptions: CliCommandOptions<IBundlerArgsInput> = {
description: "Maximum amount of gas per bundle",
type: "string",
require: false,
default: "5000000"
default: "20000000"
},
"rpc-methods": {
description: "Supported RPC methods split by commas",
Expand Down
12 changes: 8 additions & 4 deletions src/mempool/mempool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -714,10 +714,14 @@ export class MemoryMempool {

for (const opInfo of outstandingUserOperations) {
const op = deriveUserOperation(opInfo.mempoolUserOperation)
gasUsed +=
op.callGasLimit +
op.verificationGasLimit * 3n +
op.preVerificationGas
gasUsed += op.callGasLimit + op.verificationGasLimit

if (isVersion07(op)) {
gasUsed +=
(op.paymasterPostOpGasLimit ?? 0n) +
(op.paymasterVerificationGasLimit ?? 0n)
}

if (gasUsed > maxGasLimit && opsTaken >= (minOps || 0)) {
break
}
Expand Down
27 changes: 27 additions & 0 deletions src/rpc/rpcHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,33 @@ export class RpcHandler implements IRpcEndpoint {
this.eventManager.emitFailedValidation(opHash, reason)
throw new RpcError(reason)
}

if (isVersion07(userOperation)) {
const gasLimits =
userOperation.callGasLimit +
userOperation.verificationGasLimit +
(userOperation.paymasterPostOpGasLimit ?? 0n) +
(userOperation.paymasterVerificationGasLimit ?? 0n)

if (gasLimits > this.config.maxGasPerBundle) {
throw new RpcError(
`User operation gas limits exceed the max gas per bundle: ${gasLimits} > ${this.config.maxGasPerBundle}`
)
}
}

if (isVersion06(userOperation)) {
const gasLimits =
userOperation.callGasLimit + userOperation.verificationGasLimit

const maxGasPerBundle = (this.config.maxGasPerBundle * 130n) / 100n

if (gasLimits > maxGasPerBundle) {
throw new RpcError(
`User operation gas limits exceed the max gas per bundle: ${gasLimits} > ${this.config.maxGasPerBundle}`
)
}
}
}

eth_chainId(): ChainIdResponseResult {
Expand Down

0 comments on commit 20bcf51

Please sign in to comment.