diff --git a/Cargo.lock b/Cargo.lock index ad8899c..9255136 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1332,7 +1332,7 @@ dependencies = [ "rcgen 0.13.1", "redis", "rkyv", - "rustls 0.23.16", + "rustls 0.23.19", "rustls-pki-types", "sqlx", "thiserror 1.0.68", @@ -2442,7 +2442,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f2f12607f92c69b12ed746fabf9ca4f5c482cba46679c1a75b874ed7c26adb" dependencies = [ "futures-io", - "rustls 0.23.16", + "rustls 0.23.19", "rustls-pki-types", ] @@ -2856,7 +2856,7 @@ dependencies = [ [[package]] name = "hotshot" version = "0.5.79" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=rc-0.5.82#8485af8e3b182c84c4725060e4ad875276bc3e1d" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.82#ecfd22a4b3d20b7cf89282b172f178ab2ebf81a4" dependencies = [ "anyhow", "async-broadcast", @@ -2899,7 +2899,7 @@ dependencies = [ [[package]] name = "hotshot-builder-api" version = "0.1.7" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=rc-0.5.82#8485af8e3b182c84c4725060e4ad875276bc3e1d" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.82#ecfd22a4b3d20b7cf89282b172f178ab2ebf81a4" dependencies = [ "async-trait", "clap", @@ -2956,8 +2956,8 @@ dependencies = [ [[package]] name = "hotshot-events-service" -version = "0.1.50" -source = "git+https://github.com/EspressoSystems/hotshot-events-service.git?branch=hotshot/0.5.82#a12afecabc657e0753ae956b46bbf5e7beed2d25" +version = "0.1.56" +source = "git+https://github.com/EspressoSystems/hotshot-events-service.git?tag=0.1.56#c8046e6debb533c6abf431866ccf1d3787338982" dependencies = [ "async-broadcast", "async-lock 2.8.0", @@ -2984,7 +2984,7 @@ dependencies = [ [[package]] name = "hotshot-example-types" version = "0.5.79" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=rc-0.5.82#8485af8e3b182c84c4725060e4ad875276bc3e1d" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.82#ecfd22a4b3d20b7cf89282b172f178ab2ebf81a4" dependencies = [ "anyhow", "async-lock 3.4.0", @@ -3009,7 +3009,7 @@ dependencies = [ [[package]] name = "hotshot-fakeapi" version = "0.5.79" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=rc-0.5.82#8485af8e3b182c84c4725060e4ad875276bc3e1d" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.82#ecfd22a4b3d20b7cf89282b172f178ab2ebf81a4" dependencies = [ "anyhow", "async-lock 3.4.0", @@ -3027,7 +3027,7 @@ dependencies = [ [[package]] name = "hotshot-macros" version = "0.5.79" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=rc-0.5.82#8485af8e3b182c84c4725060e4ad875276bc3e1d" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.82#ecfd22a4b3d20b7cf89282b172f178ab2ebf81a4" dependencies = [ "derive_builder", "proc-macro2", @@ -3038,7 +3038,7 @@ dependencies = [ [[package]] name = "hotshot-task" version = "0.5.79" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=rc-0.5.82#8485af8e3b182c84c4725060e4ad875276bc3e1d" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.82#ecfd22a4b3d20b7cf89282b172f178ab2ebf81a4" dependencies = [ "async-broadcast", "async-trait", @@ -3051,7 +3051,7 @@ dependencies = [ [[package]] name = "hotshot-task-impls" version = "0.5.79" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=rc-0.5.82#8485af8e3b182c84c4725060e4ad875276bc3e1d" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.82#ecfd22a4b3d20b7cf89282b172f178ab2ebf81a4" dependencies = [ "anyhow", "async-broadcast", @@ -3085,7 +3085,7 @@ dependencies = [ [[package]] name = "hotshot-testing" version = "0.5.79" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=rc-0.5.82#8485af8e3b182c84c4725060e4ad875276bc3e1d" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.82#ecfd22a4b3d20b7cf89282b172f178ab2ebf81a4" dependencies = [ "anyhow", "async-broadcast", @@ -3126,7 +3126,7 @@ dependencies = [ [[package]] name = "hotshot-types" version = "0.1.11" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=rc-0.5.82#8485af8e3b182c84c4725060e4ad875276bc3e1d" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.82#ecfd22a4b3d20b7cf89282b172f178ab2ebf81a4" dependencies = [ "anyhow", "ark-bn254", @@ -3340,7 +3340,7 @@ dependencies = [ "http 1.1.0", "hyper 1.5.0", "hyper-util", - "rustls 0.23.16", + "rustls 0.23.19", "rustls-pki-types", "tokio", "tokio-rustls", @@ -3622,18 +3622,18 @@ dependencies = [ [[package]] name = "impl-codec" -version = "0.7.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b67aa010c1e3da95bf151bd8b4c059b2ed7e75387cdb969b4f8f2723a43f9941" +checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" dependencies = [ "parity-scale-codec", ] [[package]] name = "impl-serde" -version = "0.5.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a143eada6a1ec4aefa5049037a26a6d597bfd64f8c026d07b77133e02b7dd0b" +checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" dependencies = [ "serde", ] @@ -4280,7 +4280,7 @@ dependencies = [ "smallvec", "thiserror 1.0.68", "tracing", - "uint 0.9.5", + "uint", "void", ] @@ -4326,7 +4326,7 @@ dependencies = [ [[package]] name = "libp2p-networking" version = "0.5.79" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=rc-0.5.82#8485af8e3b182c84c4725060e4ad875276bc3e1d" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.82#ecfd22a4b3d20b7cf89282b172f178ab2ebf81a4" dependencies = [ "anyhow", "async-trait", @@ -4347,6 +4347,7 @@ dependencies = [ "serde", "tokio", "tracing", + "tracing-subscriber 0.3.18", ] [[package]] @@ -4366,7 +4367,7 @@ dependencies = [ "quinn", "rand 0.8.5", "ring 0.17.8", - "rustls 0.23.16", + "rustls 0.23.19", "socket2 0.5.7", "thiserror 1.0.68", "tokio", @@ -4460,7 +4461,7 @@ dependencies = [ "libp2p-identity", "rcgen 0.11.3", "ring 0.17.8", - "rustls 0.23.16", + "rustls 0.23.19", "rustls-webpki 0.101.7", "thiserror 1.0.68", "x509-parser", @@ -5557,14 +5558,14 @@ dependencies = [ [[package]] name = "primitive-types" -version = "0.13.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d15600a7d856470b7d278b3fe0e311fe28c2526348549f8ef2ff7db3299c87f5" +checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" dependencies = [ "fixed-hash", "impl-codec", "impl-serde", - "uint 0.10.0", + "uint", ] [[package]] @@ -5775,7 +5776,7 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash", - "rustls 0.23.16", + "rustls 0.23.19", "socket2 0.5.7", "thiserror 1.0.68", "tokio", @@ -5792,7 +5793,7 @@ dependencies = [ "rand 0.8.5", "ring 0.17.8", "rustc-hash", - "rustls 0.23.16", + "rustls 0.23.19", "slab", "thiserror 1.0.68", "tinyvec", @@ -6313,9 +6314,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.16" +version = "0.23.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eee87ff5d9b36712a58574e12e9f0ea80f915a5b0ac518d322b24a465617925e" +checksum = "934b404430bb06b3fae2cba809eb45a1ab1aecd64491213d7c3301b88393f8d1" dependencies = [ "log", "once_cell", @@ -7711,7 +7712,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.23.16", + "rustls 0.23.19", "rustls-pki-types", "tokio", ] @@ -8064,18 +8065,6 @@ dependencies = [ "static_assertions", ] -[[package]] -name = "uint" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "909988d098b2f738727b161a106cfc7cab00c539c2687a8836f8e565976fb53e" -dependencies = [ - "byteorder", - "crunchy", - "hex", - "static_assertions", -] - [[package]] name = "unicase" version = "2.8.0" @@ -8175,7 +8164,7 @@ dependencies = [ "flate2", "log", "once_cell", - "rustls 0.23.16", + "rustls 0.23.19", "rustls-pki-types", "url", "webpki-roots 0.26.6", @@ -8220,7 +8209,7 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "utils" version = "0.5.79" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=rc-0.5.82#8485af8e3b182c84c4725060e4ad875276bc3e1d" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.82#ecfd22a4b3d20b7cf89282b172f178ab2ebf81a4" dependencies = [ "tracing", ] diff --git a/crates/legacy/src/old/builder_state.rs b/crates/legacy/src/old/builder_state.rs index dc36fe9..dabcc91 100644 --- a/crates/legacy/src/old/builder_state.rs +++ b/crates/legacy/src/old/builder_state.rs @@ -1,9 +1,8 @@ use hotshot_types::{ - data::{DaProposal, Leaf, QuorumProposal}, + data::{DaProposal, Leaf2, QuorumProposal2}, message::Proposal, - traits::block_contents::{BlockHeader, BlockPayload}, traits::{ - block_contents::precompute_vid_commitment, + block_contents::{precompute_vid_commitment, BlockHeader, BlockPayload}, node_implementation::{ConsensusTime, NodeType}, EncodeBytes, }, @@ -12,9 +11,8 @@ use hotshot_types::{ }; use marketplace_builder_shared::block::{BlockId, BuilderStateId, ParentBlockReferences}; -use committable::Commitment; +use committable::{Commitment, Committable}; -use crate::implementation::LegacyCommit; use crate::service::{GlobalState, ReceivedTransaction}; use async_broadcast::broadcast; use async_broadcast::Receiver as BroadcastReceiver; @@ -63,7 +61,7 @@ pub struct DaProposalMessage { /// Quorum proposal message to be put on the quorum proposal channel #[derive(Clone, Debug, PartialEq)] pub struct QuorumProposalMessage { - pub proposal: Arc>>, + pub proposal: Arc>>, pub sender: Types::SignatureKey, } /// Request Message to be put on the request channel @@ -146,7 +144,7 @@ pub struct BuilderState { /// `quorum_proposal_payload_commit` to `quorum_proposal` #[allow(clippy::type_complexity)] pub quorum_proposal_payload_commit_to_quorum_proposal: - HashMap<(BuilderCommitment, Types::View), Arc>>>, + HashMap<(BuilderCommitment, Types::View), Arc>>>, /// Spawned-from references to the parent block. pub parent_block_references: ParentBlockReferences, @@ -212,9 +210,9 @@ pub struct BuilderState { /// itself. /// /// In an ideal circumstance the best [`BuilderState`] to extend from is going to -/// be the one that is immediately preceding the [`QuorumProposal`] that we are +/// be the one that is immediately preceding the [`QuorumProposal2`] that we are /// attempting to extend from. However, if all we know is the view number of -/// the [`QuorumProposal`] that we are attempting to extend from, then we may end +/// the [`QuorumProposal2`] that we are attempting to extend from, then we may end /// up in a scenario where we have multiple [`BuilderState`]s that are all equally /// valid to extend from. When this happens, we have the potential for a data /// race. @@ -223,7 +221,7 @@ pub struct BuilderState { /// [`ProxyGlobalState`](crate::service::ProxyGlobalState)'s API. In general, /// we want to be able to retrieve a [`BuilderState`] via the [`BuilderStateId`]. /// The [`BuilderStateId`] only references a [`ViewNumber`](hotshot_types::data::ViewNumber) -/// and a [`VidCommitment`] While this information is available in the [`QuorumProposal`], +/// and a [`VidCommitment`] While this information is available in the [`QuorumProposal2`], /// it only helps us to rule out [`BuilderState`]s that already exist. /// It does **NOT** help us to pick a [`BuilderState`] that is the best fit to extend from. /// @@ -237,7 +235,7 @@ pub struct BuilderState { /// This function determines the best [`BuilderState`] in the following steps: /// /// 1. If we have a [`BuilderState`] that is already spawned for the current -/// [`QuorumProposal`], then we should should return no states, as one already +/// [`QuorumProposal2`], then we should should return no states, as one already /// exists. This will prevent us from attempting to spawn duplicate /// [`BuilderState`]s. /// 2. Attempt to find all [`BuilderState`]s that are recorded within @@ -245,7 +243,7 @@ pub struct BuilderState { /// *should* only be one of these. But all would be valid extension points. /// 3. If we can't find any [`BuilderState`]s that match the view number /// and leaf commitment, then we should return for the maximum stored view -/// number that is smaller than the current [`QuorumProposal`]. +/// number that is smaller than the current [`QuorumProposal2`]. /// 4. If there is is only one [`BuilderState`] stored in the [`GlobalState`], then /// we should return that [`BuilderState`] as the best fit. /// 5. If none of the other criteria match, we return an empty result as it is @@ -258,7 +256,7 @@ pub struct BuilderState { /// > entries in the resulting [HashSet], but this is not done here in order /// > to allow us to highlight the possibility of the race. async fn best_builder_states_to_extend( - quorum_proposal: Arc>>, + quorum_proposal: Arc>>, global_state: Arc>>, ) -> HashSet> { let current_view_number = quorum_proposal.data.view_number; @@ -369,7 +367,7 @@ impl BuilderState { /// we are among the best [`BuilderState`]s to extend from. async fn am_i_the_best_builder_state_to_extend( &self, - quorum_proposal: Arc>>, + quorum_proposal: Arc>>, ) -> bool { let best_builder_states_to_extend = best_builder_states_to_extend(quorum_proposal.clone(), self.global_state.clone()).await; @@ -545,11 +543,11 @@ impl BuilderState { /// /// This helper function also adds additional checks in order to ensure /// that the [`BuilderState`] that is being spawned is the best fit for the - /// [`QuorumProposal`] that is being extended from. + /// [`QuorumProposal2`] that is being extended from. async fn spawn_clone_that_extends_self( &mut self, da_proposal_info: DAProposalInfo, - quorum_proposal: Arc>>, + quorum_proposal: Arc>>, ) { if !self .am_i_the_best_builder_state_to_extend(quorum_proposal.clone()) @@ -617,10 +615,10 @@ impl BuilderState { async fn spawn_clone( mut self, da_proposal_info: DAProposalInfo, - quorum_proposal: Arc>>, + quorum_proposal: Arc>>, req_sender: BroadcastSender>, ) { - let leaf = Leaf::from_quorum_proposal(&quorum_proposal.data); + let leaf = Leaf2::from_quorum_proposal(&quorum_proposal.data); // We replace our parent_block_references with information from the // quorum proposal. This is identifying the block that this specific @@ -628,7 +626,7 @@ impl BuilderState { self.parent_block_references = ParentBlockReferences { view_number: quorum_proposal.data.view_number, vid_commitment: quorum_proposal.data.block_header.payload_commitment(), - leaf_commit: leaf.legacy_commit(), + leaf_commit: leaf.commit(), builder_commitment: quorum_proposal.data.block_header.builder_commitment(), // Unused in old legacy builder: last_nonempty_view: None, @@ -1146,8 +1144,8 @@ mod test { use committable::RawCommitmentBuilder; use hotshot_example_types::block_types::TestTransaction; use hotshot_example_types::node_types::TestTypes; - use hotshot_types::data::ViewNumber; - use hotshot_types::data::{Leaf, QuorumProposal}; + use hotshot_types::data::Leaf2; + use hotshot_types::data::{QuorumProposal2, ViewNumber}; use hotshot_types::traits::node_implementation::{ConsensusTime, NodeType}; use hotshot_types::utils::BuilderCommitment; use marketplace_builder_shared::testing::constants::TEST_NUM_NODES_IN_VID_COMPUTATION; @@ -1414,7 +1412,7 @@ mod test { .collect::>() }) .collect::>(); - let mut prev_quorum_proposal: Option> = None; + let mut prev_quorum_proposal: Option> = None; // register some builder states for later decide event #[allow(clippy::needless_range_loop)] for round in 0..NUM_ROUNDS { @@ -1424,7 +1422,7 @@ mod test { .await; prev_quorum_proposal = Some(quorum_proposal.clone()); let (req_sender, _req_receiver) = broadcast(CHANNEL_CAPACITY); - let leaf: Leaf = Leaf::from_quorum_proposal(&quorum_proposal); + let leaf: Leaf2 = Leaf2::from_quorum_proposal(&quorum_proposal); let leaf_commit = RawCommitmentBuilder::new("leaf commitment") .u64_field("view number", leaf.view_number().u64()) .u64_field("block number", leaf.height()) diff --git a/crates/legacy/src/old/lib.rs b/crates/legacy/src/old/lib.rs index 09cf17a..820e215 100644 --- a/crates/legacy/src/old/lib.rs +++ b/crates/legacy/src/old/lib.rs @@ -22,7 +22,6 @@ pub mod service; pub mod testing; use hotshot_builder_api::v0_1::builder::BuildError; -use hotshot_types::traits::node_implementation::NodeType; use tokio::sync::mpsc::UnboundedReceiver; /// `WaitAndKeep` is a helper enum that allows for the lazy polling of a single @@ -74,15 +73,3 @@ impl WaitAndKeep { } } } - -// TODO: Update commitment calculation with the new `commit`. -// -trait LegacyCommit { - fn legacy_commit(&self) -> committable::Commitment>; -} - -impl LegacyCommit for hotshot_types::data::Leaf { - fn legacy_commit(&self) -> committable::Commitment> { - as committable::Committable>::commit(self) - } -} diff --git a/crates/legacy/src/old/service.rs b/crates/legacy/src/old/service.rs index bd6e516..c026ca3 100644 --- a/crates/legacy/src/old/service.rs +++ b/crates/legacy/src/old/service.rs @@ -8,7 +8,7 @@ use hotshot_builder_api::{ v0_2::builder::TransactionStatus, }; use hotshot_types::{ - data::{DaProposal, Leaf, QuorumProposal}, + data::{DaProposal, Leaf2, QuorumProposal2}, event::EventType, message::Proposal, traits::{ @@ -24,14 +24,11 @@ use vbs::version::StaticVersionType; use marketplace_builder_shared::block::{BlockId, BuilderStateId, ParentBlockReferences}; -use crate::builder_state::{MessageType, RequestMessage, ResponseMessage}; -use crate::{ - builder_state::{ - BuildBlockInfo, DaProposalMessage, DecideMessage, QuorumProposalMessage, TransactionSource, - TriggerStatus, - }, - implementation::LegacyCommit as _, +use crate::builder_state::{ + BuildBlockInfo, DaProposalMessage, DecideMessage, QuorumProposalMessage, TransactionSource, + TriggerStatus, }; +use crate::builder_state::{MessageType, RequestMessage, ResponseMessage}; use crate::{WaitAndKeep, WaitAndKeepGetError}; pub use async_broadcast::{broadcast, RecvError, TryRecvError}; use async_broadcast::{Sender as BroadcastSender, TrySendError}; @@ -1376,7 +1373,7 @@ enum HandleQuorumEventError { /// still open. async fn handle_quorum_event( quorum_channel_sender: &BroadcastSender>, - quorum_proposal: Arc>>, + quorum_proposal: Arc>>, sender: ::SignatureKey, ) { // We're explicitly not inspecting this error, as this function is not @@ -1398,7 +1395,7 @@ async fn handle_quorum_event( /// This function is the implementation for [`handle_quorum_event`]. async fn handle_quorum_event_implementation( quorum_channel_sender: &BroadcastSender>, - quorum_proposal: Arc>>, + quorum_proposal: Arc>>, sender: ::SignatureKey, ) -> Result<(), HandleQuorumEventError> { tracing::debug!( @@ -1407,9 +1404,9 @@ async fn handle_quorum_event_implementation( quorum_proposal.data.view_number ); - let leaf = Leaf::from_quorum_proposal(&quorum_proposal.data); + let leaf = Leaf2::from_quorum_proposal(&quorum_proposal.data); - if !sender.validate(&quorum_proposal.signature, leaf.legacy_commit().as_ref()) { + if !sender.validate(&quorum_proposal.signature, leaf.commit().as_ref()) { tracing::error!( "Validation Failure on QuorumProposal for view {:?}: Leader for the current view: {:?}", quorum_proposal.data.view_number, @@ -1645,9 +1642,13 @@ mod test { node_types::{TestTypes, TestVersions}, state_types::{TestInstanceState, TestValidatedState}, }; + use hotshot_types::data::Leaf2; + use hotshot_types::data::QuorumProposal2; + use hotshot_types::drb::INITIAL_DRB_RESULT; + use hotshot_types::drb::INITIAL_DRB_SEED_INPUT; use hotshot_types::traits::block_contents::Transaction; use hotshot_types::{ - data::{DaProposal, Leaf, QuorumProposal, ViewNumber}, + data::{DaProposal, Leaf, ViewNumber}, message::Proposal, simple_certificate::QuorumCertificate, traits::{ @@ -1670,7 +1671,6 @@ mod test { sync::{mpsc::unbounded_channel, oneshot}, }; - use crate::implementation::LegacyCommit; use crate::{ builder_state::{ BuildBlockInfo, MessageType, RequestMessage, ResponseMessage, TransactionSource, @@ -4310,30 +4310,33 @@ mod test { let view_number = ViewNumber::new(10); let quorum_proposal = { - let leaf = Leaf::::genesis( + let leaf: Leaf2<_> = Leaf::::genesis( &TestValidatedState::default(), &TestInstanceState::default(), ) - .await; + .await + .into(); - QuorumProposal:: { + QuorumProposal2:: { block_header: leaf.block_header().clone(), view_number, justify_qc: QuorumCertificate::genesis::( &TestValidatedState::default(), &TestInstanceState::default(), ) - .await, + .await + .to_qc2(), upgrade_certificate: None, - proposal_certificate: None, + view_change_evidence: None, + drb_seed: INITIAL_DRB_SEED_INPUT, + drb_result: INITIAL_DRB_RESULT, } }; - let leaf = Leaf::from_quorum_proposal(&quorum_proposal); + let leaf = Leaf2::from_quorum_proposal(&quorum_proposal); let signature = - ::sign(&leader_private_key, leaf.legacy_commit().as_ref()) - .unwrap(); + ::sign(&leader_private_key, leaf.commit().as_ref()).unwrap(); let signed_quorum_proposal = Arc::new(Proposal { data: quorum_proposal, @@ -4380,30 +4383,33 @@ mod test { let view_number = ViewNumber::new(10); let quorum_proposal = { - let leaf = Leaf::::genesis( + let leaf: Leaf2<_> = Leaf::::genesis( &TestValidatedState::default(), &TestInstanceState::default(), ) - .await; + .await + .into(); - QuorumProposal:: { + QuorumProposal2:: { block_header: leaf.block_header().clone(), view_number, justify_qc: QuorumCertificate::genesis::( &TestValidatedState::default(), &TestInstanceState::default(), ) - .await, + .await + .to_qc2(), upgrade_certificate: None, - proposal_certificate: None, + view_change_evidence: None, + drb_seed: INITIAL_DRB_SEED_INPUT, + drb_result: INITIAL_DRB_RESULT, } }; - let leaf = Leaf::from_quorum_proposal(&quorum_proposal); + let leaf = Leaf2::from_quorum_proposal(&quorum_proposal); let signature = - ::sign(&sender_private_key, leaf.legacy_commit().as_ref()) - .unwrap(); + ::sign(&sender_private_key, leaf.commit().as_ref()).unwrap(); let signed_quorum_proposal = Arc::new(Proposal { data: quorum_proposal, @@ -4441,30 +4447,33 @@ mod test { let view_number = ViewNumber::new(10); let quorum_proposal = { - let leaf = Leaf::::genesis( + let leaf: Leaf2<_> = Leaf::::genesis( &TestValidatedState::default(), &TestInstanceState::default(), ) - .await; + .await + .into(); - QuorumProposal:: { + QuorumProposal2:: { block_header: leaf.block_header().clone(), view_number, justify_qc: QuorumCertificate::genesis::( &TestValidatedState::default(), &TestInstanceState::default(), ) - .await, + .await + .to_qc2(), upgrade_certificate: None, - proposal_certificate: None, + view_change_evidence: None, + drb_seed: INITIAL_DRB_SEED_INPUT, + drb_result: INITIAL_DRB_RESULT, } }; - let leaf = Leaf::from_quorum_proposal(&quorum_proposal); + let leaf = Leaf2::from_quorum_proposal(&quorum_proposal); let signature = - ::sign(&sender_private_key, leaf.legacy_commit().as_ref()) - .unwrap(); + ::sign(&sender_private_key, leaf.commit().as_ref()).unwrap(); let signed_quorum_proposal = Arc::new(Proposal { data: quorum_proposal, diff --git a/crates/legacy/src/old/testing/basic_test.rs b/crates/legacy/src/old/testing/basic_test.rs index 57e716c..926c9da 100644 --- a/crates/legacy/src/old/testing/basic_test.rs +++ b/crates/legacy/src/old/testing/basic_test.rs @@ -1,6 +1,6 @@ pub use hotshot::traits::election::static_committee::StaticCommittee; pub use hotshot_types::{ - data::{DaProposal, EpochNumber, Leaf, QuorumProposal, ViewNumber}, + data::{DaProposal, EpochNumber, Leaf, ViewNumber}, message::Proposal, signature_key::BLSPubKey, simple_certificate::{QuorumCertificate, SimpleCertificate, SuccessThreshold}, @@ -23,9 +23,11 @@ mod tests { use hotshot_builder_api::v0_2::data_source::BuilderDataSource; use hotshot_example_types::auction_results_provider_types::TestAuctionResult; use hotshot_example_types::node_types::TestVersions; + use hotshot_types::data::{Leaf2, QuorumProposal2}; + use hotshot_types::drb::{INITIAL_DRB_RESULT, INITIAL_DRB_SEED_INPUT}; + use hotshot_types::simple_vote::QuorumData2; use hotshot_types::{ signature_key::BuilderKey, - simple_vote::QuorumData, traits::block_contents::{vid_commitment, BlockHeader}, utils::BuilderCommitment, }; @@ -46,7 +48,6 @@ mod tests { use crate::builder_state::{ DaProposalMessage, DecideMessage, QuorumProposalMessage, TransactionSource, }; - use crate::implementation::LegacyCommit; use crate::service::{ handle_received_txns, GlobalState, ProxyGlobalState, ReceivedTransaction, }; @@ -133,7 +134,7 @@ mod tests { ParentBlockReferences { view_number: ViewNumber::new(0), vid_commitment: initial_commitment, - leaf_commit: Commitment::>::default_commitment_no_preimage(), + leaf_commit: Commitment::>::default_commitment_no_preimage(), builder_commitment: BuilderCommitment::from_bytes([]), // Unused in old legacy builder: last_nonempty_view: None, @@ -171,9 +172,10 @@ mod tests { &TestValidatedState::default(), &TestInstanceState::default(), ) - .await; + .await + .to_qc2(); - QuorumProposal:: { + QuorumProposal2:: { block_header: TestBlockHeader { block_number: 0, payload_commitment: previous_commitment, @@ -187,7 +189,9 @@ mod tests { view_number: ViewNumber::new(0), justify_qc: previous_jc.clone(), upgrade_certificate: None, - proposal_certificate: None, + view_change_evidence: None, + drb_seed: INITIAL_DRB_SEED_INPUT, + drb_result: INITIAL_DRB_RESULT, } }; @@ -355,10 +359,10 @@ mod tests { let _metadata = >::metadata( &previous_quorum_proposal.block_header, ); - let leaf = Leaf::from_quorum_proposal(&previous_quorum_proposal); + let leaf = Leaf2::from_quorum_proposal(&previous_quorum_proposal); - let q_data = QuorumData:: { - leaf_commit: leaf.legacy_commit(), + let q_data = QuorumData2:: { + leaf_commit: leaf.commit(), }; let previous_quorum_view_number = @@ -371,7 +375,7 @@ mod tests { ViewNumber::new(1 + previous_justify_qc.view_number.u64()) }; // form a justify qc - SimpleCertificate::, SuccessThreshold>::new( + SimpleCertificate::, SuccessThreshold>::new( q_data.clone(), q_data.commit(), view_number, @@ -382,12 +386,14 @@ mod tests { tracing::debug!("Iteration: {} justify_qc: {:?}", round, justify_qc); - let quorum_proposal = QuorumProposal:: { + let quorum_proposal = QuorumProposal2:: { block_header, view_number: ViewNumber::new(round as u64), justify_qc: justify_qc.clone(), upgrade_certificate: None, - proposal_certificate: None, + view_change_evidence: None, + drb_seed: INITIAL_DRB_SEED_INPUT, + drb_result: INITIAL_DRB_RESULT, }; let payload_vid_commitment = @@ -416,13 +422,12 @@ mod tests { // This may not be necessary for this test let decide_message = { let leaf = match round { - 0 => { - Leaf::genesis( - &TestValidatedState::default(), - &TestInstanceState::default(), - ) - .await - } + 0 => Leaf::genesis( + &TestValidatedState::default(), + &TestInstanceState::default(), + ) + .await + .into(), _ => { let block_payload = BlockPayload::::from_bytes( &encoded_transactions, @@ -430,7 +435,7 @@ mod tests { &quorum_certificate_message.proposal.data.block_header, ), ); - let mut current_leaf = Leaf::from_quorum_proposal( + let mut current_leaf = Leaf2::from_quorum_proposal( &quorum_certificate_message.proposal.data, ); current_leaf diff --git a/crates/legacy/src/old/testing/finalization_test.rs b/crates/legacy/src/old/testing/finalization_test.rs index b683dfa..3ec611d 100644 --- a/crates/legacy/src/old/testing/finalization_test.rs +++ b/crates/legacy/src/old/testing/finalization_test.rs @@ -13,8 +13,8 @@ use hotshot::{ types::{BLSPubKey, SignatureKey}, }; use hotshot_builder_api::{ - v0_2::{block_info::AvailableBlockInfo, data_source::BuilderDataSource}, - v0_3::{builder::BuildError, data_source::AcceptsTxnSubmits}, + v0_1::{block_info::AvailableBlockInfo, data_source::BuilderDataSource}, + v0_1::{builder::BuildError, data_source::AcceptsTxnSubmits}, }; use hotshot_example_types::{ block_types::{TestBlockHeader, TestBlockPayload, TestMetadata, TestTransaction}, @@ -22,7 +22,8 @@ use hotshot_example_types::{ state_types::{TestInstanceState, TestValidatedState}, }; use hotshot_types::{ - data::{DaProposal, QuorumProposal, ViewNumber}, + data::{DaProposal, QuorumProposal2, ViewNumber}, + drb::{INITIAL_DRB_RESULT, INITIAL_DRB_SEED_INPUT}, message::Proposal, simple_certificate::QuorumCertificate, traits::{ @@ -316,16 +317,19 @@ async fn progress_round_with_transactions( random: 0, }; - let qc_proposal = QuorumProposal:: { + let qc_proposal = QuorumProposal2:: { block_header, view_number: next_view, justify_qc: QuorumCertificate::::genesis::( &TestValidatedState::default(), &TestInstanceState::default(), ) - .await, + .await + .to_qc2(), upgrade_certificate: None, - proposal_certificate: None, + view_change_evidence: None, + drb_seed: INITIAL_DRB_SEED_INPUT, + drb_result: INITIAL_DRB_RESULT, }; let payload_vid_commitment = diff --git a/crates/legacy/src/old/testing/mod.rs b/crates/legacy/src/old/testing/mod.rs index 5633788..00787a4 100644 --- a/crates/legacy/src/old/testing/mod.rs +++ b/crates/legacy/src/old/testing/mod.rs @@ -4,7 +4,6 @@ use crate::{ builder_state::{ BuilderState, DAProposalInfo, DaProposalMessage, MessageType, QuorumProposalMessage, }, - implementation::LegacyCommit, service::ReceivedTransaction, }; use async_broadcast::broadcast; @@ -14,10 +13,11 @@ use hotshot::{ types::{BLSPubKey, SignatureKey}, }; use hotshot_types::{ - data::{DaProposal, Leaf, QuorumProposal, ViewNumber}, + data::{DaProposal, Leaf2, QuorumProposal2, ViewNumber}, + drb::{INITIAL_DRB_RESULT, INITIAL_DRB_SEED_INPUT}, message::Proposal, simple_certificate::{QuorumCertificate, SimpleCertificate, SuccessThreshold}, - simple_vote::QuorumData, + simple_vote::QuorumData2, traits::{block_contents::vid_commitment, node_implementation::ConsensusTime}, utils::BuilderCommitment, }; @@ -84,7 +84,7 @@ pub async fn create_builder_state( ParentBlockReferences { view_number: ViewNumber::new(0), vid_commitment: genesis_vid_commitment, - leaf_commit: Commitment::>::default_commitment_no_preimage(), + leaf_commit: Commitment::>::default_commitment_no_preimage(), builder_commitment: genesis_builder_commitment, // Unused in old legacy builder: last_nonempty_view: None, @@ -112,10 +112,10 @@ pub async fn create_builder_state( pub async fn calc_proposal_msg( num_storage_nodes: usize, round: usize, - prev_quorum_proposal: Option>, + prev_quorum_proposal: Option>, transactions: Vec, ) -> ( - QuorumProposal, + QuorumProposal2, QuorumProposalMessage, DaProposalMessage, BuilderStateId, @@ -174,21 +174,20 @@ pub async fn calc_proposal_msg( }; let justify_qc = match prev_quorum_proposal.as_ref() { - None => { - QuorumCertificate::::genesis::( - &TestValidatedState::default(), - &TestInstanceState::default(), - ) - .await - } + None => QuorumCertificate::::genesis::( + &TestValidatedState::default(), + &TestInstanceState::default(), + ) + .await + .to_qc2(), Some(prev_proposal) => { let prev_justify_qc = &prev_proposal.justify_qc; - let quorum_data = QuorumData:: { - leaf_commit: Leaf::from_quorum_proposal(prev_proposal).legacy_commit(), + let quorum_data = QuorumData2:: { + leaf_commit: Leaf2::from_quorum_proposal(prev_proposal).commit(), }; // form a justify qc - SimpleCertificate::, SuccessThreshold>::new( + SimpleCertificate::, SuccessThreshold>::new( quorum_data.clone(), quorum_data.commit(), prev_proposal.view_number, @@ -200,12 +199,14 @@ pub async fn calc_proposal_msg( tracing::debug!("Iteration: {} justify_qc: {:?}", round, justify_qc); - let quorum_proposal = QuorumProposal:: { + let quorum_proposal = QuorumProposal2:: { block_header, view_number: ViewNumber::new(round as u64), justify_qc: justify_qc.clone(), upgrade_certificate: None, - proposal_certificate: None, + view_change_evidence: None, + drb_seed: INITIAL_DRB_SEED_INPUT, + drb_result: INITIAL_DRB_RESULT, }; let quorum_signature = diff --git a/crates/shared/src/testing/consensus.rs b/crates/shared/src/testing/consensus.rs index 9acf977..20f7b6b 100644 --- a/crates/shared/src/testing/consensus.rs +++ b/crates/shared/src/testing/consensus.rs @@ -18,6 +18,7 @@ use hotshot_example_types::{ }; use hotshot_types::{ data::{DaProposal, Leaf2, QuorumProposal2, ViewNumber}, + drb::{INITIAL_DRB_RESULT, INITIAL_DRB_SEED_INPUT}, message::Proposal, simple_certificate::{QuorumCertificate, SimpleCertificate, SuccessThreshold}, simple_vote::QuorumData2, @@ -121,9 +122,9 @@ impl SimulatedChainState { justify_qc: justify_qc.clone(), upgrade_certificate: None, view_change_evidence: None, - drb_seed: [0; 96], + drb_seed: INITIAL_DRB_SEED_INPUT, - drb_result: [0; 32], + drb_result: INITIAL_DRB_RESULT, }; let quorum_proposal_event = EventType::QuorumProposal { diff --git a/crates/shared/src/testing/mock.rs b/crates/shared/src/testing/mock.rs index 11738a3..1d9e494 100644 --- a/crates/shared/src/testing/mock.rs +++ b/crates/shared/src/testing/mock.rs @@ -11,6 +11,8 @@ use hotshot_example_types::{ }; use hotshot_types::data::QuorumProposal2; use hotshot_types::data::ViewNumber; +use hotshot_types::drb::INITIAL_DRB_RESULT; +use hotshot_types::drb::INITIAL_DRB_SEED_INPUT; use hotshot_types::event::LeafInfo; use hotshot_types::simple_certificate::QuorumCertificate2; use hotshot_types::simple_vote::QuorumData2; @@ -112,8 +114,8 @@ pub async fn proposals_with_transactions( justify_qc: genesis_qc, upgrade_certificate: None, view_change_evidence: None, - drb_seed: [0; 96], - drb_result: [0; 32], + drb_seed: INITIAL_DRB_SEED_INPUT, + drb_result: INITIAL_DRB_RESULT, }; let leaf = Leaf2::from_quorum_proposal(&parent_proposal); @@ -145,8 +147,8 @@ pub async fn proposals_with_transactions( justify_qc, upgrade_certificate: None, view_change_evidence: None, - drb_seed: [0; 96], - drb_result: [0; 32], + drb_seed: INITIAL_DRB_SEED_INPUT, + drb_result: INITIAL_DRB_RESULT, }, ) }