[PVM, DAC] Bugfixes, tests, early-exit by fail #284
Merged
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.
Why this should be merged
Bugfixes
Fixes following bugs:
Tests
PR also adds unit tests for proposal Verify, IsSuccessful, CanBeFinished implementations and slightly improves camino service GetBalance test.
AddProposalTx changes
PR adds new field to tx:
This field is limited to 2048 bytes, corresponding checks in syntactic verify, tests updated
Early-exit by fail
PR adds new early exit condition for base fee proposal:
Basically, this means, that if proposal most voted option can't get enough votes even if all not-yet casted votes would be casted for this option, than proposal is already failed and can be finished.
This is irrelevant for add/exclude member proposals, cause they have just 2 options and its impossible to not reach mostVotedTheshold without at least 3 options.
How this works
Regarding add/exclude member proposals bugs, PR adds corresponding checks to proposal verifier methods:
Regarding
baseFeeProposal
, corresponding checks were insimpleVoteOptions
- generic struct that was part ofProposalState
.ProposalState
is created by node onaddProposalTx
execution and should always be valid, soproposalState.Verify
was never called. PR removes this function and moves its logic tobaseFeeProposal.Verify
(other existing proposal types doesn't have options, e.g. add/exclude member), which is implementation ofproposal.Verify
and is called onaddProposalTx
execution beforeproposalState
is created.How this was tested
Unit tests, integration tests