Optimization of vote validation in BlockCommit
I don't have any strong opinion, just asking for your opinion. Each
HasTwoThirdsCommits(),HasSameValidators(),HasValidVotes()will perform iteration, so if we want to validate, it will take 3 times of iteration. Compared to single validation method with multiple exception cases, this implementation is much clear but may needs more computation. If we don't have to perform individual validation, may be integrating them would be also an option I think, though not sure if it's a better design. (Current design is obviously clearer for reading)
Originally posted by @OnedgeLee in https://github.com/planetarium/libplanet/pull/2331#discussion_r991804130
The current implementation of validating BlockCommit is done in multiple iterations. HasSameValidators(), HasValidVotes() and HasTwoThirdsCommits() can be checked in one iteration:
For a vote in BlockCommit checks,
- Whether a vote is created by a validator in
ValidatorSet, - Whether a vote has a valid signature,
- If the current iteration is enough to have +2/3 commit votes then the iteration can stop.
I'm kinda already working on this, so I'll take it. 😗
This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.