Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: account for time already elapsed when waiting after the commit #965

Merged
merged 23 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3dc00cb
feat!: consider time already elapsed when waiting after the commit
evan-forbes Feb 7, 2023
eaba332
chore: minor doc changes
evan-forbes Feb 7, 2023
c98755d
chore: try a different default config time
evan-forbes Feb 7, 2023
10e0cb4
chore: try increasing the config again
evan-forbes Feb 7, 2023
ccfffb3
fix: use appropriate default time
evan-forbes Feb 7, 2023
e2ce341
fix: docs
evan-forbes Feb 7, 2023
45072f3
chore: simplify addition and rename
evan-forbes Feb 15, 2023
b604775
chore: revert pointless go mod tidy change
evan-forbes Feb 15, 2023
033c4e4
chore: consistent config
evan-forbes Feb 15, 2023
c104ece
chore: replace config comments
evan-forbes Feb 15, 2023
8e5b17b
chore: fix a few remaining round -> height name changes
evan-forbes Mar 8, 2023
d477caa
Merge branch 'v0.34.x-celestia' into evan/dynamic-timeout-commits
evan-forbes Mar 15, 2023
c460586
fix: lingering compile errors from merge
evan-forbes Mar 15, 2023
189b3aa
fix: silly bug
evan-forbes Mar 18, 2023
b82bcba
fix: use correct next start time
evan-forbes Mar 18, 2023
7845254
dynamic block time modifications (#983)
cmwaters Mar 21, 2023
3b5b343
Merge branch 'v0.34.x-celestia' into evan/dynamic-timeout-commits
evan-forbes Mar 29, 2023
ec7a58d
chore: remove event collector
evan-forbes Apr 17, 2023
5391ac0
Update test/maverick/consensus/state.go
evan-forbes Apr 17, 2023
d8b6dc1
Update test/maverick/consensus/state.go
evan-forbes Apr 17, 2023
86c1add
Merge branch 'evan/dynamic-timeout-commits' of github.com:celestiaorg…
evan-forbes Apr 17, 2023
ea9a7ee
chore: formatting
evan-forbes Apr 17, 2023
3913ed5
Merge branch 'v0.34.x-celestia' into evan/dynamic-timeout-commits
evan-forbes Apr 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DOCKER/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if [ ! -d "$TMHOME/config" ]; then
-e "s/^proxy_app\s*=.*/proxy_app = \"$PROXY_APP\"/" \
-e "s/^moniker\s*=.*/moniker = \"$MONIKER\"/" \
-e 's/^addr_book_strict\s*=.*/addr_book_strict = false/' \
-e 's/^timeout_commit\s*=.*/timeout_commit = "500ms"/' \
-e 's/^target_round_duration\s*=.*/target_round_duration = "1000ms"/' \
evan-forbes marked this conversation as resolved.
Show resolved Hide resolved
-e 's/^index_all_tags\s*=.*/index_all_tags = true/' \
-e 's,^laddr = "tcp://127.0.0.1:26657",laddr = "tcp://0.0.0.0:26657",' \
-e 's/^prometheus\s*=.*/prometheus = true/' \
Expand Down
24 changes: 11 additions & 13 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -928,11 +928,10 @@ type ConsensusConfig struct {
TimeoutPrecommit time.Duration `mapstructure:"timeout_precommit"`
// How much the timeout_precommit increases with each round
TimeoutPrecommitDelta time.Duration `mapstructure:"timeout_precommit_delta"`
// 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"`
// TargetHeigtDuration is used to determine how long we wait after a
// block is committed. If this time is shorter than the actual time to reach
// consensus for that height, then we do not wait at all.
TargetHeightDuration time.Duration `mapstructure:"target_round_duration"`

// Make progress as soon as we have all the precommits (as if TimeoutCommit = 0)
SkipTimeoutCommit bool `mapstructure:"skip_timeout_commit"`
Expand All @@ -958,7 +957,7 @@ func DefaultConsensusConfig() *ConsensusConfig {
TimeoutPrevoteDelta: 500 * time.Millisecond,
TimeoutPrecommit: 1000 * time.Millisecond,
TimeoutPrecommitDelta: 500 * time.Millisecond,
TimeoutCommit: 1000 * time.Millisecond,
TargetHeightDuration: 3500 * time.Millisecond,
rootulp marked this conversation as resolved.
Show resolved Hide resolved
SkipTimeoutCommit: false,
evan-forbes marked this conversation as resolved.
Show resolved Hide resolved
CreateEmptyBlocks: true,
evan-forbes marked this conversation as resolved.
Show resolved Hide resolved
CreateEmptyBlocksInterval: 0 * time.Second,
evan-forbes marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -978,7 +977,7 @@ func TestConsensusConfig() *ConsensusConfig {
cfg.TimeoutPrecommit = 10 * time.Millisecond
cfg.TimeoutPrecommitDelta = 1 * time.Millisecond
// NOTE: when modifying, make sure to update time_iota_ms (testGenesisFmt) in toml.go
evan-forbes marked this conversation as resolved.
Show resolved Hide resolved
cfg.TimeoutCommit = 10 * time.Millisecond
cfg.TargetHeightDuration = 70 * time.Millisecond
cfg.SkipTimeoutCommit = true
cfg.PeerGossipSleepDuration = 5 * time.Millisecond
cfg.PeerQueryMaj23SleepDuration = 250 * time.Millisecond
Expand Down Expand Up @@ -1012,10 +1011,9 @@ func (cfg *ConsensusConfig) Precommit(round int32) time.Duration {
) * time.Nanosecond
}

// Commit returns the amount of time to wait for straggler votes after receiving +2/3 precommits
// for a single block (ie. a commit).
func (cfg *ConsensusConfig) Commit(t time.Time) time.Time {
return t.Add(cfg.TimeoutCommit)
// NextStartTime adds the TargetHeightDuration to the provided starting time.
func (cfg *ConsensusConfig) NextStartTime(t time.Time) time.Time {
return t.Add(cfg.TargetHeightDuration)
}

// WalFile returns the full path to the write-ahead log file
Expand Down Expand Up @@ -1052,8 +1050,8 @@ func (cfg *ConsensusConfig) ValidateBasic() error {
if cfg.TimeoutPrecommitDelta < 0 {
return errors.New("timeout_precommit_delta can't be negative")
}
if cfg.TimeoutCommit < 0 {
return errors.New("timeout_commit can't be negative")
if cfg.TargetHeightDuration < 0 {
return errors.New("target_round_duration can't be negative")
}
if cfg.CreateEmptyBlocksInterval < 0 {
return errors.New("create_empty_blocks_interval can't be negative")
Expand Down
4 changes: 2 additions & 2 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ func TestConsensusConfig_ValidateBasic(t *testing.T) {
"TimeoutPrecommit negative": {func(c *ConsensusConfig) { c.TimeoutPrecommit = -1 }, true},
"TimeoutPrecommitDelta": {func(c *ConsensusConfig) { c.TimeoutPrecommitDelta = time.Second }, false},
"TimeoutPrecommitDelta negative": {func(c *ConsensusConfig) { c.TimeoutPrecommitDelta = -1 }, true},
"TimeoutCommit": {func(c *ConsensusConfig) { c.TimeoutCommit = time.Second }, false},
"TimeoutCommit negative": {func(c *ConsensusConfig) { c.TimeoutCommit = -1 }, true},
"TargetHeightDuration": {func(c *ConsensusConfig) { c.TargetHeightDuration = time.Second }, false},
"TargetHeightDuration negative": {func(c *ConsensusConfig) { c.TargetHeightDuration = -1 }, true},
"PeerGossipSleepDuration": {func(c *ConsensusConfig) { c.PeerGossipSleepDuration = time.Second }, false},
"PeerGossipSleepDuration negative": {func(c *ConsensusConfig) { c.PeerGossipSleepDuration = -1 }, true},
"PeerQueryMaj23SleepDuration": {func(c *ConsensusConfig) { c.PeerQueryMaj23SleepDuration = time.Second }, false},
Expand Down
8 changes: 4 additions & 4 deletions config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,10 +458,10 @@ timeout_prevote_delta = "{{ .Consensus.TimeoutPrevoteDelta }}"
timeout_precommit = "{{ .Consensus.TimeoutPrecommit }}"
# How much the timeout_precommit increases with each round
timeout_precommit_delta = "{{ .Consensus.TimeoutPrecommitDelta }}"
# 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).
timeout_commit = "{{ .Consensus.TimeoutCommit }}"
# TargetHeigtDuration is used to determine how long we wait after a
# block is committed. If this time is shorter than the actual time to reach
# consensus for that height, then we do not wait at all.
target_round_duration = "{{ .Consensus.TargetHeightDuration }}"
evan-forbes marked this conversation as resolved.
Show resolved Hide resolved

# How many blocks to look back to check existence of the node's consensus votes before joining consensus
# When non-zero, the node will panic upon restart
Expand Down
4 changes: 2 additions & 2 deletions consensus/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,9 +652,9 @@ func (cs *State) updateToState(state sm.State) {
// to be gathered for the first block.
// And alternative solution that relies on clocks:
// cs.StartTime = state.LastBlockTime.Add(timeoutCommit)
cs.StartTime = cs.config.Commit(tmtime.Now())
cs.StartTime = cs.config.NextStartTime(tmtime.Now())
} else {
cs.StartTime = cs.config.Commit(cs.CommitTime)
cs.StartTime = cs.config.NextStartTime(cs.StartTime)
}

cs.Validators = validators
Expand Down
19 changes: 8 additions & 11 deletions docs/tendermint-core/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,10 @@ timeout_prevote_delta = "500ms"
timeout_precommit = "1s"
# How much the timeout_precommit increases with each round
timeout_precommit_delta = "500ms"
# 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).
timeout_commit = "1s"
# TargetHeigtDuration is used to determine how long we wait after a
# block is committed. If this time is shorter than the actual time to reach
# consensus for that height, then we do not wait at all.
target_height_duration = "15s"

# How many blocks to look back to check existence of the node's consensus votes before joining consensus
# When non-zero, the node will panic upon restart
Expand Down Expand Up @@ -457,12 +457,9 @@ timeout_prevote = "1s"
timeout_prevote_delta = "500ms"
timeout_precommit = "1s"
timeout_precommit_delta = "500ms"
timeout_commit = "1s"
target_height_duration = "1s"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[optional] these are just docs so the value doesn't matter but proposal for it to match the 15s on line 354

Suggested change
target_height_duration = "1s"
target_height_duration = "15s"

```

Note that in a successful round, the only timeout that we absolutely wait no
matter what is `timeout_commit`.

Here's a brief summary of the timeouts:

- `timeout_propose` = how long we wait for a proposal block before prevoting
Expand All @@ -476,6 +473,6 @@ Here's a brief summary of the timeouts:
anything (ie. not a single block or nil)
- `timeout_precommit_delta` = how much the timeout_precommit increases with
each round
- `timeout_commit` = 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)
- `target_height_duration` = used to determine how long we wait after a
block is committed. If this time is shorter than the actual time to reach
consensus for that height, then we do not wait at all.
4 changes: 2 additions & 2 deletions test/maverick/consensus/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -900,9 +900,9 @@ func (cs *State) updateToState(state sm.State) {
// to be gathered for the first block.
// And alternative solution that relies on clocks:
// cs.StartTime = state.LastBlockTime.Add(timeoutCommit)
cs.StartTime = cs.config.Commit(tmtime.Now())
cs.StartTime = cs.config.NextStartTime(tmtime.Now())
} else {
cs.StartTime = cs.config.Commit(cs.CommitTime)
cs.StartTime = cs.config.NextStartTime(cs.StartTime)
}

cs.Validators = validators
Expand Down