Skip to content

Commit

Permalink
allow configuring the lookback window
Browse files Browse the repository at this point in the history
  • Loading branch information
gakonst committed Nov 20, 2019
1 parent b6c389e commit c476eff
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,11 @@ var (
Usage: "Default minimum difference between two consecutive block's timestamps in seconds",
Value: uint64(eth.DefaultConfig.Istanbul.ProposerPolicy),
}
IstanbulLookbackWindowFlag = cli.Uint64Flag{
Name: "istanbul.lookbackwindow",
Usage: "Default number of blocks to use for forgiving downtime",
Value: uint64(eth.DefaultConfig.Istanbul.LookbackWindow),
}
)

// MakeDataDir retrieves the currently requested data directory, terminating
Expand Down
2 changes: 2 additions & 0 deletions consensus/istanbul/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type Config struct {
BlockPeriod uint64 `toml:",omitempty"` // Default minimum difference between two consecutive block's timestamps in second
ProposerPolicy ProposerPolicy `toml:",omitempty"` // The policy for proposer selection
Epoch uint64 `toml:",omitempty"` // The number of blocks after which to checkpoint and reset the pending votes
LookbackWindow uint64 `toml:",omitempty"` // The window of blocks in which a validator is forgived from voting
ValidatorEnodeDBPath string `toml:",omitempty"` // The location for the validator enodes DB
}

Expand All @@ -37,5 +38,6 @@ var DefaultConfig = &Config{
BlockPeriod: 1,
ProposerPolicy: ShuffledRoundRobin,
Epoch: 30000,
LookbackWindow: 12,
ValidatorEnodeDBPath: "validatorenodes",
}
3 changes: 3 additions & 0 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ func CreateConsensusEngine(ctx *node.ServiceContext, chainConfig *params.ChainCo
if chainConfig.Istanbul.Epoch != 0 {
config.Istanbul.Epoch = chainConfig.Istanbul.Epoch
}
if chainConfig.Istanbul.LookbackWindow != 0 {
config.Istanbul.LookbackWindow = chainConfig.Istanbul.LookbackWindow
}
config.Istanbul.ProposerPolicy = istanbul.ProposerPolicy(chainConfig.Istanbul.ProposerPolicy)
dataDir := getDataDirOrFail(ctx)
return istanbulBackend.New(&config.Istanbul, db, dataDir)
Expand Down
5 changes: 3 additions & 2 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,9 @@ func (c *CliqueConfig) String() string {

// IstanbulConfig is the consensus engine configs for Istanbul based sealing.
type IstanbulConfig struct {
Epoch uint64 `json:"epoch"` // Epoch length to reset votes and checkpoint
ProposerPolicy uint64 `json:"policy"` // The policy for proposer selection
Epoch uint64 `json:"epoch"` // Epoch length to reset votes and checkpoint
ProposerPolicy uint64 `json:"policy"` // The policy for proposer selection
LookbackWindow uint64 `json:"lookback"` // The number of blocks to look back when calculating uptime
}

// String implements the stringer interface, returning the consensus engine details.
Expand Down

0 comments on commit c476eff

Please sign in to comment.