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

Commit

Permalink
some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
move47 committed Feb 13, 2024
1 parent 9ddc513 commit 33486f4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 38 deletions.
14 changes: 3 additions & 11 deletions src/builder_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ impl<TYPES: BuilderType> BuilderProgress<TYPES> for BuilderState<TYPES>{
}

/// processing the DA proposal
//#[tracing::instrument(skip_all, name = "Process DA Proposal", fields(builder_id=%self.built_from_view_vid_leaf.0.get_u64(), builder_commitments=%self.built_from_view_vid_leaf.1.clone()))]
#[tracing::instrument(skip_all, name = "process da proposal",
fields(builder_view=%self.built_from_view_vid_leaf.0.get_u64(),
builder_vid=%self.built_from_view_vid_leaf.1.clone(),
Expand All @@ -247,7 +246,7 @@ impl<TYPES: BuilderType> BuilderProgress<TYPES> for BuilderState<TYPES>{
// check for signature validation and correct leader (both of these are done in the service.rs i.e. before putting hotshot events onto the da channel)

// bootstrapping part
// if the view number is 0 then keep going, and don't return from it
// if the view number is 0 and no more clone is active then keep going, and don't return from it
if self.built_from_view_vid_leaf.0.get_u64() == 0 && self.tx_receiver.receiver_count() <=1{
tracing::info!("In bootstrapping phase");
}
Expand Down Expand Up @@ -313,7 +312,7 @@ impl<TYPES: BuilderType> BuilderProgress<TYPES> for BuilderState<TYPES>{
// can use this commitment to match the da proposal or vice-versa

// bootstrapping part
// if the view number is 0 then keep going, and don't return from it
// if the view number is 0 and no more clone is active then keep going, and don't return from it
if self.built_from_view_vid_leaf.0.get_u64() == 0 && self.tx_receiver.receiver_count() <=1{
tracing::info!("In bootstrapping phase");
}
Expand Down Expand Up @@ -543,11 +542,7 @@ impl<TYPES: BuilderType> BuilderProgress<TYPES> for BuilderState<TYPES>{
tracing::info!("Builder {:?} Sending response {:?} to the request{:?}", self.built_from_view_vid_leaf, response, req);
// send the response back
self.response_sender.send(response.clone()).await.unwrap();
//let inner = Arc::unwrap_or_clone(response.join_handle);
// generate signature over the block payload and metadata and sent it back

// again sign over the block hash

// write to global state as well
self.global_state.write_arc().await.block_hash_to_block.insert(response.block_hash, (response.block_payload, response.metadata, response.join_handle, response.signature, response.sender));
}
None => {
Expand Down Expand Up @@ -591,7 +586,6 @@ impl<TYPES: BuilderType> BuilderProgress<TYPES> for BuilderState<TYPES>{
}
},
tx = self.tx_receiver.next() => {
//println!("Received tx msg in builder {}: {:?} from index", self.builder_keys.0, tx);
match tx {
Some(tx) => {
if let MessageType::TransactionMessage(rtx_msg) = tx {
Expand All @@ -614,7 +608,6 @@ impl<TYPES: BuilderType> BuilderProgress<TYPES> for BuilderState<TYPES>{
Some(da) => {
if let MessageType::DAProposalMessage(rda_msg) = da {
tracing::debug!("Received da proposal msg in builder {:?}:\n {:?}", self.built_from_view_vid_leaf, rda_msg);
//tracing::debug!("Received da proposal msg in builder {:?}: {:?} from index", self.built_from_view_vid_leaf.0, rda_msg.proposal.data.view_number);
self.process_da_proposal(rda_msg);
}
}
Expand All @@ -624,7 +617,6 @@ impl<TYPES: BuilderType> BuilderProgress<TYPES> for BuilderState<TYPES>{
}
},
qc = self.qc_receiver.next() => {
//println!("Received qc msg in builder {}: {:?} from index", self.builder_keys.0, qc);
match qc {
Some(qc) => {
if let MessageType::QCMessage(rqc_msg) = qc {
Expand Down
31 changes: 4 additions & 27 deletions src/testing/basic_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ mod tests {
let mut sda_msgs: Vec<DAProposalMessage<TestTypes>> = Vec::new();
let mut sqc_msgs: Vec<QCMessage<TestTypes>> = Vec::new();
let mut sreq_msgs: Vec<MessageType<TestTypes>> = Vec::new();
// storing response messages
let mut rres_msgs: Vec<ResponseMessage<TestTypes>> = Vec::new();


Expand Down Expand Up @@ -168,22 +169,9 @@ mod tests {
0 => QuorumCertificate::<TestTypes>::genesis(),
_ => {
let previous_justify_qc = sqc_msgs[(i-1) as usize].proposal.data.justify_qc.clone();

// Construct a leaf

//let metadata = block_header.metadata();
// metadata
let _metadata = sqc_msgs[(i-1) as usize].proposal.data.block_header.metadata();

// let leaf: Leaf<_> = Leaf {
// view_number: sqc_msgs[(i-1) as usize].proposal.data.justify_qc.view_number.clone(),
// justify_qc: sqc_msgs[(i-1) as usize].proposal.data.justify_qc.clone(),
// parent_commitment: sqc_msgs[(i-1) as usize].proposal.data.justify_qc.get_data().leaf_commit,
// block_header: sqc_msgs[(i-1) as usize].proposal.data.block_header.clone(),
// // todo currently this is set to None in builder_state, see whether needs to make None here also
// block_payload: Some(BlockPayload::from_bytes(sda_msgs[(i-1) as usize].proposal.data.encoded_transactions.clone().into_iter(), metadata)),
// proposer_id: sqc_msgs[(i-1) as usize].proposal.data.proposer_id,
// };

// Construct a leaf
let leaf: Leaf<_> = Leaf {
view_number: sqc_msgs[(i-1) as usize].proposal.data.view_number.clone(),
justify_qc: sqc_msgs[(i-1) as usize].proposal.data.justify_qc.clone(),
Expand Down Expand Up @@ -217,7 +205,6 @@ mod tests {
};
tracing::debug!("Iteration: {} justify_qc: {:?}", i, justify_qc);

//<TestTypes as BuilderType>::SignatureKey::sign(private_key, encoded_txns_vid_commitment.as_ref()).unwrap(),
let qc_proposal = QuorumProposal::<TestTypes>{
//block_header: TestBlockHeader::genesis(&TestInstanceState {}).0,
block_header: block_header,
Expand All @@ -229,7 +216,6 @@ mod tests {

let payload_commitment = qc_proposal.block_header.payload_commitment();

// let leaf_commit = qc_proposal.justify_qc.data.commit();
let qc_signature = <TestTypes as hotshot_types::traits::node_implementation::NodeType>::SignatureKey::sign(
&private_key,
payload_commitment.as_ref(),
Expand Down Expand Up @@ -262,8 +248,6 @@ mod tests {
},
};



let sdecide_msg = DecideMessage::<TestTypes>{
leaf_chain: Arc::new(vec![leaf.clone()]),
qc: Arc::new(justify_qc),
Expand All @@ -277,12 +261,7 @@ mod tests {
da_sender.broadcast(MessageType::DAProposalMessage(sda_msg.clone())).await.unwrap();
qc_sender.broadcast(MessageType::QCMessage(sqc_msg.clone())).await.unwrap();

// add some delay before sending the decide messages so that builder_state can have some time to process da and qc messages
//task::sleep(std::time::Duration::from_secs(1)).await;
//decide_sender.broadcast(MessageType::DecideMessage(sdecide_msg.clone())).await.unwrap();

//TODO: sending request message onto channel also
// send the request message as well
// send decide and request messages later
let requested_vid_commitment = payload_commitment;
let request_message = MessageType::<TestTypes>::RequestMessage(RequestMessage{
requested_vid_commitment: requested_vid_commitment,
Expand Down Expand Up @@ -342,8 +321,6 @@ mod tests {
decide_sender.broadcast(MessageType::DecideMessage(decide_msg.clone())).await.unwrap();
}

//let responses:Vec<ResponseMessage<TestTypes>> = Vec::new();

while let Ok(res_msg) = global_state_clone.write_arc().await.response_receiver.try_recv(){
rres_msgs.push(res_msg);
// if rres_msgs.len() == (num_test_messages-1) as usize{
Expand Down

0 comments on commit 33486f4

Please sign in to comment.