Skip to content

Conversation

@PlasmaPower
Copy link
Contributor

Uses OffchainLabs/go-ethereum#192 to log all requests and responses at the trace level. The performance impact of this should be negligible compared to the network overhead of an RPC request in the first place, especially considering that the request/response will only be serialized for logging if that log level is enabled.

You can also live-reload the log level config to enable trace logging and see the L1 RPC requests and responses on an already running node.

@cla-bot cla-bot bot added the s Automatically added by the CLA bot if the creator of a PR is registered as having signed the CLA. label Jan 18, 2023
@codecov
Copy link

codecov bot commented Jan 18, 2023

Codecov Report

Merging #1441 (d721711) into master (3cdd35f) will decrease coverage by 3.81%.
The diff coverage is 18.75%.

❗ Current head d721711 differs from pull request most recent head 41b01eb. Consider uploading reports for the commit 41b01eb to get more accurate results

@@            Coverage Diff             @@
##           master    #1441      +/-   ##
==========================================
- Coverage   52.32%   48.52%   -3.81%     
==========================================
  Files         257      245      -12     
  Lines       34003    29915    -4088     
  Branches      555      555              
==========================================
- Hits        17793    14515    -3278     
+ Misses      14134    13314     -820     
- Partials     2076     2086      +10     

func (l RpcResultLogger) OnResult(response interface{}, err error) {
if err != nil {
// The request might not've been logged if the log level is debug not trace, so we log it again here
log.Debug("received error response from L1 RPC", "request", l.request, "response", response, "err", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

A warning or at least info seems in place?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm just not sure under what conditions this might appear, and don't want to concern users unnecessarily. But I'll make it an info 👍

log.Debug("received error response from L1 RPC", "request", l.request, "response", response, "err", err)
} else {
// The request was already logged and can be cross-referenced by JSON-RPC id
log.Trace("received response from L1 RPC", "response", response, "err", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

err is certainly nil here, no need to print.
Maybe this should be debug and OnRequest should stay trace?
(the amount of logs should be reasonable for what we get in Debug).

Copy link
Contributor Author

@PlasmaPower PlasmaPower Jan 19, 2023

Choose a reason for hiding this comment

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

The err thing was a leftover from a previous refactor, I'll remove that
The responses for querying blocks, logs, and txs can be really large so I'd prefer to keep this hidden from users unless they need it

// The request was already logged and can be cross-referenced by JSON-RPC id
log.Trace("received response from L1 RPC", "response", response, "err", err)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

To log all l1 - we should also add a print in HeaderReader when receiving events from SubscribeNewHead, same loglevel as OnResult. I think that's the only subscribe in nitro node.
We could add a hook in client for subscriptions - but since subscription is already a hook it seems redundant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added a log line there

Copy link
Contributor

@tsahee tsahee left a comment

Choose a reason for hiding this comment

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

LGTM

@PlasmaPower PlasmaPower enabled auto-merge January 19, 2023 22:14
@PlasmaPower PlasmaPower merged commit 3fc5383 into master Jan 19, 2023
@hkalodner hkalodner deleted the l1-rpc-logging branch February 23, 2023 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

s Automatically added by the CLA bot if the creator of a PR is registered as having signed the CLA.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants