Skip to content

Commit

Permalink
config: remove narwhal committee information from ConsensusConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
bmwill committed Jul 15, 2022
1 parent 8083d11 commit 303fc29
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 60 deletions.
4 changes: 0 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/sui-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ rand = "0.7.3"
dirs = "4.0.0"
multiaddr = "0.14.0"
once_cell = "1.11.0"
debug-ignore = { version = "1.0.2", features = ["serde"] }
tracing = "0.1.35"

narwhal-config = { git = "https://github.com/MystenLabs/narwhal", rev = "5b744fa722aa5d002ec17db3602cb709f7514fb3", package = "config" }
Expand Down
42 changes: 0 additions & 42 deletions crates/sui-config/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@ use crate::{
utils, ConsensusConfig, NetworkConfig, NodeConfig, ValidatorInfo, AUTHORITIES_DB_NAME,
CONSENSUS_DB_NAME, DEFAULT_STAKE,
};
use arc_swap::ArcSwap;
use debug_ignore::DebugIgnore;
use narwhal_config::{Authority, Epoch, PrimaryAddresses, Stake, WorkerAddresses};
use rand::rngs::OsRng;
use std::{
collections::BTreeMap,
num::NonZeroUsize,
path::{Path, PathBuf},
sync::Arc,
Expand Down Expand Up @@ -136,43 +132,6 @@ impl<R: ::rand::RngCore + ::rand::CryptoRng> ConfigBuilder<R> {
builder.build()
};

let narwhal_committee = validators
.iter()
.map(|validator| {
let name = validator
.key_pair
.public_key_bytes()
.make_narwhal_public_key()
.expect("Can't get narwhal public key");
let primary = PrimaryAddresses {
primary_to_primary: validator.narwhal_primary_to_primary.clone(),
worker_to_primary: validator.narwhal_worker_to_primary.clone(),
};
let workers = [(
0, // worker_id
WorkerAddresses {
primary_to_worker: validator.narwhal_primary_to_worker.clone(),
transactions: validator.narwhal_consensus_address.clone(),
worker_to_worker: validator.narwhal_worker_to_worker.clone(),
},
)]
.into_iter()
.collect();
let authority = Authority {
stake: validator.stake as Stake, //TODO this should at least be the same size integer
primary,
workers,
};

(name, authority)
})
.collect::<BTreeMap<_, _>>();
let narwhal_committee =
DebugIgnore(Arc::new(ArcSwap::from_pointee(narwhal_config::Committee {
authorities: narwhal_committee,
epoch: genesis.epoch() as Epoch,
})));

let validator_configs = validators
.into_iter()
.map(|validator| {
Expand All @@ -191,7 +150,6 @@ impl<R: ::rand::RngCore + ::rand::CryptoRng> ConfigBuilder<R> {
consensus_address,
consensus_db_path,
narwhal_config: Default::default(),
narwhal_committee: narwhal_committee.clone(),
};

NodeConfig {
Expand Down
9 changes: 0 additions & 9 deletions crates/sui-config/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
use crate::genesis;
use crate::Config;
use anyhow::Result;
use debug_ignore::DebugIgnore;
use multiaddr::Multiaddr;
use narwhal_config::Parameters as ConsensusParameters;
use narwhal_config::SharedCommittee as ConsensusCommittee;
use narwhal_crypto::ed25519::Ed25519PublicKey;
use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
use std::net::SocketAddr;
Expand Down Expand Up @@ -111,8 +108,6 @@ pub struct ConsensusConfig {
pub consensus_db_path: PathBuf,

pub narwhal_config: ConsensusParameters,

pub narwhal_committee: DebugIgnore<ConsensusCommittee<Ed25519PublicKey>>,
}

impl ConsensusConfig {
Expand All @@ -127,10 +122,6 @@ impl ConsensusConfig {
pub fn narwhal_config(&self) -> &ConsensusParameters {
&self.narwhal_config
}

pub fn narwhal_committee(&self) -> &ConsensusCommittee<Ed25519PublicKey> {
&self.narwhal_committee
}
}

/// Publicly known information about a validator
Expand Down
4 changes: 2 additions & 2 deletions crates/sui-core/src/authority_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl ValidatorService {
let consensus_store = narwhal_node::NodeStorage::reopen(consensus_config.db_path());
narwhal_node::Node::spawn_primary(
consensus_keypair,
consensus_config.narwhal_committee().to_owned(),
config.genesis()?.narwhal_committee(),
&consensus_store,
consensus_config.narwhal_config().to_owned(),
/* consensus */ true, // Indicate that we want to run consensus.
Expand All @@ -189,7 +189,7 @@ impl ValidatorService {
narwhal_node::Node::spawn_workers(
consensus_name,
/* ids */ vec![0], // We run a single worker with id '0'.
consensus_config.narwhal_committee().to_owned(),
config.genesis()?.narwhal_committee(),
&consensus_store,
consensus_config.narwhal_config().to_owned(),
prometheus_registry,
Expand Down
4 changes: 2 additions & 2 deletions crates/workspace-hack/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ dag = { git = "https://github.com/MystenLabs/narwhal", rev = "5b744fa722aa5d002e
dashmap = { version = "5", default-features = false }
data-encoding = { version = "2", features = ["alloc", "std"] }
datatest-stable = { version = "0.1", default-features = false }
debug-ignore = { version = "1", default-features = false, features = ["serde"] }
debug-ignore = { version = "1", default-features = false }
derive_builder = { version = "0.11", features = ["std"] }
determinator = { version = "0.9", default-features = false }
deunicode = { version = "0.4", default-features = false }
Expand Down Expand Up @@ -676,7 +676,7 @@ darling_macro-582f2526e08bb6a0 = { package = "darling_macro", version = "0.14",
dashmap = { version = "5", default-features = false }
data-encoding = { version = "2", features = ["alloc", "std"] }
datatest-stable = { version = "0.1", default-features = false }
debug-ignore = { version = "1", default-features = false, features = ["serde"] }
debug-ignore = { version = "1", default-features = false }
derivative = { version = "2", default-features = false, features = ["use_core"] }
derive-syn-parse = { version = "0.1", default-features = false }
derive_builder = { version = "0.11", features = ["std"] }
Expand Down

0 comments on commit 303fc29

Please sign in to comment.