diff --git a/crates/astria-core/src/sequencer/v1/asset.rs b/crates/astria-core/src/sequencer/v1/asset.rs index 1e02981c24..ea3c0d6cd3 100644 --- a/crates/astria-core/src/sequencer/v1/asset.rs +++ b/crates/astria-core/src/sequencer/v1/asset.rs @@ -6,6 +6,8 @@ use std::{ }, }; +use serde::Serialize; + /// The default sequencer asset base denomination. pub const DEFAULT_NATIVE_ASSET_DENOM: &str = "nria"; @@ -118,7 +120,7 @@ impl From for Denom { } /// Asset ID, which is the hash of the denomination trace. -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)] pub struct Id([u8; 32]); impl Id { diff --git a/crates/astria-core/src/sequencer/v1/block/mod.rs b/crates/astria-core/src/sequencer/v1/block/mod.rs index 1789f60b4d..ef04d274c8 100644 --- a/crates/astria-core/src/sequencer/v1/block/mod.rs +++ b/crates/astria-core/src/sequencer/v1/block/mod.rs @@ -1,6 +1,7 @@ use std::collections::HashMap; use indexmap::IndexMap; +use serde::Serialize; use sha2::Sha256; use transaction::SignedTransaction; @@ -1238,7 +1239,7 @@ impl FilteredSequencerBlockError { /// /// A [`Deposit`] is constructed whenever a [`BridgeLockAction`] is executed /// and stored as part of the block's events. -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] pub struct Deposit { // the address on the sequencer to which the funds were sent to. bridge_address: Address, diff --git a/crates/astria-core/src/sequencer/v1/mod.rs b/crates/astria-core/src/sequencer/v1/mod.rs index 76691f4152..811a136206 100644 --- a/crates/astria-core/src/sequencer/v1/mod.rs +++ b/crates/astria-core/src/sequencer/v1/mod.rs @@ -1,4 +1,5 @@ use indexmap::IndexMap; +use serde::Serialize; use sha2::{ Digest as _, Sha256, @@ -38,7 +39,7 @@ use self::block::RollupTransactions; pub const ADDRESS_LEN: usize = 20; pub const ROLLUP_ID_LEN: usize = 32; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)] pub struct Address([u8; ADDRESS_LEN]); impl Address { diff --git a/crates/astria-sequencer/Cargo.toml b/crates/astria-sequencer/Cargo.toml index 88023189e0..12a2ffcf6a 100644 --- a/crates/astria-sequencer/Cargo.toml +++ b/crates/astria-sequencer/Cargo.toml @@ -16,7 +16,7 @@ default = [] mint = [] [dependencies] -astria-core = { path = "../astria-core", features = ["server"] } +astria-core = { path = "../astria-core", features = ["server", "serde"] } astria-build-info = { path = "../astria-build-info", features = ["runtime"] } config = { package = "astria-config", path = "../astria-config" } merkle = { package = "astria-merkle", path = "../astria-merkle" } diff --git a/crates/astria-sequencer/src/app.rs b/crates/astria-sequencer/src/app.rs index 1b168c25e2..5d31a9238d 100644 --- a/crates/astria-sequencer/src/app.rs +++ b/crates/astria-sequencer/src/app.rs @@ -639,7 +639,10 @@ impl App { .get_block_deposits() .await .context("failed to get block deposits in end_block")?; - debug!(deposits = %DisplayDeposits(&deposits), "end_block: got block deposits"); + debug!( + deposits = %telemetry::display::json(&DisplayDeposits(&deposits)), + "end_block: got block deposits" + ); self.current_sequencer_block_builder .as_mut() .expect( @@ -735,27 +738,9 @@ impl App { } /// Display wrapper for `HashMap>`. +#[derive(Debug, serde::Serialize)] struct DisplayDeposits<'a>(&'a HashMap>); -impl<'a> std::fmt::Display for DisplayDeposits<'a> { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "deposits: [ ")?; - - let mut deposits_iter = self.0.iter(); - if let Some((rollup_id, deposits)) = deposits_iter.next() { - write!(f, "rollup_id={rollup_id} deposit_count={}", deposits.len())?; - } - - for (rollup_id, deposits) in deposits_iter { - write!(f, ", ")?; - write!(f, "rollup_id={rollup_id} deposit_count={}", deposits.len())?; - } - - write!(f, " ]")?; - Ok(()) - } -} - #[derive(Debug)] struct SequencerBlockBuilder { header: tendermint::block::Header,