From 8ae5f1b13a5d8481ea9322f283650cf9e5287adf Mon Sep 17 00:00:00 2001 From: mouseless <97399882+mouseless-eth@users.noreply.github.com> Date: Sat, 11 Jan 2025 14:35:14 +0000 Subject: [PATCH] save only op gas values --- src/handlers/optimismManager.ts | 36 +++++++++++++++++---------------- src/utils/validation.ts | 12 +++++------ 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/handlers/optimismManager.ts b/src/handlers/optimismManager.ts index 1df7e7ad..f2003aaf 100644 --- a/src/handlers/optimismManager.ts +++ b/src/handlers/optimismManager.ts @@ -2,34 +2,34 @@ import { Address, maxUint256 } from "viem" import { SlidingWindowTimedQueue } from "../utils/slidingWindowTimedQueue" class GasQueues { - private l2PriorityFeeQueue: SlidingWindowTimedQueue - private l2MaxFeeQueue: SlidingWindowTimedQueue + private opMaxPriorityFeeQueue: SlidingWindowTimedQueue + private opMaxFeeQueue: SlidingWindowTimedQueue public lastAccessed: number constructor(queueValidity: number) { this.lastAccessed = Date.now() - this.l2PriorityFeeQueue = new SlidingWindowTimedQueue(queueValidity) - this.l2MaxFeeQueue = new SlidingWindowTimedQueue(queueValidity) + this.opMaxPriorityFeeQueue = new SlidingWindowTimedQueue(queueValidity) + this.opMaxFeeQueue = new SlidingWindowTimedQueue(queueValidity) } private access() { this.lastAccessed = Date.now() } - public getMaxL2PriorityFee() { + public getHighestMaxPriorityFee() { this.access() - return this.l2PriorityFeeQueue.getMaxValue() + return this.opMaxPriorityFeeQueue.getMaxValue() } - public getMaxL2MaxFee() { + public getHighestMaxFee() { this.access() - return this.l2MaxFeeQueue.getMaxValue() + return this.opMaxFeeQueue.getMaxValue() } - public saveValues(values: { l2MaxFee: bigint; l2PriorityFee: bigint }) { + public saveValues(values: { opMaxFee: bigint; opMaxPriorityFee: bigint }) { this.access() - this.l2MaxFeeQueue.saveValue(values.l2MaxFee) - this.l2PriorityFeeQueue.saveValue(values.l2PriorityFee) + this.opMaxFeeQueue.saveValue(values.opMaxFee) + this.opMaxPriorityFeeQueue.saveValue(values.opMaxPriorityFee) } } @@ -71,12 +71,14 @@ export class OptimismManager { return this.l1FeeQueue.getMinValue() || 1n } - public getMaxL2PriorityFee(sender: Address) { - return this.getOrCreate(sender)?.getMaxL2PriorityFee() || maxUint256 + public getHighestMaxPriorityFee(sender: Address) { + return ( + this.getOrCreate(sender)?.getHighestMaxPriorityFee() || maxUint256 + ) } - public getMaxL2MaxFee(sender: Address) { - return this.getOrCreate(sender)?.getMaxL2MaxFee() || maxUint256 + public getHighestMaxFee(sender: Address) { + return this.getOrCreate(sender)?.getHighestMaxFee() || maxUint256 } public saveOptimismValues({ @@ -87,8 +89,8 @@ export class OptimismManager { l1Fee: bigint sender: Address values: { - l2MaxFee: bigint - l2PriorityFee: bigint + opMaxFee: bigint + opMaxPriorityFee: bigint } }) { this.l1FeeQueue.saveValue(l1Fee) diff --git a/src/utils/validation.ts b/src/utils/validation.ts index 1607cfd7..18fcf180 100644 --- a/src/utils/validation.ts +++ b/src/utils/validation.ts @@ -636,10 +636,10 @@ export async function calcOptimismPreVerificationGas( let l2MaxFee let l2PriorityFee if (validate) { - l2MaxFee = gasPriceManager.optimismManager.getMaxL2MaxFee(op.sender) - l2PriorityFee = gasPriceManager.optimismManager.getMaxL2PriorityFee( - op.sender - ) + l2MaxFee = gasPriceManager.optimismManager.getHighestMaxFee(op.sender) + l2PriorityFee = + baseFeePerGas + + gasPriceManager.optimismManager.getHighestMaxPriorityFee(op.sender) } else { l2MaxFee = op.maxFeePerGas l2PriorityFee = baseFeePerGas + op.maxPriorityFeePerGas @@ -647,8 +647,8 @@ export async function calcOptimismPreVerificationGas( l1Fee, sender: op.sender, values: { - l2MaxFee, - l2PriorityFee + opMaxFee: op.maxFeePerGas, + opMaxPriorityFee: op.maxPriorityFeePerGas } }) }