Skip to content

Commit

Permalink
[fix]: fix gasoracle update frequency
Browse files Browse the repository at this point in the history
  • Loading branch information
Sha3nS committed Aug 15, 2023
1 parent db46a0c commit ed6fa65
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 5 additions & 2 deletions gas-oracle/oracle/gas_price_oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion gas-oracle/oracle/overhead.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit ed6fa65

Please sign in to comment.