-
Notifications
You must be signed in to change notification settings - Fork 759
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
Client: fix rpc debug #3125
Client: fix rpc debug #3125
Conversation
Codecov Report
Additional details and impacted files
Flags with carried forward coverage won't be shown. Click here to find out more. |
RPC log truncating has a reason being mainly that from some RPC calls - particularly from the engine API - are so large that without truncating it is not possible any more to follow on the logging. Can't completely oversee the changes from this PR respectively what it does and what not, but we need to find a good balance here to for one allow that it becomes possible - if one is interested in the outcome of one particular call - to see the full output. And on the other hand that RPC logging also allows for this "overview log", so that one has a constant ouptut of calls without getting overwhelmed. |
Just some clarification, without this PR it seems that
Note: |
Yes, not sure if my comment was clear: rpcDebug logs needs to be truncated at least as an option, otherwise this becomes completely unreadable for certain use cases. I wonder if we eventually want to bite the sour bullet or whatever and DO another explicit option here?? Side note: beyond there are some RPC log inconsistencies in the client, e.g. parts of the (core) engine API (I think FCU and newPayload() ?) is not logged through the option but on normal debug mode, which is confusing and we should fix as well at some point. |
Ah ok good point, I just re-checked, we have this (also in this PR - it is unchanged), see if (show) {
if (logger?.level === 'debug') {
msg += `${request.method} called with params:\n${inspectParams(request.params)}`
} else {
msg += `${request.method} called with params: ${inspectParams(request.params, 125)}`
}
logger?.info(msg)
} Therefore, if |
packages/client/src/util/rpc.ts
Outdated
const onRequest = (request: any) => { | ||
let msg = '' | ||
if (rpcDebug && rpcDebug !== '') { | ||
let show = false | ||
if (rpcDebug === 'all') { | ||
if (rpcDebug === '' || rpcDebug === 'all') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are earlier checking rpcDebug !== ''
then we shouldn't need to check again if rpcDebug === ''
.
packages/client/bin/cli.ts
Outdated
@@ -207,7 +207,8 @@ const args: ClientOpts = yargs(hideBin(process.argv)) | |||
.option('rpcDebug', { | |||
describe: | |||
'Additionally log complete RPC calls filtered by name (prefix), e.g.: "eth,engine_getPayload" (use "all" for all methods).', | |||
default: '', | |||
coerce: (arg: string) => (arg === '' ? 'all' : arg), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I initially changed rpcDebug
to allow for indicating a specific package for full request/response log output, I included a description with details about the need for logLevel
being set to debug
and also included choices which allowed for boolean options or a specific module to be enabled by name, as well as a default of false
: b196a13. But now that we can pass in a comma separated string that could also include specific function names (e.g. eth,engine_getPayload
), I think that we can look into using a yargs check
function for the rpcDebug
option to first validate the input and throw helpful error messages so users aren't confused as well as extend our description to include more usage details and maybe even some examples.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, would agree that this is a thing that we should well-document (also for ourselves).
@@ -207,7 +207,8 @@ const args: ClientOpts = yargs(hideBin(process.argv)) | |||
.option('rpcDebug', { | |||
describe: | |||
'Additionally log complete RPC calls filtered by name (prefix), e.g.: "eth,engine_getPayload" (use "all" for all methods).', | |||
default: '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a default value can be more intuitive than removing it and instead having to handle undefined
as a value.
Yes, I was aware of this: debug -> full RPC log, otherwise -> truncated behavior. And, yes, I think it would be worth to be able to tackle this separately (I can vaguely remember that I might have already tried on the sideline at some point?). So an alternative to yet-another-flag might be that we add a keyword If this is added we do full logging ( |
Have tested using some hive tests and can report that it works like the top post suggests. CI should also pass. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me!
} | ||
logger?.info(msg) | ||
} | ||
if (checkFilter(request.method, rpcDebugVerbose)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To note, the options are:
- both
rpcDebugVerbose
andrpcDebug
are true, in which case the full version will be logged - both
rpcDebugVerbose
andrpcDebug
are false, in which case nothing will be logged on requests and responses rpcDebugVerbose
is true andrpcDebug
is false, in which case the full version will be loggedrpcDebugVerbose
is false andrpcDebug
is true, in which case the truncated version will be logged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, so for extra for clarification: the true
and false
are the returned values from this method, and are thus applied on the filter. If there is no filter (the filter is the empty string by default, so "no filter") then it always returns false
.
Have opened a PR for hive to update as well: ethereum/hive#939 |
Maybe I missed this: what was the reasoning here again to go for the yet-another-flag solution in favor to an existing-flag using version like |
The reasoning is that you can now for instance log verbose logs for |
Ah ok, no, makes sense, cool, thanks! |
The rpc debug is inconsistent and this PR fixes it. Currently it seems to always truncate RPC logs.
It adds a new flag
rpcDebugVerbose
which allows for a comma-separated list of methods to log in full. Same forrpcDebug
, this logs the commands but will truncate those. If bothrpcDebugVerbose
andrpcDebug
filters match the method, the log is not truncated. The necessity to--loglevel debug
is removed to log the methods in full (the logs are written to INFO).TODO: explicitly test this (but this should work)
Note: it is also possible to skip adding this new flag, and instead adding the word "verbose" to
rpcDebug
as suggested by Holger. However, this would imply that then all methods which match the filter are logged in verbose and I think this extra flag option gives us more freedom to explicitly verbose-log these methods.