-
Notifications
You must be signed in to change notification settings - Fork 226
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
Validate construction and deserialization of validator::Set
#1350
Conversation
If the field is present, deserialize it into the struct field rather than skipping it completely. This will allow validation when deserializing validator::Set in tendermint.
Calculate the total voting power without overflows and validate against the protocol-defined limit, provided as the Set::MAX_TOTAL_VOTING_POWER const. In the conversion from tendermint-proto struct VaidatorSet, check the unmarshalled total_voting_power value to match the calculated sum of the list's validators, unless it's the default 0.
Use the validating conversion from the protobuf struct ValidatorSet, which should have the same schema including the optionally deserialized total_voting_power field. This is to ensure we don't blindly trust total_voting_power if it's present in the serialization, and accept when it's absent.
The Display impl called itself in infinite recursion.
These are used in serialization for ValidatorSet and LightClientAttackEvidence.
Codecov Report
@@ Coverage Diff @@
## main #1350 +/- ##
=======================================
- Coverage 59.5% 59.5% -0.1%
=======================================
Files 272 273 +1
Lines 26974 26986 +12
=======================================
- Hits 16068 16060 -8
- Misses 10906 10926 +20
... and 11 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Test for correct deserialization, the total voting power exceeding the protocol-defined limit, the total voting power computation that would overflow the u64 rejecting the value with the appropriate error, and a mismatch of total_voting_power field value.
Some light-client-js tests use fixtures where it was null. The field used to be skipped in previous serialization.
The optimization broke deserialize with deserializers that cannot always borrow.
validator::Set
Python tricked me and the values were a bit low.
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.
Great work, thanks! 🙏
Closes #1348
Use the validating conversion from the protobuf struct
ValidatorSet
, which has the same schema including the now optionally deserializedtotal_voting_power
field.This is to ensure we don't blindly trust
total_voting_power
if it'spresent in the serialization, and accept when it's absent.
Also ensure no integer overflows can occur while calculating the total voting power, and check the resulting power against
the protocol-defined sanity limit.
.changelog/