Polite GRANDPA
Task summary
- Implement "polite GRANDPA" in Gossamer. Polite GRANDPA is a mechanism that allows participants in the GRANDPA protocol to score one another in order allow participants to prefer certain peers over others. Per @qdm12, per a conversation with Andre at Parity:
- It's impolite to get a message for a round > state round + 1
- It's impolite to get a message for a round < state round - 1
- Message signature verification fails
- Any other validation failure due to the message being malformed.
- The relevant Gossamer function is
validateVoteMessageinlib/grandpa/vote_message.go
Specification reference
- Refer to the following GRANDPA implementations in Substrate:
client/finality-grandpa/src/communication/gossip.rsandclient/finality-grandpa/src/communication/mod.rs
Upon investigating we found these relevant parts of the grandpa package:
- https://github.com/paritytech/substrate/blob/88731ed619f6be1280f01cc8f02f10e2fb4cf199/client/finality-grandpa/src/communication/mod.rs#L93
- https://github.com/paritytech/substrate/blob/88731ed619f6be1280f01cc8f02f10e2fb4cf199/client/finality-grandpa/src/communication/gossip.rs#L434
We think it will be useful to have a similar misbehavior function where we can calculate the costs based on the type of misbehavior within grandpa.
We will also create a README (or some other doc) to more clearly document reporting for polite grandpa.
The list of tasks involved in this issue will be split between @EclesioMeloJunior and myself. The plan currently is to work together to develop the framework for handling reporting and then to divide and conquer implementing each specific behavior. This will involve finding all cases where this behavior is to be reported and handling it as well as adding to the documentation details about the behavior and where it is used.
- [ ] Create README to document how polite grandpa reporting works (possibly to be published somewhere since current documentation is very poor)
- [ ] Create a framework for handling reporting for polite grandpa within the grandpa package. This includes defining the costs as well as the misbehavior function.
- [ ] PAST_REJECTION
- [ ] BAD_SIGNATURE
- [ ] MALFORMED_CATCH_UP
- [ ] MALFORMED_COMMIT
- [ ] FUTURE_MESSAGE
- [ ] UNKNOWN_VOTER
- [ ] INVALID_VIEW_CHANGE
- [ ] PER_UNDECODABLE_BYTE
- [ ] PER_SIGNATURE_CHECKED
- [ ] PER_BLOCK_LOADED
- [ ] INVALID_CATCH_UP
- [ ] INVALID_COMMIT
- [ ] OUT_OF_SCOPE_MESSAGE
- [ ] CATCH_UP_REQUEST_TIMEOUT
- [ ] CATCH_UP_REPLY
- [ ] HONEST_OUT_OF_SCOPE_CATCH_UP
- [ ] NEIGHBOR_MESSAGE
- [ ] ROUND_MESSAGE
- [ ] BASIC_VALIDATED_CATCH_UP
- [ ] BASIC_VALIDATED_COMMIT
- [ ] PER_EQUIVOCATION