Skip to content

Commit 6eb9e88

Browse files
committed
chore!(code): Remove VoteSet-based synchronization protocol
1 parent 904c429 commit 6eb9e88

File tree

45 files changed

+52
-1523
lines changed

Some content is hidden

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

45 files changed

+52
-1523
lines changed

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 & 33 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

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::SignedConsensusMsg;
76
use crate::{ConsensusMsg, VoteExtensionError, WalEntry};
87

@@ -175,23 +174,6 @@ where
175174
resume::CertificateValidity,
176175
),
177176

178-
/// Consensus has been stuck in Prevote or Precommit step, ask for vote sets from peers
179-
///
180-
/// Resume with: [`resume::Continue`]
181-
RequestVoteSet(Ctx::Height, Round, resume::Continue),
182-
183-
/// A peer has required our vote set, send the response
184-
///
185-
/// Resume with: [`resume::Continue`]`
186-
SendVoteSetResponse(
187-
RequestId,
188-
Ctx::Height,
189-
Round,
190-
VoteSet<Ctx>,
191-
Vec<PolkaCertificate<Ctx>>,
192-
resume::Continue,
193-
),
194-
195177
/// Append an entry to the Write-Ahead Log for crash recovery
196178
///
197179
/// Resume with: [`resume::Continue`]`

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ mod sync;
1111
mod timeout;
1212
mod validator_set;
1313
mod vote;
14-
mod vote_set;
1514

1615
use proposal::on_proposal;
1716
use propose::on_propose;
@@ -20,7 +19,6 @@ use start_height::reset_and_start_height;
2019
use sync::on_commit_certificate;
2120
use timeout::on_timeout_elapsed;
2221
use vote::on_vote;
23-
use vote_set::{on_vote_set_request, on_vote_set_response};
2422

2523
use crate::prelude::*;
2624

@@ -61,11 +59,5 @@ where
6159
Input::CommitCertificate(certificate) => {
6260
on_commit_certificate(co, state, metrics, certificate).await
6361
}
64-
Input::VoteSetRequest(request_id, height, round) => {
65-
on_vote_set_request(co, state, metrics, request_id, height, round).await
66-
}
67-
Input::VoteSetResponse(vote_set, polka_certificate) => {
68-
on_vote_set_response(co, state, metrics, vote_set, polka_certificate).await
69-
}
7062
}
7163
}

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

Lines changed: 8 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ use crate::handle::signature::sign_proposal;
77
use crate::handle::signature::sign_vote;
88
use crate::handle::vote::on_vote;
99
use crate::prelude::*;
10-
use crate::types::SignedConsensusMsg;
10+
use crate::types::{LocallyProposedValue, SignedConsensusMsg};
1111
use crate::util::pretty::PrettyVal;
12-
use crate::LocallyProposedValue;
13-
use crate::VoteSyncMode;
1412

1513
use super::propose::on_propose;
1614

@@ -134,38 +132,7 @@ where
134132
co,
135133
Effect::CancelTimeout(Timeout::propose(state.driver.round()), Default::default())
136134
);
137-
if state.params.vote_sync_mode == VoteSyncMode::RequestResponse {
138-
// Schedule the Prevote time limit timeout
139-
perform!(
140-
co,
141-
Effect::ScheduleTimeout(
142-
Timeout::prevote_time_limit(state.driver.round()),
143-
Default::default()
144-
)
145-
);
146-
}
147-
}
148-
149-
if state.driver.step_is_precommit()
150-
&& state.params.vote_sync_mode == VoteSyncMode::RequestResponse
151-
{
152-
perform!(
153-
co,
154-
Effect::CancelTimeout(
155-
Timeout::prevote_time_limit(state.driver.round()),
156-
Default::default()
157-
)
158-
);
159-
perform!(
160-
co,
161-
Effect::ScheduleTimeout(
162-
Timeout::precommit_time_limit(state.driver.round()),
163-
Default::default()
164-
)
165-
);
166-
}
167-
168-
if state.driver.step_is_commit() {
135+
} else if state.driver.step_is_commit() {
169136
perform!(
170137
co,
171138
Effect::CancelTimeout(
@@ -287,15 +254,13 @@ where
287254

288255
state.set_last_vote(signed_vote);
289256

290-
// Schedule rebroadcast timer if necessary
291-
if state.params.vote_sync_mode == VoteSyncMode::Rebroadcast {
292-
let timeout = match vote_type {
293-
VoteType::Prevote => Timeout::prevote_rebroadcast(state.driver.round()),
294-
VoteType::Precommit => Timeout::precommit_rebroadcast(state.driver.round()),
295-
};
257+
// Schedule rebroadcast timer
258+
let timeout = match vote_type {
259+
VoteType::Prevote => Timeout::prevote_rebroadcast(state.driver.round()),
260+
VoteType::Precommit => Timeout::precommit_rebroadcast(state.driver.round()),
261+
};
296262

297-
perform!(co, Effect::ScheduleTimeout(timeout, Default::default()));
298-
}
263+
perform!(co, Effect::ScheduleTimeout(timeout, Default::default()));
299264
}
300265

301266
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>(
@@ -10,10 +10,6 @@ pub async fn on_rebroadcast_timeout<Ctx>(
1010
where
1111
Ctx: Context,
1212
{
13-
if state.params.vote_sync_mode != VoteSyncMode::Rebroadcast {
14-
return Ok(());
15-
}
16-
1713
let (height, round) = (state.driver.height(), state.driver.round());
1814

1915
let (maybe_vote, timeout) = match timeout.kind {

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

Lines changed: 1 addition & 10 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_step_limit_timeout<Ctx>(
@@ -15,15 +15,6 @@ where
1515
"Consensus is halted in {:?} step", state.driver.step()
1616
);
1717

18-
if state.params.vote_sync_mode == VoteSyncMode::RequestResponse {
19-
warn!(height = %state.driver.height(), %round, "Requesting vote set");
20-
21-
perform!(
22-
co,
23-
Effect::RequestVoteSet(state.driver.height(), round, Default::default())
24-
);
25-
}
26-
2718
#[cfg(feature = "metrics")]
2819
metrics.step_timeouts.inc();
2920

0 commit comments

Comments
 (0)