consensus: deprecate time iota ms (#5792)

time_iota_ms is intended to ensure that an honest validator always generates timestamps 
with time increasing monotonically. For this purpose, it always suffices to have this parameter
set to `1ms`. Allowing users to choose different numbers increases bug surface area.
Thus the code now ignores the user provided time_iota_ms parameter (marking it as unused), 
and uses 1ms internally.
This commit is contained in:
Dev Ojha
2020-12-17 17:32:42 +01:00
committed by GitHub
parent ced66e4eb5
commit 8c0af72987
6 changed files with 10 additions and 11 deletions
+1
View File
@@ -43,6 +43,7 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi
- [blockchain/v0] \#5741 Relax termination conditions and increase sync timeout (@melekes)
- [cli] \#5772 `gen_node_key` output now contains node ID (`id` field) (@melekes)
- [blockchain/v2] \#5774 Send status request when new peer joins (@melekes)
- [consensus] \#5792 Deprecates the `time_iota_ms` consensus parameter, to reduce the bug surface. The parameter is no longer used. (@valardragon)
### BUG FIXES
-2
View File
@@ -825,7 +825,6 @@ type ConsensusConfig struct {
// How long we wait after committing a block, before starting on the new
// height (this gives us a chance to receive some more precommits, even
// though we already have +2/3).
// NOTE: when modifying, make sure to update time-iota-ms genesis parameter
TimeoutCommit time.Duration `mapstructure:"timeout-commit"`
// Make progress as soon as we have all the precommits (as if TimeoutCommit = 0)
@@ -871,7 +870,6 @@ func TestConsensusConfig() *ConsensusConfig {
cfg.TimeoutPrevoteDelta = 1 * time.Millisecond
cfg.TimeoutPrecommit = 10 * time.Millisecond
cfg.TimeoutPrecommitDelta = 1 * time.Millisecond
// NOTE: when modifying, make sure to update time_iota_ms (testGenesisFmt) in toml.go
cfg.TimeoutCommit = 10 * time.Millisecond
cfg.SkipTimeoutCommit = true
cfg.PeerGossipSleepDuration = 5 * time.Millisecond
+6 -1
View File
@@ -2098,12 +2098,17 @@ func (cs *State) signVote(
return vote, err
}
// voteTime ensures monotonicity of the time a validator votes on.
// It ensures that for a prior block with a BFT-timestamp of T,
// any vote from this validator will have time at least time T + 1ms.
// This is needed, as monotonicity of time is a guarantee that BFT time provides.
func (cs *State) voteTime() time.Time {
now := tmtime.Now()
minVoteTime := now
// Minimum time increment between blocks
const timeIota = time.Millisecond
// TODO: We should remove next line in case we don't vote for v in case cs.ProposalBlock == nil,
// even if cs.LockedBlock != nil. See https://docs.tendermint.com/master/spec/.
timeIota := time.Duration(cs.state.ConsensusParams.Block.TimeIotaMs) * time.Millisecond
if cs.LockedBlock != nil {
// See the BFT time spec https://docs.tendermint.com/master/spec/consensus/bft-time.html
minVoteTime = cs.LockedBlock.Time.Add(timeIota)
+1 -3
View File
@@ -53,9 +53,7 @@ definition](https://github.com/tendermint/tendermint/blob/master/types/genesis.g
- `block`
- `max_bytes`: Max block size, in bytes.
- `max_gas`: Max gas per block.
- `time_iota_ms`: Minimum time increment between consecutive blocks (in
milliseconds). If the block header timestamp is ahead of the system clock,
decrease this value.
- `time_iota_ms`: Unused. This has been deprecated and will be removed in a future version.
- `evidence`
- `max_age_num_blocks`: Max age of evidence, in blocks. The basic formula
for calculating this is: MaxAgeDuration / {average block time}.
+1 -4
View File
@@ -25,10 +25,7 @@ message BlockParams {
// Max gas per block.
// Note: must be greater or equal to -1
int64 max_gas = 2;
// Minimum time increment between consecutive blocks (in milliseconds) If the
// block header timestamp is ahead of the system clock, decrease this value.
//
// Not exposed to the application.
// This parameter is unused.
int64 time_iota_ms = 3;
}
+1 -1
View File
@@ -36,7 +36,7 @@ func DefaultBlockParams() tmproto.BlockParams {
return tmproto.BlockParams{
MaxBytes: 22020096, // 21MB
MaxGas: -1,
TimeIotaMs: 1000, // 1s
TimeIotaMs: 1, // 1s, parameter is now unused
}
}