Skip to content

Commit

Permalink
Clean debug traces
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszrzasik committed Dec 11, 2024
1 parent 447fce7 commit f1a21c0
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 53 deletions.
3 changes: 0 additions & 3 deletions crates/hotshot/src/tasks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ pub fn add_network_message_task<
let network = Arc::clone(channel);
let mut state = network_state.clone();
let shutdown_signal = create_shutdown_event_monitor(handle).fuse();
let my_id = handle.hotshot.id;
let task_handle = spawn(async move {
futures::pin_mut!(shutdown_signal);

Expand All @@ -158,7 +157,6 @@ pub fn add_network_message_task<
// Make sure the message did not fail
let message = match message {
Ok(message) => {
tracing::error!("lrzasik: Received message, my id: {:?}\nmessage: {:?}", my_id, message);
message
}
Err(e) => {
Expand Down Expand Up @@ -205,7 +203,6 @@ pub fn add_network_event_task<
consensus: OuterConsensus::new(handle.consensus()),
upgrade_lock: handle.hotshot.upgrade_lock.clone(),
transmit_tasks: BTreeMap::new(),
id: handle.hotshot.id,
};
let task = Task::new(
network_state,
Expand Down
5 changes: 0 additions & 5 deletions crates/task-impls/src/consensus/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,6 @@ pub(crate) async fn handle_quorum_vote_recv<
.membership
.has_stake(&vote.signing_key(), vote.epoch() + 1)
{
tracing::error!(
"lrzasik: received vote from next epoch node, view: {:?}, epoch: {:?}",
vote.view_number,
vote.epoch()
);
handle_vote(
&mut task_state.next_epoch_vote_collectors,
&vote.clone().into(),
Expand Down
47 changes: 5 additions & 42 deletions crates/task-impls/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ pub struct NetworkEventTaskState<
pub upgrade_lock: UpgradeLock<TYPES, V>,
/// map view number to transmit tasks
pub transmit_tasks: BTreeMap<TYPES::View, Vec<JoinHandle<()>>>,
pub id: u64,
}

#[async_trait]
Expand Down Expand Up @@ -303,14 +302,12 @@ impl<
let net = Arc::clone(&self.network);
let storage = Arc::clone(&self.storage);
let consensus = OuterConsensus::new(Arc::clone(&self.consensus.inner_consensus));
let my_id = self.id;
spawn(async move {
if NetworkEventTaskState::<TYPES, V, NET, S>::maybe_record_action(
Some(HotShotAction::VidDisperse),
storage,
consensus,
view,
my_id,
)
.await
.is_err()
Expand All @@ -332,36 +329,26 @@ impl<
storage: Arc<RwLock<S>>,
consensus: OuterConsensus<TYPES>,
view: <TYPES as NodeType>::View,
id: u64,
) -> std::result::Result<(), ()> {
tracing::error!("lrzasik: entered maybe_record_action, maybe_action: {:?}, view: {:?}, my id: {}", maybe_action, view, id);
let res = if let Some(mut action) = maybe_action {
tracing::error!("lrzasik: maybe_record_action, calling update_action, maybe_action: {:?}, view: {:?}, my id: {}", maybe_action, view, id);
if let Some(mut action) = maybe_action {
if !consensus.write().await.update_action(action, view) {
tracing::warn!("Already actioned {:?} in view {:?}", action, view);
return Err(());
}
tracing::error!("lrzasik: maybe_record_action, finished update_action, maybe_action: {:?}, view: {:?}, my id: {}", maybe_action, view, id);
// If the action was view sync record it as a vote, but we don't
// want to limit to 1 View sync vote above so change the action here.
if matches!(action, HotShotAction::ViewSyncVote) {
action = HotShotAction::Vote;
}
tracing::error!("lrzasik: maybe_record_action, calling record_action, maybe_action: {:?}, view: {:?}, my id: {}", maybe_action, view, id);
let res = match storage.write().await.record_action(view, action).await {
match storage.write().await.record_action(view, action).await {
Ok(()) => Ok(()),
Err(e) => {
tracing::warn!("Not Sending {:?} because of storage error: {:?}", action, e);
Err(())
}
};
tracing::error!("lrzasik: maybe_record_action, finished record_action, maybe_action: {:?}, view: {:?}, my id: {}", maybe_action, view, id);
res
}
} else {
Ok(())
};
tracing::error!("lrzasik: exiting maybe_record_action, maybe_action: {:?}, view: {:?}, my id: {}", maybe_action, view, id);
res
}
}

/// Cancel all tasks for previous views
Expand Down Expand Up @@ -456,7 +443,6 @@ impl<
.await
>= V::Epochs::VERSION
{
tracing::error!("lrzasik: extended quorum vote sent from network, id: {:?}", self.id);
MessageKind::<TYPES>::from_consensus_message(SequencingMessage::General(
GeneralConsensusMessage::Vote2(vote.clone()),
))
Expand Down Expand Up @@ -734,7 +720,6 @@ impl<
transmit: TransmitType<TYPES>,
sender: TYPES::SignatureKey,
) {
tracing::error!("lrzasik: entered spawn_transmit_task, message kind: {:?}, transmit type: {:?}, my id: {}", message_kind, transmit, self.id);
let broadcast_delay = match &message_kind {
MessageKind::Consensus(
SequencingMessage::General(GeneralConsensusMessage::Vote(_))
Expand All @@ -755,62 +740,40 @@ impl<
let storage = Arc::clone(&self.storage);
let consensus = OuterConsensus::new(Arc::clone(&self.consensus.inner_consensus));
let upgrade_lock = self.upgrade_lock.clone();
let my_id = self.id;
let handle = spawn(async move {
tracing::error!("lrzasik: entered spawn transmit task, message kind: {:?}, transmit type: {:?}, my id: {}", message.kind, transmit, my_id);
if NetworkEventTaskState::<TYPES, V, NET, S>::maybe_record_action(
maybe_action,
Arc::clone(&storage),
consensus,
view_number,
my_id,
)
.await
.is_err()
{
tracing::error!("lrzasik: spawn transmit task, error maybe_record_action, my id: {}", my_id);
return;
}
tracing::error!("lrzasik: spawn transmit task, finished maybe_record_action, message kind: {:?}, transmit type: {:?}, my id: {}", message.kind, transmit, my_id);
if let MessageKind::Consensus(SequencingMessage::General(
GeneralConsensusMessage::Proposal(prop),
)) = &message.kind
{
tracing::error!("lrzasik: spawn transmit task, call append_proposal2, message kind: {:?}, transmit type: {:?}, my id: {}", message.kind, transmit, my_id);
if storage
.write()
.await
.append_proposal2(&convert_proposal(prop.clone()))
.await
.is_err()
{
tracing::error!("lrzasik: spawn transmit task, error append_proposal2, my id: {}", my_id);
return;
}
tracing::error!("lrzasik: spawn transmit task, finished append_proposal2, message kind: {:?}, transmit type: {:?}, my id: {}", message.kind, transmit, my_id);
}

tracing::error!("lrzasik: spawn transmit task, call serialize, message kind: {:?}, transmit type: {:?}, my id: {}", message.kind, transmit, my_id);
let serialized_message = match upgrade_lock.serialize(&message).await {
Ok(serialized) => {
if matches!(transmit, TransmitType::Broadcast) {
if let MessageKind::Consensus(SequencingMessage::General(GeneralConsensusMessage::Vote2(ref vote))) = message.kind {
tracing::error!("lrzasik: sending extended vote, my id: {:?}, vote view: {:?}, vote epoch: {:?}\nserialized message: {:?}",
my_id,
vote.view_number(),
vote.epoch(),
serialized,
);
}
}
serialized
},
Ok(serialized) => serialized,
Err(e) => {
tracing::error!("Failed to serialize message: {}", e);
return;
}
};
tracing::error!("lrzasik: spawn transmit task, finished serialize, message kind: {:?}, transmit type: {:?}, my id: {}", message.kind, transmit, my_id);

let transmit_result = match transmit {
TransmitType::Direct(recipient) => {
Expand Down
1 change: 0 additions & 1 deletion crates/testing/src/byzantine/byzantine_behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES> + std::fmt::Debug, V: Version
consensus: OuterConsensus::new(handle.consensus()),
upgrade_lock: handle.hotshot.upgrade_lock.clone(),
transmit_tasks: BTreeMap::new(),
id: handle.hotshot.id,
};
let modified_network_state = NetworkEventTaskStateModifier {
network_event_task_state: network_state,
Expand Down
2 changes: 0 additions & 2 deletions crates/testing/tests/tests_1/network_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ async fn test_network_task() {
storage,
consensus,
transmit_tasks: BTreeMap::new(),
id: 1,
};
let (tx, rx) = async_broadcast::broadcast(10);
let mut task_reg = ConsensusTaskRegistry::new();
Expand Down Expand Up @@ -239,7 +238,6 @@ async fn test_network_storage_fail() {
storage,
consensus,
transmit_tasks: BTreeMap::new(),
id: 1,
};
let (tx, rx) = async_broadcast::broadcast(10);
let mut task_reg = ConsensusTaskRegistry::new();
Expand Down

0 comments on commit f1a21c0

Please sign in to comment.