From 3e44fc45d96b6cb2b819625dd19cbee5525b467a Mon Sep 17 00:00:00 2001 From: Brendon Fish Date: Fri, 17 May 2024 12:18:07 -0400 Subject: [PATCH] Update hotshot --- Cargo.lock | 19 ++++++++------- Cargo.toml | 10 ++++---- src/builder_state.rs | 50 ++++++++++++++------------------------- src/service.rs | 16 ++++++------- src/testing/basic_test.rs | 13 ++++------ 5 files changed, 46 insertions(+), 62 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5ff58366..37b2cd5c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3031,7 +3031,7 @@ dependencies = [ [[package]] name = "hotshot" version = "0.5.43" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.54#af6e40d6157e335a7ed71c956ef37d8e820635c5" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.55#81842b54a699a255645ac195354a0feb08fdc9d6" dependencies = [ "anyhow", "async-broadcast", @@ -3076,7 +3076,7 @@ dependencies = [ [[package]] name = "hotshot-builder-api" version = "0.1.7" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.54#af6e40d6157e335a7ed71c956ef37d8e820635c5" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.55#81842b54a699a255645ac195354a0feb08fdc9d6" dependencies = [ "async-trait", "clap", @@ -3124,7 +3124,7 @@ dependencies = [ [[package]] name = "hotshot-events-service" version = "0.1.22" -source = "git+https://github.com/EspressoSystems/hotshot-events-service.git?tag=0.1.22#0986778c44d729b94b88b3e80db58d82de7dae9e" +source = "git+https://github.com/EspressoSystems/hotshot-events-service.git?tag=0.1.23#7049c81d8e697894803ea76e7128d0aca7fa47c9" dependencies = [ "async-broadcast", "async-compatibility-layer", @@ -3149,7 +3149,7 @@ dependencies = [ [[package]] name = "hotshot-example-types" version = "0.5.43" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.54#af6e40d6157e335a7ed71c956ef37d8e820635c5" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.55#81842b54a699a255645ac195354a0feb08fdc9d6" dependencies = [ "anyhow", "async-broadcast", @@ -3174,12 +3174,13 @@ dependencies = [ "time 0.3.36", "tokio", "tracing", + "vbs", ] [[package]] name = "hotshot-orchestrator" version = "0.5.43" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.54#af6e40d6157e335a7ed71c956ef37d8e820635c5" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.55#81842b54a699a255645ac195354a0feb08fdc9d6" dependencies = [ "anyhow", "async-compatibility-layer", @@ -3208,7 +3209,7 @@ dependencies = [ [[package]] name = "hotshot-task" version = "0.5.43" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.54#af6e40d6157e335a7ed71c956ef37d8e820635c5" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.55#81842b54a699a255645ac195354a0feb08fdc9d6" dependencies = [ "async-broadcast", "async-compatibility-layer", @@ -3221,7 +3222,7 @@ dependencies = [ [[package]] name = "hotshot-task-impls" version = "0.5.43" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.54#af6e40d6157e335a7ed71c956ef37d8e820635c5" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.55#81842b54a699a255645ac195354a0feb08fdc9d6" dependencies = [ "anyhow", "async-broadcast", @@ -3256,7 +3257,7 @@ dependencies = [ [[package]] name = "hotshot-types" version = "0.1.11" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.54#af6e40d6157e335a7ed71c956ef37d8e820635c5" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.55#81842b54a699a255645ac195354a0feb08fdc9d6" dependencies = [ "anyhow", "ark-bls12-381", @@ -4356,7 +4357,7 @@ dependencies = [ [[package]] name = "libp2p-networking" version = "0.5.43" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.54#af6e40d6157e335a7ed71c956ef37d8e820635c5" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.55#81842b54a699a255645ac195354a0feb08fdc9d6" dependencies = [ "anyhow", "async-compatibility-layer", diff --git a/Cargo.toml b/Cargo.toml index da28e7bf..6ab35732 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,10 +17,10 @@ clap = { version = "4.4", features = ["derive", "env"] } committable = "0.2" derivative = "2.2" futures = "0.3" -hotshot = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.54" } -hotshot-builder-api = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.54" } -hotshot-events-service = { git = "https://github.com/EspressoSystems/hotshot-events-service.git", tag = "0.1.22" } -hotshot-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.54" } +hotshot = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.55" } +hotshot-builder-api = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.55" } +hotshot-events-service = { git = "https://github.com/EspressoSystems/hotshot-events-service.git", tag = "0.1.23" } +hotshot-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.55" } serde = { version = "1.0", features = ["derive"] } sha2 = "0.10" snafu = "0.8" @@ -31,4 +31,4 @@ tracing = "0.1" vbs = "0.1" [dev-dependencies] -hotshot-example-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.54" } +hotshot-example-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.55" } diff --git a/src/builder_state.rs b/src/builder_state.rs index e55358aa..6afbdf58 100644 --- a/src/builder_state.rs +++ b/src/builder_state.rs @@ -5,10 +5,10 @@ use hotshot_types::{ traits::{ block_contents::precompute_vid_commitment, node_implementation::{ConsensusTime, NodeType}, + EncodeBytes, }, utils::BuilderCommitment, vid::{VidCommitment, VidPrecomputeData}, - vote::Certificate, }; use committable::{Commitment, Committable}; @@ -301,9 +301,8 @@ impl BuilderProgress for BuilderState { // To handle both cases, we can have the bootstrap builder running, // and only doing the insertion if and only if intended builder state for a particulat view is not present // check the presence of da_msg.proposal.data.view_number-1 in the spawned_builder_states list - if self.built_from_proposed_block.view_number.get_u64() - == self.bootstrap_view_number.get_u64() - && (da_msg.proposal.data.view_number.get_u64() == 0 + if self.built_from_proposed_block.view_number.u64() == self.bootstrap_view_number.u64() + && (da_msg.proposal.data.view_number.u64() == 0 || !self .global_state .read_arc() @@ -319,8 +318,8 @@ impl BuilderProgress for BuilderState { handled_by_bootstrap = true; } // Do the validation check - else if da_msg.proposal.data.view_number.get_u64() - != self.built_from_proposed_block.view_number.get_u64() + 1 + else if da_msg.proposal.data.view_number.u64() + != self.built_from_proposed_block.view_number.u64() + 1 { tracing::debug!("View number is not equal to built_from_view + 1, so returning"); return; @@ -423,9 +422,8 @@ impl BuilderProgress for BuilderState { // To handle both cases, we can have the bootstrap builder running, // and only doing the insertion if and only if intended builder state for a particulat view is not present // check the presence of da_msg.proposal.data.view_number-1 in the spawned_builder_states - if self.built_from_proposed_block.view_number.get_u64() - == self.bootstrap_view_number.get_u64() - && (qc_msg.proposal.data.view_number.get_u64() == 0 + if self.built_from_proposed_block.view_number.u64() == self.bootstrap_view_number.u64() + && (qc_msg.proposal.data.view_number.u64() == 0 || !self .global_state .read_arc() @@ -438,11 +436,11 @@ impl BuilderProgress for BuilderState { handled_by_bootstrap = true; } else if qc_msg.proposal.data.justify_qc.view_number != self.built_from_proposed_block.view_number - || (qc_msg.proposal.data.justify_qc.get_data().leaf_commit + || (qc_msg.proposal.data.justify_qc.data.leaf_commit != self.built_from_proposed_block.leaf_commit) { tracing::debug!("Either View number {:?} or leaf commit{:?} from justify qc does not match the built-in info {:?}, so returning", - qc_msg.proposal.data.justify_qc.view_number, qc_msg.proposal.data.justify_qc.get_data().leaf_commit, self.built_from_proposed_block); + qc_msg.proposal.data.justify_qc.view_number, qc_msg.proposal.data.justify_qc.data.leaf_commit, self.built_from_proposed_block); return; } @@ -515,29 +513,27 @@ impl BuilderProgress for BuilderState { // the special value can be 0 itself, or a view number 0 is also right answer let _block_size = decide_msg.block_size; let latest_leaf_view_number = decide_msg.latest_decide_view_number; - let latest_leaf_view_number_as_i64 = latest_leaf_view_number.get_u64() as i64; + let latest_leaf_view_number_as_i64 = latest_leaf_view_number.u64() as i64; // Garbage collection // Keep the builder states stay active till their built in view + BUFFER_VIEW_NUM - if self.built_from_proposed_block.view_number.get_u64() - == self.bootstrap_view_number.get_u64() - { + if self.built_from_proposed_block.view_number.u64() == self.bootstrap_view_number.u64() { // required to convert to prevent underflow on u64's let last_bootstrap_garbage_collected_as_i64 = self .last_bootstrap_garbage_collected_decided_seen_view_num - .get_u64() as i64; + .u64() as i64; if (latest_leaf_view_number_as_i64 - last_bootstrap_garbage_collected_as_i64) >= 2 * self.buffer_view_num_count as i64 { tracing::info!( "Bootstrapped builder state garbage collected for view number {:?}", - latest_leaf_view_number.get_u64() + latest_leaf_view_number.u64() ); let to_be_garbage_collected_view_num = <::Time as ConsensusTime>::new( - latest_leaf_view_number.get_u64() - self.buffer_view_num_count, + latest_leaf_view_number.u64() - self.buffer_view_num_count, ); let to_garbage_collect: HashSet<(VidCommitment, BuilderCommitment, TYPES::Time)> = @@ -580,7 +576,7 @@ impl BuilderProgress for BuilderState { //return Some(Status::ShouldContinue); } } else if self.built_from_proposed_block.view_number < latest_leaf_view_number { - tracing::info!("Task view is less than the currently decided leaf view {:?}; exiting builder state for view {:?}", latest_leaf_view_number.get_u64(), self.built_from_proposed_block.view_number.get_u64()); + tracing::info!("Task view is less than the currently decided leaf view {:?}; exiting builder state for view {:?}", latest_leaf_view_number.u64(), self.built_from_proposed_block.view_number.u64()); self.global_state.write_arc().await.remove_handles( &self.built_from_proposed_block.vid_commitment, self.builder_commitments.clone(), @@ -704,17 +700,7 @@ impl BuilderProgress for BuilderState { requested_view_number, )); - let encoded_txns: Vec = payload - .encode() - .inspect_err(|e| { - tracing::error!( - "Failed to encode block payload for parent {:?}@{:?}: {e}", - matching_vid, - requested_view_number - ) - }) - .ok()? - .to_vec(); + let encoded_txns: Vec = payload.encode().to_vec(); let block_size: u64 = encoded_txns.len() as u64; let offered_fee: u64 = self.base_fee * block_size; @@ -760,8 +746,8 @@ impl BuilderProgress for BuilderState { // If a spawned clone is active then it will handle the request, otherwise the bootstrapped builder will handle if (requested_vid_commitment == self.built_from_proposed_block.vid_commitment && requested_view_number == self.built_from_proposed_block.view_number) - || (self.built_from_proposed_block.view_number.get_u64() - == self.bootstrap_view_number.get_u64()) + || (self.built_from_proposed_block.view_number.u64() + == self.bootstrap_view_number.u64()) { tracing::info!( "Request handled by builder with view {:?} for (parent {:?}, view_num: {:?})", diff --git a/src/service.rs b/src/service.rs index 3f424cf0..3526a998 100644 --- a/src/service.rs +++ b/src/service.rs @@ -337,7 +337,7 @@ where >>::Error: Display, for<'a> >::Error: Display, { - async fn get_available_blocks( + async fn available_blocks( &self, for_parent: &VidCommitment, view_number: u64, @@ -617,7 +617,7 @@ where }) } } - async fn get_builder_address( + async fn builder_address( &self, ) -> Result<::BuilderSignatureKey, BuildError> { Ok(self.builder_keys.0.clone()) @@ -781,7 +781,7 @@ pub async fn run_non_permissioned_standalone_builder_service( // DA proposal event BuilderEventType::HotshotDaProposal { proposal, sender } => { // get the leader for current view - let leader = membership.get_leader(proposal.data.view_number); + let leader = membership.leader(proposal.data.view_number); // get the committee mstatked node count let total_nodes = membership.total_nodes(); @@ -797,7 +797,7 @@ pub async fn run_non_permissioned_standalone_builder_service( // QC proposal event BuilderEventType::HotshotQuorumProposal { proposal, sender } => { // get the leader for current view - let leader = membership.get_leader(proposal.data.view_number); + let leader = membership.leader(proposal.data.view_number); handle_qc_event(&qc_sender, proposal, sender, leader).await; } _ => { @@ -844,7 +844,7 @@ pub async fn run_permissioned_standalone_builder_service< // hotshot context handle hotshot_handle: SystemContextHandle, ) { - let mut event_stream = hotshot_handle.get_event_stream(); + let mut event_stream = hotshot_handle.event_stream(); loop { tracing::debug!("Waiting for events from HotShot"); match event_stream.next().await { @@ -867,14 +867,14 @@ pub async fn run_permissioned_standalone_builder_service< block_size, .. } => { - let latest_decide_view_number = leaf_chain[0].leaf.get_view_number(); + let latest_decide_view_number = leaf_chain[0].leaf.view_number(); handle_decide_event(&decide_sender, latest_decide_view_number, block_size) .await; } // DA proposal event EventType::DaProposal { proposal, sender } => { // get the leader for current view - let leader = hotshot_handle.get_leader(proposal.data.view_number).await; + let leader = hotshot_handle.leader(proposal.data.view_number).await; // get the committee staked node count let total_nodes = hotshot_handle.total_nodes(); @@ -883,7 +883,7 @@ pub async fn run_permissioned_standalone_builder_service< // QC proposal event EventType::QuorumProposal { proposal, sender } => { // get the leader for current view - let leader = hotshot_handle.get_leader(proposal.data.view_number).await; + let leader = hotshot_handle.leader(proposal.data.view_number).await; handle_qc_event(&qc_sender, proposal, sender, leader).await; } _ => { diff --git a/src/testing/basic_test.rs b/src/testing/basic_test.rs index d1b784b4..647721e6 100644 --- a/src/testing/basic_test.rs +++ b/src/testing/basic_test.rs @@ -211,17 +211,14 @@ mod tests { leaf_commit: leaf.commit(), }; - let previous_qc_view_number = sqc_msgs[(i - 1) as usize] - .proposal - .data - .view_number - .get_u64(); + let previous_qc_view_number = + sqc_msgs[(i - 1) as usize].proposal.data.view_number.u64(); let view_number = if previous_qc_view_number == 0 - && previous_justify_qc.view_number.get_u64() == 0 + && previous_justify_qc.view_number.u64() == 0 { ViewNumber::new(0) } else { - ViewNumber::new(1 + previous_justify_qc.view_number.get_u64()) + ViewNumber::new(1 + previous_justify_qc.view_number.u64()) }; // form a justify qc SimpleCertificate::, SuccessThreshold> { @@ -286,7 +283,7 @@ mod tests { }; let sdecide_msg = DecideMessage:: { - latest_decide_view_number: leaf.get_view_number(), + latest_decide_view_number: leaf.view_number(), block_size: Some(encoded_transactions.len() as u64), };