Browse Source

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.
pull/5810/head
Dev Ojha 4 years ago
committed by GitHub
parent
commit
8c0af72987
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 10 additions and 11 deletions
  1. +1
    -0
      CHANGELOG_PENDING.md
  2. +0
    -2
      config/config.go
  3. +6
    -1
      consensus/state.go
  4. +1
    -3
      docs/tendermint-core/using-tendermint.md
  5. +1
    -4
      proto/tendermint/types/params.proto
  6. +1
    -1
      types/params.go

+ 1
- 0
CHANGELOG_PENDING.md 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) - [blockchain/v0] \#5741 Relax termination conditions and increase sync timeout (@melekes)
- [cli] \#5772 `gen_node_key` output now contains node ID (`id` field) (@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) - [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 ### BUG FIXES


+ 0
- 2
config/config.go View File

@ -825,7 +825,6 @@ type ConsensusConfig struct {
// How long we wait after committing a block, before starting on the new // 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 // height (this gives us a chance to receive some more precommits, even
// though we already have +2/3). // though we already have +2/3).
// NOTE: when modifying, make sure to update time-iota-ms genesis parameter
TimeoutCommit time.Duration `mapstructure:"timeout-commit"` TimeoutCommit time.Duration `mapstructure:"timeout-commit"`
// Make progress as soon as we have all the precommits (as if TimeoutCommit = 0) // 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.TimeoutPrevoteDelta = 1 * time.Millisecond
cfg.TimeoutPrecommit = 10 * time.Millisecond cfg.TimeoutPrecommit = 10 * time.Millisecond
cfg.TimeoutPrecommitDelta = 1 * 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.TimeoutCommit = 10 * time.Millisecond
cfg.SkipTimeoutCommit = true cfg.SkipTimeoutCommit = true
cfg.PeerGossipSleepDuration = 5 * time.Millisecond cfg.PeerGossipSleepDuration = 5 * time.Millisecond


+ 6
- 1
consensus/state.go View File

@ -2098,12 +2098,17 @@ func (cs *State) signVote(
return vote, err 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 { func (cs *State) voteTime() time.Time {
now := tmtime.Now() now := tmtime.Now()
minVoteTime := 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, // 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/. // 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 { if cs.LockedBlock != nil {
// See the BFT time spec https://docs.tendermint.com/master/spec/consensus/bft-time.html // See the BFT time spec https://docs.tendermint.com/master/spec/consensus/bft-time.html
minVoteTime = cs.LockedBlock.Time.Add(timeIota) minVoteTime = cs.LockedBlock.Time.Add(timeIota)


+ 1
- 3
docs/tendermint-core/using-tendermint.md View File

@ -53,9 +53,7 @@ definition](https://github.com/tendermint/tendermint/blob/master/types/genesis.g
- `block` - `block`
- `max_bytes`: Max block size, in bytes. - `max_bytes`: Max block size, in bytes.
- `max_gas`: Max gas per block. - `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` - `evidence`
- `max_age_num_blocks`: Max age of evidence, in blocks. The basic formula - `max_age_num_blocks`: Max age of evidence, in blocks. The basic formula
for calculating this is: MaxAgeDuration / {average block time}. for calculating this is: MaxAgeDuration / {average block time}.


+ 1
- 4
proto/tendermint/types/params.proto View File

@ -25,10 +25,7 @@ message BlockParams {
// Max gas per block. // Max gas per block.
// Note: must be greater or equal to -1 // Note: must be greater or equal to -1
int64 max_gas = 2; 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; int64 time_iota_ms = 3;
} }


+ 1
- 1
types/params.go View File

@ -36,7 +36,7 @@ func DefaultBlockParams() tmproto.BlockParams {
return tmproto.BlockParams{ return tmproto.BlockParams{
MaxBytes: 22020096, // 21MB MaxBytes: 22020096, // 21MB
MaxGas: -1, MaxGas: -1,
TimeIotaMs: 1000, // 1s
TimeIotaMs: 1, // 1s, parameter is now unused
} }
} }


Loading…
Cancel
Save