nervosnetwork / ckb-light-client

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

feat: ban a peer if its last state isn't changed after timeout #170

Closed yangby-cryptape closed 8 months ago

yangby-cryptape commented 8 months ago

Description

If a peer sent the same state to light client again and again, light client should ban it.

Just let the light client don't update the update timestamp for cached last-state if it isn't changed, and ban the peer when do timeout checks.

https://github.com/nervosnetwork/ckb-light-client/blob/86865dbb450753e73c5755a75e52b779231a3114/src/protocols/light_client/mod.rs#L502-L507

https://github.com/nervosnetwork/ckb-light-client/blob/86865dbb450753e73c5755a75e52b779231a3114/src/protocols/mod.rs#L25-L26

Commits:

codecov-commenter commented 8 months ago

Codecov Report

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

Comparison is base (86865db) 71.39% compared to head (b553660) 71.37%.

Files Patch % Lines
src/protocols/light_client/peers.rs 42.85% 8 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #170 +/- ## =========================================== - Coverage 71.39% 71.37% -0.03% =========================================== Files 25 25 Lines 6479 6498 +19 =========================================== + Hits 4626 4638 +12 - Misses 1853 1860 +7 ``` | [Flag](https://app.codecov.io/gh/nervosnetwork/ckb-light-client/pull/170/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/170/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nervosnetwork) | `71.37% <75.75%> (-0.03%)` | :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.