From 4bf9cc12955a01e7867f0a08314fa19e43facef6 Mon Sep 17 00:00:00 2001 From: mouseless <97399882+mouseless-eth@users.noreply.github.com> Date: Sat, 1 Jun 2024 23:29:46 +0100 Subject: [PATCH 1/2] add flag for gas price bump --- src/cli/config/bundler.ts | 4 ++++ src/cli/config/options.ts | 6 ++++++ src/cli/handler.ts | 1 + src/utils/gasPriceManager.ts | 35 ++++------------------------------- 4 files changed, 15 insertions(+), 31 deletions(-) diff --git a/src/cli/config/bundler.ts b/src/cli/config/bundler.ts index 3fef1a57..9711ab33 100644 --- a/src/cli/config/bundler.ts +++ b/src/cli/config/bundler.ts @@ -60,6 +60,10 @@ export const bundlerArgsSchema = z.object({ "max-bundle-wait": z.number().int().min(0), "max-bundle-size": z.number().int().min(0), + "gas-price-bump": z + .string() + .transform((val) => BigInt(val)) + .default("100"), "gas-price-floor-percent": z.number().int().min(0), "gas-price-expiry": z.number().int().min(0), "gas-price-multipliers": z diff --git a/src/cli/config/options.ts b/src/cli/config/options.ts index 09a1fee9..1131f267 100644 --- a/src/cli/config/options.ts +++ b/src/cli/config/options.ts @@ -84,6 +84,12 @@ export const bundlerOptions: CliCommandOptions = { require: true, default: true }, + "gas-price-bump": { + description: "Amount to multiply the gas prices fetched from the node", + type: "string", + require: false, + default: 100 + }, "gas-price-floor-percent": { description: "The minimum percentage of incoming user operation gas prices compared to the gas price used by the bundler to submit bundles", diff --git a/src/cli/handler.ts b/src/cli/handler.ts index cdce4e70..20b3ebfc 100644 --- a/src/cli/handler.ts +++ b/src/cli/handler.ts @@ -133,6 +133,7 @@ export async function bundlerHandler(args: IOptionsInput): Promise { parsedArgs["log-level"] } ), + parsedArgs["gas-price-bump"], parsedArgs["gas-price-expiry"] ) diff --git a/src/utils/gasPriceManager.ts b/src/utils/gasPriceManager.ts index d7f00e2b..83833860 100644 --- a/src/utils/gasPriceManager.ts +++ b/src/utils/gasPriceManager.ts @@ -42,12 +42,14 @@ export class GasPriceManager { maxPriorityFeePerGas: bigint }[] = [] // Store pairs of [price, timestamp] private maxQueueSize + private gasBumpMultiplier: bigint constructor( chain: Chain, publicClient: PublicClient, legacyTransactions: boolean, logger: Logger, + gasBumpMultiplier: bigint, gasPriceTimeValidityInSeconds = 10 ) { this.maxQueueSize = gasPriceTimeValidityInSeconds @@ -55,6 +57,7 @@ export class GasPriceManager { this.publicClient = publicClient this.legacyTransactions = legacyTransactions this.logger = logger + this.gasBumpMultiplier = gasBumpMultiplier } private getDefaultGasFee( @@ -87,40 +90,10 @@ export class GasPriceManager { } } - private getBumpAmount(chainId: number) { - if (chainId === chains.sepolia.id) { - return 120n - } - - if (chainId === chains.celo.id) { - return 150n - } - - if ( - chainId === chains.arbitrum.id || - chainId === chains.scroll.id || - chainId === chains.scrollSepolia.id || - chainId === chains.arbitrumGoerli.id || - chainId === chains.mainnet.id || - chainId === chains.mantle.id || - chainId === 22222 || - chainId === chains.sepolia.id || - chainId === chains.base.id || - chainId === chains.dfk.id || - chainId === chains.celoAlfajores.id || - chainId === chains.avalanche.id || - chainId === chains.linea.id - ) { - return 111n - } - - return 100n - } - private bumpTheGasPrice( gasPriceParameters: GasPriceParameters ): GasPriceParameters { - const bumpAmount = this.getBumpAmount(this.chain.id) + const bumpAmount = this.gasBumpMultiplier const maxPriorityFeePerGas = maxBigInt( gasPriceParameters.maxPriorityFeePerGas, From 4d08a198bba6d0fd21f59e185fd158734b10f5ba Mon Sep 17 00:00:00 2001 From: mouseless <97399882+mouseless-eth@users.noreply.github.com> Date: Sun, 2 Jun 2024 01:36:48 +0100 Subject: [PATCH 2/2] fix build --- src/cli/config/options.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli/config/options.ts b/src/cli/config/options.ts index 1131f267..5eed5969 100644 --- a/src/cli/config/options.ts +++ b/src/cli/config/options.ts @@ -88,7 +88,7 @@ export const bundlerOptions: CliCommandOptions = { description: "Amount to multiply the gas prices fetched from the node", type: "string", require: false, - default: 100 + default: "100" }, "gas-price-floor-percent": { description: