mempool: Reject same block vote double spends. #1597
Merged
+137
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This requires #1595 and #1596.
Currently, the memory pool policy is to allow votes which double spend the same ticket (up to a maximum amount) since it is possible that the same ticket is selected in competing branches and thus the double spend must be allowed and will resolve itself depending on which chain is ultimately extended.
A side effect of that is that it also currently accepts votes with different hashes but otherwise both spend the same ticket and vote on the same block. This can happen when there are multiple wallets casting the vote with different settings such as when one has been upgraded to a new stake version while the others have not or an improperly configured wallet where the vote choices have been set on one, but not the others.
Consequently, this modifies the policy to explicitly reject these duplicate votes while still allowing votes on competing branches.
It also adds tests to ensure the new functionality works as expected.