Skip to content

Commit 8247a74

Browse files
author
alexis
committed
optimize l2 GasPrice comparasion
1 parent 45b23ed commit 8247a74

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

rollup/internal/controller/relayer/l2_relayer.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,8 @@ func (r *Layer2Relayer) ProcessGasPriceOracle() {
345345
}
346346

347347
// last is undefine or (suggestGasPriceUint64 >= minGasPrice && exceed diff)
348-
if r.lastGasPrice == 0 || (suggestGasPriceUint64 >= r.minGasPrice && (suggestGasPriceUint64 >= r.lastGasPrice+expectedDelta || suggestGasPriceUint64+expectedDelta <= r.lastGasPrice)) {
348+
if r.lastGasPrice == 0 || (suggestGasPriceUint64 >= r.minGasPrice &&
349+
(math.Abs(float64(suggestGasPriceUint64)-float64(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)