From fd99d0bf435ac6db7c135ec00252186b932fbdfd Mon Sep 17 00:00:00 2001 From: refcell Date: Thu, 24 Oct 2024 10:33:43 -0400 Subject: [PATCH] chore: cleanup logging --- bin/hera/src/gossip.rs | 2 +- bin/hera/src/main.rs | 2 +- crates/net/src/driver.rs | 8 +++----- crates/net/src/gossip/handler.rs | 17 +++-------------- 4 files changed, 8 insertions(+), 21 deletions(-) diff --git a/bin/hera/src/gossip.rs b/bin/hera/src/gossip.rs index ceb1c30..424114e 100644 --- a/bin/hera/src/gossip.rs +++ b/bin/hera/src/gossip.rs @@ -22,7 +22,7 @@ pub struct GossipCommand { impl GossipCommand { /// Run the discovery subcommand. pub async fn run(self, args: &GlobalArgs) -> Result<()> { - let signer = ROLLUP_CONFIGS + let signer = ROLLUP_CONFIGS .get(&args.l2_chain_id) .ok_or(eyre::eyre!("No rollup config found for chain ID"))? .genesis diff --git a/bin/hera/src/main.rs b/bin/hera/src/main.rs index 65dc574..0ae1f51 100644 --- a/bin/hera/src/main.rs +++ b/bin/hera/src/main.rs @@ -8,8 +8,8 @@ use clap::{Parser, Subcommand}; use eyre::Result; -mod globals; mod disc; +mod globals; mod gossip; mod node; diff --git a/crates/net/src/driver.rs b/crates/net/src/driver.rs index 0f1bc78..efd26fb 100644 --- a/crates/net/src/driver.rs +++ b/crates/net/src/driver.rs @@ -53,13 +53,11 @@ impl NetworkDriver { loop { select! { peer = peer_recv.recv() => { - tracing::info!("Received peer from discovery: {:?}", peer); - tracing::info!("Dialing peer: {:?}", peer); - self.gossip.dial_opt(peer).await; - tracing::info!("Connected peers: {:?}", self.gossip.connected_peers()); + self.gossip.dial_opt(peer.clone()).await; + tracing::info!("Received peer: {:?} | Connected peers: {:?}", peer, self.gossip.connected_peers()); }, event = self.gossip.select_next_some() => { - tracing::info!("Received event: {:?}", event); + tracing::debug!("Received event: {:?}", event); self.gossip.handle_event(event); }, } diff --git a/crates/net/src/gossip/handler.rs b/crates/net/src/gossip/handler.rs index 681f3d1..60e80b8 100644 --- a/crates/net/src/gossip/handler.rs +++ b/crates/net/src/gossip/handler.rs @@ -49,13 +49,13 @@ impl Handler for BlockHandler { tracing::debug!("received block"); let decoded = if msg.topic == self.blocks_v1_topic.hash() { - tracing::info!("received v1 block"); + tracing::debug!("received v1 block"); OpNetworkPayloadEnvelope::decode_v1(&msg.data) } else if msg.topic == self.blocks_v2_topic.hash() { - tracing::info!("received v2 block"); + tracing::debug!("received v2 block"); OpNetworkPayloadEnvelope::decode_v2(&msg.data) } else if msg.topic == self.blocks_v3_topic.hash() { - tracing::info!("received v3 block"); + tracing::debug!("received v3 block"); OpNetworkPayloadEnvelope::decode_v3(&msg.data) } else { return MessageAcceptance::Reject; @@ -111,30 +111,19 @@ impl BlockHandler { fn block_valid(&self, envelope: &OpNetworkPayloadEnvelope) -> bool { let current_timestamp = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_secs(); - println!("current_timestamp: {}", current_timestamp); - println!("envelope.payload.timestamp(): {}", envelope.payload.timestamp()); let is_future = envelope.payload.timestamp() > current_timestamp + 5; - println!("is_future: {}", is_future); let is_past = envelope.payload.timestamp() < current_timestamp - 60; - println!("is_past: {}", is_past); let time_valid = !(is_future || is_past); - println!("time_valid: {}", time_valid); let msg = envelope.payload_hash.signature_message(self.chain_id); - println!("msg: {:?}", msg); let block_signer = *self.unsafe_signer_recv.borrow(); - println!("block_signer: {:?}", block_signer); - println!("signature: {:?}", envelope.signature); let Ok(msg_signer) = envelope.signature.recover_address_from_prehash(&msg) else { tracing::warn!("Failed to recover address from message"); return false; }; - println!("msg_signer: {:?}", msg_signer); - println!("block_signer: {:?}", block_signer); let signer_valid = msg_signer == block_signer; - println!("signer_valid: {}", signer_valid); time_valid && signer_valid } }