Skip to content
This repository has been archived by the owner on Dec 3, 2024. It is now read-only.

Update HotShot #136

Merged
merged 1 commit into from
May 15, 2024
Merged
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
22 changes: 11 additions & 11 deletions Cargo.lock

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

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hotshot-builder-core"
version = "0.1.20"
version = "0.1.21"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -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.53" }
hotshot-builder-api = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.53" }
hotshot-events-service = { git = "https://github.com/EspressoSystems/hotshot-events-service.git", tag = "0.1.21" }
hotshot-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.53" }
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" }
serde = { version = "1.0", features = ["derive"] }
sha2 = "0.10"
snafu = "0.8"
Expand All @@ -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.53" }
hotshot-example-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.54" }
22 changes: 11 additions & 11 deletions src/builder_state.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use hotshot_types::{
data::{DAProposal, Leaf, QuorumProposal},
data::{DaProposal, Leaf, QuorumProposal},
message::Proposal,
traits::block_contents::{BlockHeader, BlockPayload},
traits::{
Expand Down Expand Up @@ -56,8 +56,8 @@ 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: Proposal<TYPES, DAProposal<TYPES>>,
pub struct DaProposalMessage<TYPES: NodeType> {
pub proposal: Proposal<TYPES, DaProposal<TYPES>>,
pub sender: TYPES::SignatureKey,
pub total_nodes: usize,
}
Expand Down Expand Up @@ -130,7 +130,7 @@ pub struct BuilderState<TYPES: NodeType> {

/// da_proposal_payload_commit to (da_proposal, node_count)
pub da_proposal_payload_commit_to_da_proposal:
HashMap<BuilderCommitment, (DAProposal<TYPES>, usize)>,
HashMap<BuilderCommitment, (DaProposal<TYPES>, usize)>,

/// quorum_proposal_payload_commit to quorum_proposal
pub quorum_proposal_payload_commit_to_quorum_proposal:
Expand Down Expand Up @@ -193,7 +193,7 @@ pub trait BuilderProgress<TYPES: NodeType> {
fn process_hotshot_transaction(&mut self, tx: Vec<TYPES::Transaction>);

/// process the DA proposal
async fn process_da_proposal(&mut self, da_msg: DAProposalMessage<TYPES>);
async fn process_da_proposal(&mut self, da_msg: DaProposalMessage<TYPES>);

/// process the quorum proposal
async fn process_quorum_proposal(&mut self, qc_msg: QCMessage<TYPES>);
Expand All @@ -204,7 +204,7 @@ pub trait BuilderProgress<TYPES: NodeType> {
/// spawn a clone of builder
async fn spawn_clone(
self,
da_proposal: DAProposal<TYPES>,
da_proposal: DaProposal<TYPES>,
quorum_proposal: QuorumProposal<TYPES>,
leader: TYPES::SignatureKey,
num_nodes: usize,
Expand Down Expand Up @@ -288,7 +288,7 @@ impl<TYPES: NodeType> BuilderProgress<TYPES> for BuilderState<TYPES> {
/// processing the DA proposal
#[tracing::instrument(skip_all, name = "process da proposal",
fields(builder_built_from_proposed_block = %self.built_from_proposed_block))]
async fn process_da_proposal(&mut self, da_msg: DAProposalMessage<TYPES>) {
async fn process_da_proposal(&mut self, da_msg: DaProposalMessage<TYPES>) {
tracing::debug!(
"Builder Received DA message for view {:?}",
da_msg.proposal.data.view_number
Expand Down Expand Up @@ -354,7 +354,7 @@ impl<TYPES: NodeType> BuilderProgress<TYPES> for BuilderState<TYPES> {
.da_proposal_payload_commit_to_da_proposal
.entry(payload_builder_commitment.clone())
{
let da_proposal_data = DAProposal {
let da_proposal_data = DaProposal {
encoded_transactions: encoded_txns.clone(),
metadata: metadata.clone(),
view_number,
Expand Down Expand Up @@ -598,7 +598,7 @@ impl<TYPES: NodeType> BuilderProgress<TYPES> for BuilderState<TYPES> {
fields(builder_built_from_proposed_block = %self.built_from_proposed_block))]
async fn spawn_clone(
mut self,
da_proposal: DAProposal<TYPES>,
da_proposal: DaProposal<TYPES>,
quorum_proposal: QuorumProposal<TYPES>,
_leader: TYPES::SignatureKey,
total_nodes: usize,
Expand Down Expand Up @@ -888,7 +888,7 @@ impl<TYPES: NodeType> BuilderProgress<TYPES> for BuilderState<TYPES> {
da = self.da_proposal_receiver.next() => {
match da {
Some(da) => {
if let MessageType::DAProposalMessage(rda_msg) = da {
if let MessageType::DaProposalMessage(rda_msg) = da {
tracing::debug!("Received da proposal msg in builder {:?}:\n {:?}", self.built_from_proposed_block, rda_msg.proposal.data.view_number);
self.process_da_proposal(rda_msg).await;
}
Expand Down Expand Up @@ -948,7 +948,7 @@ impl<TYPES: NodeType> BuilderProgress<TYPES> for BuilderState<TYPES> {
pub enum MessageType<TYPES: NodeType> {
TransactionMessage(TransactionMessage<TYPES>),
DecideMessage(DecideMessage<TYPES>),
DAProposalMessage(DAProposalMessage<TYPES>),
DaProposalMessage(DaProposalMessage<TYPES>),
QCMessage(QCMessage<TYPES>),
RequestMessage(RequestMessage),
}
Expand Down
18 changes: 9 additions & 9 deletions src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use hotshot_builder_api::{
};
use hotshot_types::{
constants::Version01,
data::{DAProposal, Leaf, QuorumProposal},
data::{DaProposal, Leaf, QuorumProposal},
event::EventType,
message::Proposal,
traits::{
Expand All @@ -24,7 +24,7 @@ use hotshot_types::{
};

use crate::builder_state::{
BuildBlockInfo, DAProposalMessage, DecideMessage, QCMessage, TransactionMessage,
BuildBlockInfo, DaProposalMessage, DecideMessage, QCMessage, TransactionMessage,
TransactionSource,
};
use crate::builder_state::{MessageType, RequestMessage, ResponseMessage};
Expand Down Expand Up @@ -779,7 +779,7 @@ pub async fn run_non_permissioned_standalone_builder_service<Types: NodeType>(
.await;
}
// DA proposal event
BuilderEventType::HotshotDAProposal { proposal, sender } => {
BuilderEventType::HotshotDaProposal { proposal, sender } => {
// get the leader for current view
let leader = membership.get_leader(proposal.data.view_number);
// get the committee mstatked node count
Expand Down Expand Up @@ -872,7 +872,7 @@ pub async fn run_permissioned_standalone_builder_service<
.await;
}
// DA proposal event
EventType::DAProposal { proposal, sender } => {
EventType::DaProposal { proposal, sender } => {
// get the leader for current view
let leader = hotshot_handle.get_leader(proposal.data.view_number).await;
// get the committee staked node count
Expand Down Expand Up @@ -900,13 +900,13 @@ Utility functions to handle the hotshot events
*/
async fn handle_da_event<Types: NodeType>(
da_channel_sender: &BroadcastSender<MessageType<Types>>,
da_proposal: Proposal<Types, DAProposal<Types>>,
da_proposal: Proposal<Types, DaProposal<Types>>,
sender: <Types as NodeType>::SignatureKey,
leader: <Types as NodeType>::SignatureKey,
total_nodes: NonZeroUsize,
) {
tracing::debug!(
"DAProposal: Leader: {:?} for the view: {:?}",
"DaProposal: Leader: {:?} for the view: {:?}",
leader,
da_proposal.data.view_number
);
Expand All @@ -915,7 +915,7 @@ async fn handle_da_event<Types: NodeType>(
let encoded_txns_hash = Sha256::digest(&da_proposal.data.encoded_transactions);
// check if the sender is the leader and the signature is valid; if yes, broadcast the DA proposal
if leader == sender && sender.validate(&da_proposal.signature, &encoded_txns_hash) {
let da_msg = DAProposalMessage::<Types> {
let da_msg = DaProposalMessage::<Types> {
proposal: da_proposal,
sender: leader,
total_nodes: total_nodes.into(),
Expand All @@ -926,7 +926,7 @@ async fn handle_da_event<Types: NodeType>(
view_number
);
if let Err(e) = da_channel_sender
.broadcast(MessageType::DAProposalMessage(da_msg))
.broadcast(MessageType::DaProposalMessage(da_msg))
.await
{
tracing::warn!(
Expand All @@ -935,7 +935,7 @@ async fn handle_da_event<Types: NodeType>(
);
}
} else {
tracing::error!("Validation Failure on DAProposal for view {:?}: Leader for the current view: {:?} and sender: {:?}", da_proposal.data.view_number, leader, sender);
tracing::error!("Validation Failure on DaProposal for view {:?}: Leader for the current view: {:?} and sender: {:?}", da_proposal.data.view_number, leader, sender);
}
}

Expand Down
12 changes: 6 additions & 6 deletions 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::GeneralStaticCommittee;
pub use hotshot_types::{
data::{DAProposal, Leaf, QuorumProposal, ViewNumber},
data::{DaProposal, Leaf, QuorumProposal, ViewNumber},
message::Proposal,
signature_key::{BLSPrivKey, BLSPubKey},
simple_certificate::{QuorumCertificate, SimpleCertificate, SuccessThreshold},
Expand Down Expand Up @@ -37,7 +37,7 @@ mod tests {
};

use crate::builder_state::{
BuiltFromProposedBlock, DAProposalMessage, DecideMessage, QCMessage, RequestMessage,
BuiltFromProposedBlock, DaProposalMessage, DecideMessage, QCMessage, RequestMessage,
TransactionMessage, TransactionSource,
};
use crate::service::GlobalState;
Expand Down Expand Up @@ -115,7 +115,7 @@ mod tests {
// to store all the sent messages
let mut stx_msgs: Vec<TransactionMessage<TestTypes>> = Vec::new();
let mut sdecide_msgs: Vec<DecideMessage<TestTypes>> = Vec::new();
let mut sda_msgs: Vec<DAProposalMessage<TestTypes>> = Vec::new();
let mut sda_msgs: Vec<DaProposalMessage<TestTypes>> = Vec::new();
let mut sqc_msgs: Vec<QCMessage<TestTypes>> = Vec::new();
#[allow(clippy::type_complexity)]
let mut sreq_msgs: Vec<(
Expand All @@ -139,7 +139,7 @@ mod tests {
};

// Prepare the DA proposal message
let da_proposal = DAProposal {
let da_proposal = DaProposal {
encoded_transactions: encoded_transactions.clone().into(),
metadata: TestMetadata,
view_number: ViewNumber::new(i as u64),
Expand All @@ -154,7 +154,7 @@ mod tests {
)
.expect("Failed to sign encoded tx hash while preparing da proposal");

let sda_msg = DAProposalMessage::<TestTypes> {
let sda_msg = DaProposalMessage::<TestTypes> {
proposal: Proposal {
data: da_proposal,
signature: da_signature.clone(),
Expand Down Expand Up @@ -298,7 +298,7 @@ mod tests {
.await
.unwrap();
da_sender
.broadcast(MessageType::DAProposalMessage(sda_msg.clone()))
.broadcast(MessageType::DaProposalMessage(sda_msg.clone()))
.await
.unwrap();
qc_sender
Expand Down
Loading