Skip to content

Commit

Permalink
always fetch gasPrice from network when bundling (#347)
Browse files Browse the repository at this point in the history
Co-authored-by: mouseless <[email protected]>
  • Loading branch information
mouseless0x and mouseless0x authored Oct 30, 2024
1 parent 7b15e26 commit ac6c685
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
11 changes: 7 additions & 4 deletions src/executor/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ export class Executor {
): Promise<ReplaceTransactionResult> {
const newRequest = { ...transactionInfo.transactionRequest }

const gasPriceParameters = await this.gasPriceManager.getGasPrice()
const gasPriceParameters =
await this.gasPriceManager.getNetworkGasPrice()

newRequest.maxFeePerGas = maxBigInt(
gasPriceParameters.maxFeePerGas,
Expand Down Expand Up @@ -490,7 +491,7 @@ export class Executor {

const wallets = Array.from(allWallets)

const gasPrice = await this.gasPriceManager.getGasPrice()
const gasPrice = await this.gasPriceManager.getNetworkGasPrice()
const promises = wallets.map((wallet) => {
flushStuckTransaction(
this.config.publicClient,
Expand Down Expand Up @@ -666,7 +667,8 @@ export class Executor {
})
childLogger.debug("bundling user operation")

const gasPriceParameters = await this.gasPriceManager.getGasPrice()
const gasPriceParameters =
await this.gasPriceManager.getNetworkGasPrice()
childLogger.debug({ gasPriceParameters }, "got gas price")

const nonce = await this.config.publicClient.getTransactionCount({
Expand Down Expand Up @@ -945,7 +947,8 @@ export class Executor {
})
childLogger.debug("bundling compressed user operation")

const gasPriceParameters = await this.gasPriceManager.getGasPrice()
const gasPriceParameters =
await this.gasPriceManager.getNetworkGasPrice()
childLogger.debug({ gasPriceParameters }, "got gas price")

const nonce = await this.config.publicClient.getTransactionCount({
Expand Down
3 changes: 2 additions & 1 deletion src/executor/executorManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,8 @@ export class ExecutorManager {
await this.refreshUserOperationStatuses()

// for all still not included check if needs to be replaced (based on gas price)
const gasPriceParameters = await this.gasPriceManager.getGasPrice()
const gasPriceParameters =
await this.gasPriceManager.getNetworkGasPrice()
this.logger.trace(
{ gasPriceParameters },
"fetched gas price parameters"
Expand Down
2 changes: 1 addition & 1 deletion src/executor/senderManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export class SenderManager {

if (Object.keys(balancesMissing).length > 0) {
const { maxFeePerGas, maxPriorityFeePerGas } =
await this.gasPriceManager.getGasPrice()
await this.gasPriceManager.getNetworkGasPrice()

if (this.config.refillHelperContract) {
const instructions = []
Expand Down
4 changes: 4 additions & 0 deletions src/handlers/gasPriceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,10 @@ export class GasPriceManager {
}
}

public async getNetworkGasPrice(): Promise<GasPriceParameters> {
return await this.innerGetGasPrice()
}

public async getMaxBaseFeePerGas(): Promise<bigint> {
let maxBaseFeePerGas = this.baseFeePerGasQueue.getMaxValue()
if (!maxBaseFeePerGas) {
Expand Down

0 comments on commit ac6c685

Please sign in to comment.