Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

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

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ bytesize = "1.3"
committable = { git = "https://github.com/EspressoSystems/commit.git", features = ["ark-serialize"] }
derivative = "2.2"
itertools = "0.12"
jf-advz = { git = "https://github.com/EspressoSystems/jellyfish-compat", tag = "jf-advz-v0.2.1", features = [
"std",
"parallel",
] }
jf-crhf = { git = "https://github.com/EspressoSystems/jellyfish", tag = "jf-crhf-v0.2.0" }
jf-merkle-tree-compat = { git = "https://github.com/EspressoSystems/jellyfish-compat", tag = "jf-merkle-tree-compat-v0.1.0", features = [
"std",
Expand All @@ -200,10 +204,6 @@ jf-signature = { git = "https://github.com/EspressoSystems/jellyfish", tag = "jf
"std",
] }
jf-utils = { git = "https://github.com/EspressoSystems/jellyfish", tag = "jf-utils-v0.5.0" }
jf-advz = { git = "https://github.com/EspressoSystems/jellyfish-compat", tag = "jf-advz-v0.2.1", features = [
"std",
"parallel",
] }
libp2p = { package = "libp2p", version = "0.56", default-features = false, features = [
"macros",
"autonat",
Expand Down
23 changes: 12 additions & 11 deletions benchmark-stats/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ use std::{
};

use clap::{Parser, Subcommand};
use espresso_types::SeqTypes;
use hotshot_task_impls::stats::{LeaderViewStats, ReplicaViewStats};
use hotshot_types::data::ViewNumber;
use hotshot_types::{
benchmarking::{LeaderViewStats, ReplicaViewStats},
data::ViewNumber,
};
use plotly::{
common::{HoverInfo, Line, Marker, MarkerSymbol, Mode},
layout::{self, Axis, GridPattern, LayoutGrid},
Expand Down Expand Up @@ -81,14 +82,14 @@ struct ReplicaStats {
/// Read replica stats from CSV into a BTreeMap
fn read_replica_view_stats(
path: &Path,
) -> Result<BTreeMap<ViewNumber, ReplicaViewStats<SeqTypes>>, Box<dyn std::error::Error>> {
) -> Result<BTreeMap<ViewNumber, ReplicaViewStats<ViewNumber>>, Box<dyn std::error::Error>> {
println!("\n**--- Replica Stats ---**");
let mut reader = csv::Reader::from_path(path)
.map_err(|e| format!("Failed to open replica stats CSV at {path:?}: {e}"))?;
let mut replica_view_stats = BTreeMap::new();

for result in reader.deserialize() {
let record: ReplicaViewStats<SeqTypes> = result?;
let record: ReplicaViewStats<ViewNumber> = result?;
replica_view_stats.insert(record.view, record);
}

Expand All @@ -97,7 +98,7 @@ fn read_replica_view_stats(

/// Generate plots of replica stats
fn plot_replica_stats(
replica_view_stats: &BTreeMap<ViewNumber, ReplicaViewStats<SeqTypes>>,
replica_view_stats: &BTreeMap<ViewNumber, ReplicaViewStats<ViewNumber>>,
output_file: &Path,
) -> Result<(), Box<dyn std::error::Error>> {
let mut x_views = Vec::new();
Expand Down Expand Up @@ -294,7 +295,7 @@ fn plot_replica_stats(
/// it generates the time difference for VID/DAC/Proposal
/// from the view change event
fn generate_replica_stats(
replica_view_stats: &BTreeMap<ViewNumber, ReplicaViewStats<SeqTypes>>,
replica_view_stats: &BTreeMap<ViewNumber, ReplicaViewStats<ViewNumber>>,
) -> ReplicaStats {
let mut vid_deltas_from_vc = Vec::new();
let mut dac_deltas_from_vc = Vec::new();
Expand Down Expand Up @@ -336,21 +337,21 @@ fn print_replica_stats(stats: &ReplicaStats) {
/// Read leader stats from CSV into a BTreeMap
fn read_leader_view_stats(
path: &Path,
) -> Result<BTreeMap<ViewNumber, LeaderViewStats<SeqTypes>>, Box<dyn std::error::Error>> {
) -> Result<BTreeMap<ViewNumber, LeaderViewStats<ViewNumber>>, Box<dyn std::error::Error>> {
println!("\n**--- Leader Stats ---**");
let mut reader = csv::Reader::from_path(path)
.map_err(|e| format!("Failed to open leader stats CSV at {path:?}: {e}"))?;
let mut leader_view_stats = BTreeMap::<ViewNumber, LeaderViewStats<SeqTypes>>::new();
let mut leader_view_stats = BTreeMap::<ViewNumber, LeaderViewStats<ViewNumber>>::new();

for result in reader.deserialize() {
let record: LeaderViewStats<SeqTypes> = result?;
let record: LeaderViewStats<ViewNumber> = result?;
leader_view_stats.insert(record.view, record);
}
Ok(leader_view_stats)
}

fn plot_and_print_leader_stats(
leader_view_stats: &BTreeMap<ViewNumber, LeaderViewStats<SeqTypes>>,
leader_view_stats: &BTreeMap<ViewNumber, LeaderViewStats<ViewNumber>>,
output_file: &Path,
) -> Result<(), Box<dyn std::error::Error>> {
let mut views = Vec::new();
Expand Down
2 changes: 1 addition & 1 deletion crates/hotshot-builder/legacy/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ impl<Types: NodeType> GlobalState<Types> {
.insert(state_id, response_msg);

if let Some(previous_builder_state_entry) = previous_builder_state_entry {
tracing::warn!(
tracing::info!(
"block {id} overwrote previous block: {previous_builder_state_entry:?}. previous \
cache entry: {previous_cache_entry:?}"
);
Expand Down
41 changes: 10 additions & 31 deletions crates/hotshot/examples/infra/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ use hotshot_types::{
node_implementation::{ConsensusTime, NodeType, Versions},
states::TestableState,
},
utils::genesis_epoch_from_version,
HotShotConfig, PeerConfig, ValidatorConfig,
};
use rand::{rngs::StdRng, SeedableRng};
Expand Down Expand Up @@ -366,6 +365,7 @@ pub trait RunDa<
async fn initialize_state_and_hotshot(
&self,
membership: Arc<RwLock<<TYPES as NodeType>::Membership>>,
orchestrator_url: Option<Url>,
) -> SystemContextHandle<TYPES, NODE, V> {
let initializer = hotshot::HotShotInitializer::<TYPES>::from_genesis::<V>(
TestInstanceState::default(),
Expand Down Expand Up @@ -401,6 +401,7 @@ pub trait RunDa<
ConsensusMetricsValue::default(),
storage,
StorageMetricsValue::default(),
orchestrator_url,
)
.await
.expect("Could not init hotshot")
Expand All @@ -415,7 +416,7 @@ pub trait RunDa<
transactions: &mut Vec<TestTransaction>,
transactions_to_send_per_round: u64,
transaction_size_in_bytes: u64,
) -> BenchResults {
) -> BenchResults<TYPES::View> {
let NetworkConfig {
rounds, node_index, ..
} = self.config();
Expand Down Expand Up @@ -525,16 +526,6 @@ pub trait RunDa<
},
}
}
// Panic if we don't have the genesis epoch, there is no recovery from that
let num_eligible_leaders = context
.hotshot
.membership_coordinator
.membership_for_epoch(genesis_epoch_from_version::<V, TYPES>())
.await
.unwrap()
.stake_table()
.await
.len();
let consensus_lock = context.hotshot.consensus();
let consensus_reader = consensus_lock.read().await;
let total_num_views = usize::try_from(consensus_reader.locked_view().u64()).unwrap();
Expand Down Expand Up @@ -566,23 +557,7 @@ pub trait RunDa<
{avg_latency_in_sec} sec."
);

BenchResults {
partial_results: "Unset".to_string(),
avg_latency_in_sec,
num_latency,
minimum_latency_in_sec: minimum_latency,
maximum_latency_in_sec: maximum_latency,
throughput_bytes_per_sec,
total_transactions_committed,
transaction_size_in_bytes: transaction_size_in_bytes + 8, // extra 8 bytes for timestamp
total_time_elapsed_in_sec: total_time_elapsed.as_secs(),
total_num_views,
failed_num_views,
committee_type: format!(
"{} with {num_eligible_leaders} eligible leaders",
std::any::type_name::<TYPES::Membership>()
),
}
BenchResults::default()
} else {
// all values with zero
BenchResults::default()
Expand Down Expand Up @@ -994,7 +969,9 @@ pub async fn main_entry_point<
&membership,
)
.await;
let hotshot = run.initialize_state_and_hotshot(membership).await;
let hotshot = run
.initialize_state_and_hotshot(membership, Some(args.url))
.await;

if let Some(task) = builder_task {
task.start(Box::new(hotshot.event_stream()));
Expand Down Expand Up @@ -1041,7 +1018,9 @@ pub async fn main_entry_point<
(transaction_size + 8) as u64, // extra 8 bytes for transaction base, see `create_random_transaction`.
)
.await;
orchestrator_client.post_bench_results(bench_results).await;
orchestrator_client
.post_bench_results::<TYPES>(bench_results)
.await;
}

/// Sets correct builder_url and registers a builder with orchestrator if this node is running one.
Expand Down
13 changes: 13 additions & 0 deletions crates/hotshot/hotshot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ use hotshot_types::{
pub use rand;
use tokio::{spawn, time::sleep};
use tracing::{debug, instrument, trace};
use url::Url;

// -- Rexports
// External
Expand Down Expand Up @@ -112,6 +113,9 @@ pub struct SystemContext<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versi
/// Memberships used by consensus
pub membership_coordinator: EpochMembershipCoordinator<TYPES>,

/// The orchestrator url
pub orchestrator_url: Option<Url>,

/// the metrics that the implementor is using.
metrics: Arc<ConsensusMetricsValue>,

Expand Down Expand Up @@ -167,6 +171,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> Clone
config: self.config.clone(),
network: Arc::clone(&self.network),
membership_coordinator: self.membership_coordinator.clone(),
orchestrator_url: self.orchestrator_url.clone(),
metrics: Arc::clone(&self.metrics),
consensus: self.consensus.clone(),
instance_state: Arc::clone(&self.instance_state),
Expand Down Expand Up @@ -209,6 +214,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> SystemContext<T
consensus_metrics: ConsensusMetricsValue,
storage: I::Storage,
storage_metrics: StorageMetricsValue,
orchestrator_url: Option<Url>,
) -> Arc<Self> {
let internal_chan = broadcast(EVENT_CHANNEL_SIZE);
let external_chan = broadcast(EXTERNAL_EVENT_CHANNEL_SIZE);
Expand All @@ -227,6 +233,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> SystemContext<T
storage_metrics,
internal_chan,
external_chan,
orchestrator_url,
)
.await
}
Expand Down Expand Up @@ -256,6 +263,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> SystemContext<T
Receiver<Arc<HotShotEvent<TYPES>>>,
),
external_channel: (Sender<Event<TYPES>>, Receiver<Event<TYPES>>),
orchestrator_url: Option<Url>,
) -> Arc<Self> {
debug!("Creating a new hotshot");

Expand Down Expand Up @@ -414,6 +422,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> SystemContext<T
storage,
storage_metrics,
upgrade_lock,
orchestrator_url,
});

inner
Expand Down Expand Up @@ -677,6 +686,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> SystemContext<T
consensus_metrics: ConsensusMetricsValue,
storage: I::Storage,
storage_metrics: StorageMetricsValue,
orchestrator_url: Option<Url>,
) -> Result<
(
SystemContextHandle<TYPES, I, V>,
Expand All @@ -697,6 +707,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> SystemContext<T
consensus_metrics,
storage,
storage_metrics,
orchestrator_url,
)
.await;
let handle = Arc::clone(&hotshot).run_tasks().await;
Expand Down Expand Up @@ -859,6 +870,7 @@ where
consensus_metrics.clone(),
storage.clone(),
storage_metrics.clone(),
None,
)
.await;
let right_system_context = SystemContext::new(
Expand All @@ -873,6 +885,7 @@ where
consensus_metrics,
storage,
storage_metrics,
None,
)
.await;

Expand Down
1 change: 1 addition & 0 deletions crates/hotshot/hotshot/src/tasks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ where
consensus_metrics,
storage.clone(),
storage_metrics,
None,
)
.await;
let consensus_registry = ConsensusTaskRegistry::new();
Expand Down
2 changes: 2 additions & 0 deletions crates/hotshot/hotshot/src/tasks/task_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,13 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> CreateTaskState
{
async fn create_from(handle: &SystemContextHandle<TYPES, I, V>) -> Self {
StatsTaskState::<TYPES>::new(
handle.hotshot.id,
handle.cur_view().await,
handle.cur_epoch().await,
handle.public_key().clone(),
OuterConsensus::new(handle.hotshot.consensus()),
handle.hotshot.membership_coordinator.clone(),
handle.hotshot.orchestrator_url.clone(),
)
}
}
Expand Down
Loading