Skip to content

Commit fa0927c

Browse files
alexisdevilliersalexisgeorgehao
authored
optimize l2 GasPrice comparasion (#1581)
Co-authored-by: alexis <[email protected]> Co-authored-by: georgehao <[email protected]>
1 parent f92029a commit fa0927c

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

common/version/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"runtime/debug"
66
)
77

8-
var tag = "v4.4.84"
8+
var tag = "v4.4.85"
99

1010
var commit = func() string {
1111
if info, ok := debug.ReadBuildInfo(); ok {

rollup/internal/controller/relayer/l1_relayer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,14 +251,14 @@ func (r *Layer1Relayer) shouldUpdateGasOracle(baseFee uint64, blobBaseFee uint64
251251
}
252252

253253
expectedBaseFeeDelta := r.lastBaseFee*r.gasPriceDiff/gasPriceDiffPrecision + 1
254-
if baseFee >= r.minGasPrice && (baseFee >= r.lastBaseFee+expectedBaseFeeDelta || baseFee+expectedBaseFeeDelta <= r.lastBaseFee) {
254+
if baseFee >= r.minGasPrice && math.Abs(float64(baseFee)-float64(r.lastBaseFee)) >= float64(expectedBaseFeeDelta) {
255255
return true
256256
}
257257

258258
expectedBlobBaseFeeDelta := r.lastBlobBaseFee * r.gasPriceDiff / gasPriceDiffPrecision
259259
// Plus a minimum of 0.01 gwei, since the blob base fee is usually low, preventing short-time flunctuation.
260260
expectedBlobBaseFeeDelta += 10000000
261-
if blobBaseFee >= r.minGasPrice && (blobBaseFee >= r.lastBlobBaseFee+expectedBlobBaseFeeDelta || blobBaseFee+expectedBlobBaseFeeDelta <= r.lastBlobBaseFee) {
261+
if blobBaseFee >= r.minGasPrice && math.Abs(float64(blobBaseFee)-float64(r.lastBlobBaseFee)) >= float64(expectedBlobBaseFeeDelta) {
262262
return true
263263
}
264264

rollup/internal/controller/relayer/l2_relayer.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,9 @@ func (r *Layer2Relayer) ProcessGasPriceOracle() {
344344
expectedDelta = 1
345345
}
346346

347-
// last is undefine or (suggestGasPriceUint64 >= minGasPrice && exceed diff)
348-
if r.lastGasPrice == 0 || (suggestGasPriceUint64 >= r.minGasPrice && (suggestGasPriceUint64 >= r.lastGasPrice+expectedDelta || suggestGasPriceUint64+expectedDelta <= r.lastGasPrice)) {
347+
// last is undefined or (suggestGasPriceUint64 >= minGasPrice && exceed diff)
348+
if r.lastGasPrice == 0 || (suggestGasPriceUint64 >= r.minGasPrice &&
349+
(math.Abs(float64(suggestGasPriceUint64)-float64(r.lastGasPrice)) >= float64(expectedDelta))) {
349350
data, err := r.l2GasOracleABI.Pack("setL2BaseFee", suggestGasPrice)
350351
if err != nil {
351352
log.Error("Failed to pack setL2BaseFee", "batch.Hash", batch.Hash, "GasPrice", suggestGasPrice.Uint64(), "err", err)

0 commit comments

Comments
 (0)