-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add flag to enable logging on rejected gossip message #11524
Conversation
beacon-chain/sync/subscriber.go
Outdated
func rejectGossipMessage(msg *pubsub.Message) pubsub.ValidationResult { | ||
if features.Get().EnableFullSSZDataLogging { | ||
log.WithField("rawMessage", msg).Debug("Rejected gossip message with data") | ||
} | ||
return pubsub.ValidationReject | ||
} |
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.
Could you add a function level comment?
What is the intended behavior of this function?
If you are trying to log the message as a ssz hex string, I don't think printing the Edit: Here's an example of something testing a log message:
Also see how require.LogsContain works. It should be able to read content from fields like when you do |
beacon-chain/sync/subscriber.go
Outdated
|
||
func rejectGossipMessage(msg *pubsub.Message) pubsub.ValidationResult { | ||
if features.Get().EnableFullSSZDataLogging { | ||
log.WithField("rawMessage", msg).Debug("Rejected gossip message with data") |
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.
If you want to match Teku's log, they also log the reason or error and topic.
Edit: Added "and topic". Teku logs the message, topic, and rejection reason / error
Yeah I think you want to convert this to a hex string that can be directly fed to a ssz marshaller. Also notice that it's mandatory to have the expected object at least, otherwise we won't know what schema to use to unmarshal |
I think https://pkg.go.dev/github.com/libp2p/go-libp2p-pubsub@v0.8.1/pb#Message |
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 isnt the correct place to check for it, it needs to be in our gossip handler wrapper.
Yes but if you print a byte slice with the logger it won't print it as a hex string, and also to decode the ssz you need to know what object the message was. |
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.
LGTM
What type of PR is this?
Feature
What does this PR do? Why is it needed?
This PR adds a new feature flag to enable logging on rejected gossip messages.
Which issues(s) does this PR fix?
Fixes #11431
Other notes for review
If we add this flag to the docs we need to make sure we add a note about the potential risks of running a node with this flag enabled as pointed out on the issue.
Essentially that this can easily become a potential DoS vector.