Skip to content

Commit

Permalink
Bump HotShot
Browse files Browse the repository at this point in the history
  • Loading branch information
QuentinI committed Nov 28, 2024
1 parent 1f1f21a commit 73dc1aa
Show file tree
Hide file tree
Showing 15 changed files with 243 additions and 465 deletions.
537 changes: 150 additions & 387 deletions Cargo.lock

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@
resolver = "2"
members = ["crates/*"]

[workspace.package]
version = "0.1.57"
edition = "2021"

[workspace.dependencies]
hotshot = { git = "https://github.com/EspressoSystems/HotShot.git", rev = "f62b557" }
hotshot-builder-api = { git = "https://github.com/EspressoSystems/HotShot.git", rev = "f62b557" }
hotshot-events-service = { git = "https://github.com/EspressoSystems/hotshot-events-service.git", branch = "sishan/tx_status_api" }
hotshot-macros = { git = "https://github.com/EspressoSystems/HotShot.git", rev = "f62b557" }
hotshot-task-impls = { git = "https://github.com/EspressoSystems/HotShot.git", rev = "f62b557" }
hotshot-testing = { git = "https://github.com/EspressoSystems/HotShot.git", rev = "f62b557" }
hotshot-types = { git = "https://github.com/EspressoSystems/HotShot.git", rev = "f62b557" }
hotshot-example-types = { git = "https://github.com/EspressoSystems/HotShot.git", rev = "f62b557" }
hotshot = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "rc-0.5.82" }
hotshot-builder-api = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "rc-0.5.82" }
hotshot-events-service = { git = "https://github.com/EspressoSystems/hotshot-events-service.git", branch = "hotshot/0.5.82" }
hotshot-macros = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "rc-0.5.82" }
hotshot-task-impls = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "rc-0.5.82" }
hotshot-testing = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "rc-0.5.82" }
hotshot-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "rc-0.5.82" }
hotshot-example-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "rc-0.5.82" }

anyhow = "1"
async-broadcast = "0.7"
Expand Down Expand Up @@ -51,10 +55,6 @@ vbs = "0.1"
vec1 = "1.12"
tracing-subscriber = "0.3"

[workspace.package]
version = "0.1.56"
edition = "2021"

[workspace.lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage_nightly)'] }

Expand Down
2 changes: 1 addition & 1 deletion crates/legacy/src/block_store.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::marker::PhantomData;

use hotshot::traits::BlockPayload;
use hotshot_builder_api::v0_2::block_info::AvailableBlockInfo;
use hotshot_builder_api::v0_1::block_info::AvailableBlockInfo;
use hotshot_types::traits::signature_key::BuilderSignatureKey;
use hotshot_types::vid::{VidCommitment, VidPrecomputeData};
use marketplace_builder_shared::error::Error;
Expand Down
14 changes: 9 additions & 5 deletions crates/legacy/src/testing/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use hotshot_builder_api::v0_1::data_source::BuilderDataSource;
use hotshot_example_types::block_types::{TestBlockHeader, TestMetadata, TestTransaction};
use hotshot_example_types::node_types::{TestTypes, TestVersions};
use hotshot_example_types::state_types::{TestInstanceState, TestValidatedState};
use hotshot_types::data::{Leaf, QuorumProposal, ViewNumber};
use hotshot_types::data::{Leaf2, QuorumProposal2, ViewNumber};
use hotshot_types::event::LeafInfo;
use hotshot_types::simple_certificate::QuorumCertificate;
use hotshot_types::traits::block_contents::BlockHeader;
Expand Down Expand Up @@ -186,8 +186,10 @@ async fn test_pruning() {
// everything else is boilerplate.

let mock_qc =
QuorumCertificate::genesis::<TestVersions>(&Default::default(), &Default::default()).await;
let leaf = Leaf::from_quorum_proposal(&QuorumProposal {
QuorumCertificate::genesis::<TestVersions>(&Default::default(), &Default::default())
.await
.to_qc2();
let leaf = Leaf2::from_quorum_proposal(&QuorumProposal2 {
block_header: <TestBlockHeader as BlockHeader<TestTypes>>::genesis(
&Default::default(),
Default::default(),
Expand All @@ -196,10 +198,12 @@ async fn test_pruning() {
num_transactions: 0,
},
),
view_number: ViewNumber::new(DECIDE_VIEW), // <- This is the only thing we're interested in
view_number: ViewNumber::new(DECIDE_VIEW),
justify_qc: mock_qc.clone(),
upgrade_certificate: None,
proposal_certificate: None,
view_change_evidence: None,
drb_seed: [0; 96],
drb_result: [0; 32],
});
event_stream_sender
.broadcast(hotshot::types::Event {
Expand Down
12 changes: 6 additions & 6 deletions crates/marketplace/src/builder_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ pub struct BuilderState<Types: NodeType> {
/// 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.
Expand All @@ -193,7 +193,7 @@ pub struct BuilderState<Types: NodeType> {
/// [`BuilderState`] via the [`BuilderStateId`]. The [`BuilderStateId`] only
/// references a [`ViewNumber`](hotshot_types::data::ViewNumber) and a
/// [`VidCommitment`](hotshot_types::vid::VidCommitment). While this information
/// is available in the [`QuorumProposal`], it only helps us to rule out
/// 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.
///
Expand All @@ -207,15 +207,15 @@ pub struct BuilderState<Types: NodeType> {
/// 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
/// [`GlobalState`] that have matching view number and leaf commitments. There
/// *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
Expand Down Expand Up @@ -521,7 +521,7 @@ impl<Types: NodeType> BuilderState<Types> {
///
/// 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: Arc<DaProposalMessage<Types>>,
Expand Down
2 changes: 1 addition & 1 deletion crates/marketplace/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use futures::{
use hotshot::types::Event;
use hotshot_builder_api::{
v0_2::builder::TransactionStatus,
v0_3::{
v0_99::{
builder::{define_api, submit_api, BuildError, Error as BuilderApiError},
data_source::{AcceptsTxnSubmits, BuilderDataSource},
},
Expand Down
2 changes: 1 addition & 1 deletion crates/marketplace/src/testing/basic_test.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use async_broadcast::broadcast;
use hotshot_builder_api::v0_3::data_source::{AcceptsTxnSubmits, BuilderDataSource};
use hotshot_builder_api::v0_99::data_source::{AcceptsTxnSubmits, BuilderDataSource};

use hotshot_example_types::block_types::TestTransaction;
use tracing_test::traced_test;
Expand Down
2 changes: 1 addition & 1 deletion crates/marketplace/src/testing/order_test.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use async_broadcast::broadcast;
use hotshot_builder_api::v0_3::data_source::{AcceptsTxnSubmits, BuilderDataSource};
use hotshot_builder_api::v0_99::data_source::{AcceptsTxnSubmits, BuilderDataSource};
use hotshot_types::{bundle::Bundle, traits::node_implementation::ConsensusTime};
use marketplace_builder_shared::{block::BuilderStateId, testing::consensus::SimulatedChainState};
use tracing_test::traced_test;
Expand Down
5 changes: 2 additions & 3 deletions crates/shared/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
use std::time::Instant;

use committable::{Commitment, Committable};
use hotshot_types::data::fake_commitment;
use hotshot_types::data::{fake_commitment, Leaf2};
use hotshot_types::traits::node_implementation::ConsensusTime;
use hotshot_types::{
data::Leaf,
traits::{block_contents::Transaction, node_implementation::NodeType},
utils::BuilderCommitment,
vid::VidCommitment,
Expand Down Expand Up @@ -101,7 +100,7 @@ pub struct ParentBlockReferences<Types: NodeType> {
/// VID commitment of the parent block payload
pub vid_commitment: VidCommitment,
/// Leaf commitment of the parent leaf
pub leaf_commit: Commitment<Leaf<Types>>,
pub leaf_commit: Commitment<Leaf2<Types>>,
/// Builder commitment of the parent block payload
pub builder_commitment: BuilderCommitment,
/// Number of transactions included in the parent block
Expand Down
24 changes: 12 additions & 12 deletions crates/shared/src/coordinator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use either::Either;
use hotshot::traits::BlockPayload;
use hotshot_builder_api::v0_1::builder::TransactionStatus;
use hotshot_types::{
data::{DaProposal, QuorumProposal},
data::{DaProposal, QuorumProposal2},
event::LeafInfo,
traits::{
block_contents::BlockHeader,
Expand All @@ -33,7 +33,7 @@ use crate::{
pub mod tiered_view_map;

type ProposalMap<Types> =
HashMap<ProposalId<Types>, Either<QuorumProposal<Types>, DaProposal<Types>>>;
HashMap<ProposalId<Types>, Either<QuorumProposal2<Types>, DaProposal<Types>>>;

type BuilderStateMap<Types> = TieredViewMap<BuilderStateId<Types>, Arc<BuilderState<Types>>>;

Expand Down Expand Up @@ -222,7 +222,7 @@ where
/// This function should be called whenever new Quorum Proposal is recieved from HotShot.
/// Coordinator uses matching Quorum and DA proposals to track creation of new blocks
/// and spawning corresponding builder states for those.
pub async fn handle_quorum_proposal(&self, quorum_proposal: QuorumProposal<Types>) {
pub async fn handle_quorum_proposal(&self, quorum_proposal: QuorumProposal2<Types>) {
let proposal_id = ProposalId::from_quorum_proposal(&quorum_proposal);
self.handle_proposal(proposal_id, Either::Left(quorum_proposal))
.await;
Expand All @@ -238,7 +238,7 @@ where
async fn handle_proposal(
&self,
proposal_id: ProposalId<Types>,
proposal: Either<QuorumProposal<Types>, DaProposal<Types>>,
proposal: Either<QuorumProposal2<Types>, DaProposal<Types>>,
) {
match self.proposals.lock().await.entry(proposal_id) {
Entry::Occupied(entry) => {
Expand Down Expand Up @@ -307,7 +307,7 @@ where
/// Spawn a new builder state off of matching pair of Quorum and DA proposals, store it in [`Self::builder_states`]
async fn spawn_builder_state(
&self,
quorum_proposal: QuorumProposal<Types>,
quorum_proposal: QuorumProposal2<Types>,
da_proposal: DaProposal<Types>,
) {
assert_eq!(quorum_proposal.view_number, da_proposal.view_number);
Expand Down Expand Up @@ -345,12 +345,12 @@ where
}

/// This is an utility function that is used to determine which [`BuilderState`]s
/// are the best fit to extend from for given [`QuorumProposal`]
/// are the best fit to extend from for given [`QuorumProposal2`]
///
/// 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.
Expand All @@ -359,7 +359,7 @@ where
/// [`BuilderStateCoordinator`]'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`](`hotshot_types::vid::VidCommitment`).
/// While this information is available in the [`QuorumProposal`],
/// 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.
///
Expand All @@ -374,15 +374,15 @@ where
/// 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
/// coordinator that have matching view number and leaf commitments. There
/// *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 coordinator, 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
Expand All @@ -401,7 +401,7 @@ where
#[must_use]
async fn find_builder_states_to_extend(
&self,
quorum_proposal: &QuorumProposal<Types>,
quorum_proposal: &QuorumProposal2<Types>,
) -> Vec<Arc<BuilderState<Types>>> {
// This is ID of the state we want to spawn
let current_builder_state_id = BuilderStateId {
Expand Down
2 changes: 1 addition & 1 deletion crates/shared/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::sync::Arc;

use async_broadcast::TrySendError;
use hotshot::traits::BlockPayload;
use hotshot_builder_api::v0_3::builder::BuildError;
use hotshot_builder_api::v0_99::builder::BuildError;
use hotshot_types::traits::{node_implementation::NodeType, signature_key::BuilderSignatureKey};
use thiserror::Error;

Expand Down
6 changes: 3 additions & 3 deletions crates/shared/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use async_lock::{Mutex, RwLock};
use committable::{Commitment, Committable};
use hotshot::traits::{BlockPayload, ValidatedState};
use hotshot_types::{
data::{DaProposal, Leaf, QuorumProposal},
data::{DaProposal, Leaf2, QuorumProposal2},
traits::{block_contents::BlockHeader, node_implementation::NodeType},
};

Expand Down Expand Up @@ -142,10 +142,10 @@ where

pub(crate) async fn new_child(
self: Arc<Self>,
quorum_proposal: QuorumProposal<Types>,
quorum_proposal: QuorumProposal2<Types>,
da_proposal: DaProposal<Types>,
) -> Arc<Self> {
let leaf = Leaf::from_quorum_proposal(&quorum_proposal);
let leaf = Leaf2::from_quorum_proposal(&quorum_proposal);

let validated_state = Types::ValidatedState::from_header(leaf.block_header());

Expand Down
32 changes: 17 additions & 15 deletions crates/shared/src/testing/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ use hotshot_example_types::{
state_types::{TestInstanceState, TestValidatedState},
};
use hotshot_types::{
data::{DaProposal, Leaf, QuorumProposal, ViewNumber},
data::{DaProposal, Leaf2, QuorumProposal2, ViewNumber},
message::Proposal,
simple_certificate::{QuorumCertificate, SimpleCertificate, SuccessThreshold},
simple_vote::QuorumData,
simple_vote::QuorumData2,
traits::{block_contents::vid_commitment, node_implementation::ConsensusTime},
};
use sha2::{Digest, Sha256};

pub struct SimulatedChainState {
round: ViewNumber,
previous_quorum_proposal: Option<QuorumProposal<TestTypes>>,
previous_quorum_proposal: Option<QuorumProposal2<TestTypes>>,
event_stream_sender: Sender<Event<TestTypes>>,
}

Expand Down Expand Up @@ -90,21 +90,20 @@ impl SimulatedChainState {
};

let justify_qc = match self.previous_quorum_proposal.as_ref() {
None => {
QuorumCertificate::<TestTypes>::genesis::<TestVersions>(
&TestValidatedState::default(),
&TestInstanceState::default(),
)
.await
}
None => QuorumCertificate::<TestTypes>::genesis::<TestVersions>(
&TestValidatedState::default(),
&TestInstanceState::default(),
)
.await
.to_qc2(),
Some(prev_proposal) => {
let prev_justify_qc = &prev_proposal.justify_qc;
let quorum_data = QuorumData::<TestTypes> {
leaf_commit: Committable::commit(&Leaf::from_quorum_proposal(prev_proposal)),
let quorum_data = QuorumData2::<TestTypes> {
leaf_commit: Committable::commit(&Leaf2::from_quorum_proposal(prev_proposal)),
};

// form a justify qc
SimpleCertificate::<TestTypes, QuorumData<TestTypes>, SuccessThreshold>::new(
SimpleCertificate::<TestTypes, QuorumData2<TestTypes>, SuccessThreshold>::new(
quorum_data.clone(),
quorum_data.commit(),
prev_proposal.view_number,
Expand All @@ -116,12 +115,15 @@ impl SimulatedChainState {

tracing::debug!("Iteration: {} justify_qc: {:?}", self.round, justify_qc);

let quorum_proposal = QuorumProposal::<TestTypes> {
let quorum_proposal = QuorumProposal2::<TestTypes> {
block_header,
view_number: self.round,
justify_qc: justify_qc.clone(),
upgrade_certificate: None,
proposal_certificate: None,
view_change_evidence: None,
drb_seed: [0; 96],

drb_result: [0; 32],
};

let quorum_proposal_event = EventType::QuorumProposal {
Expand Down
Loading

0 comments on commit 73dc1aa

Please sign in to comment.