Skip to content

Commit

Permalink
Adapt base round timeout on every block, because block time could hav…
Browse files Browse the repository at this point in the history
…e been affected by the governance
  • Loading branch information
Stefan-Ethernal committed Apr 25, 2024
1 parent 01447d0 commit d3ceeaf
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions consensus/polybft/polybft.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,13 +508,6 @@ func (p *Polybft) Initialize() error {
}

p.ibft = newIBFTConsensusWrapper(p.logger, p.runtime, p)
// if block time is greater than default base round timeout,
// set base round timeout as twice the block time
blockTime := time.Duration(int64(p.config.BlockTime)) * time.Second
if blockTime >= core.DefaultBaseRoundTimeout {
baseRoundTimeout := int64(blockTime.Seconds() * baseRoundTimeoutScaleFactor)
p.ibft.SetBaseRoundTimeout(time.Duration(baseRoundTimeout) * time.Second)
}

if err = p.subscribeToIbftTopic(); err != nil {
return fmt.Errorf("IBFT topic subscription failed: %w", err)
Expand Down Expand Up @@ -671,6 +664,14 @@ func (p *Polybft) startConsensusProtocol() {
continue
}

// if block time is greater than default base round timeout,
// set base round timeout as twice the block time
blockTime := time.Duration(int64(p.config.BlockTime)) * time.Second
if blockTime >= core.DefaultBaseRoundTimeout {
baseRoundTimeout := int64(blockTime.Seconds() * baseRoundTimeoutScaleFactor)
p.ibft.SetBaseRoundTimeout(time.Duration(baseRoundTimeout) * time.Second)
}

sequenceCh, stopSequence = p.ibft.runSequence(latestHeader.Number + 1)
}

Expand Down

0 comments on commit d3ceeaf

Please sign in to comment.