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

Make sending gas fees optional #290

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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: 2 additions & 1 deletion src/cli/config/bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ export const compatibilityArgsSchema = z.object({
"fixed-gas-limit-for-estimation": z
.string()
.transform((val) => BigInt(val))
.optional()
.optional(),
"use-gas-fees-during-estimation": z.boolean().default(true)
})

export const serverArgsSchema = z.object({
Expand Down
6 changes: 6 additions & 0 deletions src/cli/config/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,12 @@ export const compatibilityOptions: CliCommandOptions<ICompatibilityArgsInput> =
type: "string",
require: true,
default: "110"
},
"use-gas-fees-during-estimation": {
description: "Use maxFeePerGas during estimation",
type: "boolean",
require: false,
default: true
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/cli/setupServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ const getExecutor = ({
parsedArgs["legacy-transactions"],
parsedArgs["fixed-gas-limit-for-estimation"],
parsedArgs["block-tag-support"],
parsedArgs["local-gas-limit-calculation"]
parsedArgs["local-gas-limit-calculation"],
parsedArgs["use-gas-fees-during-estimation"]
)
}

Expand Down
14 changes: 10 additions & 4 deletions src/executor/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export class Executor {
blockTagSupport: boolean
mutex: Mutex
eventManager: EventManager
sendGasFees: boolean

constructor(
publicClient: PublicClient,
Expand All @@ -141,7 +142,8 @@ export class Executor {
legacyTransactions = false,
fixedGasLimitForEstimation?: bigint,
blockTagSupport = true,
localGasLimitCalculation = false
localGasLimitCalculation = false,
sendGasFees = true
) {
this.publicClient = publicClient
this.walletClient = walletClient
Expand All @@ -158,6 +160,7 @@ export class Executor {
this.eventManager = eventManager
this.blockTagSupport = blockTagSupport
this.entryPoints = entryPoints
this.sendGasFees = sendGasFees

this.mutex = new Mutex()
}
Expand Down Expand Up @@ -279,7 +282,8 @@ export class Executor {
this.legacyTransactions,
this.fixedGasLimitForEstimation,
this.reputationManager,
this.logger
this.logger,
this.sendGasFees
)

const childLogger = this.logger.child({
Expand Down Expand Up @@ -616,7 +620,8 @@ export class Executor {
this.legacyTransactions,
this.fixedGasLimitForEstimation,
this.reputationManager,
childLogger
childLogger,
this.sendGasFees
)

if (simulatedOps.length === 0) {
Expand Down Expand Up @@ -912,7 +917,8 @@ export class Executor {
this.legacyTransactions,
this.fixedGasLimitForEstimation,
this.reputationManager,
childLogger
childLogger,
this.sendGasFees
)

gasLimit += 10_000n
Expand Down
11 changes: 7 additions & 4 deletions src/executor/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ export async function filterOpsAndEstimateGas(
onlyPre1559: boolean,
fixedGasLimitForEstimation: bigint | undefined,
reputationManager: InterfaceReputationManager,
logger: Logger
logger: Logger,
sendGasFees: boolean
) {
const simulatedOps: {
owh: UserOperationWithHash
Expand All @@ -148,9 +149,11 @@ export async function filterOpsAndEstimateGas(
callContext.type !== "default" || // All compressed ops are v6 by default
isVersion06(simulatedOps[0].owh.mempoolUserOperation as UserOperation)

const gasOptions = onlyPre1559
? { gasPrice: maxFeePerGas }
: { maxFeePerGas, maxPriorityFeePerGas }
const gasOptions = sendGasFees
? onlyPre1559
? { gasPrice: maxFeePerGas }
: { maxFeePerGas, maxPriorityFeePerGas }
: {}

let fixedEstimationGasLimit: bigint | undefined = fixedGasLimitForEstimation
let retriesLeft = 5
Expand Down
Loading