Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Commit

Permalink
feat: improve node log for large inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
gligneul committed Sep 12, 2023
1 parent 183322d commit 5b5ca25
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Updated state-fold libraries to version 0.8
- Added `SS_MAX_DECODING_MESSAGE_SIZE` to state-server and dispatcher with 100MB default
- Improved node log for large inputs

### Fixed

Expand Down
4 changes: 2 additions & 2 deletions offchain/dispatcher/src/machine/rollups_broker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,13 @@ impl BrokerSend for BrokerFacade {
input_index: u64,
input: &Input,
) -> Result<(), BrokerFacadeError> {
tracing::info!(?input_index, ?input, "enqueueing input");
tracing::trace!(?input_index, ?input, "enqueueing input");

let mut broker = self.broker.lock().await;
let status = self.broker_status(&mut broker).await?;

let event = build_next_input(input, &status);
tracing::trace!(?event, "producing input event");
tracing::info!(?event, "producing input event");

input_sanity_check!(event, input_index);

Expand Down
10 changes: 9 additions & 1 deletion offchain/rollups-events/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ use std::fmt::Write;
pub const ADDRESS_SIZE: usize = 20;
pub const HASH_SIZE: usize = 32;

const PAYLOAD_DEBUG_MAX_LEN: usize = 100;

/// A binary array that is converted to a hex string when serialized
#[derive(Clone, Hash, Eq, PartialEq)]
pub struct HexArray<const N: usize>([u8; N]);
Expand Down Expand Up @@ -143,7 +145,13 @@ impl<'de> Deserialize<'de> for Payload {

impl std::fmt::Debug for Payload {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", base64_engine.encode(self.inner()))
let len = self.inner().len();
if len > PAYLOAD_DEBUG_MAX_LEN {
let slice = &self.inner().as_slice()[0..PAYLOAD_DEBUG_MAX_LEN];
write!(f, "{}...[total: {} bytes]", base64_engine.encode(slice), len)
} else {
write!(f, "{}", base64_engine.encode(self.inner()))
}
}
}

Expand Down

0 comments on commit 5b5ca25

Please sign in to comment.