Skip to content

Commit

Permalink
Remove unused config stuff (#3771)
Browse files Browse the repository at this point in the history
* Remove unused config stuff

* remove is_da param in a bunch of places

* don't reset lock in bad proposal task

* lint

* allow one timeout

* allow bad proposal leader to fail everytime

* fix after merge

* correct num fails

* final fix

* more

* reset actions

* lint

* log at debug

* Fix test 3
  • Loading branch information
bfish713 authored Oct 29, 2024
1 parent 9d5c868 commit f5941ff
Show file tree
Hide file tree
Showing 27 changed files with 18 additions and 188 deletions.
15 changes: 3 additions & 12 deletions crates/examples/infra/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@ use std::{
net::{IpAddr, Ipv4Addr, SocketAddr, SocketAddrV4},
num::NonZeroUsize,
sync::Arc,
time::{Duration, Instant},
time::Instant,
};

use async_compatibility_layer::{
art::async_sleep,
logging::{setup_backtrace, setup_logging},
};
use async_compatibility_layer::logging::{setup_backtrace, setup_logging};
use async_trait::async_trait;
use cdn_broker::reexports::crypto::signature::KeyPair;
use chrono::Utc;
Expand Down Expand Up @@ -443,10 +440,7 @@ pub trait RunDa<
transaction_size_in_bytes: u64,
) -> BenchResults {
let NetworkConfig {
rounds,
node_index,
start_delay_seconds,
..
rounds, node_index, ..
} = self.config();

let mut total_transactions_committed = 0;
Expand All @@ -456,9 +450,6 @@ pub trait RunDa<
let mut total_latency = 0;
let mut num_latency = 0;

info!("Sleeping for {start_delay_seconds} seconds before starting hotshot!");
async_sleep(Duration::from_secs(start_delay_seconds)).await;

info!("Starting HotShot example!");
let start = Instant::now();

Expand Down
4 changes: 2 additions & 2 deletions crates/hotshot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,9 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> SystemContext<T
// and will be updated to be part of SystemContext. I wanted to use associated
// constants in NodeType, but that seems to be unavailable in the current Rust.
api
.network.broadcast_message(
.network.da_broadcast_message(
serialized_message,
da_membership.committee_topic(),
da_membership.committee_members(view_number, TYPES::Epoch::new(1)).iter().cloned().collect(),
BroadcastDelay::None,
),
api
Expand Down
2 changes: 0 additions & 2 deletions crates/hotshot/src/tasks/task_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> CreateTaskState
private_key: handle.private_key().clone(),
storage: Arc::clone(&handle.storage),
timeout: handle.hotshot.config.next_view_timeout,
round_start_delay: handle.hotshot.config.round_start_delay,
id: handle.hotshot.id,
formed_upgrade_certificate: None,
upgrade_lock: handle.hotshot.upgrade_lock.clone(),
Expand All @@ -292,7 +291,6 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> CreateTaskState
timeout_membership: handle.hotshot.memberships.quorum_membership.clone().into(),
timeout_task: async_spawn(async {}),
timeout: handle.hotshot.config.next_view_timeout,
round_start_delay: handle.hotshot.config.round_start_delay,
output_event_stream: handle.hotshot.external_event_stream.0.clone(),
storage: Arc::clone(&handle.storage),
proposal_cert: None,
Expand Down
3 changes: 0 additions & 3 deletions crates/hotshot/src/traits/networking/combined_network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ impl<TYPES: NodeType> TestableNetworkingImplementation<TYPES> for CombinedNetwor
num_bootstrap: usize,
network_id: usize,
da_committee_size: usize,
is_da: bool,
reliability_config: Option<Box<dyn NetworkReliability>>,
secondary_network_delay: Duration,
) -> AsyncGenerator<Arc<Self>> {
Expand All @@ -271,7 +270,6 @@ impl<TYPES: NodeType> TestableNetworkingImplementation<TYPES> for CombinedNetwor
num_bootstrap,
network_id,
da_committee_size,
is_da,
None,
Duration::default(),
),
Expand All @@ -280,7 +278,6 @@ impl<TYPES: NodeType> TestableNetworkingImplementation<TYPES> for CombinedNetwor
num_bootstrap,
network_id,
da_committee_size,
is_da,
reliability_config,
Duration::default(),
)
Expand Down
35 changes: 1 addition & 34 deletions crates/hotshot/src/traits/networking/libp2p_network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,6 @@ struct Libp2pNetworkInner<K: SignatureKey + 'static> {
#[cfg(feature = "hotshot-testing")]
/// reliability_config
reliability_config: Option<Box<dyn NetworkReliability>>,
/// if we're a member of the DA committee or not
is_da: bool,
/// Killswitch sender
kill_switch: channel::Sender<()>,
}
Expand Down Expand Up @@ -207,7 +205,6 @@ impl<TYPES: NodeType> TestableNetworkingImplementation<TYPES>
num_bootstrap: usize,
_network_id: usize,
da_committee_size: usize,
_is_da: bool,
reliability_config: Option<Box<dyn NetworkReliability>>,
_secondary_network_delay: Duration,
) -> AsyncGenerator<Arc<Self>> {
Expand All @@ -217,16 +214,6 @@ impl<TYPES: NodeType> TestableNetworkingImplementation<TYPES>
);
let bootstrap_addrs: PeerInfoVec = Arc::default();
let node_ids: Arc<RwLock<HashSet<u64>>> = Arc::default();
// We assign known_nodes' public key and stake value rather than read from config file since it's a test
let mut da_keys = BTreeSet::new();

for i in 0u64..(expected_node_count as u64) {
let privkey = TYPES::SignatureKey::generated_from_seed_indexed([0u8; 32], i).1;
let pubkey = TYPES::SignatureKey::from_private(&privkey);
if i < da_committee_size as u64 {
da_keys.insert(pubkey.clone());
}
}

// NOTE uncomment this for easier debugging
// let start_port = 5000;
Expand Down Expand Up @@ -277,7 +264,6 @@ impl<TYPES: NodeType> TestableNetworkingImplementation<TYPES>

let bootstrap_addrs_ref = Arc::clone(&bootstrap_addrs);
let node_ids_ref = Arc::clone(&node_ids);
let da = da_keys.clone();
let reliability_config_dup = reliability_config.clone();

Box::pin(async move {
Expand All @@ -299,7 +285,6 @@ impl<TYPES: NodeType> TestableNetworkingImplementation<TYPES>
usize::try_from(node_id).unwrap(),
#[cfg(feature = "hotshot-testing")]
reliability_config_dup,
da.contains(&pubkey),
)
.await
{
Expand Down Expand Up @@ -484,12 +469,6 @@ impl<K: SignatureKey + 'static> Libp2pNetwork<K> {

// Calculate all keys so we can keep track of direct message recipients
let mut all_keys = BTreeSet::new();
let mut da_keys = BTreeSet::new();

// Make a node DA if it is under the staked committee size
for node in config.config.known_da_nodes {
da_keys.insert(K::public_key(&node.stake_table_entry));
}

// Insert all known nodes into the set of all keys
for node in config.config.known_nodes_with_stake {
Expand All @@ -505,7 +484,6 @@ impl<K: SignatureKey + 'static> Libp2pNetwork<K> {
usize::try_from(config.node_index)?,
#[cfg(feature = "hotshot-testing")]
None,
da_keys.contains(pub_key),
)
.await?)
}
Expand Down Expand Up @@ -547,7 +525,6 @@ impl<K: SignatureKey + 'static> Libp2pNetwork<K> {
bootstrap_addrs: BootstrapAddrs,
id: usize,
#[cfg(feature = "hotshot-testing")] reliability_config: Option<Box<dyn NetworkReliability>>,
is_da: bool,
) -> Result<Libp2pNetwork<K>, NetworkError> {
let (mut rx, network_handle) = spawn_network_node::<K>(config.clone(), id)
.await
Expand All @@ -562,10 +539,7 @@ impl<K: SignatureKey + 'static> Libp2pNetwork<K> {
pubkey_pid_map.insert(pk.clone(), network_handle.peer_id());

// Subscribe to the relevant topics
let mut subscribed_topics = HashSet::from_iter(vec![QC_TOPIC.to_string()]);
if is_da {
subscribed_topics.insert("DA".to_string());
}
let subscribed_topics = HashSet::from_iter(vec![QC_TOPIC.to_string()]);

// unbounded channels may not be the best choice (spammed?)
// if bounded figure out a way to log dropped msgs
Expand Down Expand Up @@ -594,7 +568,6 @@ impl<K: SignatureKey + 'static> Libp2pNetwork<K> {
latest_seen_view: Arc::new(AtomicU64::new(0)),
#[cfg(feature = "hotshot-testing")]
reliability_config,
is_da,
kill_switch: kill_tx,
}),
};
Expand Down Expand Up @@ -644,7 +617,6 @@ impl<K: SignatureKey + 'static> Libp2pNetwork<K> {
let handle = Arc::clone(&self.inner.handle);
let is_bootstrapped = Arc::clone(&self.inner.is_bootstrapped);
let inner = Arc::clone(&self.inner);
let is_da = self.inner.is_da;

async_spawn({
let is_ready = Arc::clone(&self.inner.is_ready);
Expand All @@ -664,11 +636,6 @@ impl<K: SignatureKey + 'static> Libp2pNetwork<K> {
// Subscribe to the QC topic
handle.subscribe(QC_TOPIC.to_string()).await.unwrap();

// Only subscribe to DA events if we are DA
if is_da {
handle.subscribe("DA".to_string()).await.unwrap();
}

// Map our staking key to our Libp2p Peer ID so we can properly
// route direct messages
while handle
Expand Down
1 change: 0 additions & 1 deletion crates/hotshot/src/traits/networking/memory_network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ impl<TYPES: NodeType> TestableNetworkingImplementation<TYPES>
_num_bootstrap: usize,
_network_id: usize,
da_committee_size: usize,
_is_da: bool,
reliability_config: Option<Box<dyn NetworkReliability>>,
_secondary_network_delay: Duration,
) -> AsyncGenerator<Arc<Self>> {
Expand Down
1 change: 0 additions & 1 deletion crates/hotshot/src/traits/networking/push_cdn_network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ impl<TYPES: NodeType> TestableNetworkingImplementation<TYPES>
_num_bootstrap: usize,
_network_id: usize,
da_committee_size: usize,
_is_da: bool,
_reliability_config: Option<Box<dyn NetworkReliability>>,
_secondary_network_delay: Duration,
) -> AsyncGenerator<Arc<Self>> {
Expand Down
4 changes: 0 additions & 4 deletions crates/orchestrator/run-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ transactions_per_round = 10
transaction_size = 1000
node_index = 0
seed = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
start_delay_seconds = 0
cdn_marshal_address = "127.0.0.1:9000"
public_keys = [
{ stake_table_key = "BLS_VER_KEY~bQszS-QKYvUij2g20VqS8asttGSb95NrTu2PUj0uMh1CBUxNy1FqyPDjZqB29M7ZbjWqj79QkEOWkpga84AmDYUeTuWmy-0P1AdKHD3ehc-dKvei78BDj5USwXPJiDUlCxvYs_9rWYhagaq-5_LXENr78xel17spftNd5MA1Mw5U", state_ver_key = "SCHNORR_VER_KEY~lJqDaVZyM0hWP2Br52IX5FeE-dCAIC-dPX7bL5-qUx-vjbunwe-ENOeZxj6FuOyvDCFzoGeP7yZ0fM995qF-CRE", stake = 1, da = true },
Expand Down Expand Up @@ -34,9 +33,6 @@ start_threshold = [8, 10]
staked_da_nodes = 10
fixed_leader_for_gpuvid = 1
next_view_timeout = 30000
timeout_ratio = [11, 10]
round_start_delay = 1
start_delay = 1
num_bootstrap = 5
epoch_height = 0

Expand Down
4 changes: 0 additions & 4 deletions crates/orchestrator/staging-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ seed = [
0
]
transaction_size = 100
start_delay_seconds = 10
builder = "Simple"

[config]
Expand All @@ -47,9 +46,6 @@ num_nodes_with_stake = 10
staked_da_nodes = 10
fixed_leader_for_gpuvid = 1
next_view_timeout = 15_000
timeout_ratio = [ 11, 10 ]
round_start_delay = 1
start_delay = 10_000
num_bootstrap = 5
builder_urls = [ "https://builder.staging.testnet.espresso.network/" ]

Expand Down
8 changes: 2 additions & 6 deletions crates/task-impls/src/quorum_proposal/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
//! This module holds the dependency task for the QuorumProposalTask. It is spawned whenever an event that could
//! initiate a proposal occurs.
use std::{marker::PhantomData, sync::Arc, time::Duration};
use std::{marker::PhantomData, sync::Arc};

use async_broadcast::{InactiveReceiver, Sender};
use async_compatibility_layer::art::{async_sleep, async_spawn};
use async_compatibility_layer::art::async_spawn;
use async_lock::RwLock;
use hotshot_task::{
dependency::{Dependency, EventDependency},
Expand Down Expand Up @@ -83,9 +83,6 @@ pub struct ProposalDependencyHandle<TYPES: NodeType, V: Versions> {
/// Our Private Key
pub private_key: <TYPES::SignatureKey as SignatureKey>::PrivateKey,

/// Round start delay from config, in milliseconds.
pub round_start_delay: u64,

/// Shared consensus task state
pub consensus: OuterConsensus<TYPES>,

Expand Down Expand Up @@ -233,7 +230,6 @@ impl<TYPES: NodeType, V: Versions> ProposalDependencyHandle<TYPES, V> {
proposed_leaf.view_number(),
);

async_sleep(Duration::from_millis(self.round_start_delay)).await;
broadcast_event(
Arc::new(HotShotEvent::QuorumProposalSend(
message.clone(),
Expand Down
4 changes: 0 additions & 4 deletions crates/task-impls/src/quorum_proposal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ pub struct QuorumProposalTaskState<TYPES: NodeType, I: NodeImplementation<TYPES>
/// View timeout from config.
pub timeout: u64,

/// Round start delay from config, in milliseconds.
pub round_start_delay: u64,

/// This node's storage ref
pub storage: Arc<RwLock<I::Storage>>,

Expand Down Expand Up @@ -326,7 +323,6 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions>
quorum_membership: Arc::clone(&self.quorum_membership),
public_key: self.public_key.clone(),
private_key: self.private_key.clone(),
round_start_delay: self.round_start_delay,
instance_state: Arc::clone(&self.instance_state),
consensus: OuterConsensus::new(Arc::clone(&self.consensus.inner_consensus)),
formed_upgrade_certificate: self.formed_upgrade_certificate.clone(),
Expand Down
3 changes: 0 additions & 3 deletions crates/task-impls/src/quorum_proposal_recv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ pub struct QuorumProposalRecvTaskState<TYPES: NodeType, I: NodeImplementation<TY
/// View timeout from config.
pub timeout: u64,

/// Round start delay from config, in milliseconds.
pub round_start_delay: u64,

/// Output events to application
pub output_event_stream: async_broadcast::Sender<Event<TYPES>>,

Expand Down
2 changes: 1 addition & 1 deletion crates/task/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl<S: TaskState + Send + 'static> Task<S> {
let _ =
S::handle_event(&mut self.state, input, &self.sender, &self.receiver)
.await
.inspect_err(|e| tracing::info!("{e}"));
.inspect_err(|e| tracing::debug!("{e}"));
}
Err(RecvError::Closed) => {
break self.boxed_state();
Expand Down
6 changes: 2 additions & 4 deletions crates/testing/src/byzantine/byzantine_behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> EventTransforme
HotShotEvent::QuorumProposalSend(proposal, signature) => {
let mut result = Vec::new();

for n in 0..self.multiplier {
// reset last actioned view so we actually propose multiple times
consensus.write().await.reset_actions();
for n in 1..self.multiplier {
let mut modified_proposal = proposal.clone();

modified_proposal.data.view_number += n * self.increment;
Expand All @@ -66,8 +64,8 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> EventTransforme
signature.clone(),
));
}
consensus.write().await.reset_actions();

consensus.write().await.reset_actions();
result
}
_ => vec![event.clone()],
Expand Down
Loading

0 comments on commit f5941ff

Please sign in to comment.