Skip to content

Commit

Permalink
use maxL1BaseFeeEstimate if l1BaseFee=0
Browse files Browse the repository at this point in the history
  • Loading branch information
mouseless-eth committed Oct 1, 2024
1 parent db22351 commit b5f34a9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
13 changes: 13 additions & 0 deletions src/handlers/gasPriceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,19 @@ class ArbitrumManager {
)
}

public async getMaxL1BaseFee() {
const queue = this.queueL1BaseFee

if (queue.length === 0) {
return maxUint128
}

return queue.reduce(
(acc: bigint, cur) => maxBigInt(cur.baseFee, acc),
queue[0].baseFee
)
}

public async getMaxL2BaseFee() {
const queue = this.queueL2BaseFee

Expand Down
9 changes: 6 additions & 3 deletions src/utils/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -660,10 +660,13 @@ export async function calcArbitrumPreVerificationGas(
gasPriceManager.arbitrumManager.saveL2BaseFee(l2BaseFee)

if (validate) {
if (l1BaseFeeEstimate === 0n) {
l1BaseFeeEstimate =
await gasPriceManager.arbitrumManager.getMaxL1BaseFee()
}

// gasEstimateL1Component source: https://github.com/OffchainLabs/nitro/blob/5cd7d6913eb6b4dedb08f6ea49d7f9802d2cc5b9/execution/nodeInterface/NodeInterface.go#L515-L551
const l1BaseFee =
l1BaseFeeEstimate === 0n ? maxUint256 : l1BaseFeeEstimate
const feesForL1 = (gasForL1 * l2BaseFee) / l1BaseFee
const feesForL1 = (gasForL1 * l2BaseFee) / l1BaseFeeEstimate

const minL1BaseFeeEstimate =
await gasPriceManager.arbitrumManager.getMinL1BaseFee()
Expand Down

0 comments on commit b5f34a9

Please sign in to comment.