diff --git a/gas-oracle/oracle/gas_price_oracle.go b/gas-oracle/oracle/gas_price_oracle.go index dfa88d3d3..2a470eaf7 100644 --- a/gas-oracle/oracle/gas_price_oracle.go +++ b/gas-oracle/oracle/gas_price_oracle.go @@ -206,7 +206,7 @@ func (g *GasPriceOracle) OverHeadLoop() { db, height := readGasOracleSyncHeight() log.Info("ReadGasOracleSyncHeight", "height", height) // set channel - stateBatchAppendChan := make(chan *bindings.StateCommitmentChainStateBatchAppended, 10) + stateBatchAppendChan := make(chan *bindings.StateCommitmentChainStateBatchAppended, 1) // set context ctcTotalBatches, err := g.ctcBackend.GetTotalBatches(&bind.CallOpts{}) @@ -247,7 +247,10 @@ func (g *GasPriceOracle) OverHeadLoop() { case stateBatchAppendChan <- iter.Event: log.Info("write event into channel", "channel length is", len(stateBatchAppendChan)) default: - log.Error("write too many event into channel, increase channel length") + // discard additional event to process the last one + <-stateBatchAppendChan + stateBatchAppendChan <- iter.Event + log.Warn("write additional event into channel, will ignore prev events") } } _ = writeGasOracleSyncHeight(db, latestHeader.Number) diff --git a/gas-oracle/oracle/overhead.go b/gas-oracle/oracle/overhead.go index a2008d437..77b939aba 100644 --- a/gas-oracle/oracle/overhead.go +++ b/gas-oracle/oracle/overhead.go @@ -88,7 +88,11 @@ func wrapUpdateOverhead(l2Backend DeployContractBackend, cfg *Config) (func(*big if err != nil { return err } - + // skip update if overhead is not changed + if overhead == newOverheadLevel { + log.Info("skip update overhead", "overhead", overhead) + return nil + } // Use the configured gas price if it is set, // otherwise use gas estimation if cfg.gasPrice != nil {