Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up and improve logs #2544

Merged
merged 35 commits into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
32cf498
Instrument more functions using `tracing`
romac Aug 9, 2022
db00740
Use error level everywhere
romac Aug 10, 2022
267a30c
Bit more cleanup
romac Aug 10, 2022
6e9061e
Instrument more functions under the `chain::cosmos` module
romac Aug 10, 2022
080d863
Merge branch 'master' into romac/cleanup-logs
romac Aug 10, 2022
d781630
Removed debug log which outputs the options passed to CLIs
ljoss17 Aug 11, 2022
759c6ac
Cleanup imports
romac Aug 11, 2022
b8f9b5b
Remove `Serialize` bound on `ChainHandle`
romac Aug 11, 2022
df1055a
Remove `Serialize` instances on `ChainHandle` imps
romac Aug 11, 2022
f38dcd2
Preserve current tracing span across the runtime boundary
romac Aug 11, 2022
dae97a9
Remove ad-hoc Display and Debug impl for client and channel events
romac Aug 11, 2022
efbbb40
Improve spawning logs
romac Aug 11, 2022
2e5cec3
Better span for some workers
romac Aug 11, 2022
06a9c54
Extract telemetry code into its own function
romac Aug 11, 2022
4ed6a4e
Few more improvements
romac Aug 11, 2022
75cb215
Tighter Display impl for account-related newtypes
romac Aug 11, 2022
6bfc72b
Add `Display` impl for `version::Specs`
romac Aug 11, 2022
d611f24
Fix clippy warning
romac Aug 11, 2022
ea9a6aa
Cleanup `From` instace for `PathIdentifiers`
romac Aug 11, 2022
a0c7b49
Merge branch 'master' into romac/cleanup-logs
ljoss17 Aug 16, 2022
a528046
Fixed bugs from merge. Clippy and cargo fmt
ljoss17 Aug 16, 2022
3034db8
Emit JSON to stdout
romac Aug 16, 2022
157db23
More instrumentation in `relay_path`
romac Aug 17, 2022
a0971c9
replaced {:#?} by {:?}
Aug 18, 2022
e17b0b7
Updated metrics for events and added comment for method recording met…
ljoss17 Aug 22, 2022
82acba0
Replace all the Debug with Display fmt for 'info!', 'warn!' and 'erro…
ljoss17 Aug 24, 2022
0ed9e6e
Merge branch 'master' into romac/cleanup-logs
ljoss17 Aug 24, 2022
8eabb06
Fixed issues following merge with master. Added comment
ljoss17 Aug 24, 2022
f47801d
Updated std::time to core::time in modules pretty.rs file
ljoss17 Aug 24, 2022
ab72083
Removed line returns in info logs
ljoss17 Aug 25, 2022
8450bf1
Merge branch 'master' into romac/cleanup-logs
ljoss17 Aug 31, 2022
bdb3ac2
Merge branch 'master' into romac/cleanup-logs
ljoss17 Sep 1, 2022
0cfbb10
Merge branch 'master' into romac/cleanup-logs
romac Sep 7, 2022
e2f3117
Add changelog entry
romac Sep 7, 2022
5b1a28d
Merge branch 'master' into romac/cleanup-logs
romac Sep 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Clean up the logs emitted by the relayer and add more
structured information to the messages recorded in the logs
([#1538](https://github.com/informalsystems/ibc-rs/issues/1538))
4 changes: 2 additions & 2 deletions modules/src/applications/transfer/acknowledgement.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use core::fmt::{Display, Formatter};
use core::fmt::{Display, Error as FmtError, Formatter};

use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -51,7 +51,7 @@ impl AsRef<[u8]> for Acknowledgement {
}

impl Display for Acknowledgement {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
match self {
Acknowledgement::Success(_) => write!(f, "{}", ACK_SUCCESS_B64),
Acknowledgement::Error(err_str) => write!(f, "{}", err_str),
Expand Down
18 changes: 9 additions & 9 deletions modules/src/applications/transfer/denom.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use core::fmt;
use core::fmt::{Display, Error as FmtError, Formatter};
use core::str::FromStr;

use derive_more::{Display, From, Into};
Expand Down Expand Up @@ -50,8 +50,8 @@ impl TracePrefix {
}
}

impl fmt::Display for TracePrefix {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
impl Display for TracePrefix {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
write!(f, "{}/{}", self.port_id, self.channel_id)
}
}
Expand Down Expand Up @@ -128,8 +128,8 @@ impl FromStr for TracePath {
}
}

impl fmt::Display for TracePath {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
impl Display for TracePath {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
let path = self
.0
.iter()
Expand Down Expand Up @@ -267,8 +267,8 @@ impl From<BaseDenom> for PrefixedDenom {
}
}

impl fmt::Display for PrefixedDenom {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
impl Display for PrefixedDenom {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
if self.trace_path.0.is_empty() {
write!(f, "{}", self.base_denom)
} else {
Expand Down Expand Up @@ -349,8 +349,8 @@ impl From<BaseCoin> for PrefixedCoin {
}
}

impl fmt::Display for PrefixedCoin {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
impl Display for PrefixedCoin {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
write!(f, "{}-{}", self.amount, self.denom)
}
}
Expand Down
10 changes: 9 additions & 1 deletion modules/src/clients/ics07_tendermint/header.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use alloc::string::ToString;
use core::cmp::Ordering;
use core::fmt::{Display, Error as FmtError, Formatter};

use bytes::Buf;
use ibc_proto::google::protobuf::Any;
Expand All @@ -15,6 +16,7 @@ use crate::core::ics02_client::client_type::ClientType;
use crate::core::ics02_client::error::Error as Ics02Error;
use crate::core::ics24_host::identifier::ChainId;
use crate::timestamp::Timestamp;
use crate::utils::pretty::{PrettySignedHeader, PrettyValidatorSet};
use crate::Height;

pub const TENDERMINT_HEADER_TYPE_URL: &str = "/ibc.lightclients.tendermint.v1.Header";
Expand All @@ -30,11 +32,17 @@ pub struct Header {
}

impl core::fmt::Debug for Header {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
write!(f, " Header {{...}}")
}
}

impl Display for Header {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
write!(f, "Header {{ signed_header: {}, validator_set: {}, trusted_height: {}, trusted_validator_set: {} }}", PrettySignedHeader(&self.signed_header), PrettyValidatorSet(&self.validator_set), self.trusted_height, PrettyValidatorSet(&self.trusted_validator_set))
}
}

impl Header {
pub fn height(&self) -> Height {
Height::new(
Expand Down
2 changes: 1 addition & 1 deletion modules/src/clients/ics07_tendermint/misbehaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl core::fmt::Display for Misbehaviour {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> {
write!(
f,
"{:?} h1: {:?}-{:?} h2: {:?}-{:?}",
"{} h1: {}-{} h2: {}-{}",
self.client_id,
self.header1.height(),
self.header1.trusted_height,
Expand Down
6 changes: 3 additions & 3 deletions modules/src/core/ics02_client/client_type.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::prelude::*;
use core::fmt;
use core::fmt::{Display, Error as FmtError, Formatter};
use serde_derive::{Deserialize, Serialize};

use super::error::Error;
Expand Down Expand Up @@ -30,8 +30,8 @@ impl ClientType {
}
}

impl fmt::Display for ClientType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
impl Display for ClientType {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
write!(f, "ClientType({})", self.as_str())
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/src/core/ics02_client/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ define_error! {
latest_height: Height
}
| e | {
format!("received header height ({:?}) is lower than (or equal to) client latest height ({:?})",
format!("received header height ({}) is lower than (or equal to) client latest height ({})",
e.header_height, e.latest_height)
},

Expand Down
72 changes: 47 additions & 25 deletions modules/src/core/ics02_client/events.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Types for the IBC events emitted from Tendermint Websocket by the client module.

use core::fmt::{Display, Error as FmtError, Formatter};
use serde_derive::{Deserialize, Serialize};
use tendermint::abci::tag::Tag;
use tendermint::abci::Event as AbciEvent;
Expand Down Expand Up @@ -42,6 +43,12 @@ impl NewBlock {
}
}

impl Display for NewBlock {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
write!(f, "NewBlock {{ height: {} }}", self.height)
}
}

impl From<NewBlock> for IbcEvent {
fn from(v: NewBlock) -> Self {
IbcEvent::NewBlock(v)
Expand All @@ -65,6 +72,16 @@ impl Default for Attributes {
}
}

impl Display for Attributes {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
write!(
f,
"Attributes {{ client_id: {}, client_type: {}, consensus_height: {} }}",
self.client_id, self.client_type, self.consensus_height
)
}
}

/// Convert attributes to Tendermint ABCI tags
///
/// # Note
Expand All @@ -91,12 +108,6 @@ impl From<Attributes> for Vec<Tag> {
}
}

impl core::fmt::Display for Attributes {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> {
write!(f, "cs_h: {}({})", self.client_id, self.consensus_height)
}
}

/// CreateClient event signals the creation of a new on-chain client (IBC client).
#[derive(Debug, Serialize, Clone, PartialEq, Eq)]
pub struct CreateClient(pub Attributes);
Expand All @@ -107,6 +118,12 @@ impl CreateClient {
}
}

impl Display for CreateClient {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
write!(f, "CreateClient {{ {} }}", self.0)
}
}

impl From<Attributes> for CreateClient {
fn from(attrs: Attributes) -> Self {
CreateClient(attrs)
Expand All @@ -129,14 +146,8 @@ impl From<CreateClient> for AbciEvent {
}
}

impl core::fmt::Display for CreateClient {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> {
write!(f, "{}", self.0)
}
}

/// UpdateClient event signals a recent update of an on-chain client (IBC Client).
#[derive(Serialize, Clone, PartialEq)]
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct UpdateClient {
pub common: Attributes,
pub header: Option<Box<dyn Header>>,
Expand All @@ -156,6 +167,17 @@ impl UpdateClient {
}
}

impl Display for UpdateClient {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
// TODO Display: Check for a solution for Box<dyn Header>
write!(
f,
"UpdateClient {{ common: {}, header: None }}",
self.common
)
}
}

impl From<Attributes> for UpdateClient {
fn from(attrs: Attributes) -> Self {
UpdateClient {
Expand Down Expand Up @@ -188,18 +210,6 @@ impl From<UpdateClient> for AbciEvent {
}
}

impl core::fmt::Display for UpdateClient {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> {
write!(f, "{}", self.common)
}
}

impl core::fmt::Debug for UpdateClient {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.common)
}
}

/// ClientMisbehaviour event signals the update of an on-chain client (IBC Client) with evidence of
/// misbehaviour.
#[derive(Debug, Serialize, Clone, PartialEq, Eq)]
Expand All @@ -211,6 +221,12 @@ impl ClientMisbehaviour {
}
}

impl Display for ClientMisbehaviour {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
write!(f, "ClientMisbehaviour {{ {} }}", self.0)
}
}

impl From<Attributes> for ClientMisbehaviour {
fn from(attrs: Attributes) -> Self {
ClientMisbehaviour(attrs)
Expand Down Expand Up @@ -243,6 +259,12 @@ impl UpgradeClient {
}
}

impl Display for UpgradeClient {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
write!(f, "UpgradeClient {{ {} }}", self.0)
}
}

impl From<Attributes> for UpgradeClient {
fn from(attrs: Attributes) -> Self {
UpgradeClient(attrs)
Expand Down
9 changes: 6 additions & 3 deletions modules/src/core/ics02_client/trust_threshold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
//! represented as a fraction with valid values in the
//! range `[0, 1)`.

use core::{convert::TryFrom, fmt};
use core::{
convert::TryFrom,
fmt::{Display, Error as FmtError, Formatter},
};

use ibc_proto::protobuf::Protobuf;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -123,8 +126,8 @@ impl Default for TrustThreshold {
}
}

impl fmt::Display for TrustThreshold {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
impl Display for TrustThreshold {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
write!(f, "{}/{}", self.numerator, self.denominator)
}
}
9 changes: 6 additions & 3 deletions modules/src/core/ics03_connection/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ use crate::prelude::*;

use core::str::FromStr;
use core::time::Duration;
use core::{fmt, u64};
use core::{
fmt::{Display, Error as FmtError, Formatter},
u64,
};

use ibc_proto::protobuf::Protobuf;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -366,8 +369,8 @@ impl State {
}
}

impl fmt::Display for State {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
impl Display for State {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
write!(f, "{}", self.as_str())
}
}
Expand Down
Loading