chore: small updates to logging (#2211)

This commit is contained in:
Antonio
2026-02-18 11:45:14 +01:00
committed by GitHub
parent 5764729d78
commit de49930ff6
20 changed files with 121 additions and 60 deletions
Generated
+1
View File
@@ -4406,6 +4406,7 @@ dependencies = [
"bytes",
"ed25519-dalek",
"generic-array 1.3.5",
"hex",
"logos-blockchain-groth16",
"logos-blockchain-key-management-system-macros",
"logos-blockchain-poseidon2",
@@ -163,8 +163,8 @@ where
) -> Poll<
ConnectionHandlerEvent<Self::OutboundProtocol, Self::OutboundOpenInfo, Self::ToBehaviour>,
> {
tracing::info!(gauge.pending_outbound_messages = self.outbound_msgs.len() as u64,);
tracing::info!(
tracing::trace!(gauge.pending_outbound_messages = self.outbound_msgs.len() as u64,);
tracing::trace!(
gauge.pending_events_to_behaviour = self.pending_events_to_behaviour.len() as u64,
);
@@ -367,7 +367,7 @@ where
}
};
tracing::info!(counter.connection_event = 1, event = event_name);
tracing::trace!(counter.connection_event = 1, event = event_name);
self.try_wake();
}
}
+25 -3
View File
@@ -1,3 +1,5 @@
use core::fmt::{self, Debug, Formatter};
use blake2::Digest as _;
use lb_cryptarchia_engine::Slot;
use lb_groth16::fr_to_bytes;
@@ -14,15 +16,33 @@ use crate::{
utils::{display_hex_bytes_newtype, serde_bytes_newtype},
};
#[derive(Clone, Debug, Eq, PartialEq, Copy, Hash, PartialOrd, Ord)]
#[derive(Clone, Eq, PartialEq, Copy, Hash, PartialOrd, Ord)]
pub struct HeaderId([u8; 32]);
#[derive(Clone, Debug, Eq, PartialEq, Copy, Hash)]
impl Debug for HeaderId {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "HeaderId({})", hex::encode(self.0))
}
}
#[derive(Clone, Eq, PartialEq, Copy, Hash)]
pub struct ContentId([u8; 32]);
#[derive(Clone, Debug, Eq, PartialEq, Copy)]
impl Debug for ContentId {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "ContentId({})", hex::encode(self.0))
}
}
#[derive(Clone, Eq, PartialEq, Copy)]
pub struct Nonce([u8; 32]);
impl Debug for Nonce {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "Nonce({})", hex::encode(self.0))
}
}
#[derive(Clone, Debug, Eq, PartialEq, Copy, Serialize, Deserialize)]
#[repr(u8)]
pub enum Version {
@@ -173,9 +193,11 @@ impl From<ContentId> for [u8; 32] {
display_hex_bytes_newtype!(HeaderId);
display_hex_bytes_newtype!(ContentId);
display_hex_bytes_newtype!(Nonce);
serde_bytes_newtype!(HeaderId, 32);
serde_bytes_newtype!(ContentId, 32);
serde_bytes_newtype!(Nonce, 32);
#[derive(Debug, thiserror::Error)]
pub enum Error {
+16 -1
View File
@@ -1,3 +1,4 @@
use core::fmt::Debug;
use std::sync::LazyLock;
use ark_ff::{Field as _, PrimeField as _};
@@ -16,7 +17,7 @@ use crate::{
proofs::merkle::merkle_path_to_witness,
};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Clone, Serialize, Deserialize)]
pub struct Groth16LeaderProof {
#[serde(with = "proof_serde")]
proof: lb_pol::PoLProof,
@@ -26,6 +27,20 @@ pub struct Groth16LeaderProof {
voucher_cm: VoucherCm,
}
impl Debug for Groth16LeaderProof {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("Groth16LeaderProof")
.field(
"proof",
&format_args!("{} bytes", size_of::<lb_pol::PoLProof>()),
)
.field("entropy_contribution", &self.entropy_contribution)
.field("leader_key", &self.leader_key)
.field("voucher_cm", &self.voucher_cm)
.finish()
}
}
#[derive(Debug, Error)]
pub enum Error {
#[error("Proof of leadership failed: {0}")]
+1
View File
@@ -17,6 +17,7 @@ async-trait = { default-features = false, version = "0.1" }
bytes = { workspace = true }
ed25519-dalek = { features = ["rand_core", "serde", "zeroize"], workspace = true }
generic-array = { default-features = false, version = "1.2.0" }
hex = { workspace = true }
lb-groth16 = { workspace = true }
lb-key-management-system-macros = { workspace = true }
lb-poseidon2 = { workspace = true }
+9 -1
View File
@@ -1,3 +1,5 @@
use core::fmt::{self, Debug, Formatter};
use ed25519_dalek::{PUBLIC_KEY_LENGTH, SignatureError, Verifier as _, VerifyingKey};
use lb_utils::serde::{deserialize_bytes_array, serialize_bytes_array};
use serde::{Deserialize, Deserializer, Serialize, Serializer, de::Error};
@@ -6,7 +8,7 @@ use crate::keys::{Ed25519Signature, X25519PublicKey};
pub const KEY_SIZE: usize = PUBLIC_KEY_LENGTH;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
pub struct PublicKey(VerifyingKey);
impl Serialize for PublicKey {
@@ -18,6 +20,12 @@ impl Serialize for PublicKey {
}
}
impl Debug for PublicKey {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "PublicKey({})", hex::encode(self.0.as_bytes()))
}
}
impl<'de> Deserialize<'de> for PublicKey {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
@@ -342,9 +342,9 @@ where
.validate_and_publish_message(msg)
{
tracing::error!(target: LOG_TARGET, "Failed to publish message to blend network: {e:?}");
tracing::info!(counter.failed_outbound_messages = 1);
tracing::trace!(counter.failed_outbound_messages = 1);
} else {
tracing::info!(counter.successful_outbound_messages = 1);
tracing::trace!(counter.successful_outbound_messages = 1);
}
}
@@ -361,20 +361,20 @@ where
.validate_and_forward_message(msg, except)
{
tracing::error!(target: LOG_TARGET, "Failed to forward message to blend network: {e:?}");
tracing::info!(counter.failed_outbound_messages = 1);
tracing::trace!(counter.failed_outbound_messages = 1);
} else {
tracing::info!(counter.successful_outbound_messages = 1);
tracing::trace!(counter.successful_outbound_messages = 1);
}
}
fn report_message_to_service(&self, msg: EncapsulatedMessageWithVerifiedPublicHeader) {
tracing::debug!("Received message from a peer: {msg:?}");
tracing::trace!("Received message from a peer: {msg:?}");
if let Err(e) = self.incoming_message_sender.send(msg) {
tracing::error!(target: LOG_TARGET, "Failed to send incoming message to channel: {e}");
tracing::info!(counter.failed_inbound_messages = 1);
tracing::trace!(counter.failed_inbound_messages = 1);
} else {
tracing::info!(counter.successful_inbound_messages = 1);
tracing::trace!(counter.successful_inbound_messages = 1);
}
}
@@ -422,9 +422,9 @@ where
.validate_and_publish_message(msg)
{
tracing::error!(target: LOG_TARGET, "Failed to publish message to blend network: {e:?}");
tracing::info!(counter.failed_outbound_messages = 1);
tracing::trace!(counter.failed_outbound_messages = 1);
} else {
tracing::info!(counter.successful_outbound_messages = 1);
tracing::trace!(counter.successful_outbound_messages = 1);
}
}
}
@@ -496,7 +496,7 @@ where
connection_id,
error,
} => {
tracing::error!(
tracing::warn!(
target: LOG_TARGET,
"Dialing error for peer: {peer_id:?} on connection: {connection_id:?}. Error: {error:?}"
);
@@ -510,7 +510,7 @@ where
}
_ => {
tracing::debug!(target: LOG_TARGET, "Received event from blend network that will be ignored.");
tracing::info!(counter.ignored_event = 1);
tracing::trace!(counter.ignored_event = 1);
}
}
}
+6 -6
View File
@@ -1301,11 +1301,11 @@ where
let deserialized_data_message =
NetworkMessage::from_bytes(fully_decapsulated_message.payload_body())
.expect("Locally-generated and serialized message should be deserializable.");
tracing::debug!(target: LOG_TARGET, "Locally generated data message {deserialized_data_message:?} had all the {} layers addressed to this same node. Propagating only the fully decapsulated message.", blending_tokens.len());
tracing::trace!(target: LOG_TARGET, "Locally generated data message {deserialized_data_message:?} had all the {} layers addressed to this same node. Propagating only the fully decapsulated message.", blending_tokens.len());
ProcessedMessage::from(deserialized_data_message)
}
DecapsulatedMessageType::Incompleted(remaining_encapsulated_message) => {
tracing::debug!(target: LOG_TARGET, "Locally generated data message had the outermost {} layers addressed to this same node. Propagating only the remaining encapsulated layers.", blending_tokens.len());
tracing::trace!(target: LOG_TARGET, "Locally generated data message had the outermost {} layers addressed to this same node. Propagating only the remaining encapsulated layers.", blending_tokens.len());
ProcessedMessage::from(*remaining_encapsulated_message)
}
};
@@ -1512,21 +1512,21 @@ where
DecapsulatedMessageType::Completed(fully_decapsulated_message) => {
match fully_decapsulated_message.into_components() {
(PayloadType::Cover, _) => {
tracing::info!(target: LOG_TARGET, "Discarding received cover message.");
tracing::trace!(target: LOG_TARGET, "Discarding received cover message.");
(None, blending_tokens.into_iter())
}
(PayloadType::Data, serialized_data_message) => {
tracing::debug!(target: LOG_TARGET, "Processing a fully decapsulated data message.");
tracing::trace!(target: LOG_TARGET, "Processing a fully decapsulated data message.");
match NetworkMessage::from_bytes(&serialized_data_message) {
Ok(deserialized_network_message) => {
tracing::debug!(target: LOG_TARGET, "Fully decapsulated and deserialized processed data message: {deserialized_network_message:?}");
tracing::trace!(target: LOG_TARGET, "Fully decapsulated and deserialized processed data message: {deserialized_network_message:?}");
let processed_message =
ProcessedMessage::from(deserialized_network_message);
scheduler.schedule_processed_message(processed_message.clone());
(Some(processed_message), blending_tokens.into_iter())
}
Err(e) => {
tracing::debug!(target: LOG_TARGET, "Unrecognized data message from blend backend. Dropping: {e:?}");
tracing::trace!(target: LOG_TARGET, "Unrecognized data message from blend backend. Dropping: {e:?}");
(None, blending_tokens.into_iter())
}
}
+5 -5
View File
@@ -18,7 +18,7 @@ use overwatch::{
use serde::{Deserialize, Serialize};
use tokio::sync::{broadcast, oneshot};
use tokio_stream::wrappers::BroadcastStream;
use tracing::{error, info};
use tracing::{debug, error, info};
const BROADCAST_CHANNEL_SIZE: usize = 128;
@@ -95,14 +95,14 @@ where
while let Some(msg) = self.service_resources_handle.inbound_relay.recv().await {
match msg {
BlockBroadcastMsg::BroadcastFinalizedBlock(block) => {
if let Err(err) = self.finalized_blocks.send(block) {
error!("Could not send to new blocks channel: {err}");
if self.finalized_blocks.send(block).is_err() {
debug!("No listener for finalized blocks. Not broadcasting. ");
}
}
BlockBroadcastMsg::BroadcastBlendSession(session) => {
self.last_blend_session = Some(session.clone());
if let Err(err) = self.blend_session.send(session) {
error!("Could not send to new blocks channel: {err}");
if self.blend_session.send(session).is_err() {
debug!("No listener for blend sessions. Not broadcasting. ");
}
}
BlockBroadcastMsg::SubscribeToFinalizedBlocks { result_sender } => {
+10 -6
View File
@@ -279,9 +279,13 @@ impl<'service> PotentialWinningPoLSlotNotifier<'service> {
}
};
if let Err(err) = self.sender.send(Some((leader_private, epoch_state.epoch))) {
tracing::error!(
"Failed to send pre-calculated PoL winning slots to receivers. Error: {err:?}"
if self
.sender
.send(Some((leader_private, epoch_state.epoch)))
.is_err()
{
tracing::debug!(
"No active listeners for pre-calculated PoL winning slots. Not broadcasting."
);
} else {
// We stop the iteration as soon as the first winning slot for this epoch is
@@ -316,9 +320,9 @@ impl<'service> PotentialWinningPoLSlotNotifier<'service> {
return;
}
if let Err(err) = self.sender.send(Some((private_inputs, epoch))) {
tracing::error!(
"Failed to send pre-calculated PoL winning slots to receivers. Error: {err:?}"
if self.sender.send(Some((private_inputs, epoch))).is_err() {
tracing::debug!(
"No active listeners for pre-calculated PoL winning slots. Not broadcasting."
);
}
}
+4 -4
View File
@@ -38,7 +38,7 @@ use overwatch::{
use serde::{Deserialize, Serialize, de::DeserializeOwned};
use thiserror::Error;
use tokio::sync::oneshot;
use tracing::{Level, debug, error, info, instrument, span};
use tracing::{Level, debug, error, info, instrument, span, trace};
use tracing_futures::Instrument as _;
pub use crate::{
@@ -343,7 +343,7 @@ where
relays.mempool_adapter(),
).await {
Ok(()) => {
info!(counter.consensus_processed_blocks = 1);
trace!(counter.consensus_processed_blocks = 1);
}
Err(e) => {
error!(target: LOG_TARGET, "Error processing orphan downloader block: {e:?}");
@@ -510,7 +510,7 @@ where
{
Ok(()) => {
orphan_downloader.remove_orphan(&block_id);
info!(counter.consensus_processed_blocks = 1);
trace!(counter.consensus_processed_blocks = 1);
}
Err(err) => {
Self::handle_proposal_processing_error(err, block_id, orphan_downloader);
@@ -611,7 +611,7 @@ where
RecoverableMempool<BlockId = HeaderId, Key = TxHash, Item = Cryptarchia::Tx> + Send + Sync,
RuntimeServiceId: Send + Sync,
{
debug!("received proposal {:?}", block);
debug!("Received proposal with ID: {:?}", block.header().id());
let (tip, reorged_txs) = cryptarchia.apply_block(block.clone()).await?;
@@ -146,10 +146,7 @@ where
None
},
|msg| match msg {
NetworkMessage::Proposal(proposal) => {
debug!("received proposal {:?}", proposal.header().id());
Some(proposal)
}
NetworkMessage::Proposal(proposal) => Some(proposal),
},
),
Err(BroadcastStreamRecvError::Lagged(n)) => {
+2 -3
View File
@@ -904,8 +904,7 @@ where
new_block_subscription_sender: &broadcast::Sender<ProcessedBlockEvent>,
lib_broadcaster: &broadcast::Sender<LibUpdate>,
) -> Result<(Cryptarchia, PrunedBlocks<HeaderId>, Vec<Tx>), Error> {
debug!("received proposal {:?}", block);
debug!("Received proposal with ID: {:?}", block.header().id());
let header = block.header();
let prev_lib = cryptarchia.lib();
@@ -1264,7 +1263,7 @@ where
height: tip.length(),
});
info!("Sending tip response: {response:?}");
debug!("Sending tip response: {response:?}");
if let Err(e) = reply_sender.send(response).await {
error!("Failed to send tip header: {e}");
}
@@ -72,7 +72,7 @@ impl<R: Clone + Send + RngCore + 'static> SwarmHandler<R> {
}
Err(gossipsub::PublishError::InsufficientPeers) if retry_count < MAX_RETRY => {
let wait = exp_backoff(retry_count);
tracing::error!(
tracing::debug!(
"failed to broadcast message to topic due to insufficient peers, trying again in {wait:?}"
);
+5 -5
View File
@@ -253,7 +253,7 @@ impl<RuntimeServiceId> NetworkBackend<RuntimeServiceId> for Mock {
async fn process(&self, msg: Self::Message) {
match msg {
MockBackendMessage::BootProducer { spawner } => {
tracing::info!("booting producer");
tracing::debug!("booting producer");
let this = self.clone();
match (spawner)(Box::pin(async move { this.run_producer_handler().await })) {
Ok(()) => {}
@@ -263,7 +263,7 @@ impl<RuntimeServiceId> NetworkBackend<RuntimeServiceId> for Mock {
}
}
MockBackendMessage::Broadcast { topic, msg } => {
tracing::info!("processed normal message");
tracing::debug!("processed normal message");
self.messages
.lock()
.unwrap()
@@ -273,15 +273,15 @@ impl<RuntimeServiceId> NetworkBackend<RuntimeServiceId> for Mock {
drop(self.pubsub_events_tx.send(NetworkEvent::RawMessage(msg)));
}
MockBackendMessage::RelaySubscribe { topic } => {
tracing::info!("processed relay subscription for topic: {topic}");
tracing::debug!("processed relay subscription for topic: {topic}");
self.subscribed_topics.lock().unwrap().insert(topic);
}
MockBackendMessage::RelayUnSubscribe { topic } => {
tracing::info!("processed relay unsubscription for topic: {topic}");
tracing::debug!("processed relay unsubscription for topic: {topic}");
self.subscribed_topics.lock().unwrap().remove(&topic);
}
MockBackendMessage::Query { topic, tx } => {
tracing::info!("processed query");
tracing::debug!("processed query");
let msgs = self
.messages
.lock()
+1 -2
View File
@@ -218,8 +218,7 @@ where
} => Self::handle_execute(backend, transaction, reply_channel).await,
StorageMsg::Api { request: api_call } => Self::handle_api_call(api_call, backend).await,
} {
// TODO: add proper logging
println!("{e}");
tracing::error!("Error handling storage message: {e}");
}
}
/// Handle load message
@@ -72,7 +72,7 @@ impl<RuntimeServiceId> NetworkAdapter<RuntimeServiceId> for MockAdapter<RuntimeS
let stream = receiver.await.unwrap();
Box::new(Box::pin(stream.filter_map(async |event| match event {
Ok(NetworkEvent::RawMessage(message)) => {
tracing::info!("Received message: {:?}", message.payload());
tracing::debug!("Received message: {:?}", message.payload());
message.content_topic().eq(&MOCK_TX_CONTENT_TOPIC).then(|| {
let tx = MockTransaction::new(message);
(tx.id(), tx)
+1 -1
View File
@@ -531,7 +531,7 @@ where
drop(tx_broadcast.send(item));
tracing::info!(counter.tx_mempool_pending_items = pool.pending_item_count());
tracing::trace!(counter.tx_mempool_pending_items = pool.pending_item_count());
state_updater.update(Some(<Pool as RecoverableMempool>::save(pool).into()));
}
+2 -2
View File
@@ -16,7 +16,7 @@ ark-ff = { version = "0.4" }
ark-groth16 = { default-features = false, features = ["std"], version = "0.4" }
ark-serialize = { default-features = false, version = "0.4.2" }
generic-array = { default-features = false, version = "1.2" }
hex = { default-features = false, features = ["alloc"], optional = true, version = "0.4" }
hex = { default-features = false, features = ["alloc"], version = "0.4" }
num-bigint = { default-features = false, version = "0.4" }
serde = { features = ["derive"], optional = true, workspace = true }
serde_json = { default-features = false, features = ["alloc"], optional = true, version = "1.0" }
@@ -31,4 +31,4 @@ workspace = true
[features]
default = []
deser = ["dep:hex", "dep:serde", "dep:serde_json", "generic-array/serde"]
deser = ["dep:serde", "dep:serde_json", "generic-array/serde"]
+16 -1
View File
@@ -1,6 +1,8 @@
#[cfg(feature = "deser")]
pub mod deserialize;
use core::fmt::{self, Debug, Formatter};
use ark_bn254::Bn254;
use ark_ec::pairing::Pairing;
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize as _, SerializationError};
@@ -27,13 +29,26 @@ pub trait CompressSize: Pairing {
type G2CompressedSize: ArrayLength;
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[derive(Clone, PartialEq, Eq, Hash)]
pub struct CompressedProof<E: CompressSize> {
pub pi_a: GenericArray<u8, E::G1CompressedSize>,
pub pi_b: GenericArray<u8, E::G2CompressedSize>,
pub pi_c: GenericArray<u8, E::G1CompressedSize>,
}
impl<E> Debug for CompressedProof<E>
where
E: CompressSize,
{
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.debug_struct("CompressedProof")
.field("pi_a", &hex::encode(&self.pi_a))
.field("pi_b", &hex::encode(&self.pi_b))
.field("pi_c", &hex::encode(&self.pi_c))
.finish()
}
}
impl<E> Copy for CompressedProof<E>
where
E: CompressSize,