From 96ee2ed467ab8dd582e4cc8f4ffcd0de4880cfab Mon Sep 17 00:00:00 2001 From: Ethan Oroshiba Date: Thu, 19 Dec 2024 09:00:28 -0600 Subject: [PATCH] chore(sequencer): add instrumentation (#1761) ## Summary Added instrumentation to most async functions which did not have it. ## Background Adding instrumentation to all async calls will aid in tracing since spans will be emitted even if no events happen under them. ## Changes - Added instrumentation to most async functions which did not have it. - Added `err` argument to the `instrument` macro where applicable. - Added fields to the `instrument` macro where applicable. ## Testing Passing all tests. ## Changelogs No updates required ## Related Issues closes #1321 --- .../src/accounts/component.rs | 2 +- crates/astria-sequencer/src/accounts/query.rs | 12 +++++- .../src/accounts/state_ext.rs | 17 ++++---- .../src/action_handler/impls/bridge_lock.rs | 5 +++ .../impls/bridge_sudo_change.rs | 5 +++ .../src/action_handler/impls/bridge_unlock.rs | 6 +++ .../action_handler/impls/fee_asset_change.rs | 5 +++ .../src/action_handler/impls/fee_change.rs | 5 +++ .../impls/ibc_relayer_change.rs | 5 +++ .../action_handler/impls/ibc_sudo_change.rs | 5 +++ .../action_handler/impls/ics20_withdrawal.rs | 6 +++ .../impls/init_bridge_account.rs | 5 +++ .../impls/rollup_data_submission.rs | 5 +++ .../impls/sudo_address_change.rs | 5 +++ .../src/action_handler/impls/transaction.rs | 7 +++- .../src/action_handler/impls/transfer.rs | 5 +++ .../action_handler/impls/validator_update.rs | 5 +++ .../astria-sequencer/src/address/state_ext.rs | 16 ++++++-- crates/astria-sequencer/src/app/mod.rs | 26 ++++++------ crates/astria-sequencer/src/app/state_ext.rs | 15 ++++--- crates/astria-sequencer/src/assets/query.rs | 2 + .../astria-sequencer/src/assets/state_ext.rs | 11 +++-- .../src/authority/component.rs | 11 +++-- .../src/authority/state_ext.rs | 11 +++-- crates/astria-sequencer/src/bridge/query.rs | 6 ++- .../astria-sequencer/src/bridge/state_ext.rs | 24 +++++++---- crates/astria-sequencer/src/fees/component.rs | 2 +- crates/astria-sequencer/src/fees/mod.rs | 2 +- crates/astria-sequencer/src/fees/query.rs | 5 ++- crates/astria-sequencer/src/fees/state_ext.rs | 14 ++++--- crates/astria-sequencer/src/grpc/state_ext.rs | 21 ++++++---- crates/astria-sequencer/src/ibc/component.rs | 11 +++-- .../src/ibc/host_interface.rs | 5 +++ .../src/ibc/ics20_transfer.rs | 31 ++++++++++---- crates/astria-sequencer/src/ibc/state_ext.rs | 11 ++--- .../src/mempool/mempool_state.rs | 7 +++- crates/astria-sequencer/src/mempool/mod.rs | 11 +++-- .../src/mempool/transactions_container.rs | 8 +++- crates/astria-sequencer/src/sequencer.rs | 41 +++++++++++-------- .../astria-sequencer/src/service/consensus.rs | 10 +++-- .../src/service/mempool/mod.rs | 4 ++ .../src/transaction/checks.rs | 11 +++-- 42 files changed, 299 insertions(+), 122 deletions(-) diff --git a/crates/astria-sequencer/src/accounts/component.rs b/crates/astria-sequencer/src/accounts/component.rs index c9d515ec45..b8869d4a7c 100644 --- a/crates/astria-sequencer/src/accounts/component.rs +++ b/crates/astria-sequencer/src/accounts/component.rs @@ -25,7 +25,7 @@ pub(crate) struct AccountsComponent; impl Component for AccountsComponent { type AppState = GenesisAppState; - #[instrument(name = "AccountsComponent::init_chain", skip_all)] + #[instrument(name = "AccountsComponent::init_chain", skip_all, err)] async fn init_chain(mut state: S, app_state: &Self::AppState) -> Result<()> where S: accounts::StateWriteExt + assets::StateReadExt, diff --git a/crates/astria-sequencer/src/accounts/query.rs b/crates/astria-sequencer/src/accounts/query.rs index 00c23a4095..af7d320228 100644 --- a/crates/astria-sequencer/src/accounts/query.rs +++ b/crates/astria-sequencer/src/accounts/query.rs @@ -28,7 +28,10 @@ use tendermint::{ }, block::Height, }; -use tracing::instrument; +use tracing::{ + instrument, + Level, +}; use crate::{ accounts::StateReadExt as _, @@ -36,6 +39,7 @@ use crate::{ assets::StateReadExt as _, }; +#[instrument(skip_all, fields(%asset), err(level = Level::DEBUG))] async fn ibc_to_trace( state: S, asset: &asset::IbcPrefixed, @@ -47,7 +51,7 @@ async fn ibc_to_trace( .ok_or_eyre("asset not found when user has balance of it; this is a bug") } -#[instrument(skip_all, fields(%address))] +#[instrument(skip_all, fields(%address), err(level = Level::DEBUG))] async fn get_trace_prefixed_account_balances( state: &S, address: &Address, @@ -70,6 +74,7 @@ async fn get_trace_prefixed_account_balances( /// Returns a list of [`AssetBalance`]s for the provided address. `AssetBalance`s are sorted /// alphabetically by [`asset::Denom`]. +#[instrument(skip_all)] pub(crate) async fn balance_request( storage: Storage, request: request::Query, @@ -112,6 +117,7 @@ pub(crate) async fn balance_request( } } +#[instrument(skip_all)] pub(crate) async fn nonce_request( storage: Storage, request: request::Query, @@ -150,6 +156,7 @@ pub(crate) async fn nonce_request( } } +#[instrument(skip_all, fields(%height), err(level = Level::DEBUG))] async fn get_snapshot_and_height(storage: &Storage, height: Height) -> Result<(Snapshot, Height)> { let snapshot = match height.value() { 0 => storage.latest_snapshot(), @@ -173,6 +180,7 @@ async fn get_snapshot_and_height(storage: &Storage, height: Height) -> Result<(S Ok((snapshot, height)) } +#[instrument(skip_all)] async fn preprocess_request( storage: &Storage, request: &request::Query, diff --git a/crates/astria-sequencer/src/accounts/state_ext.rs b/crates/astria-sequencer/src/accounts/state_ext.rs index ff466469db..2cae372809 100644 --- a/crates/astria-sequencer/src/accounts/state_ext.rs +++ b/crates/astria-sequencer/src/accounts/state_ext.rs @@ -25,7 +25,10 @@ use cnidarium::{ }; use futures::Stream; use pin_project_lite::pin_project; -use tracing::instrument; +use tracing::{ + instrument, + Level, +}; use super::storage::{ self, @@ -141,7 +144,7 @@ pub(crate) trait StateReadExt: StateRead + crate::assets::StateReadExt { } } - #[instrument(skip_all, fields(address = %address.display_address(), %asset), err)] + #[instrument(skip_all, fields(address = %address.display_address(), %asset), err(level = Level::WARN))] async fn get_account_balance<'a, TAddress, TAsset>( &self, address: &TAddress, @@ -165,7 +168,7 @@ pub(crate) trait StateReadExt: StateRead + crate::assets::StateReadExt { .wrap_err("invalid balance bytes") } - #[instrument(skip_all)] + #[instrument(skip_all, err)] async fn get_account_nonce(&self, address: &T) -> Result { let bytes = self .get_raw(&keys::nonce(address)) @@ -186,7 +189,7 @@ impl StateReadExt for T {} #[async_trait] pub(crate) trait StateWriteExt: StateWrite { - #[instrument(skip_all, fields(address = %address.display_address(), %asset, balance), err)] + #[instrument(skip_all, fields(address = %address.display_address(), %asset, balance), err(level = Level::WARN))] fn put_account_balance<'a, TAddress, TAsset>( &mut self, address: &TAddress, @@ -205,7 +208,7 @@ pub(crate) trait StateWriteExt: StateWrite { Ok(()) } - #[instrument(skip_all)] + #[instrument(skip_all, fields(address = %address.display_address(), nonce), err(level = Level::WARN))] fn put_account_nonce(&mut self, address: &T, nonce: u32) -> Result<()> { let bytes = StoredValue::from(storage::Nonce::from(nonce)) .serialize() @@ -214,7 +217,7 @@ pub(crate) trait StateWriteExt: StateWrite { Ok(()) } - #[instrument(skip_all, fields(address = %address.display_address(), %asset, amount), err)] + #[instrument(skip_all, fields(address = %address.display_address(), %asset, amount), err(level = Level::WARN))] async fn increase_balance<'a, TAddress, TAsset>( &mut self, address: &TAddress, @@ -241,7 +244,7 @@ pub(crate) trait StateWriteExt: StateWrite { Ok(()) } - #[instrument(skip_all, fields(address = %address.display_address(), %asset, amount))] + #[instrument(skip_all, fields(address = %address.display_address(), %asset, amount), err(level = Level::DEBUG))] async fn decrease_balance<'a, TAddress, TAsset>( &mut self, address: &TAddress, diff --git a/crates/astria-sequencer/src/action_handler/impls/bridge_lock.rs b/crates/astria-sequencer/src/action_handler/impls/bridge_lock.rs index 3be717fc61..38c61520c6 100644 --- a/crates/astria-sequencer/src/action_handler/impls/bridge_lock.rs +++ b/crates/astria-sequencer/src/action_handler/impls/bridge_lock.rs @@ -13,6 +13,10 @@ use astria_eyre::eyre::{ }; use async_trait::async_trait; use cnidarium::StateWrite; +use tracing::{ + instrument, + Level, +}; use crate::{ action_handler::{ @@ -36,6 +40,7 @@ impl ActionHandler for BridgeLock { Ok(()) } + #[instrument(skip_all, err(level = Level::DEBUG))] async fn check_and_execute(&self, mut state: S) -> Result<()> { let from = state .get_transaction_context() diff --git a/crates/astria-sequencer/src/action_handler/impls/bridge_sudo_change.rs b/crates/astria-sequencer/src/action_handler/impls/bridge_sudo_change.rs index a69775cf5f..97f7dbaa57 100644 --- a/crates/astria-sequencer/src/action_handler/impls/bridge_sudo_change.rs +++ b/crates/astria-sequencer/src/action_handler/impls/bridge_sudo_change.rs @@ -7,6 +7,10 @@ use astria_eyre::eyre::{ }; use async_trait::async_trait; use cnidarium::StateWrite; +use tracing::{ + instrument, + Level, +}; use crate::{ action_handler::ActionHandler, @@ -24,6 +28,7 @@ impl ActionHandler for BridgeSudoChange { Ok(()) } + #[instrument(skip_all, err(level = Level::DEBUG))] async fn check_and_execute(&self, mut state: S) -> Result<()> { let from = state .get_transaction_context() diff --git a/crates/astria-sequencer/src/action_handler/impls/bridge_unlock.rs b/crates/astria-sequencer/src/action_handler/impls/bridge_unlock.rs index d2362a5742..3789fa5bde 100644 --- a/crates/astria-sequencer/src/action_handler/impls/bridge_unlock.rs +++ b/crates/astria-sequencer/src/action_handler/impls/bridge_unlock.rs @@ -10,6 +10,10 @@ use astria_eyre::eyre::{ }; use async_trait::async_trait; use cnidarium::StateWrite; +use tracing::{ + instrument, + Level, +}; use crate::{ action_handler::{ @@ -28,6 +32,7 @@ use crate::{ #[async_trait] impl ActionHandler for BridgeUnlock { // TODO(https://github.com/astriaorg/astria/issues/1430): move checks to the `BridgeUnlock` parsing. + #[instrument(skip_all, err(level = Level::DEBUG))] async fn check_stateless(&self) -> Result<()> { ensure!(self.amount > 0, "amount must be greater than zero",); ensure!(self.memo.len() <= 64, "memo must not be more than 64 bytes"); @@ -46,6 +51,7 @@ impl ActionHandler for BridgeUnlock { Ok(()) } + #[instrument(skip_all, err(level = Level::DEBUG))] async fn check_and_execute(&self, mut state: S) -> Result<()> { let from = state .get_transaction_context() diff --git a/crates/astria-sequencer/src/action_handler/impls/fee_asset_change.rs b/crates/astria-sequencer/src/action_handler/impls/fee_asset_change.rs index c92161e751..fabbe3247c 100644 --- a/crates/astria-sequencer/src/action_handler/impls/fee_asset_change.rs +++ b/crates/astria-sequencer/src/action_handler/impls/fee_asset_change.rs @@ -8,6 +8,10 @@ use async_trait::async_trait; use cnidarium::StateWrite; use futures::StreamExt as _; use tokio::pin; +use tracing::{ + instrument, + Level, +}; use crate::{ action_handler::ActionHandler, @@ -25,6 +29,7 @@ impl ActionHandler for FeeAssetChange { Ok(()) } + #[instrument(skip_all, err(level = Level::DEBUG))] async fn check_and_execute(&self, mut state: S) -> eyre::Result<()> { let from = state .get_transaction_context() diff --git a/crates/astria-sequencer/src/action_handler/impls/fee_change.rs b/crates/astria-sequencer/src/action_handler/impls/fee_change.rs index f066ded9ea..3b399ddc40 100644 --- a/crates/astria-sequencer/src/action_handler/impls/fee_change.rs +++ b/crates/astria-sequencer/src/action_handler/impls/fee_change.rs @@ -6,6 +6,10 @@ use astria_eyre::eyre::{ }; use async_trait::async_trait; use cnidarium::StateWrite; +use tracing::{ + instrument, + Level, +}; use crate::{ action_handler::ActionHandler, @@ -22,6 +26,7 @@ impl ActionHandler for FeeChange { /// check that the signer of the transaction is the current sudo address, /// as only that address can change the fee + #[instrument(skip_all, err(level = Level::DEBUG))] async fn check_and_execute(&self, mut state: S) -> eyre::Result<()> { let from = state .get_transaction_context() diff --git a/crates/astria-sequencer/src/action_handler/impls/ibc_relayer_change.rs b/crates/astria-sequencer/src/action_handler/impls/ibc_relayer_change.rs index e5de94afbe..9ddce3ea30 100644 --- a/crates/astria-sequencer/src/action_handler/impls/ibc_relayer_change.rs +++ b/crates/astria-sequencer/src/action_handler/impls/ibc_relayer_change.rs @@ -6,6 +6,10 @@ use astria_eyre::eyre::{ }; use async_trait::async_trait; use cnidarium::StateWrite; +use tracing::{ + instrument, + Level, +}; use crate::{ action_handler::ActionHandler, @@ -23,6 +27,7 @@ impl ActionHandler for IbcRelayerChange { Ok(()) } + #[instrument(skip_all, err(level = Level::DEBUG))] async fn check_and_execute(&self, mut state: S) -> Result<()> { let from = state .get_transaction_context() diff --git a/crates/astria-sequencer/src/action_handler/impls/ibc_sudo_change.rs b/crates/astria-sequencer/src/action_handler/impls/ibc_sudo_change.rs index f82af648fc..487f71b4e6 100644 --- a/crates/astria-sequencer/src/action_handler/impls/ibc_sudo_change.rs +++ b/crates/astria-sequencer/src/action_handler/impls/ibc_sudo_change.rs @@ -6,6 +6,10 @@ use astria_eyre::eyre::{ }; use async_trait::async_trait; use cnidarium::StateWrite; +use tracing::{ + instrument, + Level, +}; use crate::{ action_handler::ActionHandler, @@ -21,6 +25,7 @@ impl ActionHandler for IbcSudoChange { Ok(()) } + #[instrument(skip_all, err(level = Level::DEBUG))] async fn check_and_execute(&self, mut state: S) -> Result<()> { let from = state .get_transaction_context() diff --git a/crates/astria-sequencer/src/action_handler/impls/ics20_withdrawal.rs b/crates/astria-sequencer/src/action_handler/impls/ics20_withdrawal.rs index 34fecb3cf1..cf29705315 100644 --- a/crates/astria-sequencer/src/action_handler/impls/ics20_withdrawal.rs +++ b/crates/astria-sequencer/src/action_handler/impls/ics20_withdrawal.rs @@ -37,6 +37,10 @@ use penumbra_ibc::component::packet::{ Unchecked, }; use penumbra_proto::core::component::ibc::v1::FungibleTokenPacketData; +use tracing::{ + instrument, + Level, +}; use crate::{ accounts::{ @@ -60,6 +64,7 @@ use crate::{ #[async_trait] impl ActionHandler for action::Ics20Withdrawal { // TODO(https://github.com/astriaorg/astria/issues/1430): move checks to the `Ics20Withdrawal` parsing. + #[instrument(skip_all, err(level = Level::DEBUG))] async fn check_stateless(&self) -> Result<()> { ensure!(self.timeout_time() != 0, "timeout time must be non-zero",); ensure!(self.amount() > 0, "amount must be greater than zero",); @@ -95,6 +100,7 @@ impl ActionHandler for action::Ics20Withdrawal { Ok(()) } + #[instrument(skip_all, err(level = Level::DEBUG))] async fn check_and_execute(&self, mut state: S) -> Result<()> { let from = state .get_transaction_context() diff --git a/crates/astria-sequencer/src/action_handler/impls/init_bridge_account.rs b/crates/astria-sequencer/src/action_handler/impls/init_bridge_account.rs index 85e05de042..fdea8cab4f 100644 --- a/crates/astria-sequencer/src/action_handler/impls/init_bridge_account.rs +++ b/crates/astria-sequencer/src/action_handler/impls/init_bridge_account.rs @@ -9,6 +9,10 @@ use astria_eyre::eyre::{ }; use async_trait::async_trait; use cnidarium::StateWrite; +use tracing::{ + instrument, + Level, +}; use crate::{ action_handler::ActionHandler, @@ -26,6 +30,7 @@ impl ActionHandler for InitBridgeAccount { Ok(()) } + #[instrument(skip_all, err(level = Level::DEBUG))] async fn check_and_execute(&self, mut state: S) -> Result<()> { let from = state .get_transaction_context() diff --git a/crates/astria-sequencer/src/action_handler/impls/rollup_data_submission.rs b/crates/astria-sequencer/src/action_handler/impls/rollup_data_submission.rs index 3881e221bf..23be358129 100644 --- a/crates/astria-sequencer/src/action_handler/impls/rollup_data_submission.rs +++ b/crates/astria-sequencer/src/action_handler/impls/rollup_data_submission.rs @@ -5,11 +5,16 @@ use astria_eyre::eyre::{ }; use async_trait::async_trait; use cnidarium::StateWrite; +use tracing::{ + instrument, + Level, +}; use crate::action_handler::ActionHandler; #[async_trait] impl ActionHandler for RollupDataSubmission { + #[instrument(skip_all, err(level = Level::DEBUG))] async fn check_stateless(&self) -> Result<()> { // TODO: do we want to place a maximum on the size of the data? // https://github.com/astriaorg/astria/issues/222 diff --git a/crates/astria-sequencer/src/action_handler/impls/sudo_address_change.rs b/crates/astria-sequencer/src/action_handler/impls/sudo_address_change.rs index 7c7cb2e5e2..eb3f4f771a 100644 --- a/crates/astria-sequencer/src/action_handler/impls/sudo_address_change.rs +++ b/crates/astria-sequencer/src/action_handler/impls/sudo_address_change.rs @@ -6,6 +6,10 @@ use astria_eyre::eyre::{ }; use async_trait::async_trait; use cnidarium::StateWrite; +use tracing::{ + instrument, + Level, +}; use crate::{ action_handler::ActionHandler, @@ -25,6 +29,7 @@ impl ActionHandler for SudoAddressChange { /// check that the signer of the transaction is the current sudo address, /// as only that address can change the sudo address + #[instrument(skip_all, err(level = Level::DEBUG))] async fn check_and_execute(&self, mut state: S) -> Result<()> { let from = state .get_transaction_context() diff --git a/crates/astria-sequencer/src/action_handler/impls/transaction.rs b/crates/astria-sequencer/src/action_handler/impls/transaction.rs index a5b66bf4fd..8605906ad4 100644 --- a/crates/astria-sequencer/src/action_handler/impls/transaction.rs +++ b/crates/astria-sequencer/src/action_handler/impls/transaction.rs @@ -18,6 +18,10 @@ use astria_eyre::{ }, }; use cnidarium::StateWrite; +use tracing::{ + instrument, + Level, +}; use crate::{ accounts::{ @@ -74,6 +78,7 @@ impl std::error::Error for InvalidNonce {} #[async_trait::async_trait] impl ActionHandler for Transaction { + #[instrument(skip_all, err(level = Level::DEBUG))] async fn check_stateless(&self) -> Result<()> { ensure!(!self.actions().is_empty(), "must have at least one action"); @@ -149,7 +154,7 @@ impl ActionHandler for Transaction { // FIXME (https://github.com/astriaorg/astria/issues/1584): because most lines come from delegating (and error wrapping) to the // individual actions. This could be tidied up by implementing `ActionHandler for Action` // and letting it delegate. - #[expect(clippy::too_many_lines, reason = "should be refactored")] + #[instrument(skip_all, err(level = Level::DEBUG))] async fn check_and_execute(&self, mut state: S) -> Result<()> { // Add the current signed transaction into the ephemeral state in case // downstream actions require access to it. diff --git a/crates/astria-sequencer/src/action_handler/impls/transfer.rs b/crates/astria-sequencer/src/action_handler/impls/transfer.rs index 27d955bca3..75735e8df4 100644 --- a/crates/astria-sequencer/src/action_handler/impls/transfer.rs +++ b/crates/astria-sequencer/src/action_handler/impls/transfer.rs @@ -6,6 +6,10 @@ use astria_eyre::eyre::{ }; use async_trait::async_trait; use cnidarium::StateWrite; +use tracing::{ + instrument, + Level, +}; use crate::{ action_handler::{ @@ -23,6 +27,7 @@ impl ActionHandler for Transfer { Ok(()) } + #[instrument(skip_all, err(level = Level::DEBUG))] async fn check_and_execute(&self, state: S) -> Result<()> { let from = state .get_transaction_context() diff --git a/crates/astria-sequencer/src/action_handler/impls/validator_update.rs b/crates/astria-sequencer/src/action_handler/impls/validator_update.rs index 4bd0d72c3c..5ad1ceab06 100644 --- a/crates/astria-sequencer/src/action_handler/impls/validator_update.rs +++ b/crates/astria-sequencer/src/action_handler/impls/validator_update.rs @@ -7,6 +7,10 @@ use astria_eyre::eyre::{ }; use async_trait::async_trait; use cnidarium::StateWrite; +use tracing::{ + instrument, + Level, +}; use crate::{ action_handler::ActionHandler, @@ -23,6 +27,7 @@ impl ActionHandler for ValidatorUpdate { Ok(()) } + #[instrument(skip_all, err(level = Level::DEBUG))] async fn check_and_execute(&self, mut state: S) -> Result<()> { let from = state .get_transaction_context() diff --git a/crates/astria-sequencer/src/address/state_ext.rs b/crates/astria-sequencer/src/address/state_ext.rs index 0f5cd5bf30..b217e80a56 100644 --- a/crates/astria-sequencer/src/address/state_ext.rs +++ b/crates/astria-sequencer/src/address/state_ext.rs @@ -16,16 +16,23 @@ use cnidarium::{ StateRead, StateWrite, }; -use tracing::instrument; +use tracing::{ + instrument, + Level, +}; use super::storage::{ self, keys, }; -use crate::storage::StoredValue; +use crate::{ + accounts::AddressBytes as _, + storage::StoredValue, +}; #[async_trait] pub(crate) trait StateReadExt: StateRead { + #[instrument(skip_all, fields(address = %address.display_address()), err(level = Level::DEBUG))] async fn ensure_base_prefix(&self, address: &Address) -> Result<()> { let prefix = self .get_base_prefix() @@ -39,6 +46,7 @@ pub(crate) trait StateReadExt: StateRead { Ok(()) } + #[instrument(skip_all, err(level = Level::DEBUG))] async fn try_base_prefixed(&self, slice: &[u8]) -> Result
{ let prefix = self .get_base_prefix() @@ -51,7 +59,7 @@ pub(crate) trait StateReadExt: StateRead { .wrap_err("failed to construct address from byte slice and state-provided base prefix") } - #[instrument(skip_all, err)] + #[instrument(skip_all, err(level = Level::WARN))] async fn get_base_prefix(&self) -> Result { let Some(bytes) = self .get_raw(keys::BASE_PREFIX) @@ -66,7 +74,7 @@ pub(crate) trait StateReadExt: StateRead { .context("invalid base prefix bytes") } - #[instrument(skip_all, err)] + #[instrument(skip_all, err(level = Level::WARN))] async fn get_ibc_compat_prefix(&self) -> Result { let Some(bytes) = self .get_raw(keys::IBC_COMPAT_PREFIX) diff --git a/crates/astria-sequencer/src/app/mod.rs b/crates/astria-sequencer/src/app/mod.rs index 78386c6f9f..794f5720c2 100644 --- a/crates/astria-sequencer/src/app/mod.rs +++ b/crates/astria-sequencer/src/app/mod.rs @@ -79,6 +79,7 @@ use tracing::{ debug, info, instrument, + Level, }; pub(crate) use self::state_ext::{ @@ -235,6 +236,7 @@ pub(crate) struct App { } impl App { + #[instrument(name = "App::new", skip_all, err)] pub(crate) async fn new( snapshot: Snapshot, mempool: Mempool, @@ -268,7 +270,7 @@ impl App { }) } - #[instrument(name = "App:init_chain", skip_all)] + #[instrument(name = "App:init_chain", skip_all, err)] pub(crate) async fn init_chain( &mut self, storage: Storage, @@ -355,7 +357,7 @@ impl App { /// It puts this special "commitment" as the first transaction in a block. /// When other validators receive the block, they know the first transaction is /// supposed to be the commitment, and verifies that is it correct. - #[instrument(name = "App::prepare_proposal", skip_all)] + #[instrument(name = "App::prepare_proposal", skip_all, err(level = Level::WARN))] pub(crate) async fn prepare_proposal( &mut self, prepare_proposal: abci::request::PrepareProposal, @@ -405,7 +407,7 @@ impl App { /// Generates a commitment to the `sequence::Actions` in the block's transactions /// and ensures it matches the commitment created by the proposer, which /// should be the first transaction in the block. - #[instrument(name = "App::process_proposal", skip_all)] + #[instrument(name = "App::process_proposal", skip_all, err(level = Level::WARN))] pub(crate) async fn process_proposal( &mut self, process_proposal: abci::request::ProcessProposal, @@ -565,7 +567,7 @@ impl App { /// /// As a result, all transactions in a sequencer block are guaranteed to execute /// successfully. - #[instrument(name = "App::execute_transactions_prepare_proposal", skip_all)] + #[instrument(name = "App::execute_transactions_prepare_proposal", skip_all, err(level = Level::DEBUG))] async fn execute_transactions_prepare_proposal( &mut self, block_size_constraints: &mut BlockSizeConstraints, @@ -745,7 +747,7 @@ impl App { /// /// As a result, all transactions in a sequencer block are guaranteed to execute /// successfully. - #[instrument(name = "App::execute_transactions_process_proposal", skip_all)] + #[instrument(name = "App::execute_transactions_process_proposal", skip_all, err(level = Level::DEBUG))] async fn execute_transactions_process_proposal( &mut self, txs: Vec, @@ -823,7 +825,7 @@ impl App { /// /// this *must* be called anytime before a block's txs are executed, whether it's /// during the proposal phase, or finalize_block phase. - #[instrument(name = "App::pre_execute_transactions", skip_all, err)] + #[instrument(name = "App::pre_execute_transactions", skip_all, err(level = Level::WARN))] async fn pre_execute_transactions(&mut self, block_data: BlockData) -> Result<()> { let chain_id = self .state @@ -878,7 +880,7 @@ impl App { /// `SequencerBlock`. /// /// this must be called after a block's transactions are executed. - #[instrument(name = "App::post_execute_transactions", skip_all)] + #[instrument(name = "App::post_execute_transactions", skip_all, err(level = Level::WARN))] async fn post_execute_transactions( &mut self, block_hash: Hash, @@ -962,7 +964,7 @@ impl App { /// /// This is called by cometbft after the block has already been /// committed by the network's consensus. - #[instrument(name = "App::finalize_block", skip_all)] + #[instrument(name = "App::finalize_block", skip_all, err)] pub(crate) async fn finalize_block( &mut self, finalize_block: abci::request::FinalizeBlock, @@ -1076,7 +1078,7 @@ impl App { Ok(finalize_block) } - #[instrument(skip_all, err)] + #[instrument(skip_all, err(level = Level::WARN))] async fn prepare_commit(&mut self, storage: Storage) -> Result { // extract the state we've built up to so we can prepare it as a `StagedWriteBatch`. let dummy_state = StateDelta::new(storage.latest_snapshot()); @@ -1113,7 +1115,7 @@ impl App { Ok(app_hash) } - #[instrument(name = "App::begin_block", skip_all)] + #[instrument(name = "App::begin_block", skip_all, err(level = Level::WARN))] async fn begin_block( &mut self, begin_block: &abci::request::BeginBlock, @@ -1149,7 +1151,7 @@ impl App { } /// Executes a signed transaction. - #[instrument(name = "App::execute_transaction", skip_all)] + #[instrument(name = "App::execute_transaction", skip_all, err(level = Level::DEBUG))] async fn execute_transaction(&mut self, signed_tx: Arc) -> Result> { signed_tx .check_stateless() @@ -1186,7 +1188,7 @@ impl App { Ok(events) } - #[instrument(name = "App::end_block", skip_all)] + #[instrument(name = "App::end_block", skip_all, err(level = Level::WARN))] async fn end_block( &mut self, height: u64, diff --git a/crates/astria-sequencer/src/app/state_ext.rs b/crates/astria-sequencer/src/app/state_ext.rs index b9a2e3b78e..d1dfb5e07a 100644 --- a/crates/astria-sequencer/src/app/state_ext.rs +++ b/crates/astria-sequencer/src/app/state_ext.rs @@ -12,7 +12,10 @@ use cnidarium::{ StateWrite, }; use tendermint::Time; -use tracing::instrument; +use tracing::{ + instrument, + Level, +}; use super::storage::{ self, @@ -22,7 +25,7 @@ use crate::storage::StoredValue; #[async_trait] pub(crate) trait StateReadExt: StateRead { - #[instrument(skip_all)] + #[instrument(skip_all, err(level = Level::WARN))] async fn get_chain_id(&self) -> Result { let Some(bytes) = self .get_raw(keys::CHAIN_ID) @@ -37,7 +40,7 @@ pub(crate) trait StateReadExt: StateRead { .wrap_err("invalid chain id bytes") } - #[instrument(skip_all)] + #[instrument(skip_all, err(level = Level::WARN))] async fn get_revision_number(&self) -> Result { let Some(bytes) = self .get_raw(keys::REVISION_NUMBER) @@ -52,7 +55,7 @@ pub(crate) trait StateReadExt: StateRead { .wrap_err("invalid revision number bytes") } - #[instrument(skip_all)] + #[instrument(skip_all, err(level = Level::WARN))] async fn get_block_height(&self) -> Result { let Some(bytes) = self .get_raw(keys::BLOCK_HEIGHT) @@ -67,7 +70,7 @@ pub(crate) trait StateReadExt: StateRead { .context("invalid block height bytes") } - #[instrument(skip_all)] + #[instrument(skip_all, err(level = Level::WARN))] async fn get_block_timestamp(&self) -> Result