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

Commit

Permalink
remove instance state (#107)
Browse files Browse the repository at this point in the history
* enable batch processing

* cargo fmt

* remove instance state and typos

* remove dup hash
  • Loading branch information
move47 authored Apr 26, 2024
1 parent dc5e356 commit a972a2c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 23 deletions.
5 changes: 2 additions & 3 deletions src/builder_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ impl<TYPES: NodeType> BuilderProgress<TYPES> for BuilderState<TYPES> {
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)
Expand Down Expand Up @@ -310,8 +309,8 @@ impl<TYPES: NodeType> BuilderProgress<TYPES> for BuilderState<TYPES> {
{
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
Expand Down
24 changes: 5 additions & 19 deletions src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub struct GlobalState<Types: NodeType> {
pub spawned_builder_states: HashMap<VidCommitment, Types::Time>,

// 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<VidCommitment, ResponseMessage>,

// scheduled GC by view number
Expand All @@ -90,9 +90,6 @@ pub struct GlobalState<Types: NodeType> {
// NOTE: Currently, we don't differentiate between the transactions from the hotshot and the private mempool
pub tx_sender: BroadcastSender<MessageType<Types>>,

// Instance state
pub instance_state: Types::InstanceState,

// last garbage collected view number
pub last_garbage_collected_view_num: Types::Time,

Expand All @@ -106,7 +103,6 @@ impl<Types: NodeType> GlobalState<Types> {
request_sender: BroadcastSender<MessageType<Types>>,
response_receiver: UnboundedReceiver<ResponseMessage>,
tx_sender: BroadcastSender<MessageType<Types>>,
instance_state: Types::InstanceState,
bootstrapped_builder_state_id: VidCommitment,
bootstrapped_view_num: Types::Time,
last_garbage_collected_view_num: Types::Time,
Expand All @@ -121,7 +117,6 @@ impl<Types: NodeType> GlobalState<Types> {
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(),
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -726,9 +717,6 @@ pub async fn run_permissioned_standalone_builder_service<

// hotshot context handle
hotshot_handle: SystemContextHandle<Types, I>,

// pass the instance state
instance_state: Types::InstanceState,
) {
let mut event_stream = hotshot_handle.get_event_stream();
loop {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -825,7 +812,6 @@ async fn handle_qc_event<Types: NodeType>(
qc_proposal: Proposal<Types, QuorumProposal<Types>>,
sender: <Types as NodeType>::SignatureKey,
leader: <Types as NodeType>::SignatureKey,
_instance_state: &Types::InstanceState,
) {
tracing::debug!(
"QCProposal: Leader: {:?} for the view: {:?}",
Expand Down
1 change: 0 additions & 1 deletion src/testing/basic_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ mod tests {
req_sender,
res_receiver,
tx_sender.clone(),
TestInstanceState {},
vid_commitment(&[], 8),
ViewNumber::new(0),
ViewNumber::new(0),
Expand Down

0 comments on commit a972a2c

Please sign in to comment.