From a972a2cb35f534ab4484caaa721fb47e2a90b387 Mon Sep 17 00:00:00 2001 From: Himanshu Goyal Date: Fri, 26 Apr 2024 15:13:36 -0400 Subject: [PATCH] remove instance state (#107) * enable batch processing * cargo fmt * remove instance state and typos * remove dup hash --- src/builder_state.rs | 5 ++--- src/service.rs | 24 +++++------------------- src/testing/basic_test.rs | 1 - 3 files changed, 7 insertions(+), 23 deletions(-) diff --git a/src/builder_state.rs b/src/builder_state.rs index 1a189cef..8dce6921 100644 --- a/src/builder_state.rs +++ b/src/builder_state.rs @@ -261,7 +261,6 @@ impl BuilderProgress for BuilderState { txns.iter().for_each(|tx| { let tx_hash = tx.commit(); tracing::debug!("Transaction hash: {:?}", tx_hash); - let tx_hash = tx.commit(); // HOTSHOT MEMPOOL TRANSACTION PROCESSING // If it already exists, then discard it. Decide the existence based on the tx_hash_tx and check in both the local pool and already included txns if self.tx_hash_to_available_txns.contains_key(&tx_hash) @@ -310,8 +309,8 @@ impl BuilderProgress for BuilderState { { tracing::info!("DA Proposal handled by bootstrapped builder state"); - // if we are bootstraping and we spwan a clone, we can assume in the healty version of we can just zero out - // da_proposal to filter out the bootstraping state and zero out the case + // if we are bootstrapping and we spawn a clone, we can assume in the healthy version of we can just zero out + // da_proposal to filter out the bootstrapping state and zero out the case handled_by_bootstrap = true; } // Do the validation check diff --git a/src/service.rs b/src/service.rs index 0d64ef91..39a39552 100644 --- a/src/service.rs +++ b/src/service.rs @@ -73,7 +73,7 @@ pub struct GlobalState { pub spawned_builder_states: HashMap, // builder state -> last built block , it is used to respond the client - // if the req channel times out during get_avaialble_blocks + // if the req channel times out during get_available_blocks pub builder_state_to_last_built_block: HashMap, // scheduled GC by view number @@ -90,9 +90,6 @@ pub struct GlobalState { // NOTE: Currently, we don't differentiate between the transactions from the hotshot and the private mempool pub tx_sender: BroadcastSender>, - // Instance state - pub instance_state: Types::InstanceState, - // last garbage collected view number pub last_garbage_collected_view_num: Types::Time, @@ -106,7 +103,6 @@ impl GlobalState { request_sender: BroadcastSender>, response_receiver: UnboundedReceiver, tx_sender: BroadcastSender>, - instance_state: Types::InstanceState, bootstrapped_builder_state_id: VidCommitment, bootstrapped_view_num: Types::Time, last_garbage_collected_view_num: Types::Time, @@ -121,7 +117,6 @@ impl GlobalState { request_sender, response_receiver, tx_sender, - instance_state, last_garbage_collected_view_num, buffer_view_num_count, builder_state_to_last_built_block: Default::default(), @@ -293,8 +288,8 @@ where let mut bootstrapped_state_build_block = false; - // check in the local spawned builder states, if it doesn't exist it means it cound be two cases - // it has been sent to garbed collected, or never exists, in this let bootstrapped build a block for it + // check in the local spawned builder states, if it doesn't exist it means there could be two cases + // it has been sent to garbed collected, or never exists, in later case let bootstrapped build a block for it let just_return_with_this = { let global_state = self.global_state.read_arc().await; if !global_state.spawned_builder_states.contains_key(for_parent) { @@ -599,9 +594,6 @@ pub async fn run_non_permissioned_standalone_builder_service< EventStreamError, vbs::version::StaticVersion<0, 1>, >, - - // instance state - instance_state: Types::InstanceState, ) { // handle the startup event at the start let membership = if let Some(Ok(event)) = subscribed_events.next().await { @@ -690,8 +682,7 @@ pub async fn run_non_permissioned_standalone_builder_service< BuilderEventType::HotshotQuorumProposal { proposal, sender } => { // get the leader for current view let leader = membership.get_leader(proposal.data.view_number); - handle_qc_event(&qc_sender, proposal, sender, leader, &instance_state) - .await; + handle_qc_event(&qc_sender, proposal, sender, leader).await; } _ => { tracing::error!("Unhandled event from Builder"); @@ -726,9 +717,6 @@ pub async fn run_permissioned_standalone_builder_service< // hotshot context handle hotshot_handle: SystemContextHandle, - - // pass the instance state - instance_state: Types::InstanceState, ) { let mut event_stream = hotshot_handle.get_event_stream(); loop { @@ -770,8 +758,7 @@ pub async fn run_permissioned_standalone_builder_service< EventType::QuorumProposal { proposal, sender } => { // get the leader for current view let leader = hotshot_handle.get_leader(proposal.data.view_number).await; - handle_qc_event(&qc_sender, proposal, sender, leader, &instance_state) - .await; + handle_qc_event(&qc_sender, proposal, sender, leader).await; } _ => { tracing::error!("Unhandled event from Builder: {:?}", event.event); @@ -825,7 +812,6 @@ async fn handle_qc_event( qc_proposal: Proposal>, sender: ::SignatureKey, leader: ::SignatureKey, - _instance_state: &Types::InstanceState, ) { tracing::debug!( "QCProposal: Leader: {:?} for the view: {:?}", diff --git a/src/testing/basic_test.rs b/src/testing/basic_test.rs index ae34d618..190acc90 100644 --- a/src/testing/basic_test.rs +++ b/src/testing/basic_test.rs @@ -110,7 +110,6 @@ mod tests { req_sender, res_receiver, tx_sender.clone(), - TestInstanceState {}, vid_commitment(&[], 8), ViewNumber::new(0), ViewNumber::new(0),