Skip to content

Commit

Permalink
make env and log fix (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
move47 authored Apr 23, 2024
1 parent 8dc46a8 commit fbe3880
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
18 changes: 11 additions & 7 deletions src/builder_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ use std::sync::Arc;
use std::time::SystemTime;
use std::{cmp::PartialEq, num::NonZeroUsize};

const BUFFER_VIEW_NUM: usize = 10;

pub type TxTimeStamp = u128;

/// Enum to hold the different sources of the transaction
Expand Down Expand Up @@ -172,6 +170,9 @@ pub struct BuilderState<TYPES: NodeType> {

/// last bootstrap garbage collected decided seen view_num
pub last_bootstrap_garbage_collected_decided_seen_view_num: TYPES::Time,

/// number of view to buffer before garbage collect
pub buffer_view_num_count: usize,
}

/// Trait to hold the helper functions for the builder
Expand Down Expand Up @@ -490,7 +491,7 @@ impl<TYPES: NodeType> BuilderProgress<TYPES> for BuilderState<TYPES> {
.get_u64() as i64;

if (latest_leaf_view_number_as_i64 - last_bootstrap_garbage_collected_as_i64)
>= 2 * BUFFER_VIEW_NUM as i64
>= 2 * self.buffer_view_num_count as i64
{
tracing::info!(
"Bootstrapped builder state garbage collected for view number {:?}",
Expand All @@ -501,7 +502,7 @@ impl<TYPES: NodeType> BuilderProgress<TYPES> for BuilderState<TYPES> {
<<TYPES as NodeType>::Time as ConsensusTime>::new(
self.last_bootstrap_garbage_collected_decided_seen_view_num
.get_u64()
+ BUFFER_VIEW_NUM as u64,
+ self.buffer_view_num_count as u64,
);

// split_off returns greater than equal to set, so we want everything after the latest decide event
Expand Down Expand Up @@ -550,7 +551,7 @@ impl<TYPES: NodeType> BuilderProgress<TYPES> for BuilderState<TYPES> {
//return Some(Status::ShouldContinue);
}
} else if built_from_view_as_i64
<= (latest_leaf_view_number_as_i64 - BUFFER_VIEW_NUM as i64)
<= (latest_leaf_view_number_as_i64 - self.buffer_view_num_count as i64)
{
tracing::info!("Task view is less than or equal to the currently decided leaf view {:?}; exiting builder state for view {:?}", latest_leaf_view_number.get_u64(), self.built_from_proposed_block.view_number.get_u64());
// convert leaf commitments into buildercommiments
Expand All @@ -564,7 +565,8 @@ impl<TYPES: NodeType> BuilderProgress<TYPES> for BuilderState<TYPES> {

// clear out the local_block_hash_to_block
return Some(Status::ShouldExit);
} else if built_from_view_as_i64 > (latest_leaf_view_number_as_i64 - BUFFER_VIEW_NUM as i64)
} else if built_from_view_as_i64
> (latest_leaf_view_number_as_i64 - self.buffer_view_num_count as i64)
{
return Some(Status::ShouldContinue);
}
Expand Down Expand Up @@ -747,7 +749,7 @@ impl<TYPES: NodeType> BuilderProgress<TYPES> for BuilderState<TYPES> {
.contains_key(&requested_vid_commitment)))
{
tracing::info!(
"REQUEST HANDLED BY BUILDER WITH VIEW {:?}",
"Request handled by builder with view {:?}",
self.built_from_proposed_block.view_number
);
let response = self.build_block(requested_vid_commitment).await;
Expand Down Expand Up @@ -939,6 +941,7 @@ impl<TYPES: NodeType> BuilderState<TYPES> {
response_sender: UnboundedSender<ResponseMessage>,
num_nodes: NonZeroUsize,
bootstrap_view_number: TYPES::Time,
buffer_view_num_count: usize,
) -> Self {
BuilderState {
timestamp_to_tx: BTreeMap::new(),
Expand All @@ -959,6 +962,7 @@ impl<TYPES: NodeType> BuilderState<TYPES> {
bootstrap_view_number,
spawned_clones_views_list: Arc::new(RwLock::new(BTreeSet::new())),
last_bootstrap_garbage_collected_decided_seen_view_num: bootstrap_view_number,
buffer_view_num_count,
}
}
}
13 changes: 5 additions & 8 deletions src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ where
_phantom: Default::default(),
};
tracing::info!(
"sending Initial block info response for parent {:?} with block hash {:?}",
"Sending Available Block info response for parent {:?} with block hash {:?}",
req_msg.requested_vid_commitment,
response.builder_hash
);
Expand All @@ -281,15 +281,15 @@ where

// We failed to get available blocks
Ok(Err(err)) => {
tracing::error!(%err, "Couldn't get available blocks in time");
tracing::error!(%err, "Couldn't get available blocks in time for parent {:?}", req_msg.requested_vid_commitment);
Err(BuildError::Error {
message: "No blocks available".to_string(),
})
}

// We timed out while getting available blocks
Err(err) => {
tracing::error!(%err, "Time out while getting available blocks in time");
tracing::error!(%err, "Time out while getting available blocks for parent {:?} in time", req_msg.requested_vid_commitment);
Err(BuildError::Error {
message: "No blocks available".to_string(),
})
Expand Down Expand Up @@ -336,10 +336,7 @@ where
signature: signature_over_builder_commitment,
sender: pub_key.clone(),
};
tracing::info!(
"Sending claimed block data for block hash: {:?}",
block_hash
);
tracing::info!("Sending Claim Block data for block hash: {:?}", block_hash);
Ok(block_data)
} else {
tracing::error!("Claim Block not found");
Expand Down Expand Up @@ -398,7 +395,7 @@ where
sender: pub_key.clone(),
};
tracing::info!(
"Sending claimed block header input response for block hash: {:?}",
"Sending Claim Block Header Input response for block hash: {:?}",
block_hash
);
Ok(response)
Expand Down
1 change: 1 addition & 0 deletions src/testing/basic_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ mod tests {
res_sender,
NonZeroUsize::new(TEST_NUM_NODES_IN_VID_COMPUTATION).unwrap(),
ViewNumber::new(0),
10,
);

//builder_state.event_loop().await;
Expand Down

0 comments on commit fbe3880

Please sign in to comment.