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

Fix op-stack PVG calculations #397

Merged
merged 3 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
use highest gasValues when validating
  • Loading branch information
mouseless0x committed Jan 9, 2025
commit 7cf7a0166641bbd28ae20e136d25777da1a2dc26
21 changes: 21 additions & 0 deletions src/handlers/gasPriceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,27 @@ export class GasPriceManager {
return maxBaseFeePerGas
}

public async getHighestMaxFeePerGas(): Promise<bigint> {
let highestMaxFeePerGas = this.maxFeePerGasQueue.getMaxValue()
if (!highestMaxFeePerGas) {
const gasPrice = await this.getGasPrice()
highestMaxFeePerGas = gasPrice.maxFeePerGas
}

return highestMaxFeePerGas
}

public async getHighestMaxPriorityFeePerGas(): Promise<bigint> {
let highestMaxPriorityFeePerGas =
this.maxPriorityFeePerGasQueue.getMaxValue()
if (!highestMaxPriorityFeePerGas) {
const gasPrice = await this.getGasPrice()
highestMaxPriorityFeePerGas = gasPrice.maxPriorityFeePerGas
}

return highestMaxPriorityFeePerGas
}

private async getMinMaxFeePerGas(): Promise<bigint> {
let minMaxFeePerGas = this.maxFeePerGasQueue.getMinValue()
if (!minMaxFeePerGas) {
Expand Down
12 changes: 9 additions & 3 deletions src/utils/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -628,9 +628,15 @@ export async function calcOptimismPreVerificationGas(
op.maxFeePerGas = gasPrices.maxFeePerGas
}

const l2MaxFee = op.maxFeePerGas

const l2PriorityFee = baseFeePerGas + op.maxPriorityFeePerGas
const l2MaxFee = validate
? await gasPriceManager.getHighestMaxFeePerGas()
: op.maxFeePerGas

const l2PriorityFee =
baseFeePerGas +
(validate
? await gasPriceManager.getHighestMaxPriorityFeePerGas()
: op.maxPriorityFeePerGas)

const l2price = minBigInt(l2MaxFee, l2PriorityFee)

Expand Down
Loading