Skip to content

Commit

Permalink
Add a field to control chain_monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
mask-pp committed Sep 13, 2023
1 parent 7506adf commit 57b7760
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions rollup/conf/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"gas_price_diff": 50000
},
"chain_monitor": {
"enable_chain_monitor": false,
"timeout": 3,
"try_times": 5,
"base_url": "http://localhost:8750"
Expand Down
9 changes: 5 additions & 4 deletions rollup/internal/config/relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions rollup/internal/controller/relayer/l2_relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 57b7760

Please sign in to comment.