-
Notifications
You must be signed in to change notification settings - Fork 117
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
Decide if Zebra is at the chain tip #2722
Conversation
The function Also note that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good minimal implementation.
We can tweak the constants later during testing, if needed.
It looks like the waits_until_close_to_tip
test is failing because it assumes that a random series of sync lengths will always be close to the tip. (Which isn't true.)
And in this PR we actually check the lengths, so the test fails.
@jvff should be able to help out here.
I think this looks pretty good. Should we create a specific test for it or our current tests covers it ? |
I think the proptest is good, but I'd also like us to test some test vectors. For example:
Those are 3 basic tests that should keep on working, even if we tweak the algorithm or constants. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! If you need any help adding the test vectors, let me know 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make clippy happy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests look good to me, nice job.
Motivation
Zebra needs a way to tell when it has reached the chain tip.
Closes #2592.
Solution
This PR simply calculates the average recent sync length, and returns
true
if this value falls below 20. This constant (20) is based on #2592 (comment).Reviewer Checklist