Skip to content

Commit

Permalink
[R4R]-{develop}: fix gasoracle update frequency (#1344)
Browse files Browse the repository at this point in the history
# Goals of PR

Core changes:
fix gasoracle update frequency

Notes:
no

Related Issues:
no
  • Loading branch information
Sha3nS committed Aug 15, 2023
2 parents db46a0c + ed6fa65 commit 0a5ea1f
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 0a5ea1f

Please sign in to comment.