-
Notifications
You must be signed in to change notification settings - Fork 20.5k
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
les: implement server handler fuzzer #22237
Conversation
miscServingTimeHelperTrieTimer.Update(servingTime) | ||
} | ||
|
||
func (r GetHelperTrieProofsReq) Serve(backend serverBackend, reqID uint64, p *clientPeer, waitOrStop func() bool) *reply { |
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.
Just curious, would it be possible to abstract away the reqID
from the method handler, and have that handled on the outside?
Like, reply.SetReqId(reqID)
?
I'm wondering, because for eth
, when we implement eth/66
, it would be neat to use a similar handling, but only set the reqId
on the response in the cases where the protocol is 66
.
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.
Well. Not sure it's necessary. REQID
exists in the protocol all the time.
cceec68
to
fb1f727
Compare
fb1f727
to
41f2410
Compare
e928f34
to
4312690
Compare
tests: update les fuzzer tests/fuzzer/les: release resources tests/fuzzer/les: pre-initialize all resources
4312690
to
1263724
Compare
Looks like the fuzzer now works correctly
|
} | ||
}() | ||
} | ||
r := GetBlockHeadersReq{} |
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.
@zsfelfoldi I change this to the struct instead of the pointer. Because I think the pointer is unnecessary.
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.
I'm a bit torn. You've rearchitected it so the basic pattern is
- Unmarshall
message
. - Call
message.Serve(backend, foo, bar...)
.
I'd prefer that it's not based on the actual messages doing the handling but instead
- Unmarshall the message
- Lookup the
handler
based on message id or type hander( msg, backend, foo, bar, ...)
github.com/dvyukov/go-fuzz v0.0.0-20210103155950-6a8e9d1f2415 h1:q1oJaUPdmpDm/VyXosjgPgr6wS7c5iV2p0PwJD73bUI= | ||
github.com/dvyukov/go-fuzz v0.0.0-20210103155950-6a8e9d1f2415/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw= |
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.
These shouldn't really be needed...?
@holiman I need a struct type definition for each message type in order to unmarshall so it just seemed logical to define the handler function over the message type structs. What is the drawback? Would you prefer putting the decoding of the actual request inside the handler functions? (that just seemed like unnecessary duplicated code to me because I want to do the same rlp decodind and decode error handling for each message type) |
This PR adds the LES fuzzer for fuzzing server handler.
Please keep the two commits from @zsfelfoldi if we decide to merge this PR.