Skip to content

Commit

Permalink
Fix compilation and tests
Browse files Browse the repository at this point in the history
- Replace DAProposal with DAProposal2
- Add arbirary epoch and EPOCH_HEIGHT values
- Set empty (None) next_epoch_justify_qc
  • Loading branch information
sveitser committed Dec 19, 2024
1 parent 1cee49f commit 8b6361e
Show file tree
Hide file tree
Showing 13 changed files with 154 additions and 145 deletions.
185 changes: 80 additions & 105 deletions Cargo.lock

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ version = "0.1.58"
edition = "2021"

[workspace.dependencies]
hotshot = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.82" }
hotshot-builder-api = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.82" }
hotshot-events-service = { git = "https://github.com/EspressoSystems/hotshot-events-service.git", tag = "0.1.56" }
hotshot-macros = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.82" }
hotshot-task-impls = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.82" }
hotshot-testing = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.82" }
hotshot-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.82" }
hotshot-example-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.82" }
hotshot = { git = "https://github.com/EspressoSystems/HotShot.git", branch = "bump/0.5.83" }
hotshot-builder-api = { git = "https://github.com/EspressoSystems/HotShot.git", branch = "bump/0.5.83" }
hotshot-events-service = { git = "https://github.com/EspressoSystems/hotshot-events-service.git", branch = "ma/hotshot-0.5.83" }
hotshot-macros = { git = "https://github.com/EspressoSystems/HotShot.git", branch = "bump/0.5.83" }
hotshot-task-impls = { git = "https://github.com/EspressoSystems/HotShot.git", branch = "bump/0.5.83" }
hotshot-testing = { git = "https://github.com/EspressoSystems/HotShot.git", branch = "bump/0.5.83" }
hotshot-types = { git = "https://github.com/EspressoSystems/HotShot.git", branch = "bump/0.5.83" }
hotshot-example-types = { git = "https://github.com/EspressoSystems/HotShot.git", branch = "bump/0.5.83" }

anyhow = "1"
async-broadcast = "0.7"
Expand Down
6 changes: 3 additions & 3 deletions crates/legacy/src/builder_state.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use hotshot_types::{
data::{DaProposal, Leaf2, QuorumProposal2},
data::{DaProposal2, Leaf2, QuorumProposal2},
message::Proposal,
traits::{
block_contents::{precompute_vid_commitment, BlockHeader, BlockPayload},
Expand Down Expand Up @@ -55,7 +55,7 @@ pub struct DecideMessage<Types: NodeType> {
/// DA Proposal Message to be put on the da proposal channel
#[derive(Clone, Debug, PartialEq)]
pub struct DaProposalMessage<Types: NodeType> {
pub proposal: Arc<Proposal<Types, DaProposal<Types>>>,
pub proposal: Arc<Proposal<Types, DaProposal2<Types>>>,
pub sender: Types::SignatureKey,
}
/// Quorum proposal message to be put on the quorum proposal channel
Expand Down Expand Up @@ -108,7 +108,7 @@ pub enum Status {
#[derive(Debug, Clone, PartialEq)]
pub struct DAProposalInfo<Types: NodeType> {
pub view_number: Types::View,
pub proposal: Arc<Proposal<Types, DaProposal<Types>>>,
pub proposal: Arc<Proposal<Types, DaProposal2<Types>>>,
}

/// [`ALLOW_EMPTY_BLOCK_PERIOD`] is a constant that is used to determine the
Expand Down
25 changes: 18 additions & 7 deletions crates/legacy/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use hotshot_builder_api::{
v0_2::builder::TransactionStatus,
};
use hotshot_types::{
data::{DaProposal, Leaf2, QuorumProposal2},
data::{DaProposal2, Leaf2, QuorumProposal2},
event::EventType,
message::Proposal,
traits::{
Expand Down Expand Up @@ -1287,7 +1287,7 @@ enum HandleDaEventError<Types: NodeType> {
/// still open.
async fn handle_da_event<Types: NodeType>(
da_channel_sender: &BroadcastSender<MessageType<Types>>,
da_proposal: Arc<Proposal<Types, DaProposal<Types>>>,
da_proposal: Arc<Proposal<Types, DaProposal2<Types>>>,
sender: <Types as NodeType>::SignatureKey,
) {
// We're explicitly not inspecting this error, as this function is not
Expand All @@ -1309,7 +1309,7 @@ async fn handle_da_event<Types: NodeType>(
/// This function is the implementation for [`handle_da_event`].
async fn handle_da_event_implementation<Types: NodeType>(
da_channel_sender: &BroadcastSender<MessageType<Types>>,
da_proposal: Arc<Proposal<Types, DaProposal<Types>>>,
da_proposal: Arc<Proposal<Types, DaProposal2<Types>>>,
sender: <Types as NodeType>::SignatureKey,
) -> Result<(), HandleDaEventError<Types>> {
tracing::debug!(
Expand Down Expand Up @@ -1642,13 +1642,15 @@ mod test {
node_types::{TestTypes, TestVersions},
state_types::{TestInstanceState, TestValidatedState},
};
use hotshot_types::data::DaProposal2;
use hotshot_types::data::EpochNumber;
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, ViewNumber},
data::{Leaf, ViewNumber},
message::Proposal,
simple_certificate::QuorumCertificate,
traits::{
Expand Down Expand Up @@ -4140,13 +4142,15 @@ mod test {
<BLSPubKey as BuilderSignatureKey>::generated_from_seed_indexed([0; 32], 1);
let (da_channel_sender, _) = async_broadcast::broadcast(10);
let view_number = ViewNumber::new(10);
let epoch = EpochNumber::new(1);

let da_proposal = DaProposal::<TestTypes> {
let da_proposal = DaProposal2::<TestTypes> {
encoded_transactions: Arc::new([1, 2, 3, 4, 5, 6]),
metadata: TestMetadata {
num_transactions: 1,
}, // arbitrary
view_number,
epoch,
};

let encoded_txns_hash = Sha256::digest(&da_proposal.encoded_transactions);
Expand Down Expand Up @@ -4196,13 +4200,15 @@ mod test {
};

let view_number = ViewNumber::new(10);
let epoch = EpochNumber::new(1);

let da_proposal = DaProposal::<TestTypes> {
let da_proposal = DaProposal2::<TestTypes> {
encoded_transactions: Arc::new([1, 2, 3, 4, 5, 6]),
metadata: TestMetadata {
num_transactions: 1,
}, // arbitrary
view_number,
epoch,
};

let encoded_txns_hash = Sha256::digest(&da_proposal.encoded_transactions);
Expand Down Expand Up @@ -4243,13 +4249,15 @@ mod test {
<BLSPubKey as BuilderSignatureKey>::generated_from_seed_indexed([0; 32], 0);
let (da_channel_sender, da_channel_receiver) = async_broadcast::broadcast(10);
let view_number = ViewNumber::new(10);
let epoch = EpochNumber::new(1);

let da_proposal = DaProposal::<TestTypes> {
let da_proposal = DaProposal2::<TestTypes> {
encoded_transactions: Arc::new([1, 2, 3, 4, 5, 6]),
metadata: TestMetadata {
num_transactions: 1,
}, // arbitrary
view_number,
epoch,
};

let encoded_txns_hash = Sha256::digest(&da_proposal.encoded_transactions);
Expand Down Expand Up @@ -4330,6 +4338,7 @@ mod test {
view_change_evidence: None,
drb_seed: INITIAL_DRB_SEED_INPUT,
drb_result: INITIAL_DRB_RESULT,
next_epoch_justify_qc: None,
}
};

Expand Down Expand Up @@ -4403,6 +4412,7 @@ mod test {
view_change_evidence: None,
drb_seed: INITIAL_DRB_SEED_INPUT,
drb_result: INITIAL_DRB_RESULT,
next_epoch_justify_qc: None,
}
};

Expand Down Expand Up @@ -4467,6 +4477,7 @@ mod test {
view_change_evidence: None,
drb_seed: INITIAL_DRB_SEED_INPUT,
drb_result: INITIAL_DRB_RESULT,
next_epoch_justify_qc: None,
}
};

Expand Down
11 changes: 8 additions & 3 deletions crates/legacy/src/testing/basic_test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub use hotshot::traits::election::static_committee::StaticCommittee;
pub use hotshot_types::{
data::{DaProposal, EpochNumber, Leaf, ViewNumber},
data::{EpochNumber, Leaf, ViewNumber},
message::Proposal,
signature_key::BLSPubKey,
simple_certificate::{QuorumCertificate, SimpleCertificate, SuccessThreshold},
Expand All @@ -23,7 +23,7 @@ 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::data::{DaProposal2, Leaf2, QuorumProposal2};
use hotshot_types::drb::{INITIAL_DRB_RESULT, INITIAL_DRB_SEED_INPUT};
use hotshot_types::simple_vote::QuorumData2;
use hotshot_types::{
Expand Down Expand Up @@ -93,6 +93,7 @@ mod tests {
type Membership = StaticCommittee<Self>;
type BuilderSignatureKey = BuilderKey;
type AuctionResult = TestAuctionResult;
const EPOCH_HEIGHT: u64 = 1000; // arbitrary
}
// no of test messages to send
let num_test_messages = 5;
Expand Down Expand Up @@ -192,6 +193,7 @@ mod tests {
view_change_evidence: None,
drb_seed: INITIAL_DRB_SEED_INPUT,
drb_result: INITIAL_DRB_RESULT,
next_epoch_justify_qc: None,
}
};

Expand Down Expand Up @@ -290,12 +292,13 @@ mod tests {

// Prepare the DA proposal message
let da_proposal_message = {
let da_proposal = DaProposal {
let da_proposal = DaProposal2 {
encoded_transactions: encoded_transactions.clone().into(),
metadata: TestMetadata {
num_transactions: encoded_transactions.len() as u64,
},
view_number: ViewNumber::new(round as u64),
epoch: EpochNumber::genesis(), // TODO: check if this is okay
};
let encoded_transactions_hash = Sha256::digest(&encoded_transactions);
let seed = [round as u8; 32];
Expand Down Expand Up @@ -363,6 +366,7 @@ mod tests {

let q_data = QuorumData2::<TestTypes> {
leaf_commit: leaf.commit(),
epoch: EpochNumber::genesis(), // TODO: check if this is okay
};

let previous_quorum_view_number =
Expand Down Expand Up @@ -394,6 +398,7 @@ mod tests {
view_change_evidence: None,
drb_seed: INITIAL_DRB_SEED_INPUT,
drb_result: INITIAL_DRB_RESULT,
next_epoch_justify_qc: None,
};

let payload_vid_commitment =
Expand Down
6 changes: 4 additions & 2 deletions crates/legacy/src/testing/finalization_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use hotshot_example_types::{
state_types::{TestInstanceState, TestValidatedState},
};
use hotshot_types::{
data::{DaProposal, QuorumProposal2, ViewNumber},
data::{DaProposal2, EpochNumber, QuorumProposal2, ViewNumber},
drb::{INITIAL_DRB_RESULT, INITIAL_DRB_SEED_INPUT},
message::Proposal,
simple_certificate::QuorumCertificate,
Expand Down Expand Up @@ -278,10 +278,11 @@ async fn progress_round_with_transactions(
da_proposal_sender
.broadcast(MessageType::DaProposalMessage(DaProposalMessage {
proposal: Arc::new(Proposal {
data: DaProposal::<TestTypes> {
data: DaProposal2::<TestTypes> {
encoded_transactions: encoded_transactions.clone().into(),
metadata,
view_number: next_view,
epoch: EpochNumber::genesis(), // TODO
},
signature: da_signature,
_pd: Default::default(),
Expand Down Expand Up @@ -330,6 +331,7 @@ async fn progress_round_with_transactions(
view_change_evidence: None,
drb_seed: INITIAL_DRB_SEED_INPUT,
drb_result: INITIAL_DRB_RESULT,
next_epoch_justify_qc: None, // TODO
};

let payload_vid_commitment =
Expand Down
7 changes: 5 additions & 2 deletions crates/legacy/src/testing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use hotshot::{
types::{BLSPubKey, SignatureKey},
};
use hotshot_types::{
data::{DaProposal, Leaf2, QuorumProposal2, ViewNumber},
data::{DaProposal2, EpochNumber, Leaf2, QuorumProposal2, ViewNumber},
drb::{INITIAL_DRB_RESULT, INITIAL_DRB_SEED_INPUT},
message::Proposal,
simple_certificate::{QuorumCertificate, SimpleCertificate, SuccessThreshold},
Expand Down Expand Up @@ -139,12 +139,13 @@ pub async fn calc_proposal_msg(

// Prepare the DA proposal message
let da_proposal_message: DaProposalMessage<TestTypes> = {
let da_proposal = DaProposal {
let da_proposal = DaProposal2 {
encoded_transactions: encoded_transactions.clone().into(),
metadata: TestMetadata {
num_transactions: encoded_transactions.len() as u64,
},
view_number: ViewNumber::new(round as u64),
epoch: EpochNumber::new(1),
};
let encoded_transactions_hash = Sha256::digest(&encoded_transactions);
let da_signature =
Expand Down Expand Up @@ -184,6 +185,7 @@ pub async fn calc_proposal_msg(
let prev_justify_qc = &prev_proposal.justify_qc;
let quorum_data = QuorumData2::<TestTypes> {
leaf_commit: Leaf2::from_quorum_proposal(prev_proposal).commit(),
epoch: EpochNumber::new(1),
};

// form a justify qc
Expand All @@ -207,6 +209,7 @@ pub async fn calc_proposal_msg(
view_change_evidence: None,
drb_seed: INITIAL_DRB_SEED_INPUT,
drb_result: INITIAL_DRB_RESULT,
next_epoch_justify_qc: None, // TODO
};

let quorum_signature =
Expand Down
1 change: 1 addition & 0 deletions crates/legacy_refactored/src/testing/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ async fn test_pruning() {
view_change_evidence: None,
drb_seed: INITIAL_DRB_SEED_INPUT,
drb_result: INITIAL_DRB_RESULT,
next_epoch_justify_qc: None, // TODO
});
event_stream_sender
.broadcast(hotshot::types::Event {
Expand Down
10 changes: 5 additions & 5 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, QuorumProposal2},
data::{DaProposal2, 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<QuorumProposal2<Types>, DaProposal<Types>>>;
HashMap<ProposalId<Types>, Either<QuorumProposal2<Types>, DaProposal2<Types>>>;

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

Expand Down Expand Up @@ -213,7 +213,7 @@ where
/// This function should be called whenever new DA 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_da_proposal(&self, da_proposal: DaProposal<Types>) {
pub async fn handle_da_proposal(&self, da_proposal: DaProposal2<Types>) {
let proposal_id = ProposalId::from_da_proposal(&da_proposal);
self.handle_proposal(proposal_id, Either::Right(da_proposal))
.await;
Expand All @@ -238,7 +238,7 @@ where
async fn handle_proposal(
&self,
proposal_id: ProposalId<Types>,
proposal: Either<QuorumProposal2<Types>, DaProposal<Types>>,
proposal: Either<QuorumProposal2<Types>, DaProposal2<Types>>,
) {
match self.proposals.lock().await.entry(proposal_id) {
Entry::Occupied(entry) => {
Expand Down Expand Up @@ -308,7 +308,7 @@ where
async fn spawn_builder_state(
&self,
quorum_proposal: QuorumProposal2<Types>,
da_proposal: DaProposal<Types>,
da_proposal: DaProposal2<Types>,
) {
assert_eq!(quorum_proposal.view_number, da_proposal.view_number);

Expand Down
4 changes: 2 additions & 2 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, Leaf2, QuorumProposal2},
data::{DaProposal2, Leaf2, QuorumProposal2},
traits::{block_contents::BlockHeader, node_implementation::NodeType},
};

Expand Down Expand Up @@ -143,7 +143,7 @@ where
pub(crate) async fn new_child(
self: Arc<Self>,
quorum_proposal: QuorumProposal2<Types>,
da_proposal: DaProposal<Types>,
da_proposal: DaProposal2<Types>,
) -> Arc<Self> {
let leaf = Leaf2::from_quorum_proposal(&quorum_proposal);

Expand Down
Loading

0 comments on commit 8b6361e

Please sign in to comment.