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

Reverse PendingTx chain id args and remove its Display impl #1843

Merged
merged 2 commits into from
Feb 14, 2022

Conversation

seanchen1991
Copy link
Contributor

@seanchen1991 seanchen1991 commented Feb 4, 2022

Closes: #1488

Description

Reverses the order of the chain_id and counterparty_chain_id arguments when displaying a PendingTx. PendingTx's Display impl was also removed as per the recent log reformatting work.

I'm not sure I went about this in the best way though. Is there a better way to handle constructing the relay path? Also, why is that for PendingTx's, the order of the chain IDs need to be reversed in the first place? Is this actually correct?


PR author checklist:

  • Added changelog entry, using unclog.
  • Added tests: integration (for Hermes) or unit/mock tests (for modules).
  • Linked to GitHub issue.
  • Updated code comments and documentation (e.g., docs/).

Reviewer checklist:

  • Reviewed Files changed in the GitHub PR explorer.
  • Manually tested (in case integration/unit/mock tests are absent).

@seanchen1991 seanchen1991 requested review from mzabaluev and removed request for ancazamfir February 4, 2022 21:22
Comment on lines 84 to 85
"[{}] putting error response in error event queue: {:?} ",
self,
&relay_path,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is better, but I'd rather rework all these [{}] constructs into span-wise KVs whenever the opportunity arises, as was partially done in #1491.

Copy link
Contributor Author

@seanchen1991 seanchen1991 Feb 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rework all these [{}] constructs into span-wise KVs

I'm not entirely clear what this means. What will the resulting log lines look like?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely clear what this means. What will the resulting log lines look like?

That will depend on the tracing backend. One of the benefits of using KVs is that they are converted into similar structural fields in logging backends supporting this (e.g. journald). In the terminal output subscriber that is used by Hermes now, a tracing event in a span created with span!(tracing::Level::ERROR, "some_op", chain="foo", connection="bar") will look something like this (with some bold and italic font styling added on an ANSI terminal):

some_op{chain=foo connection=bar}: here comes the event message

So, the information will still be flattened in this simple backend, but it will be easy to decipher and search for (if a bit more verbose).

Copy link
Member

@romac romac Feb 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's perhaps add a span to this method, as @mzabaluev suggests:

    let span = trace_span!(
             "inserting new pending txs",
             chain = %relay_path.chain_id()
             counterparty_chain = %relay_path.counterparty_chain_id,
             port = %relay_path.port_id,
             channel = %relay_path.channel_id,
    );

    let _guard = span.enter();

Comment on lines 128 to 134
format!(
"{}:{}/{} -> {}",
self.counterparty_chain_id,
self.port_id,
self.channel_id,
self.chain_id()
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these could rather be in KV pairs to potentially aid log filtering.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess they could but they're also useful when combing through the logs "by hand". But perhaps we can have both?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But perhaps we can have both?

I'm not sure what's the best way to go about achieving this.

Copy link
Member

@romac romac Feb 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave it like this for now and see if we can improve things in another PR. Nevermind, let's do this: https://github.com/informalsystems/ibc-rs/pull/1843/files/31d0316899456fe9de31fe4991fb10b98b8b5707#r803620700

Copy link
Contributor

@mzabaluev mzabaluev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good inasmuch as it resolves the representation problem in logs.

@seanchen1991
Copy link
Contributor Author

seanchen1991 commented Feb 10, 2022

Incorporating the changes suggested by @mzabaluev and @romac produces pending transaction logs structured like this:

2022-02-10T16:57:04.094471Z  INFO ThreadId(27) packet_cmd{src_chain=network2 src_port=transfer src_channel=channel-0 dst_chain=network1}:relay{odata=kFyYp1_fHH ->Destination @0-111380; len=1}: success                                                                     
2022-02-10T16:57:04.176579Z TRACE ThreadId(27) packet_cmd{src_chain=network2 src_port=transfer src_channel=channel-0 dst_chain=network1}:processing pending tx{chain=network1 counterparty_chain=network2 port=transfer channel=channel-0}: trying to confirm TxHashes: count=1; 56CA346F921BBD61A96AED34A4D281DFA4B8388E095B3CE9CA26839C2944C364 

compared to the previous style:

2022-02-01T16:58:45.701278Z  INFO ThreadId(27) [network2:transfer/channel-0 -> network1] success
2022-02-01T16:58:45.701300Z TRACE ThreadId(27) [network2:transfer/channel-0 -> network1] trying to confirm TxHashes: count=1; 122F297830AAE108E14695763F054C7106B094828C259140874D8C01C734EF43 

@romac
Copy link
Member

romac commented Feb 11, 2022

@adizere What do you think?

@adizere
Copy link
Member

adizere commented Feb 14, 2022 via email

Copy link
Member

@adizere adizere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, neat work here! Glad we're slowly getting rid of fmt::Displays.

@adizere adizere merged commit 6506555 into informalsystems:master Feb 14, 2022
@adizere
Copy link
Member

adizere commented Feb 14, 2022

I went ahead and merged, though I overlooked theres was no changelog entry. Cc @seanchen1991 to remember the changelogs in future PRs.

@seanchen1991 seanchen1991 deleted the pending-tx-logs branch February 14, 2022 16:40
hu55a1n1 pushed a commit to hu55a1n1/hermes that referenced this pull request Sep 13, 2022
…systems#1843)

* Reverse PendingTx chain id args and remove its Display impl

* Add `trace_spans` and remove `relay_path` method.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Confusing debug fmt string for PendingTx
4 participants