From de49930ff6c82f81f87ce03df0d0dad7895dc795 Mon Sep 17 00:00:00 2001 From: Antonio Date: Wed, 18 Feb 2026 11:45:14 +0100 Subject: [PATCH] chore: small updates to logging (#2211) --- Cargo.lock | 1 + .../core/with_core/behaviour/handler/mod.rs | 6 ++-- core/src/header/mod.rs | 28 +++++++++++++++++-- core/src/proofs/leader_proof.rs | 17 ++++++++++- kms/keys/Cargo.toml | 1 + kms/keys/src/keys/ed25519/public.rs | 10 ++++++- .../blend/src/core/backends/libp2p/swarm.rs | 22 +++++++-------- services/blend/src/core/mod.rs | 12 ++++---- services/chain/broadcast-service/src/lib.rs | 10 +++---- services/chain/chain-leader/src/leadership.rs | 16 +++++++---- services/chain/chain-network/src/lib.rs | 8 +++--- .../src/network/adapters/libp2p.rs | 5 +--- services/chain/chain-service/src/lib.rs | 5 ++-- .../src/backends/libp2p/swarm/gossipsub.rs | 2 +- services/network/src/backends/mock.rs | 10 +++---- services/storage/src/lib.rs | 3 +- .../tx-service/src/network/adapters/mock.rs | 2 +- services/tx-service/src/tx/service.rs | 2 +- zk/groth16/Cargo.toml | 4 +-- zk/groth16/src/proof/mod.rs | 17 ++++++++++- 20 files changed, 121 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0f87d0a7f..83d5debc3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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", diff --git a/blend/network/src/core/with_core/behaviour/handler/mod.rs b/blend/network/src/core/with_core/behaviour/handler/mod.rs index 7aba1ba4b..b18122021 100644 --- a/blend/network/src/core/with_core/behaviour/handler/mod.rs +++ b/blend/network/src/core/with_core/behaviour/handler/mod.rs @@ -163,8 +163,8 @@ where ) -> Poll< ConnectionHandlerEvent, > { - 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(); } } diff --git a/core/src/header/mod.rs b/core/src/header/mod.rs index a06107178..36032bb59 100644 --- a/core/src/header/mod.rs +++ b/core/src/header/mod.rs @@ -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 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 { diff --git a/core/src/proofs/leader_proof.rs b/core/src/proofs/leader_proof.rs index b7fee7289..2ed8f5136 100644 --- a/core/src/proofs/leader_proof.rs +++ b/core/src/proofs/leader_proof.rs @@ -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::()), + ) + .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}")] diff --git a/kms/keys/Cargo.toml b/kms/keys/Cargo.toml index 19ef3bdd3..305fc5be8 100644 --- a/kms/keys/Cargo.toml +++ b/kms/keys/Cargo.toml @@ -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 } diff --git a/kms/keys/src/keys/ed25519/public.rs b/kms/keys/src/keys/ed25519/public.rs index 9bfe8d4da..b45dcc85e 100644 --- a/kms/keys/src/keys/ed25519/public.rs +++ b/kms/keys/src/keys/ed25519/public.rs @@ -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(deserializer: D) -> Result where diff --git a/services/blend/src/core/backends/libp2p/swarm.rs b/services/blend/src/core/backends/libp2p/swarm.rs index b5dd7a873..4219f5c80 100644 --- a/services/blend/src/core/backends/libp2p/swarm.rs +++ b/services/blend/src/core/backends/libp2p/swarm.rs @@ -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); } } } diff --git a/services/blend/src/core/mod.rs b/services/blend/src/core/mod.rs index 7ebc1b69f..00db0f2bd 100644 --- a/services/blend/src/core/mod.rs +++ b/services/blend/src/core/mod.rs @@ -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()) } } diff --git a/services/chain/broadcast-service/src/lib.rs b/services/chain/broadcast-service/src/lib.rs index 5dbad4046..9aeb272a2 100644 --- a/services/chain/broadcast-service/src/lib.rs +++ b/services/chain/broadcast-service/src/lib.rs @@ -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 } => { diff --git a/services/chain/chain-leader/src/leadership.rs b/services/chain/chain-leader/src/leadership.rs index 9f3b172e2..702d69656 100644 --- a/services/chain/chain-leader/src/leadership.rs +++ b/services/chain/chain-leader/src/leadership.rs @@ -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." ); } } diff --git a/services/chain/chain-network/src/lib.rs b/services/chain/chain-network/src/lib.rs index 539d640d4..5a93dfe67 100644 --- a/services/chain/chain-network/src/lib.rs +++ b/services/chain/chain-network/src/lib.rs @@ -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 + 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?; diff --git a/services/chain/chain-network/src/network/adapters/libp2p.rs b/services/chain/chain-network/src/network/adapters/libp2p.rs index 3ece1182c..9d2aeeff5 100644 --- a/services/chain/chain-network/src/network/adapters/libp2p.rs +++ b/services/chain/chain-network/src/network/adapters/libp2p.rs @@ -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)) => { diff --git a/services/chain/chain-service/src/lib.rs b/services/chain/chain-service/src/lib.rs index 14b072714..19fabb718 100644 --- a/services/chain/chain-service/src/lib.rs +++ b/services/chain/chain-service/src/lib.rs @@ -904,8 +904,7 @@ where new_block_subscription_sender: &broadcast::Sender, lib_broadcaster: &broadcast::Sender, ) -> Result<(Cryptarchia, PrunedBlocks, Vec), 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}"); } diff --git a/services/network/src/backends/libp2p/swarm/gossipsub.rs b/services/network/src/backends/libp2p/swarm/gossipsub.rs index 0b19f2d09..2cdb28f7f 100644 --- a/services/network/src/backends/libp2p/swarm/gossipsub.rs +++ b/services/network/src/backends/libp2p/swarm/gossipsub.rs @@ -72,7 +72,7 @@ impl SwarmHandler { } 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:?}" ); diff --git a/services/network/src/backends/mock.rs b/services/network/src/backends/mock.rs index cbdbee28a..77c595c84 100644 --- a/services/network/src/backends/mock.rs +++ b/services/network/src/backends/mock.rs @@ -253,7 +253,7 @@ impl NetworkBackend 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 NetworkBackend 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 NetworkBackend 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() diff --git a/services/storage/src/lib.rs b/services/storage/src/lib.rs index 3635c8bdc..deb740190 100644 --- a/services/storage/src/lib.rs +++ b/services/storage/src/lib.rs @@ -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 diff --git a/services/tx-service/src/network/adapters/mock.rs b/services/tx-service/src/network/adapters/mock.rs index 9ac53addf..f6d76f6d2 100644 --- a/services/tx-service/src/network/adapters/mock.rs +++ b/services/tx-service/src/network/adapters/mock.rs @@ -72,7 +72,7 @@ impl NetworkAdapter for MockAdapter { - 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) diff --git a/services/tx-service/src/tx/service.rs b/services/tx-service/src/tx/service.rs index 1b0c8ca86..d71f74a13 100644 --- a/services/tx-service/src/tx/service.rs +++ b/services/tx-service/src/tx/service.rs @@ -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(::save(pool).into())); } diff --git a/zk/groth16/Cargo.toml b/zk/groth16/Cargo.toml index 7ef7cdfd6..8586ecf9b 100644 --- a/zk/groth16/Cargo.toml +++ b/zk/groth16/Cargo.toml @@ -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"] diff --git a/zk/groth16/src/proof/mod.rs b/zk/groth16/src/proof/mod.rs index 1db4ccfbc..91f16da0d 100644 --- a/zk/groth16/src/proof/mod.rs +++ b/zk/groth16/src/proof/mod.rs @@ -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 { pub pi_a: GenericArray, pub pi_b: GenericArray, pub pi_c: GenericArray, } +impl Debug for CompressedProof +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 Copy for CompressedProof where E: CompressSize,