Skip to content

Commit 2497086

Browse files
authored
chore(code)!: Remove VoteSet-based synchronization protocol (#1008)
1 parent 1420a0f commit 2497086

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+137
-1711
lines changed

BREAKING_CHANGES.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,19 @@
22

33
## Unreleased
44

5+
### `malachitebft-core-types`
6+
- Removed the VoteSet synchronization protocol, as it is neither required nor sufficient for liveness.
7+
See ([#998](https://github.com/informalsystems/malachite/issues/998)) for more details.
8+
59
### `malachitebft-core-consensus`
10+
- Removed the VoteSet synchronization protocol, as it is neither required nor sufficient for liveness.
11+
See ([#998](https://github.com/informalsystems/malachite/issues/998)) for more details.
612
- Added new variants to `Input` enum: `PolkaCertificate` and `RoundCertificate`
713
- Added new variant to `Effect` enum: `PublishLivenessMessage`
814

915
### `malachitebft-engine`
16+
- Removed the VoteSet synchronization protocol, as it is neither required nor sufficient for liveness.
17+
See ([#998](https://github.com/informalsystems/malachite/issues/998)) for more details.
1018
- Changed the reply channel of `GetValidatorSet` message to take an `Option<Ctx::ValidatorSet>` instead of `Ctx::ValidatorSet`.
1119
- Added new variant to `Msg` enum: `PublishLivenessMsg`
1220
- Added new variants to `NetworkEvent` enum: `PolkaCertificate` and `RoundCertificate`
@@ -23,6 +31,10 @@
2331
- Renamed `Event::Message` variant to `Event::ConsensusMessage`
2432
- Added new variant to `Event::LivenessMessage`
2533

34+
### `malachitebft-sync`
35+
- Removed the VoteSet synchronization protocol, as it is neither required nor sufficient for liveness.
36+
See ([#998](https://github.com/informalsystems/malachite/issues/998)) for more details.
37+
2638
## 0.2.0
2739

2840
### `malachitebft-core-types`

RELEASE_NOTES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Removed the VoteSet synchronization protocol, as it is neither required nor sufficient for liveness.
6+
See ([#998](https://github.com/informalsystems/malachite/issues/998)) for more details.
57
- Reply to `GetValidatorSet` is now optional ([#990](https://github.com/informalsystems/malachite/issues/990))
68
- Clarify and improve the application handling of multiple proposals for same height and round ([#833](https://github.com/informalsystems/malachite/issues/833))
79

code/crates/app-channel/src/run.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ where
5656
network.clone(),
5757
connector.clone(),
5858
cfg.value_sync(),
59-
&cfg.consensus().vote_sync,
6059
&registry,
6160
)
6261
.await?;

code/crates/app/src/spawn.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ use malachitebft_engine::util::events::TxEvent;
1616
use malachitebft_engine::wal::{Wal, WalCodec, WalRef};
1717
use malachitebft_network::{Config as NetworkConfig, DiscoveryConfig, GossipSubConfig, Keypair};
1818

19-
use crate::config::{self, ConsensusConfig, PubSubProtocol, ValueSyncConfig, VoteSyncConfig};
19+
use crate::config::{ConsensusConfig, PubSubProtocol, ValueSyncConfig};
2020
use crate::metrics::{Metrics, SharedRegistry};
2121
use crate::types::core::{Context, SigningProvider};
2222
use crate::types::sync;
23-
use crate::types::{ValuePayload, VoteSyncMode};
23+
use crate::types::ValuePayload;
2424

2525
pub async fn spawn_node_actor<Ctx>(
2626
ctx: Ctx,
@@ -92,18 +92,12 @@ where
9292
config::ValuePayload::ProposalAndParts => ValuePayload::ProposalAndParts,
9393
};
9494

95-
let vote_sync_mode = match cfg.vote_sync.mode {
96-
config::VoteSyncMode::RequestResponse => VoteSyncMode::RequestResponse,
97-
config::VoteSyncMode::Rebroadcast => VoteSyncMode::Rebroadcast,
98-
};
99-
10095
let consensus_params = ConsensusParams {
10196
initial_height,
10297
initial_validator_set,
10398
address,
10499
threshold_params: Default::default(),
105100
value_payload,
106-
vote_sync_mode,
107101
};
108102

109103
Consensus::spawn(
@@ -148,13 +142,12 @@ pub async fn spawn_sync_actor<Ctx>(
148142
network: NetworkRef<Ctx>,
149143
host: HostRef<Ctx>,
150144
config: &ValueSyncConfig,
151-
vote_sync: &VoteSyncConfig,
152145
registry: &SharedRegistry,
153146
) -> Result<Option<SyncRef<Ctx>>>
154147
where
155148
Ctx: Context,
156149
{
157-
if !config.enabled && vote_sync.mode != config::VoteSyncMode::RequestResponse {
150+
if !config.enabled {
158151
return Ok(None);
159152
}
160153

code/crates/app/src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
pub use libp2p_identity::Keypair;
44

55
pub use malachitebft_core_consensus::{
6-
ConsensusMsg, ProposedValue, SignedConsensusMsg, ValuePayload, VoteSyncMode,
6+
ConsensusMsg, ProposedValue, SignedConsensusMsg, ValuePayload,
77
};
88
pub use malachitebft_engine::host::LocallyProposedValue;
99
pub use malachitebft_peer::PeerId;

code/crates/config/src/lib.rs

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -447,39 +447,6 @@ pub struct ConsensusConfig {
447447

448448
/// Message types that can carry values
449449
pub value_payload: ValuePayload,
450-
451-
/// VoteSync configuration options
452-
pub vote_sync: VoteSyncConfig,
453-
}
454-
455-
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
456-
pub struct VoteSyncConfig {
457-
/// The mode of vote synchronization
458-
/// - RequestResponse: The lagging node sends a request to a peer for the missing votes
459-
/// - Rebroadcast: Nodes rebroadcast their last vote to all peers
460-
pub mode: VoteSyncMode,
461-
}
462-
463-
/// The mode of vote synchronization
464-
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
465-
#[serde(rename_all = "kebab-case")]
466-
pub enum VoteSyncMode {
467-
/// The lagging node sends a request to a peer for the missing votes
468-
#[default]
469-
RequestResponse,
470-
471-
/// Nodes rebroadcast their last vote to all peers
472-
Rebroadcast,
473-
}
474-
475-
impl VoteSyncMode {
476-
pub fn is_request_response(&self) -> bool {
477-
matches!(self, Self::RequestResponse)
478-
}
479-
480-
pub fn is_rebroadcast(&self) -> bool {
481-
matches!(self, Self::Rebroadcast)
482-
}
483450
}
484451

485452
/// Message types required by consensus to deliver the value being proposed
@@ -535,11 +502,6 @@ pub struct TimeoutConfig {
535502
#[serde(with = "humantime_serde")]
536503
pub timeout_precommit_delta: Duration,
537504

538-
/// How long we stay in preovte or precommit steps before starting
539-
/// the vote synchronization protocol.
540-
#[serde(with = "humantime_serde")]
541-
pub timeout_step: Duration,
542-
543505
/// How long we wait after entering a round before starting
544506
/// the rebroadcast liveness protocol
545507
#[serde(with = "humantime_serde")]
@@ -552,8 +514,6 @@ impl TimeoutConfig {
552514
TimeoutKind::Propose => self.timeout_propose,
553515
TimeoutKind::Prevote => self.timeout_prevote,
554516
TimeoutKind::Precommit => self.timeout_precommit,
555-
TimeoutKind::PrevoteTimeLimit => self.timeout_step,
556-
TimeoutKind::PrecommitTimeLimit => self.timeout_step,
557517
TimeoutKind::Rebroadcast => {
558518
self.timeout_propose + self.timeout_prevote + self.timeout_precommit
559519
}
@@ -565,8 +525,6 @@ impl TimeoutConfig {
565525
TimeoutKind::Propose => Some(self.timeout_propose_delta),
566526
TimeoutKind::Prevote => Some(self.timeout_prevote_delta),
567527
TimeoutKind::Precommit => Some(self.timeout_precommit_delta),
568-
TimeoutKind::PrevoteTimeLimit => None,
569-
TimeoutKind::PrecommitTimeLimit => None,
570528
TimeoutKind::Rebroadcast => None,
571529
}
572530
}
@@ -577,7 +535,6 @@ impl Default for TimeoutConfig {
577535
let timeout_propose = Duration::from_secs(3);
578536
let timeout_prevote = Duration::from_secs(1);
579537
let timeout_precommit = Duration::from_secs(1);
580-
let timeout_step = Duration::from_secs(2);
581538
let timeout_rebroadcast = timeout_propose + timeout_prevote + timeout_precommit;
582539

583540
Self {
@@ -587,7 +544,6 @@ impl Default for TimeoutConfig {
587544
timeout_prevote_delta: Duration::from_millis(500),
588545
timeout_precommit,
589546
timeout_precommit_delta: Duration::from_millis(500),
590-
timeout_step,
591547
timeout_rebroadcast,
592548
}
593549
}

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

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use derive_where::derive_where;
22

33
use malachitebft_core_types::*;
44

5-
use crate::input::RequestId;
65
use crate::types::{LivenessMsg, SignedConsensusMsg};
76
use crate::{ConsensusMsg, VoteExtensionError, WalEntry};
87

@@ -185,23 +184,6 @@ where
185184
resume::CertificateValidity,
186185
),
187186

188-
/// Consensus has been stuck in Prevote or Precommit step, ask for vote sets from peers
189-
///
190-
/// Resume with: [`resume::Continue`]
191-
RequestVoteSet(Ctx::Height, Round, resume::Continue),
192-
193-
/// A peer has required our vote set, send the response
194-
///
195-
/// Resume with: [`resume::Continue`]`
196-
SendVoteSetResponse(
197-
RequestId,
198-
Ctx::Height,
199-
Round,
200-
VoteSet<Ctx>,
201-
Vec<PolkaCertificate<Ctx>>,
202-
resume::Continue,
203-
),
204-
205187
/// Append an entry to the Write-Ahead Log for crash recovery
206188
///
207189
/// Resume with: [`resume::Continue`]`

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ 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;
1413
mod vote;
15-
mod vote_set;
1614

1715
use liveness::{on_polka_certificate, on_round_certificate};
1816
use proposal::on_proposal;
@@ -22,7 +20,6 @@ use start_height::reset_and_start_height;
2220
use sync::on_commit_certificate;
2321
use timeout::on_timeout_elapsed;
2422
use vote::on_vote;
25-
use vote_set::{on_vote_set_request, on_vote_set_response};
2623

2724
use crate::prelude::*;
2825

@@ -63,12 +60,6 @@ where
6360
Input::CommitCertificate(certificate) => {
6461
on_commit_certificate(co, state, metrics, certificate).await
6562
}
66-
Input::VoteSetRequest(request_id, height, round) => {
67-
on_vote_set_request(co, state, metrics, request_id, height, round).await
68-
}
69-
Input::VoteSetResponse(vote_set, polka_certificate) => {
70-
on_vote_set_response(co, state, metrics, vote_set, polka_certificate).await
71-
}
7263
Input::PolkaCertificate(certificate) => {
7364
on_polka_certificate(co, state, metrics, certificate).await
7465
}

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

Lines changed: 16 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ use crate::handle::signature::sign_vote;
88
use crate::handle::vote::on_vote;
99
use crate::params::HIDDEN_LOCK_ROUND;
1010
use crate::prelude::*;
11-
use crate::types::{LivenessMsg, SignedConsensusMsg};
11+
use crate::types::{
12+
LivenessMsg, {LocallyProposedValue, SignedConsensusMsg},
13+
};
1214
use crate::util::pretty::PrettyVal;
13-
use crate::LocallyProposedValue;
14-
use crate::VoteSyncMode;
1515

1616
use super::propose::on_propose;
1717

@@ -69,11 +69,9 @@ where
6969
#[cfg(feature = "metrics")]
7070
metrics.rebroadcast_timeouts.inc();
7171

72-
// Schedule rebroadcast timer if necessary
73-
if state.params.vote_sync_mode == VoteSyncMode::Rebroadcast {
74-
let timeout = Timeout::rebroadcast(*round);
75-
perform!(co, Effect::ScheduleTimeout(timeout, Default::default()));
76-
}
72+
// Schedule rebroadcast timer
73+
let timeout = Timeout::rebroadcast(*round);
74+
perform!(co, Effect::ScheduleTimeout(timeout, Default::default()));
7775
}
7876

7977
DriverInput::ProposeValue(round, _) => {
@@ -165,53 +163,12 @@ where
165163
}
166164
}
167165

168-
if prev_step != new_step {
169-
if state.driver.step_is_prevote() {
170-
// Cancel the Propose timeout since we have moved from Propose to Prevote
171-
perform!(
172-
co,
173-
Effect::CancelTimeout(Timeout::propose(state.driver.round()), Default::default())
174-
);
175-
if state.params.vote_sync_mode == VoteSyncMode::RequestResponse {
176-
// Schedule the Prevote time limit timeout
177-
perform!(
178-
co,
179-
Effect::ScheduleTimeout(
180-
Timeout::prevote_time_limit(state.driver.round()),
181-
Default::default()
182-
)
183-
);
184-
}
185-
}
186-
187-
if state.driver.step_is_precommit()
188-
&& state.params.vote_sync_mode == VoteSyncMode::RequestResponse
189-
{
190-
perform!(
191-
co,
192-
Effect::CancelTimeout(
193-
Timeout::prevote_time_limit(state.driver.round()),
194-
Default::default()
195-
)
196-
);
197-
perform!(
198-
co,
199-
Effect::ScheduleTimeout(
200-
Timeout::precommit_time_limit(state.driver.round()),
201-
Default::default()
202-
)
203-
);
204-
}
205-
206-
if state.driver.step_is_commit() {
207-
perform!(
208-
co,
209-
Effect::CancelTimeout(
210-
Timeout::precommit_time_limit(state.driver.round()),
211-
Default::default()
212-
)
213-
);
214-
}
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+
);
215172
}
216173

217174
process_driver_outputs(co, state, metrics, outputs).await?;
@@ -405,6 +362,10 @@ where
405362
);
406363

407364
state.set_last_vote(signed_vote);
365+
366+
// Schedule rebroadcast timer
367+
let timeout = Timeout::rebroadcast(state.driver.round());
368+
perform!(co, Effect::ScheduleTimeout(timeout, Default::default()));
408369
}
409370

410371
Ok(())

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{prelude::*, VoteSyncMode};
1+
use crate::prelude::*;
22

33
#[cfg_attr(not(feature = "metrics"), allow(unused_variables))]
44
pub async fn on_rebroadcast_timeout<Ctx>(
@@ -9,10 +9,6 @@ pub async fn on_rebroadcast_timeout<Ctx>(
99
where
1010
Ctx: Context,
1111
{
12-
if state.params.vote_sync_mode != VoteSyncMode::Rebroadcast {
13-
return Ok(());
14-
}
15-
1612
let (height, round) = (state.driver.height(), state.driver.round());
1713

1814
if let Some(vote) = state.last_signed_prevote.as_ref() {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ where
6262
Ok(result)
6363
}
6464

65+
// NOTE: Will be used again in #997
66+
#[allow(dead_code)]
6567
pub async fn verify_polka_certificate<Ctx>(
6668
co: &Co<Ctx>,
6769
certificate: PolkaCertificate<Ctx>,

0 commit comments

Comments
 (0)