Skip to content

Commit 6b470f7

Browse files
authored
cleanup(consensus): Remove Broadcaster and wrapper around NetworkManager (#6794)
# Description of change This PR simplifies the implementation of managing network setup in the Starfish consensus implementation. It removes unnecessary `NetworkManager` trait, because there is currently one supported network type - Tonic. Since Tonic supports streaming, Broadcaster has also been removed as it was only used for network types that don't support streaming. ## Links to any relevant issues Fixes #6423 ## Type of change Choose a type of change, and delete any options that are not relevant. - Enhancement (a non-breaking change which adds functionality) ## How the change has been tested Unable to test because starfish implementation is not yet in a working condition. Make sure to provide instructions for the maintainer as well as any relevant configurations. - [x] Basic tests (linting, compilation, formatting, unit/integration tests) - [ ] Patch-specific tests (correctness, functionality coverage)
1 parent 98db455 commit 6b470f7

File tree

14 files changed

+71
-605
lines changed

14 files changed

+71
-605
lines changed

crates/iota-core/src/consensus_manager/starfish_manager.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use async_trait::async_trait;
88
use fastcrypto::ed25519;
99
use iota_config::NodeConfig;
1010
use iota_metrics::{RegistryID, RegistryService, monitored_mpsc::unbounded_channel};
11-
use iota_protocol_config::ConsensusNetwork;
1211
use iota_types::{
1312
committee::EpochId,
1413
iota_system_state::epoch_start_iota_system_state::EpochStartSystemStateTrait,
@@ -83,21 +82,6 @@ impl StarfishManager {
8382
store_path.push(format!("{}", epoch));
8483
store_path
8584
}
86-
87-
fn pick_network(&self, epoch_store: &AuthorityPerEpochStore) -> ConsensusNetwork {
88-
if let Ok(type_str) = std::env::var("CONSENSUS_NETWORK") {
89-
match type_str.to_lowercase().as_str() {
90-
"tonic" => return ConsensusNetwork::Tonic,
91-
_ => {
92-
info!(
93-
"Invalid consensus network type {} in env var. Continue to use the value from protocol config.",
94-
type_str
95-
);
96-
}
97-
}
98-
}
99-
epoch_store.protocol_config().consensus_network()
100-
}
10185
}
10286

10387
#[async_trait]
@@ -115,7 +99,6 @@ impl ConsensusManagerTrait for StarfishManager {
11599
let committee: Committee = system_state.get_starfish_committee();
116100
let epoch = epoch_store.epoch();
117101
let protocol_config = epoch_store.protocol_config();
118-
let network_type = self.pick_network(&epoch_store);
119102

120103
let Some(_guard) = RunningLockGuard::acquire_start(
121104
&self.metrics,
@@ -183,7 +166,6 @@ impl ConsensusManagerTrait for StarfishManager {
183166
}
184167

185168
let authority = ConsensusAuthority::start(
186-
network_type,
187169
own_index,
188170
committee.clone(),
189171
parameters.clone(),

crates/iota-core/src/unit_tests/starfish_manager_tests.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use iota_types::messages_checkpoint::{
1010
CertifiedCheckpointSummary, CheckpointContents, CheckpointSummary,
1111
};
1212
use prometheus::Registry;
13-
use tokio::{sync::mpsc, time::sleep};
13+
use tokio::{sync::mpsc, task::yield_now, time::sleep};
1414

1515
use crate::{
1616
authority::{AuthorityState, test_authority_builder::TestAuthorityBuilder},
@@ -132,5 +132,8 @@ async fn test_starfish_manager() {
132132

133133
// THEN
134134
assert!(!manager.is_running().await);
135+
136+
// Yield to ensure that RocksDB releases the lock before the next iteration.
137+
yield_now().await;
135138
}
136139
}

0 commit comments

Comments
 (0)