filecoin-project / lotus

Reference implementation of the Filecoin protocol, written in Go
https://lotus.filecoin.io/
Other
2.81k stars 1.25k forks source link

wire-level message tracing for selected protocols #6325

Open raulk opened 3 years ago

raulk commented 3 years ago

There are several protocols in the Filecoin stack that would benefit from message-level tracing. That is, tracing messages in and messages out on a DEBUG level, on dedicated loggers.

Some protocols are very interactive/chatty, and there are several things happening at once, so being able to inspect the actual flow of messages is very useful for debugging races and other conditions.

Such protocols include:

Proposal

Introduce the msgtrace/ prefix as a convention for these loggers. Logging happens at DEBUG level. For example, enabling the DEBUG level of msgtrace/datatransfer would have Lotus pring statements like this:

2021-05-25T00:00:01.000+0100  DEBUG  msgtrace/datatransfer  <<< [p: peerId]  (JSON-serialized protobuf, potentially eliding data fields)
2021-05-25T00:00:02.000+0100  DEBUG  msgtrace/datatransfer  >>> [p: peerId]  (JSON-serialized protobuf, potentially eliding data fields)
magik6k commented 3 years ago

I wonder if it is possible to create a wireshark plugin+libp2p plugin which would dump all streams from libp2p into wireshark

raulk commented 3 years ago

There was some exploration of that here: https://github.com/mikevoronov/libp2p-dissector, but I'm thinking of something simpler inside Lotus that can be enabled/disabled with lotus log set-level. We definitely don't want to maintain protocol parsers for go-data-transfer, graphsync, go-fil-markets, etc. elsewhere, at least for now.

dirkmc commented 3 years ago

I don't believe there's a way in lotus to output logs with a particular prefix / pattern. That would be helpful to be able to trace flow through different parts of the code (eg data transfer / graphsync / markets etc).