From 57b776070dc2b37528fdb6a950bca47d689b3280 Mon Sep 17 00:00:00 2001 From: maskpp Date: Wed, 13 Sep 2023 14:37:18 +0800 Subject: [PATCH] Add a field to control chain_monitor --- rollup/conf/config.json | 1 + rollup/internal/config/relayer.go | 9 +++++---- rollup/internal/controller/relayer/l2_relayer.go | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/rollup/conf/config.json b/rollup/conf/config.json index 5261f30726..d311972ff6 100644 --- a/rollup/conf/config.json +++ b/rollup/conf/config.json @@ -54,6 +54,7 @@ "gas_price_diff": 50000 }, "chain_monitor": { + "enable_chain_monitor": false, "timeout": 3, "try_times": 5, "base_url": "http://localhost:8750" diff --git a/rollup/internal/config/relayer.go b/rollup/internal/config/relayer.go index b41c09f9fd..58ce555281 100644 --- a/rollup/internal/config/relayer.go +++ b/rollup/internal/config/relayer.go @@ -39,9 +39,10 @@ type SenderConfig struct { // ChainMonitor this config is used to get batch status from chain_monitor API. type ChainMonitor struct { - TimeOut int `json:"timeout"` - TryTimes int `json:"try_times"` - BaseURL string `json:"base_url"` + EnableChainMonitor bool `json:"enable_chain_monitor"` + TimeOut int `json:"timeout"` + TryTimes int `json:"try_times"` + BaseURL string `json:"base_url"` } // RelayerConfig loads relayer configuration items. @@ -56,7 +57,7 @@ type RelayerConfig struct { // gas oracle config GasOracleConfig *GasOracleConfig `json:"gas_oracle_config"` // ChainMonitor config of monitoring service - ChainMonitor *ChainMonitor `json:"chain_monitor,omitempty"` + ChainMonitor *ChainMonitor `json:"chain_monitor"` // L1CommitGasLimitMultiplier multiplier for fallback gas limit in commitBatch txs L1CommitGasLimitMultiplier float64 `json:"l1_commit_gas_limit_multiplier,omitempty"` // The private key of the relayer diff --git a/rollup/internal/controller/relayer/l2_relayer.go b/rollup/internal/controller/relayer/l2_relayer.go index c2e1144ead..771e55dc8b 100644 --- a/rollup/internal/controller/relayer/l2_relayer.go +++ b/rollup/internal/controller/relayer/l2_relayer.go @@ -124,7 +124,7 @@ func NewLayer2Relayer(ctx context.Context, l2Client *ethclient.Client, db *gorm. } // chain_monitor client - if cfg.ChainMonitor != nil { + if cfg.ChainMonitor.EnableChainMonitor { layer2Relayer.chainMonitorClient = resty.New() layer2Relayer.chainMonitorClient.SetRetryCount(cfg.ChainMonitor.TryTimes) layer2Relayer.chainMonitorClient.SetTimeout(time.Duration(cfg.ChainMonitor.TimeOut) * time.Second) @@ -554,7 +554,7 @@ type batchStatusResponse struct { } func (r *Layer2Relayer) getBatchStatusByIndex(batchIndex uint64) (bool, error) { - if r.chainMonitorClient == nil { + if !r.cfg.ChainMonitor.EnableChainMonitor { return true, nil } var response batchStatusResponse