Skip to content
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

vochain: refactor vote transaction check #864

Merged
merged 2 commits into from
Mar 28, 2023
Merged

Conversation

p4u
Copy link
Member

@p4u p4u commented Mar 24, 2023

see commit messages

1. Reuse code and improve readability. Remove duplicates.
2. Add comments.
3. Fix issue with maxCensusSize and maxVoteOverwrite
   If a process already reached maxCensusSize, it should not
   discard votes that are doing an overwrite.
4. Use VoterID type instead of pubkey/address directly. So the
   pubkey/address primitives are now abstracted.

Signed-off-by: p4u <pau@dabax.net>
@p4u p4u force-pushed the f/refactor_vote_tx_check branch from d3ea4e7 to aa0b0ef Compare March 24, 2023 23:08
@@ -14,25 +14,35 @@ import (

// VoteTxCheck performs basic checks on a vote transaction.
func (t *TransactionHandler) VoteTxCheck(vtx *vochaintx.VochainTx, forCommit bool) (*vstate.Vote, error) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the method where I'd need review. It is a very crucial part of the system and the logic should be double-checked. @mvdan @altergui @lucasmenendez @jordipainan

Most of the functions we use from ethereum cryptography, are
defined in the crypt/ethereum package.

For coherency and better abstraction, we might use always the new
type ethereum.Address{} instead of common.Address{} (from go-ethereum).

Ideally the only package that would import the ethereum common and other
go-ethereum packages would be crypto/ethereum, while the others relay on
the types and primitives defined within crypto/ethereum.

This approach would also bring better flexibility for changing the address
schema to a new one.

This commit is only part of the work.

Signed-off-by: p4u <pau@dabax.net>
@p4u p4u force-pushed the f/refactor_vote_tx_check branch from 884099c to 511cd31 Compare March 28, 2023 07:02
@p4u p4u merged commit c1978b4 into master Mar 28, 2023
@p4u p4u deleted the f/refactor_vote_tx_check branch March 28, 2023 07:16
@altergui
Copy link
Contributor

altergui commented Mar 29, 2023

LGTM, i didn't do my review in time, sorry about that, but here's a small (late) contribution: what testsuite covers of VoteTxCheck (i.e. tested on each CI run). the only significant omission is "// if vote exists, check if it has reached the max overwrite count" this is not covered. but it's precisely what Maria is working on.

image
image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants