mirror of
https://github.com/scroll-tech/scroll.git
synced 2026-01-08 21:48:11 -05:00
feat(rollup-relayer): add blob fee tolerance (#1773)
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
|||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
)
|
)
|
||||||
|
|
||||||
var tag = "v4.7.9"
|
var tag = "v4.7.10"
|
||||||
|
|
||||||
var commit = func() string {
|
var commit = func() string {
|
||||||
if info, ok := debug.ReadBuildInfo(); ok {
|
if info, ok := debug.ReadBuildInfo(); ok {
|
||||||
|
|||||||
@@ -58,7 +58,8 @@
|
|||||||
"min_batches": 1,
|
"min_batches": 1,
|
||||||
"max_batches": 6,
|
"max_batches": 6,
|
||||||
"timeout": 7200,
|
"timeout": 7200,
|
||||||
"backlog_max": 75
|
"backlog_max": 75,
|
||||||
|
"blob_fee_tolerance": 500000000
|
||||||
},
|
},
|
||||||
"gas_oracle_config": {
|
"gas_oracle_config": {
|
||||||
"min_gas_price": 0,
|
"min_gas_price": 0,
|
||||||
|
|||||||
@@ -48,6 +48,10 @@ type BatchSubmission struct {
|
|||||||
TimeoutSec int64 `json:"timeout"`
|
TimeoutSec int64 `json:"timeout"`
|
||||||
// The maximum number of pending batches to keep in the backlog.
|
// The maximum number of pending batches to keep in the backlog.
|
||||||
BacklogMax int64 `json:"backlog_max"`
|
BacklogMax int64 `json:"backlog_max"`
|
||||||
|
// BlobFeeTolerance is the absolute tolerance (in wei) added to the target blob fee.
|
||||||
|
// If the current fee is below target + tolerance, we proceed with submission.
|
||||||
|
// This prevents skipping submission when the price difference is negligible.
|
||||||
|
BlobFeeTolerance uint64 `json:"blob_fee_tolerance"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChainMonitor this config is used to get batch status from chain_monitor API.
|
// ChainMonitor this config is used to get batch status from chain_monitor API.
|
||||||
|
|||||||
@@ -1255,16 +1255,20 @@ func (r *Layer2Relayer) skipSubmitByFee(oldest time.Time, metrics *l2RelayerMetr
|
|||||||
target := calculateTargetPrice(windowSec, r.batchStrategy, oldest, hist)
|
target := calculateTargetPrice(windowSec, r.batchStrategy, oldest, hist)
|
||||||
current := hist[len(hist)-1]
|
current := hist[len(hist)-1]
|
||||||
|
|
||||||
|
// apply absolute tolerance offset to target
|
||||||
|
tolerance := new(big.Int).SetUint64(r.cfg.BatchSubmission.BlobFeeTolerance)
|
||||||
|
threshold := new(big.Int).Add(target, tolerance)
|
||||||
|
|
||||||
currentFloat, _ := current.Float64()
|
currentFloat, _ := current.Float64()
|
||||||
targetFloat, _ := target.Float64()
|
targetFloat, _ := target.Float64()
|
||||||
metrics.rollupL2RelayerCurrentBlobPrice.Set(currentFloat)
|
metrics.rollupL2RelayerCurrentBlobPrice.Set(currentFloat)
|
||||||
metrics.rollupL2RelayerTargetBlobPrice.Set(targetFloat)
|
metrics.rollupL2RelayerTargetBlobPrice.Set(targetFloat)
|
||||||
|
|
||||||
// if current fee > target and still inside the timeout window, skip
|
// if current fee > threshold (target + tolerance) and still inside the timeout window, skip
|
||||||
if current.Cmp(target) > 0 && time.Since(oldest) < time.Duration(windowSec)*time.Second {
|
if current.Cmp(threshold) > 0 && time.Since(oldest) < time.Duration(windowSec)*time.Second {
|
||||||
return true, fmt.Errorf(
|
return true, fmt.Errorf(
|
||||||
"blob-fee above target & window not yet passed; current=%s target=%s age=%s",
|
"blob-fee above threshold & window not yet passed; current=%s target=%s threshold=%s tolerance=%s age=%s",
|
||||||
current.String(), target.String(), time.Since(oldest),
|
current.String(), target.String(), threshold.String(), tolerance.String(), time.Since(oldest),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user