Skip to content

Commit 2e60739

Browse files
authored
Remove the time limit related code (#1037)
1 parent 7894bc0 commit 2e60739

File tree

17 files changed

+16
-137
lines changed

17 files changed

+16
-137
lines changed

code/crates/config/src/lib.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -502,11 +502,6 @@ pub struct TimeoutConfig {
502502
#[serde(with = "humantime_serde")]
503503
pub timeout_precommit_delta: Duration,
504504

505-
/// How long we stay in preovte or precommit steps before starting
506-
/// the vote synchronization protocol.
507-
#[serde(with = "humantime_serde")]
508-
pub timeout_step: Duration,
509-
510505
/// How long we wait after entering a round before starting
511506
/// the rebroadcast liveness protocol
512507
#[serde(with = "humantime_serde")]
@@ -519,8 +514,6 @@ impl TimeoutConfig {
519514
TimeoutKind::Propose => self.timeout_propose,
520515
TimeoutKind::Prevote => self.timeout_prevote,
521516
TimeoutKind::Precommit => self.timeout_precommit,
522-
TimeoutKind::PrevoteTimeLimit => self.timeout_step,
523-
TimeoutKind::PrecommitTimeLimit => self.timeout_step,
524517
TimeoutKind::Rebroadcast => {
525518
self.timeout_propose + self.timeout_prevote + self.timeout_precommit
526519
}
@@ -532,8 +525,6 @@ impl TimeoutConfig {
532525
TimeoutKind::Propose => Some(self.timeout_propose_delta),
533526
TimeoutKind::Prevote => Some(self.timeout_prevote_delta),
534527
TimeoutKind::Precommit => Some(self.timeout_precommit_delta),
535-
TimeoutKind::PrevoteTimeLimit => None,
536-
TimeoutKind::PrecommitTimeLimit => None,
537528
TimeoutKind::Rebroadcast => None,
538529
}
539530
}
@@ -544,7 +535,6 @@ impl Default for TimeoutConfig {
544535
let timeout_propose = Duration::from_secs(3);
545536
let timeout_prevote = Duration::from_secs(1);
546537
let timeout_precommit = Duration::from_secs(1);
547-
let timeout_step = Duration::from_secs(2);
548538
let timeout_rebroadcast = timeout_propose + timeout_prevote + timeout_precommit;
549539

550540
Self {
@@ -554,7 +544,6 @@ impl Default for TimeoutConfig {
554544
timeout_prevote_delta: Duration::from_millis(500),
555545
timeout_precommit,
556546
timeout_precommit_delta: Duration::from_millis(500),
557-
timeout_step,
558547
timeout_rebroadcast,
559548
}
560549
}

code/crates/core-consensus/src/handle.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ mod proposed_value;
77
mod rebroadcast_timeout;
88
mod signature;
99
mod start_height;
10-
mod step_timeout;
1110
mod sync;
1211
mod timeout;
1312
mod validator_set;

code/crates/core-consensus/src/handle/driver.rs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -163,22 +163,12 @@ where
163163
}
164164
}
165165

166-
if prev_step != new_step {
167-
if state.driver.step_is_prevote() {
168-
// Cancel the Propose timeout since we have moved from Propose to Prevote
169-
perform!(
170-
co,
171-
Effect::CancelTimeout(Timeout::propose(state.driver.round()), Default::default())
172-
);
173-
} else if state.driver.step_is_commit() {
174-
perform!(
175-
co,
176-
Effect::CancelTimeout(
177-
Timeout::precommit_time_limit(state.driver.round()),
178-
Default::default()
179-
)
180-
);
181-
}
166+
if prev_step != new_step && state.driver.step_is_prevote() {
167+
// Cancel the Propose timeout since we have moved from Propose to Prevote
168+
perform!(
169+
co,
170+
Effect::CancelTimeout(Timeout::propose(state.driver.round()), Default::default())
171+
);
182172
}
183173

184174
process_driver_outputs(co, state, metrics, outputs).await?;

code/crates/core-consensus/src/handle/step_timeout.rs

Lines changed: 0 additions & 42 deletions
This file was deleted.

code/crates/core-consensus/src/handle/timeout.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::handle::driver::apply_driver_input;
22
use crate::handle::rebroadcast_timeout::on_rebroadcast_timeout;
3-
use crate::handle::step_timeout::on_step_limit_timeout;
43
use crate::prelude::*;
54
use crate::types::WalEntry;
65

@@ -49,11 +48,9 @@ where
4948

5049
apply_driver_input(co, state, metrics, DriverInput::TimeoutElapsed(timeout)).await?;
5150

52-
match timeout.kind {
53-
TimeoutKind::Rebroadcast => on_rebroadcast_timeout(co, state, metrics).await,
54-
TimeoutKind::PrevoteTimeLimit | TimeoutKind::PrecommitTimeLimit => {
55-
on_step_limit_timeout(co, state, metrics, timeout.round).await
56-
}
57-
_ => Ok(()),
51+
if matches!(timeout.kind, TimeoutKind::Rebroadcast) {
52+
on_rebroadcast_timeout(co, state, metrics).await?;
5853
}
54+
55+
Ok(())
5956
}

code/crates/core-driver/src/driver.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,6 @@ where
548548
TimeoutKind::Precommit => RoundInput::TimeoutPrecommit,
549549

550550
// The driver never receives these events, so we can just ignore them.
551-
TimeoutKind::PrevoteTimeLimit => return Ok(None),
552-
TimeoutKind::PrecommitTimeLimit => return Ok(None),
553551
TimeoutKind::Rebroadcast => return Ok(None),
554552
};
555553

code/crates/core-types/src/timeout.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,9 @@ pub enum TimeoutKind {
1111
/// Timeout for the prevote step.
1212
Prevote,
1313

14-
/// Timeout for detecting consensus being in the prevote step for too long.
15-
PrevoteTimeLimit,
16-
1714
/// Timeout for the precommit step.
1815
Precommit,
1916

20-
/// Timeout for detecting consensus being in the precommit step for too long.
21-
PrecommitTimeLimit,
22-
2317
/// Timeout to rebroadcast the round synchronization messages
2418
Rebroadcast,
2519
}
@@ -50,19 +44,10 @@ impl Timeout {
5044
Self::new(round, TimeoutKind::Prevote)
5145
}
5246

53-
/// Create a new timeout for the prevote step of the given round.
54-
pub const fn prevote_time_limit(round: Round) -> Self {
55-
Self::new(round, TimeoutKind::PrevoteTimeLimit)
56-
}
57-
5847
/// Create a new timeout for the precommit step of the given round.
5948
pub const fn precommit(round: Round) -> Self {
6049
Self::new(round, TimeoutKind::Precommit)
6150
}
62-
/// Create a new timeout for the precommit step of the given round.
63-
pub const fn precommit_time_limit(round: Round) -> Self {
64-
Self::new(round, TimeoutKind::PrecommitTimeLimit)
65-
}
6651

6752
/// Create a new timeout for rebroadcasting the round synchronization messages.
6853
pub const fn rebroadcast(round: Round) -> Self {

code/crates/engine/src/consensus.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,6 @@ impl Timeouts {
185185
TimeoutKind::Propose => self.config.timeout_propose,
186186
TimeoutKind::Prevote => self.config.timeout_prevote,
187187
TimeoutKind::Precommit => self.config.timeout_precommit,
188-
TimeoutKind::PrevoteTimeLimit => self.config.timeout_step,
189-
TimeoutKind::PrecommitTimeLimit => self.config.timeout_step,
190188
TimeoutKind::Rebroadcast => {
191189
self.config.timeout_propose
192190
+ self.config.timeout_prevote
@@ -201,8 +199,6 @@ impl Timeouts {
201199
TimeoutKind::Propose => c.timeout_propose += c.timeout_propose_delta,
202200
TimeoutKind::Prevote => c.timeout_prevote += c.timeout_prevote_delta,
203201
TimeoutKind::Precommit => c.timeout_precommit += c.timeout_precommit_delta,
204-
TimeoutKind::PrevoteTimeLimit => (),
205-
TimeoutKind::PrecommitTimeLimit => (),
206202
TimeoutKind::Rebroadcast => {
207203
c.timeout_rebroadcast +=
208204
c.timeout_propose_delta + c.timeout_prevote_delta + c.timeout_precommit_delta
@@ -640,10 +636,7 @@ where
640636
// Print debug information if the timeout is for a prevote or precommit
641637
if matches!(
642638
timeout.kind,
643-
TimeoutKind::Prevote
644-
| TimeoutKind::Precommit
645-
| TimeoutKind::PrevoteTimeLimit
646-
| TimeoutKind::PrecommitTimeLimit
639+
TimeoutKind::Prevote | TimeoutKind::Precommit | TimeoutKind::Rebroadcast
647640
) {
648641
warn!(step = ?timeout.kind, "Timeout elapsed");
649642
state.consensus.print_state();

code/crates/engine/src/wal/entry.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ fn encode_timeout(tag: u8, timeout: &Timeout, mut buf: impl Write) -> io::Result
123123

124124
// Consensus will typically not want to store these timeouts in the WAL,
125125
// but we still need to handle them here.
126-
TimeoutKind::PrevoteTimeLimit => 5,
127-
TimeoutKind::PrecommitTimeLimit => 6,
128126
TimeoutKind::Rebroadcast => 7,
129127
};
130128

@@ -154,9 +152,7 @@ fn decode_timeout(mut buf: impl Read) -> io::Result<Timeout> {
154152

155153
// Consensus will typically not want to store these timeouts in the WAL,
156154
// but we still need to handle them here.
157-
5 => TimeoutKind::PrevoteTimeLimit,
158-
6 => TimeoutKind::PrecommitTimeLimit,
159-
7 => TimeoutKind::Rebroadcast,
155+
5 => TimeoutKind::Rebroadcast,
160156

161157
_ => {
162158
return Err(io::Error::new(

code/crates/metrics/src/metrics.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,6 @@ pub struct Inner {
7878
/// The round of the proposal that was decided on
7979
pub proposal_round: Histogram,
8080

81-
/// Number of times consensus was blocked in Prevote or Precommit step and required vote synchronization
82-
pub step_timeouts: Counter,
83-
8481
/// Number of times consensus rebroadcasted Prevote or Precommit votes due to no round progress
8582
pub rebroadcast_timeouts: Counter,
8683

@@ -123,7 +120,6 @@ impl Metrics {
123120
block_size_bytes: Histogram::new(linear_buckets(0.0, 64.0 * 1024.0, 128)),
124121
consensus_round: Histogram::new(linear_buckets(0.0, 1.0, 20)),
125122
proposal_round: Histogram::new(linear_buckets(0.0, 1.0, 20)),
126-
step_timeouts: Counter::default(),
127123
rebroadcast_timeouts: Counter::default(),
128124
connected_peers: Gauge::default(),
129125
height: Gauge::default(),
@@ -194,16 +190,10 @@ impl Metrics {
194190
metrics.proposal_round.clone(),
195191
);
196192

197-
registry.register(
198-
"step_timeouts",
199-
"Number of times consensus was blocked and required vote synchronization",
200-
metrics.step_timeouts.clone(),
201-
);
202-
203193
registry.register(
204194
"rebroadcast_timeouts",
205195
"Number of times consensus rebroadcasted its vote due to no round progress",
206-
metrics.step_timeouts.clone(),
196+
metrics.rebroadcast_timeouts.clone(),
207197
);
208198

209199
registry.register(

code/crates/network/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,11 @@ impl TransportProtocol {
133133

134134
/// sync event details:
135135
///
136-
/// peer1: sync peer2: network peer2: sync peer1: network
137-
/// or consensus
136+
/// peer1: sync peer2: network peer2: sync peer1: network
138137
/// CtrlMsg::SyncRequest --> Event::Sync -----------> CtrlMsg::SyncReply ------> Event::Sync
139138
/// (peer_id, height) (RawMessage::Request (request_id, height) RawMessage::Response
140139
/// {request_id, peer_id, request} {request_id, response}
141140
///
142-
/// - request can be for a block or vote set
143141
///
144142
/// An event that can be emitted by the gossip layer
145143
#[derive(Clone, Debug)]

code/crates/starknet/test/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ fn apply_params(config: &mut Config, params: &TestParams) {
230230
config.consensus.value_payload = ValuePayload::PartsOnly;
231231
config.value_sync.enabled = params.enable_value_sync;
232232
config.consensus.p2p.protocol = params.protocol;
233-
config.consensus.timeouts.timeout_step = params.timeout_step;
234233
config.test.max_block_size = params.block_size;
235234
config.test.txs_per_part = params.txs_per_part;
236235
config.test.vote_extensions.enabled = params.vote_extensions.is_some();

code/crates/sync/src/handle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub enum Input<Ctx: Context> {
7171
/// Got a response from the application to our `GetValue` request
7272
GotDecidedValue(InboundRequestId, Ctx::Height, Option<RawDecidedValue<Ctx>>),
7373

74-
/// A request for a value or vote set timed out
74+
/// A request for a value timed out
7575
SyncRequestTimedOut(PeerId, Request<Ctx>),
7676

7777
/// We received an invalid [`CommitCertificate`]

code/crates/test/app/config.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ timeout_precommit_delta = "500ms"
5757
# Override with MALACHITE__CONSENSUS__TIMEOUT_COMMIT env variable
5858
timeout_commit = "0s"
5959

60-
# How long we wait in the prevote and precommit steps before starting
61-
# the vote synchronization protocol
62-
# Override with MALACHITE__CONSENSUS__TIMEOUT_STEP env variable
63-
timeout_step = "2s"
6460

6561
# How long we wait after entering a round before starting the rebroadcast liveness protocol
6662
# Override with MALACHITE__CONSENSUS__TIMEOUT_REBROADCAST env variable

code/crates/test/framework/src/params.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ impl TestParams {
4040
pub fn apply_to_config(&self, config: &mut Config) {
4141
config.value_sync.enabled = self.enable_value_sync;
4242
config.consensus.p2p.protocol = self.protocol;
43-
config.consensus.timeouts.timeout_step = self.timeout_step;
4443
config.consensus.value_payload = self.value_payload;
4544
config.test.max_block_size = self.block_size;
4645
config.test.txs_per_part = self.txs_per_part;

code/crates/test/tests/it/main.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,7 @@ impl TestRunner {
144144
consensus: ConsensusConfig {
145145
// Current test app does not support proposal-only value payload properly as Init does not include valid_round
146146
value_payload: ValuePayload::ProposalAndParts,
147-
timeouts: TimeoutConfig {
148-
timeout_step: Duration::from_secs(2),
149-
..Default::default()
150-
},
147+
timeouts: TimeoutConfig::default(),
151148
p2p: P2pConfig {
152149
protocol,
153150
discovery: DiscoveryConfig::default(),

code/examples/channel/config.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@ timeout_precommit_delta = "500ms"
5757
# Override with MALACHITE__CONSENSUS__TIMEOUT_COMMIT env variable
5858
timeout_commit = "0s"
5959

60-
# How long we wait in the prevote and precommit steps before starting
61-
# the vote synchronization protocol
62-
# Override with MALACHITE__CONSENSUS__TIMEOUT_STEP env variable
63-
timeout_step = "2s"
64-
6560
# How long we wait after entering a round before starting the rebroadcast liveness protocol
6661
# Override with MALACHITE__CONSENSUS__TIMEOUT_REBROADCAST env variable
6762
timeout_rebroadcast = "5s"

0 commit comments

Comments
 (0)