nervosnetwork / ckb-light-client

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

fix: allow no matched blocks for samples in the range of boundary block #80

Closed yangby-cryptape closed 2 years ago

yangby-cryptape commented 2 years ago

Issue

Assume the environment is as following:

So the server should reply proof for blocks [1, 2, 3, 7, 8, 9] to the client.

But the client will raise an error because there is no matched block for 50 and 50 is not in the difficulty range of those continuous blocks.

How to Fix

Before this PR, the check for difficulties without matched blocks is:

After this PR, change the check to be:

Commits

p.s. Review the last commit first is easier because the code for fix is only 1 lines, half code for logs and others for a test.

codecov-commenter commented 2 years ago

Codecov Report

Base: 76.75% // Head: 75.99% // Decreases project coverage by -0.76% :warning:

Coverage data is based on head (72ac841) compared to base (d1e670d). Patch coverage: 31.88% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #80 +/- ## =========================================== - Coverage 76.75% 75.99% -0.77% =========================================== Files 23 23 Lines 4208 4265 +57 =========================================== + Hits 3230 3241 +11 - Misses 978 1024 +46 ``` | Flag | Coverage Δ | | |---|---|---| | unittests | `75.99% <31.88%> (-0.77%)` | :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. | [Impacted Files](https://codecov.io/gh/nervosnetwork/ckb-light-client/pull/80?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nervosnetwork) | Coverage Δ | | |---|---|---| | [...s/light\_client/components/send\_last\_state\_proof.rs](https://codecov.io/gh/nervosnetwork/ckb-light-client/pull/80/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nervosnetwork#diff-c3JjL3Byb3RvY29scy9saWdodF9jbGllbnQvY29tcG9uZW50cy9zZW5kX2xhc3Rfc3RhdGVfcHJvb2YucnM=) | `84.78% <31.88%> (-6.51%)` | :arrow_down: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nervosnetwork). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nervosnetwork)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.