Skip to content

Commit

Permalink
add callGasLimit multiplier flag (#342)
Browse files Browse the repository at this point in the history
* add callGasLimit multiplier flag

* move paymasterGasLimit multiplier to gasOptions

* only multiply v0.6

---------

Co-authored-by: mouseless <[email protected]>
  • Loading branch information
mouseless0x and mouseless0x authored Oct 23, 2024
1 parent e453977 commit ec6fe4a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
3 changes: 3 additions & 0 deletions src/cli/alto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
bundlerOptions,
compatibilityOptions,
debugOptions,
gasEstimationOptions,
logOptions,
rpcOptions,
serverOptions
Expand Down Expand Up @@ -64,6 +65,8 @@ export function getAltoCli(): yargs.Argv {
.group(Object.keys(logOptions), "Logging Options:")
.options(debugOptions)
.group(Object.keys(debugOptions), "Debug Options:")
.options(gasEstimationOptions)
.group(Object.keys(gasEstimationOptions), "Gas Estimation Options:")
// blank scriptName so that help text doesn't display the cli name before each command
.scriptName("")
.demandCommand(1)
Expand Down
7 changes: 3 additions & 4 deletions src/cli/config/bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,6 @@ export const compatibilityArgsSchema = z.object({
"balance-override": z.boolean(),
"local-gas-limit-calculation": z.boolean(),
"flush-stuck-transactions-during-startup": z.boolean(),
"paymaster-gas-limit-multiplier": z
.string()
.transform((val) => BigInt(val)),
"fixed-gas-limit-for-estimation": z
.string()
.transform((val) => BigInt(val))
Expand Down Expand Up @@ -210,7 +207,9 @@ export const gasEstimationArgsSchema = z.object({
"binary-search-gas-allowance": z
.string()
.transform((val) => BigInt(val))
.default("1000000")
.default("1000000"),
"call-gas-limit-multiplier": z.string().transform((val) => BigInt(val)),
"paymaster-gas-limit-multiplier": z.string().transform((val) => BigInt(val))
})

export type IBundlerArgs = z.infer<typeof bundlerArgsSchema>
Expand Down
21 changes: 14 additions & 7 deletions src/cli/config/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,20 @@ export const gasEstimationOptions: CliCommandOptions<IGasEstimationArgsInput> =
type: "string",
require: false,
default: "1000000"
},
"call-gas-limit-multiplier": {
description:
"Amount to multiply the call gas limits fetched from simulations",
type: "string",
require: true,
default: "100"
},
"paymaster-gas-limit-multiplier": {
description:
"Amount to multiply the paymaster gas limits fetched from simulations",
type: "string",
require: true,
default: "110"
}
}

Expand Down Expand Up @@ -268,13 +282,6 @@ export const compatibilityOptions: CliCommandOptions<ICompatibilityArgsInput> =
type: "string",
require: false,
default: "v1"
},
"paymaster-gas-limit-multiplier": {
description:
"Amount to multiply the paymaster gas limits fetched from simulations",
type: "string",
require: true,
default: "110"
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/rpc/rpcHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,13 @@ export class RpcHandler implements IRpcEndpoint {
callGasLimit = 0n
}

if (isVersion06(userOperation)) {
callGasLimit = scaleBigIntByPercent(
callGasLimit,
Number(this.config.callGasLimitMultiplier)
)
}

// If a balance override is provided for the sender, perform an additional simulation
// to verify the userOperation succeeds with the specified balance.
if (stateOverrides?.[userOperation.sender]?.balance) {
Expand Down

0 comments on commit ec6fe4a

Please sign in to comment.