mirror of
https://github.com/scroll-tech/scroll.git
synced 2026-01-09 22:18:00 -05:00
feat(gas-oracle): tweak gas price update logic (#1305)
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
||||
"runtime/debug"
|
||||
)
|
||||
|
||||
var tag = "v4.4.1"
|
||||
var tag = "v4.4.2"
|
||||
|
||||
var commit = func() string {
|
||||
if info, ok := debug.ReadBuildInfo(); ok {
|
||||
|
||||
@@ -19,7 +19,9 @@
|
||||
},
|
||||
"gas_oracle_config": {
|
||||
"min_gas_price": 0,
|
||||
"gas_price_diff": 50000
|
||||
"gas_price_diff": 50000,
|
||||
"l1_base_fee_weight": 0.132,
|
||||
"l1_blob_base_fee_weight": 0.145
|
||||
},
|
||||
"gas_oracle_sender_private_key": "1313131313131313131313131313131313131313131313131313131313131313"
|
||||
}
|
||||
|
||||
@@ -70,8 +70,14 @@ type RelayerConfig struct {
|
||||
type GasOracleConfig struct {
|
||||
// MinGasPrice store the minimum gas price to set.
|
||||
MinGasPrice uint64 `json:"min_gas_price"`
|
||||
// GasPriceDiff store the percentage of gas price difference.
|
||||
// GasPriceDiff is the minimum percentage of gas price difference to update gas oracle.
|
||||
GasPriceDiff uint64 `json:"gas_price_diff"`
|
||||
|
||||
// The following configs are only for updating L1 gas price, used for sender in L2.
|
||||
// The weight for L1 base fee.
|
||||
L1BaseFeeWeight float64 `json:"l1_base_fee_weight"`
|
||||
// The weight for L1 blob base fee.
|
||||
L1BlobBaseFeeWeight float64 `json:"l1_blob_base_fee_weight"`
|
||||
}
|
||||
|
||||
// relayerConfigAlias RelayerConfig alias name
|
||||
|
||||
@@ -3,6 +3,7 @@ package relayer
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math"
|
||||
"math/big"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
@@ -35,9 +36,11 @@ type Layer1Relayer struct {
|
||||
gasOracleSender *sender.Sender
|
||||
l1GasOracleABI *abi.ABI
|
||||
|
||||
lastGasPrice uint64
|
||||
minGasPrice uint64
|
||||
gasPriceDiff uint64
|
||||
lastGasPrice uint64
|
||||
minGasPrice uint64
|
||||
gasPriceDiff uint64
|
||||
l1BaseFeeWeight float64
|
||||
l1BlobBaseFeeWeight float64
|
||||
|
||||
l1BlockOrm *orm.L1Block
|
||||
l2BlockOrm *orm.L2Block
|
||||
@@ -86,8 +89,10 @@ func NewLayer1Relayer(ctx context.Context, db *gorm.DB, cfg *config.RelayerConfi
|
||||
gasOracleSender: gasOracleSender,
|
||||
l1GasOracleABI: bridgeAbi.L1GasPriceOracleABI,
|
||||
|
||||
minGasPrice: minGasPrice,
|
||||
gasPriceDiff: gasPriceDiff,
|
||||
minGasPrice: minGasPrice,
|
||||
gasPriceDiff: gasPriceDiff,
|
||||
l1BaseFeeWeight: cfg.GasOracleConfig.L1BaseFeeWeight,
|
||||
l1BlobBaseFeeWeight: cfg.GasOracleConfig.L1BlobBaseFeeWeight,
|
||||
}
|
||||
|
||||
l1Relayer.metrics = initL1RelayerMetrics(reg)
|
||||
@@ -140,7 +145,7 @@ func (r *Layer1Relayer) ProcessGasPriceOracle() {
|
||||
|
||||
var baseFee uint64
|
||||
if isBernoulli && block.BlobBaseFee != 0 {
|
||||
baseFee = block.BlobBaseFee
|
||||
baseFee = uint64(math.Ceil(r.l1BaseFeeWeight*float64(block.BaseFee) + r.l1BlobBaseFeeWeight*float64(block.BlobBaseFee)))
|
||||
} else {
|
||||
baseFee = block.BaseFee
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user