-
Notifications
You must be signed in to change notification settings - Fork 16
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
feat: check block filter hashes #132
feat: check block filter hashes #132
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## develop #132 +/- ##
===========================================
- Coverage 79.35% 69.71% -9.64%
===========================================
Files 23 26 +3
Lines 4950 6373 +1423
===========================================
+ Hits 3928 4443 +515
- Misses 1022 1930 +908
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
5ec5fd4
to
c2a005f
Compare
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 PR's code logic looks good to me, leave only some code style comments.
Commits
refactor: move some data from peer state to peer itself
Why? Some data are not belongs to the peer state, when state was changed, those data should keep as before.
N.B. Rename many
peer
topeer_index
sincepeer
andpeer_index
are different things.refactor: refactor peer state to be a state machine
Why? It's hard to use a lot of
.some()
to distinguish the peer state.The complexity of that struct grows exponentially.
refactor: better judgment for timeout
Remove several TODO.
chore(deps): bump ckb from 0.106.0 to 0.108.0
feat: check block filter hashes
First, the light client will try to connect more than
max_outband_peers
peers.If a check point was confirmed by more than
max_outband_peers / 2
peers and there are more thancheck_point_interval
blocks between it and the last proved number, we finalized it and store it in to disk.N.B. A finalized check point could not roll back! Since it's a long fork.
After a check point was finalized, for each peer, light client will maintain a list of block filters between that check point and the last proved number.
Denote those lists as
[L]
(called as "latest block filter hashes" in the code).If light client want to get block filters for blocks which start number is
N
:If
N
is less than the finalized check point number, and it is between the check pointM
and check pointM+1
, light client will request the hashes between check pointM
and check pointM+1
(called as "cached block filter hashes" in the code).After all hashes were downloaded, then light client will request the block filters and checks them with those hashes.
If
N
is greater than the finalized check point number, then light client will only request the block filters which were confirmed by more thanmax_outband_peers / 2
peers in[L]
, and check those block filters with hashes in[L]
.TODO