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

add callGasLimit multiplier flag #342

Merged
merged 3 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
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
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
Loading