From 21ec06dfc2843bc923a5ba09fcef66c322fc5b34 Mon Sep 17 00:00:00 2001 From: colinlyguo Date: Mon, 18 Nov 2024 20:32:40 +0800 Subject: [PATCH 1/4] fix(gas-oracle): check blob gas fee before entering default gas price mode --- rollup/conf/config.json | 3 ++- rollup/internal/config/relayer.go | 3 +++ rollup/internal/controller/relayer/l1_relayer.go | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/rollup/conf/config.json b/rollup/conf/config.json index fa9ba680a..368a02e8c 100644 --- a/rollup/conf/config.json +++ b/rollup/conf/config.json @@ -20,7 +20,8 @@ "gas_price_diff": 50000, "check_committed_batches_window_minutes": 5, "l1_base_fee_default": 15000000000, - "l1_blob_base_fee_default": 1 + "l1_blob_base_fee_default": 1, + "l1_blob_base_fee_threshold": 100000000000 }, "gas_oracle_sender_signer_config": { "signer_type": "PrivateKey", diff --git a/rollup/internal/config/relayer.go b/rollup/internal/config/relayer.go index 4cbee5f29..f76010890 100644 --- a/rollup/internal/config/relayer.go +++ b/rollup/internal/config/relayer.go @@ -89,6 +89,9 @@ type GasOracleConfig struct { CheckCommittedBatchesWindowMinutes int `json:"check_committed_batches_window_minutes"` L1BaseFeeDefault uint64 `json:"l1_base_fee_default"` L1BlobBaseFeeDefault uint64 `json:"l1_blob_base_fee_default"` + + // L1BlobBaseFeeThreshold the threshold of L1 blob base fee to enter the default gas price mode + L1BlobBaseFeeThreshold uint64 `json:"l1_blob_base_fee_threshold"` } // SignerConfig - config of signer, contains type and config corresponding to type diff --git a/rollup/internal/controller/relayer/l1_relayer.go b/rollup/internal/controller/relayer/l1_relayer.go index 14d34ebb7..232f7eaee 100644 --- a/rollup/internal/controller/relayer/l1_relayer.go +++ b/rollup/internal/controller/relayer/l1_relayer.go @@ -166,7 +166,7 @@ func (r *Layer1Relayer) ProcessGasPriceOracle() { // If we are not committing batches due to high fees then we shouldn't update fees to prevent users from paying high l1_data_fee // Also, set fees to some default value, because we have already updated fees to some high values, probably var reachTimeout bool - if reachTimeout, err = r.commitBatchReachTimeout(); reachTimeout && err == nil { + if reachTimeout, err = r.commitBatchReachTimeout(); reachTimeout && block.BlobBaseFee > r.cfg.GasOracleConfig.L1BlobBaseFeeThreshold && err == nil { if r.lastBaseFee == r.cfg.GasOracleConfig.L1BaseFeeDefault && r.lastBlobBaseFee == r.cfg.GasOracleConfig.L1BlobBaseFeeDefault { return } From 3cf340315d40f4b24749d291d8c16a5937100526 Mon Sep 17 00:00:00 2001 From: colinlyguo Date: Mon, 18 Nov 2024 12:41:20 +0000 Subject: [PATCH 2/4] =?UTF-8?q?chore:=20auto=20version=20bump=E2=80=89[bot?= =?UTF-8?q?]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/version/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/version/version.go b/common/version/version.go index f84f9b78c..01f8a6df5 100644 --- a/common/version/version.go +++ b/common/version/version.go @@ -5,7 +5,7 @@ import ( "runtime/debug" ) -var tag = "v4.4.75" +var tag = "v4.4.76" var commit = func() string { if info, ok := debug.ReadBuildInfo(); ok { From 60d12d89d0e2233478d7adcdc55c8101444d9f47 Mon Sep 17 00:00:00 2001 From: colinlyguo Date: Mon, 18 Nov 2024 21:00:14 +0800 Subject: [PATCH 3/4] fix unit tests --- rollup/conf/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rollup/conf/config.json b/rollup/conf/config.json index 368a02e8c..c522c0fcf 100644 --- a/rollup/conf/config.json +++ b/rollup/conf/config.json @@ -21,7 +21,7 @@ "check_committed_batches_window_minutes": 5, "l1_base_fee_default": 15000000000, "l1_blob_base_fee_default": 1, - "l1_blob_base_fee_threshold": 100000000000 + "l1_blob_base_fee_threshold": 0 }, "gas_oracle_sender_signer_config": { "signer_type": "PrivateKey", From 324579ba89f0ff10f38afe4db7b9e958c7e36045 Mon Sep 17 00:00:00 2001 From: colinlyguo Date: Mon, 18 Nov 2024 21:13:10 +0800 Subject: [PATCH 4/4] remove an unused config --- rollup/cmd/gas_oracle/app/app.go | 8 +------- rollup/internal/controller/relayer/l1_relayer.go | 7 ++----- rollup/internal/controller/relayer/l1_relayer_test.go | 7 +++---- rollup/tests/gas_oracle_test.go | 4 ++-- 4 files changed, 8 insertions(+), 18 deletions(-) diff --git a/rollup/cmd/gas_oracle/app/app.go b/rollup/cmd/gas_oracle/app/app.go index 156c6c394..43775b044 100644 --- a/rollup/cmd/gas_oracle/app/app.go +++ b/rollup/cmd/gas_oracle/app/app.go @@ -78,15 +78,9 @@ func action(ctx *cli.Context) error { log.Crit("failed to connect l2 geth", "config file", cfgFile, "error", err) } - genesisPath := ctx.String(utils.Genesis.Name) - genesis, err := utils.ReadGenesis(genesisPath) - if err != nil { - log.Crit("failed to read genesis", "genesis file", genesisPath, "error", err) - } - l1watcher := watcher.NewL1WatcherClient(ctx.Context, l1client, cfg.L1Config.StartHeight, db, registry) - l1relayer, err := relayer.NewLayer1Relayer(ctx.Context, db, cfg.L1Config.RelayerConfig, genesis.Config, relayer.ServiceTypeL1GasOracle, registry) + l1relayer, err := relayer.NewLayer1Relayer(ctx.Context, db, cfg.L1Config.RelayerConfig, relayer.ServiceTypeL1GasOracle, registry) if err != nil { log.Crit("failed to create new l1 relayer", "config file", cfgFile, "error", err) } diff --git a/rollup/internal/controller/relayer/l1_relayer.go b/rollup/internal/controller/relayer/l1_relayer.go index 232f7eaee..36aeade98 100644 --- a/rollup/internal/controller/relayer/l1_relayer.go +++ b/rollup/internal/controller/relayer/l1_relayer.go @@ -11,7 +11,6 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/scroll-tech/go-ethereum/accounts/abi" "github.com/scroll-tech/go-ethereum/log" - "github.com/scroll-tech/go-ethereum/params" "gorm.io/gorm" "scroll-tech/common/types" @@ -30,8 +29,7 @@ import ( type Layer1Relayer struct { ctx context.Context - cfg *config.RelayerConfig - chainCfg *params.ChainConfig + cfg *config.RelayerConfig gasOracleSender *sender.Sender l1GasOracleABI *abi.ABI @@ -49,7 +47,7 @@ type Layer1Relayer struct { } // NewLayer1Relayer will return a new instance of Layer1RelayerClient -func NewLayer1Relayer(ctx context.Context, db *gorm.DB, cfg *config.RelayerConfig, chainCfg *params.ChainConfig, serviceType ServiceType, reg prometheus.Registerer) (*Layer1Relayer, error) { +func NewLayer1Relayer(ctx context.Context, db *gorm.DB, cfg *config.RelayerConfig, serviceType ServiceType, reg prometheus.Registerer) (*Layer1Relayer, error) { var gasOracleSender *sender.Sender var err error @@ -80,7 +78,6 @@ func NewLayer1Relayer(ctx context.Context, db *gorm.DB, cfg *config.RelayerConfi l1Relayer := &Layer1Relayer{ cfg: cfg, - chainCfg: chainCfg, ctx: ctx, l1BlockOrm: orm.NewL1Block(db), l2BlockOrm: orm.NewL2Block(db), diff --git a/rollup/internal/controller/relayer/l1_relayer_test.go b/rollup/internal/controller/relayer/l1_relayer_test.go index 08f6f9b50..129378eff 100644 --- a/rollup/internal/controller/relayer/l1_relayer_test.go +++ b/rollup/internal/controller/relayer/l1_relayer_test.go @@ -8,7 +8,6 @@ import ( "github.com/agiledragon/gomonkey/v2" "github.com/scroll-tech/go-ethereum/common" "github.com/scroll-tech/go-ethereum/crypto/kzg4844" - "github.com/scroll-tech/go-ethereum/params" "github.com/smartystreets/goconvey/convey" "github.com/stretchr/testify/assert" "gorm.io/gorm" @@ -36,7 +35,7 @@ func setupL1RelayerDB(t *testing.T) *gorm.DB { func testCreateNewL1Relayer(t *testing.T) { db := setupL1RelayerDB(t) defer database.CloseDB(db) - relayer, err := NewLayer1Relayer(context.Background(), db, cfg.L2Config.RelayerConfig, ¶ms.ChainConfig{}, ServiceTypeL1GasOracle, nil) + relayer, err := NewLayer1Relayer(context.Background(), db, cfg.L2Config.RelayerConfig, ServiceTypeL1GasOracle, nil) assert.NoError(t, err) assert.NotNil(t, relayer) defer relayer.StopSenders() @@ -58,7 +57,7 @@ func testL1RelayerGasOracleConfirm(t *testing.T) { l1Cfg := cfg.L1Config ctx, cancel := context.WithCancel(context.Background()) defer cancel() - l1Relayer, err := NewLayer1Relayer(ctx, db, l1Cfg.RelayerConfig, ¶ms.ChainConfig{}, ServiceTypeL1GasOracle, nil) + l1Relayer, err := NewLayer1Relayer(ctx, db, l1Cfg.RelayerConfig, ServiceTypeL1GasOracle, nil) assert.NoError(t, err) defer l1Relayer.StopSenders() @@ -91,7 +90,7 @@ func testL1RelayerProcessGasPriceOracle(t *testing.T) { l1Cfg := cfg.L1Config ctx, cancel := context.WithCancel(context.Background()) defer cancel() - l1Relayer, err := NewLayer1Relayer(ctx, db, l1Cfg.RelayerConfig, ¶ms.ChainConfig{}, ServiceTypeL1GasOracle, nil) + l1Relayer, err := NewLayer1Relayer(ctx, db, l1Cfg.RelayerConfig, ServiceTypeL1GasOracle, nil) assert.NoError(t, err) assert.NotNil(t, l1Relayer) defer l1Relayer.StopSenders() diff --git a/rollup/tests/gas_oracle_test.go b/rollup/tests/gas_oracle_test.go index c7a0b50e3..f44587dc2 100644 --- a/rollup/tests/gas_oracle_test.go +++ b/rollup/tests/gas_oracle_test.go @@ -30,7 +30,7 @@ func testImportL1GasPrice(t *testing.T) { l1Cfg := rollupApp.Config.L1Config // Create L1Relayer - l1Relayer, err := relayer.NewLayer1Relayer(context.Background(), db, l1Cfg.RelayerConfig, ¶ms.ChainConfig{LondonBlock: big.NewInt(0), BernoulliBlock: big.NewInt(0), CurieBlock: big.NewInt(0), DarwinTime: new(uint64), DarwinV2Time: new(uint64)}, relayer.ServiceTypeL1GasOracle, nil) + l1Relayer, err := relayer.NewLayer1Relayer(context.Background(), db, l1Cfg.RelayerConfig, relayer.ServiceTypeL1GasOracle, nil) assert.NoError(t, err) defer l1Relayer.StopSenders() @@ -105,7 +105,7 @@ func testImportDefaultL1GasPriceDueToL1GasPriceSpike(t *testing.T) { // set CheckCommittedBatchesWindowMinutes to zero to not pass check for commit batch timeout l1CfgCopy.RelayerConfig.GasOracleConfig.CheckCommittedBatchesWindowMinutes = 0 // Create L1Relayer - l1Relayer, err := relayer.NewLayer1Relayer(context.Background(), db, l1CfgCopy.RelayerConfig, ¶ms.ChainConfig{BernoulliBlock: big.NewInt(0), CurieBlock: big.NewInt(0)}, relayer.ServiceTypeL1GasOracle, nil) + l1Relayer, err := relayer.NewLayer1Relayer(context.Background(), db, l1CfgCopy.RelayerConfig, relayer.ServiceTypeL1GasOracle, nil) assert.NoError(t, err) defer l1Relayer.StopSenders()