nervosnetwork / ckb-light-client

CKB light client reference implementation
MIT License
14 stars 16 forks source link

fix: don't sync block filter hashes if finalized checkpoint is too less than the last proved header #169

Closed yangby-cryptape closed 8 months ago

yangby-cryptape commented 8 months ago

Why < self.check_point_interval * 2?

https://github.com/nervosnetwork/ckb-light-client/blob/fc45e35cd3ce40fae5762daa97e4c89991094262/src/protocols/light_client/peers.rs#L539-L541

Because light client don't finalize the latest checkpoint, light client will keep a checkpoint as a safe distance, so it doesn't have to rollback such many blocks even there is a fork. (N.B. Light client won't handle a long fork.)

So, as an approximated value, I use < self.check_point_interval * 2 here.

Ref: the 2nd issue in https://github.com/nervosnetwork/ckb-light-client/issues/168#issuecomment-1871169613.

codecov-commenter commented 8 months ago

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (fc45e35) 71.41% compared to head (82a46db) 71.39%.

Files Patch % Lines
src/protocols/light_client/peers.rs 50.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #169 +/- ## =========================================== - Coverage 71.41% 71.39% -0.02% =========================================== Files 25 25 Lines 6478 6479 +1 =========================================== Hits 4626 4626 - Misses 1852 1853 +1 ``` | [Flag](https://app.codecov.io/gh/nervosnetwork/ckb-light-client/pull/169/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nervosnetwork) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/nervosnetwork/ckb-light-client/pull/169/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nervosnetwork) | `71.39% <50.00%> (-0.02%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nervosnetwork#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.