Skip to content

Commit

Permalink
add flags to control userOperation simulation params
Browse files Browse the repository at this point in the history
  • Loading branch information
mouseless0x committed Dec 12, 2024
1 parent 5c24d60 commit 04fd4ca
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 14 deletions.
10 changes: 10 additions & 0 deletions src/cli/config/bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,16 @@ export const gasEstimationArgsSchema = z.object({
.transform((val) => BigInt(val))
.default("1000000"),
"call-gas-limit-multiplier": z.string().transform((val) => BigInt(val)),
"simulation-call-gas-limit": z.string().transform((val) => BigInt(val)),
"simulation-verification-gas-limit": z
.string()
.transform((val) => BigInt(val)),
"simulation-paymaster-verification-gas-limit": z
.string()
.transform((val) => BigInt(val)),
"simulation-paymaster-post-op-gas-limit": z
.string()
.transform((val) => BigInt(val)),
"paymaster-gas-limit-multiplier": z.string().transform((val) => BigInt(val))
})

Expand Down
28 changes: 28 additions & 0 deletions src/cli/config/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,34 @@ export const gasEstimationOptions: CliCommandOptions<IGasEstimationArgsInput> =
type: "string",
require: true,
default: "110"
},
"simulation-call-gas-limit": {
description:
"UserOperation's callGasLimit used during gas estimation simulations",
type: "string",
require: true,
default: "10000000"
},
"simulation-verification-gas-limit": {
description:
"UserOperation's verificationGasLimit used during gas estimation simulations",
type: "string",
require: true,
default: "10000000"
},
"simulation-paymaster-verification-gas-limit": {
description:
"UserOperation's paymasterVerificationGasLimit used during gas estimation simulations",
type: "string",
require: true,
default: "5000000"
},
"simulation-paymaster-post-op-gas-limit": {
description:
"UserOperation's paymasterPostOpGasLimit used during gas estimation simulations",
type: "string",
require: true,
default: "2000000"
}
}

Expand Down
27 changes: 13 additions & 14 deletions src/rpc/rpcHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,27 +390,26 @@ export class RpcHandler implements IRpcEndpoint {
})
preVerificationGas = scaleBigIntByPercent(preVerificationGas, 110)

const {
simulationVerificationGasLimit,
simulationCallGasLimit,
simulationPaymasterVerificationGasLimit,
simulationPaymasterPostOpGasLimit
} = this.config

// biome-ignore lint/style/noParameterAssign: prepare userOperaiton for simulation
userOperation = {
...userOperation,
preVerificationGas,
verificationGasLimit: 10_000_000n,
callGasLimit: 10_000_000n
}

if (this.config.publicClient.chain.id === base.id) {
userOperation.verificationGasLimit = 5_000_000n
}

if (this.config.chainType === "hedera") {
// The eth_call gasLimit is set to 12_500_000 on Hedera.
userOperation.verificationGasLimit = 5_000_000n
userOperation.callGasLimit = 4_500_000n
verificationGasLimit: simulationVerificationGasLimit,
callGasLimit: simulationCallGasLimit
}

if (isVersion07(userOperation)) {
userOperation.paymasterPostOpGasLimit = 2_000_000n
userOperation.paymasterVerificationGasLimit = 5_000_000n
userOperation.paymasterVerificationGasLimit =
simulationPaymasterVerificationGasLimit
userOperation.paymasterPostOpGasLimit =
simulationPaymasterPostOpGasLimit
}

// This is necessary because entryPoint pays
Expand Down

0 comments on commit 04fd4ca

Please sign in to comment.