Skip to content

Commit d24c81a

Browse files
authoredJul 11, 2023
Revert "feat!: account for time already elapsed when waiting after the commit (#965)" (#1033)
This reverts commit cc1bc3f.
1 parent fc8278c commit d24c81a

File tree

8 files changed

+43
-43
lines changed

8 files changed

+43
-43
lines changed
 

‎DOCKER/docker-entrypoint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ if [ ! -d "$CMTHOME/config" ]; then
99
-e "s/^proxy_app\s*=.*/proxy_app = \"$PROXY_APP\"/" \
1010
-e "s/^moniker\s*=.*/moniker = \"$MONIKER\"/" \
1111
-e 's/^addr_book_strict\s*=.*/addr_book_strict = false/' \
12-
-e 's/^target_height_duration\s*=.*/target_height_duration = "1000ms"/' \
12+
-e 's/^timeout_commit\s*=.*/timeout_commit = "500ms"/' \
1313
-e 's/^index_all_tags\s*=.*/index_all_tags = true/' \
1414
-e 's,^laddr = "tcp://127.0.0.1:26657",laddr = "tcp://0.0.0.0:26657",' \
1515
-e 's/^prometheus\s*=.*/prometheus = true/' \

‎config/config.go

+14-19
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import (
88
"os"
99
"path/filepath"
1010
"time"
11-
12-
tmtime "github.com/tendermint/tendermint/types/time"
1311
)
1412

1513
const (
@@ -946,10 +944,11 @@ type ConsensusConfig struct {
946944
TimeoutPrecommit time.Duration `mapstructure:"timeout_precommit"`
947945
// How much the timeout_precommit increases with each round
948946
TimeoutPrecommitDelta time.Duration `mapstructure:"timeout_precommit_delta"`
949-
// TargetHeigtDuration is used to determine how long we wait after a
950-
// block is committed. If this time is shorter than the actual time to reach
951-
// consensus for that height, then we do not wait at all.
952-
TargetHeightDuration time.Duration `mapstructure:"target_height_duration"`
947+
// How long we wait after committing a block, before starting on the new
948+
// height (this gives us a chance to receive some more precommits, even
949+
// though we already have +2/3).
950+
// NOTE: when modifying, make sure to update time_iota_ms genesis parameter
951+
TimeoutCommit time.Duration `mapstructure:"timeout_commit"`
953952

954953
// Make progress as soon as we have all the precommits (as if TimeoutCommit = 0)
955954
SkipTimeoutCommit bool `mapstructure:"skip_timeout_commit"`
@@ -969,13 +968,13 @@ type ConsensusConfig struct {
969968
func DefaultConsensusConfig() *ConsensusConfig {
970969
return &ConsensusConfig{
971970
WalPath: filepath.Join(defaultDataDir, "cs.wal", "wal"),
972-
TimeoutPropose: 2000 * time.Millisecond,
971+
TimeoutPropose: 3000 * time.Millisecond,
973972
TimeoutProposeDelta: 500 * time.Millisecond,
974973
TimeoutPrevote: 1000 * time.Millisecond,
975974
TimeoutPrevoteDelta: 500 * time.Millisecond,
976975
TimeoutPrecommit: 1000 * time.Millisecond,
977976
TimeoutPrecommitDelta: 500 * time.Millisecond,
978-
TargetHeightDuration: 3000 * time.Millisecond,
977+
TimeoutCommit: 1000 * time.Millisecond,
979978
SkipTimeoutCommit: false,
980979
CreateEmptyBlocks: true,
981980
CreateEmptyBlocksInterval: 0 * time.Second,
@@ -995,7 +994,7 @@ func TestConsensusConfig() *ConsensusConfig {
995994
cfg.TimeoutPrecommit = 10 * time.Millisecond
996995
cfg.TimeoutPrecommitDelta = 1 * time.Millisecond
997996
// NOTE: when modifying, make sure to update time_iota_ms (testGenesisFmt) in toml.go
998-
cfg.TargetHeightDuration = 70 * time.Millisecond
997+
cfg.TimeoutCommit = 10 * time.Millisecond
999998
cfg.SkipTimeoutCommit = true
1000999
cfg.PeerGossipSleepDuration = 5 * time.Millisecond
10011000
cfg.PeerQueryMaj23SleepDuration = 250 * time.Millisecond
@@ -1029,14 +1028,10 @@ func (cfg *ConsensusConfig) Precommit(round int32) time.Duration {
10291028
) * time.Nanosecond
10301029
}
10311030

1032-
// NextStartTime adds the TargetHeightDuration to the provided starting time.
1033-
func (cfg *ConsensusConfig) NextStartTime(t time.Time) time.Time {
1034-
newStartTime := t.Add(cfg.TargetHeightDuration)
1035-
now := tmtime.Now()
1036-
if newStartTime.Before(now) {
1037-
return now
1038-
}
1039-
return newStartTime
1031+
// Commit returns the amount of time to wait for straggler votes after receiving +2/3 precommits
1032+
// for a single block (ie. a commit).
1033+
func (cfg *ConsensusConfig) Commit(t time.Time) time.Time {
1034+
return t.Add(cfg.TimeoutCommit)
10401035
}
10411036

10421037
// WalFile returns the full path to the write-ahead log file
@@ -1073,8 +1068,8 @@ func (cfg *ConsensusConfig) ValidateBasic() error {
10731068
if cfg.TimeoutPrecommitDelta < 0 {
10741069
return errors.New("timeout_precommit_delta can't be negative")
10751070
}
1076-
if cfg.TargetHeightDuration < 0 {
1077-
return errors.New("target_height_duration can't be negative")
1071+
if cfg.TimeoutCommit < 0 {
1072+
return errors.New("timeout_commit can't be negative")
10781073
}
10791074
if cfg.CreateEmptyBlocksInterval < 0 {
10801075
return errors.New("create_empty_blocks_interval can't be negative")

‎config/config_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ func TestConsensusConfig_ValidateBasic(t *testing.T) {
157157
"TimeoutPrecommit negative": {func(c *ConsensusConfig) { c.TimeoutPrecommit = -1 }, true},
158158
"TimeoutPrecommitDelta": {func(c *ConsensusConfig) { c.TimeoutPrecommitDelta = time.Second }, false},
159159
"TimeoutPrecommitDelta negative": {func(c *ConsensusConfig) { c.TimeoutPrecommitDelta = -1 }, true},
160-
"TargetHeightDuration": {func(c *ConsensusConfig) { c.TargetHeightDuration = time.Second }, false},
161-
"TargetHeightDuration negative": {func(c *ConsensusConfig) { c.TargetHeightDuration = -1 }, true},
160+
"TimeoutCommit": {func(c *ConsensusConfig) { c.TimeoutCommit = time.Second }, false},
161+
"TimeoutCommit negative": {func(c *ConsensusConfig) { c.TimeoutCommit = -1 }, true},
162162
"PeerGossipSleepDuration": {func(c *ConsensusConfig) { c.PeerGossipSleepDuration = time.Second }, false},
163163
"PeerGossipSleepDuration negative": {func(c *ConsensusConfig) { c.PeerGossipSleepDuration = -1 }, true},
164164
"PeerQueryMaj23SleepDuration": {func(c *ConsensusConfig) { c.PeerQueryMaj23SleepDuration = time.Second }, false},

‎config/toml.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -464,10 +464,10 @@ timeout_prevote_delta = "{{ .Consensus.TimeoutPrevoteDelta }}"
464464
timeout_precommit = "{{ .Consensus.TimeoutPrecommit }}"
465465
# How much the timeout_precommit increases with each round
466466
timeout_precommit_delta = "{{ .Consensus.TimeoutPrecommitDelta }}"
467-
# TargetHeigtDuration is used to determine how long we wait after a
468-
# block is committed. If this time is shorter than the actual time to reach
469-
# consensus for that height, then we do not wait at all.
470-
target_height_duration = "{{ .Consensus.TargetHeightDuration }}"
467+
# How long we wait after committing a block, before starting on the new
468+
# height (this gives us a chance to receive some more precommits, even
469+
# though we already have +2/3).
470+
timeout_commit = "{{ .Consensus.TimeoutCommit }}"
471471
472472
# How many blocks to look back to check existence of the node's consensus votes before joining consensus
473473
# When non-zero, the node will panic upon restart

‎consensus/state.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -664,11 +664,14 @@ func (cs *State) updateToState(state sm.State) {
664664
cs.updateRoundStep(0, cstypes.RoundStepNewHeight)
665665

666666
if cs.CommitTime.IsZero() {
667-
// If it is the first block, start time is equal to
668-
// states last block time which is the genesis time.
669-
cs.StartTime = state.LastBlockTime
667+
// "Now" makes it easier to sync up dev nodes.
668+
// We add timeoutCommit to allow transactions
669+
// to be gathered for the first block.
670+
// And alternative solution that relies on clocks:
671+
// cs.StartTime = state.LastBlockTime.Add(timeoutCommit)
672+
cs.StartTime = cs.config.Commit(cmttime.Now())
670673
} else {
671-
cs.StartTime = cs.config.NextStartTime(cs.StartTime)
674+
cs.StartTime = cs.config.Commit(cs.CommitTime)
672675
}
673676

674677
cs.Validators = validators

‎docs/core/configuration.md

+12-10
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,10 @@ timeout_prevote_delta = "500ms"
414414
timeout_precommit = "1s"
415415
# How much the timeout_precommit increases with each round
416416
timeout_precommit_delta = "500ms"
417-
# TargetHeigtDuration is used to determine how long we wait after a
418-
# block is committed. If this time is shorter than the actual time to reach
419-
# consensus for that height, then we do not wait at all.
420-
target_height_duration = "15s"
417+
# How long we wait after committing a block, before starting on the new
418+
# height (this gives us a chance to receive some more precommits, even
419+
# though we already have +2/3).
420+
timeout_commit = "1s"
421421

422422
# How many blocks to look back to check existence of the node's consensus votes before joining consensus
423423
# When non-zero, the node will panic upon restart
@@ -537,9 +537,12 @@ timeout_prevote = "1s"
537537
timeout_prevote_delta = "500ms"
538538
timeout_precommit = "1s"
539539
timeout_precommit_delta = "500ms"
540-
target_height_duration = "1s"
540+
timeout_commit = "1s"
541541
```
542542

543+
Note that in a successful round, the only timeout that we absolutely wait no
544+
matter what is `timeout_commit`.
545+
543546
Here's a brief summary of the timeouts:
544547

545548
- `timeout_propose` = how long we wait for a proposal block before prevoting nil
@@ -549,8 +552,7 @@ Here's a brief summary of the timeouts:
549552
- `timeout_prevote_delta` = how much the `timeout_prevote` increases with each round
550553
- `timeout_precommit` = how long we wait after receiving +2/3 precommits for
551554
anything (ie. not a single block or nil)
552-
- `timeout_precommit_delta` = how much the timeout_precommit increases with
553-
each round
554-
- `target_height_duration` = used to determine how long we wait after a
555-
block is committed. If this time is shorter than the actual time to reach
556-
consensus for that height, then we do not wait at all.
555+
- `timeout_precommit_delta` = how much the `timeout_precommit` increases with each round
556+
- `timeout_commit` = how long we wait after committing a block, before starting
557+
on the new height (this gives us a chance to receive some more precommits,
558+
even though we already have +2/3)

‎state/execution.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ func execBlockOnProxyApp(
407407
return nil, err
408408
}
409409

410-
logger.Info("executed block", "height", block.Height, "num_valid_txs", validTxs, "num_invalid_txs", invalidTxs, "time", block.Time)
410+
logger.Info("executed block", "height", block.Height, "num_valid_txs", validTxs, "num_invalid_txs", invalidTxs)
411411
return abciResponses, nil
412412
}
413413

‎test/maverick/consensus/state.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -900,9 +900,9 @@ func (cs *State) updateToState(state sm.State) {
900900
// to be gathered for the first block.
901901
// And alternative solution that relies on clocks:
902902
// cs.StartTime = state.LastBlockTime.Add(timeoutCommit)
903-
cs.StartTime = state.LastBlockTime
903+
cs.StartTime = cs.config.Commit(cmttime.Now())
904904
} else {
905-
cs.StartTime = cs.config.NextStartTime(cs.StartTime)
905+
cs.StartTime = cs.config.Commit(cs.CommitTime)
906906
}
907907

908908
cs.Validators = validators

0 commit comments

Comments
 (0)