-
Notifications
You must be signed in to change notification settings - Fork 20.2k
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
graphql: validate block params #27876
Conversation
Co-authored-by: Martin Holst Swende <[email protected]>
Hi, I personally disagree with the direction this goes -> Not because this is a bad idea, but because there is a language centric method of validation for things like this already in go-validator, here is an example of how that might look, although I'll allow you and the reviewer to decide on what that means for this PR and allow you to retain the edit :)!
above is the validation function, using go-validate, which would then run the validation and return an error inline. This is a much more go-thonic and sustainable way to do validation throughout etherium. This could compromise a substantial value add for other areas of the etherium project as well, providing more sustainable and expandable validation in many areas of the codebase. |
@wsb1994 I don't think we want to go down the route of annotating validation rules in struct tags. We use a handful of consensus structures which have wildly different validation criteria based on which entrypoint they appear in our codebase. Whether network propagation, RPC APIs, sync vs. block processing, etc. All in all I am not a fan of declarative rules, they almost always lack some flexibility that results in the same old custom code needing to be written anyway. |
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
Block takes a number and a hash. The spec is unclear on what should happen in this case, leaving it an implemenation detail. With this change, we return an error in case both number and hash are passed in.
This reverts commit 6396183.
This reverts commit 6396183.
Block takes a
number
and ahash
. The spec is unclear on this. My interpretation is either of these should be provided and we should error in case both are passed in.Fixes #25899