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

Fix #1297: Make Enrollments valid for nomination on only a single block height #1421

Merged
merged 7 commits into from Dec 21, 2020

Conversation

omerfirmak
Copy link
Contributor

With this, PreImages are consumed not by new enrollments but by new blocks. Commitments in new enrollments should be the PreImage that would be revealed on the height that Enrollment would be available.

More background info at #1297

Copy link
Contributor

@AndrejMitrovic AndrejMitrovic left a comment

Choose a reason for hiding this comment

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

A few comments.

source/agora/consensus/state/ValidatorSet.d Show resolved Hide resolved
source/agora/consensus/PreImage.d Outdated Show resolved Hide resolved
source/agora/consensus/PreImage.d Outdated Show resolved Hide resolved
source/agora/consensus/EnrollmentManager.d Show resolved Hide resolved
source/agora/consensus/validation/Block.d Show resolved Hide resolved
@AndrejMitrovic
Copy link
Contributor

@linked0 could you also take a look at this and tell us what you think?

@omerfirmak
Copy link
Contributor Author

Thanks for the review @AndrejMitrovic , all of your comments should be addressed now.

@AndrejMitrovic
Copy link
Contributor

It would be good to add a network test in source/agora/test/*. There are some examples there where a custom node is instantiated which behaves badly, a similar test could be added where a node tries enroll (or re-enroll) with an enrollment with the wrong random_seed.

@linked0
Copy link
Contributor

linked0 commented Dec 17, 2020

@linked0 could you also take a look at this and tell us what you think?

I'm reviewing it now. Sorry for the late review. Anyway, it looks really awesome. I will leave some comments or suggestions soon.

Copy link
Contributor

@linked0 linked0 left a comment

Choose a reason for hiding this comment

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

Good work and very important code change.
But the code about the avail_height was removed unintentionally. Some test code that changed does not go with the original purpose. Please check the comments.

source/agora/consensus/EnrollmentManager.d Show resolved Hide resolved
source/agora/consensus/EnrollmentManager.d Show resolved Hide resolved
source/agora/consensus/EnrollmentManager.d Show resolved Hide resolved
source/agora/consensus/EnrollmentManager.d Outdated Show resolved Hide resolved
source/agora/consensus/EnrollmentManager.d Outdated Show resolved Hide resolved
@omerfirmak
Copy link
Contributor Author

It would be good to add a network test in source/agora/test/*. There are some examples there where a custom node is instantiated which behaves badly, a similar test could be added where a node tries enroll (or re-enroll) with an enrollment with the wrong random_seed.

Yeah, I wanted to get some feedback before writing a network test.

@omerfirmak
Copy link
Contributor Author

Added the network test.

This field would indicate if a enrollment is active or not. It lets
expired enrollment entries to linger so that once that Validator would
re-enroll we can validate its commitment.
Enrollments will be validated against the past Enrollments to eliminate
the replay attack described in Issue bosagora#1297. For this we need a way to
efficiently query past enrollments.
As explained in Issue bosagora#1297, current Enrollments can be reused by a
third party any time. With Enrollments including the PreImage that
of the current height, they will be only valid for a single block.
@omerfirmak
Copy link
Contributor Author

Thanks for the review, @linked0 . I have rebased to v0.x.x.

Copy link
Contributor

@linked0 linked0 left a comment

Choose a reason for hiding this comment

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

Great work.
Some suggestions.

source/agora/test/ValidatorRecurringEnrollment.d Outdated Show resolved Hide resolved
source/agora/test/ValidatorRecurringEnrollment.d Outdated Show resolved Hide resolved
source/agora/test/ValidatorRecurringEnrollment.d Outdated Show resolved Hide resolved
source/agora/test/ValidatorRecurringEnrollment.d Outdated Show resolved Hide resolved
source/agora/test/ValidatorRecurringEnrollment.d Outdated Show resolved Hide resolved
source/agora/test/ValidatorRecurringEnrollment.d Outdated Show resolved Hide resolved
source/agora/test/ValidatorRecurringEnrollment.d Outdated Show resolved Hide resolved
With the enrollments being valid for only a single height, enrollemnts
in the pool should be revalidated before nomination.
@omerfirmak
Copy link
Contributor Author

omerfirmak commented Dec 18, 2020

I've applied the changes you suggested @linked0. I'll take a look at the CircleCI failure. Integration tests on my local machine has no problems, its weird.

@codecov
Copy link

codecov bot commented Dec 18, 2020

Codecov Report

Merging #1421 (c0993fa) into v0.x.x (a92aead) will increase coverage by 0.15%.
The diff coverage is 96.20%.

Impacted file tree graph

@@            Coverage Diff             @@
##           v0.x.x    #1421      +/-   ##
==========================================
+ Coverage   81.14%   81.30%   +0.15%     
==========================================
  Files         120      120              
  Lines       10551    10678     +127     
==========================================
+ Hits         8562     8682     +120     
- Misses       1989     1996       +7     
Flag Coverage Δ
integration 37.87% <52.94%> (-0.18%) ⬇️
unittests 79.97% <96.20%> (+0.17%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
source/agora/node/Validator.d 94.00% <ø> (ø)
source/agora/test/QuorumPreimage.d 70.27% <ø> (ø)
source/agora/consensus/validation/Block.d 96.89% <78.26%> (-1.12%) ⬇️
source/agora/test/ValidatorRecurringEnrollment.d 93.75% <93.10%> (-0.99%) ⬇️
source/agora/consensus/state/ValidatorSet.d 88.40% <94.11%> (+0.77%) ⬆️
source/agora/consensus/EnrollmentManager.d 95.36% <100.00%> (+1.21%) ⬆️
source/agora/consensus/EnrollmentPool.d 83.17% <100.00%> (-2.68%) ⬇️
source/agora/consensus/PreImage.d 71.42% <100.00%> (+4.76%) ⬆️
source/agora/consensus/validation/Enrollment.d 98.85% <100.00%> (+0.43%) ⬆️
source/agora/node/Ledger.d 95.52% <100.00%> (ø)
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a92aead...c0993fa. Read the comment docs.

@omerfirmak
Copy link
Contributor Author

All green

@AndrejMitrovic AndrejMitrovic merged commit b6c7b12 into bosagora:v0.x.x Dec 21, 2020
@AndrejMitrovic
Copy link
Contributor

Thank you @omerfirmak, nice job!

Thanks @linked0 for the review!

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