Closed yangby-cryptape closed 10 months ago
All modified lines are covered by tests :white_check_mark:
Comparison is base (
dfcd2cc
) 69.83% compared to head (96a9209
) 69.88%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Descriptions
Split (or access) the
start_index
-th item oflatest_block_filter_hashes
without checks.https://github.com/nervosnetwork/ckb-light-client/blob/02721f38854ad0722347e8d132d31c173dd7cdaf/src/protocols/filter/components/block_filters_process.rs#L159-L160
But
latest_block_filter_hashes
could be empty or less thanstart_index
.https://github.com/nervosnetwork/ckb-light-client/blob/02721f38854ad0722347e8d132d31c173dd7cdaf/src/protocols/light_client/peers.rs#L1713-L1715
Commits
Add a test to reproduce the bug.
Fix the bug.
Review this commit could find the difference on the unit test easier.
And could understand how does this bug happened and how to fix it easier.
Add more logs.
Error Logs
Full of the Error Logs
``` [2023-10-08T22:29:01Z TRACE ckb_light_client::protocols::status] LightClientProtocol.received SendLastStateProof from SessionId(7094), result OK(200) [2023-10-08T22:29:01Z TRACE ckb_light_client::protocols::synchronizer] SyncProtocol.received peer=SessionId(6201), message=GetHeaders [2023-10-08T22:29:02Z TRACE ckb_light_client::protocols::light_client] no fetching headers/transactions needed [2023-10-08T22:29:02Z TRACE ckb_light_client::protocols::synchronizer] SyncProtocol.received peer=SessionId(23), message=GetHeaders [2023-10-08T22:29:03Z TRACE ckb_light_client::protocols::filter::block_filter] could request block filters from 10888757 or not: true, finalized: index 5443, number 10886000; cached: index 5444, number 10888000, length 0; next cached: number 10890000 [2023-10-08T22:29:03Z DEBUG ckb_light_client::protocols::filter::block_filter] found best proved peer SessionId(9261) [2023-10-08T22:29:03Z TRACE ckb_light_client::protocols::filter::block_filter] no block filters is required to download [2023-10-08T22:29:04Z TRACE ckb_light_client::protocols::filter::block_filter] request block filter hashes from peer SessionId(7094), starts at 10886001 [2023-10-08T22:29:04Z TRACE ckb_light_client::protocols::filter::block_filter] request block filter hashes from peer SessionId(23), starts at 10888759 [2023-10-08T22:29:04Z TRACE ckb_light_client::protocols::filter::block_filter] request block filter hashes from peer SessionId(9262), starts at 10888759 [2023-10-08T22:29:04Z TRACE ckb_light_client::protocols::filter::block_filter] request block filter hashes from peer SessionId(9261), starts at 10888759 [2023-10-08T22:29:04Z TRACE ckb_light_client::protocols::filter::components::block_filter_hashes_process] peer SessionId(9261): last-state: PeerState::Ready { last_state: 10888759 }, add block filter hashes (start: 10888759, len: 1) and parent block filter hash is 0xc5ca1bf9b62cc39580d3619bf33081c7ee38bbe3a3dbfcdd9fe740da14b35d51 [2023-10-08T22:29:04Z TRACE ckb_light_client::protocols::filter::components::block_filter_hashes_process] finalized: index 5443, number 10886000; cached: index 5444, number 10888000, length 0; next cached: number 10890000 [2023-10-08T22:29:04Z TRACE ckb_light_client::protocols::status] BlockFilterProtocol.received BlockFilterHashes from SessionId(9261), result OK(200) [2023-10-08T22:29:04Z TRACE ckb_light_client::protocols::filter::components::block_filter_hashes_process] peer SessionId(9262): last-state: PeerState::Ready { last_state: 10888759 }, add block filter hashes (start: 10888759, len: 1) and parent block filter hash is 0xc5ca1bf9b62cc39580d3619bf33081c7ee38bbe3a3dbfcdd9fe740da14b35d51 [2023-10-08T22:29:04Z TRACE ckb_light_client::protocols::filter::components::block_filter_hashes_process] finalized: index 5443, number 10886000; cached: index 5444, number 10888000, length 0; next cached: number 10890000 [2023-10-08T22:29:04Z TRACE ckb_light_client::protocols::status] BlockFilterProtocol.received BlockFilterHashes from SessionId(9262), result OK(200) [2023-10-08T22:29:04Z TRACE ckb_light_client::protocols::filter::components::block_filter_hashes_process] peer SessionId(23): last-state: PeerState::Ready { last_state: 10888759 }, add block filter hashes (start: 10888759, len: 1) and parent block filter hash is 0xc5ca1bf9b62cc39580d3619bf33081c7ee38bbe3a3dbfcdd9fe740da14b35d51 [2023-10-08T22:29:04Z TRACE ckb_light_client::protocols::filter::components::block_filter_hashes_process] finalized: index 5443, number 10886000; cached: index 5444, number 10888000, length 0; next cached: number 10890000 [2023-10-08T22:29:04Z TRACE ckb_light_client::protocols::status] BlockFilterProtocol.received BlockFilterHashes from SessionId(23), result OK(200) [2023-10-08T22:29:05Z TRACE ckb_light_client::protocols::light_client] no fetching headers/transactions needed [2023-10-08T22:29:05Z TRACE ckb_light_client::protocols::filter::components::block_filter_hashes_process] peer SessionId(7094): last-state: PeerState::Ready { last_state: 10888759 }, add block filter hashes (start: 10886001, len: 2000) and parent block filter hash is 0x5f388b30206fe7324bfaeec95ef15b7c791fe02d408a251aeba38d270eb3de5d [2023-10-08T22:29:05Z TRACE ckb_light_client::protocols::filter::components::block_filter_hashes_process] finalized: index 5443, number 10886000; cached: index 5444, number 10888000, length 0; next cached: number 10890000 [2023-10-08T22:29:05Z TRACE ckb_light_client::protocols::filter::block_filter] request block filter hashes from peer SessionId(7094), starts at 10888001 [2023-10-08T22:29:05Z TRACE ckb_light_client::protocols::status] BlockFilterProtocol.received BlockFilterHashes from SessionId(7094), result OK(200) [2023-10-08T22:29:05Z TRACE ckb_light_client::protocols::filter::components::block_filter_hashes_process] peer SessionId(7094): last-state: PeerState::Ready { last_state: 10888759 }, add block filter hashes (start: 10888001, len: 759) and parent block filter hash is 0x5ecfac4d3328b6cc7f53d0d8c18bfc9d701d4fca4efc9e3cda80987ebe928c89 [2023-10-08T22:29:05Z TRACE ckb_light_client::protocols::filter::components::block_filter_hashes_process] finalized: index 5443, number 10886000; cached: index 5444, number 10888000, length 0; next cached: number 10890000 [2023-10-08T22:29:05Z TRACE ckb_light_client::protocols::status] BlockFilterProtocol.received BlockFilterHashes from SessionId(7094), result OK(200) [2023-10-08T22:29:06Z TRACE ckb_light_client::protocols::filter::block_filter] could request block filters from 10888757 or not: true, finalized: index 5443, number 10886000; cached: index 5444, number 10888000, length 0; next cached: number 10890000 [2023-10-08T22:29:06Z DEBUG ckb_light_client::protocols::filter::block_filter] found best proved peer SessionId(9261) [2023-10-08T22:29:06Z TRACE ckb_light_client::protocols::filter::block_filter] no block filters is required to download [2023-10-08T22:29:08Z TRACE ckb_light_client::protocols::light_client] no fetching headers/transactions needed [2023-10-08T22:29:09Z TRACE ckb_light_client::protocols::filter::block_filter] could request block filters from 10888757 or not: true, finalized: index 5443, number 10886000; cached: index 5444, number 10888000, length 0; next cached: number 10890000 [2023-10-08T22:29:09Z DEBUG ckb_light_client::protocols::filter::block_filter] found best proved peer SessionId(9261) [2023-10-08T22:29:09Z DEBUG ckb_light_client::protocols::filter::block_filter] send get block filters to SessionId(9261), start_number=10888757 [2023-10-08T22:29:09Z TRACE ckb_light_client::protocols::filter::block_filter] request block filter from peer SessionId(9261), starts at 10888757 [2023-10-08T22:29:09Z TRACE ckb_light_client::protocols::light_client] peer SessionId(6201): copy prove state from peer SessionId(7094) [2023-10-08T22:29:09Z TRACE ckb_light_client::protocols::light_client] peer SessionId(2): copy prove state from peer SessionId(6201) [2023-10-08T22:29:09Z TRACE ckb_light_client::protocols::light_client] peer SessionId(9265): copy prove state from peer SessionId(6201) [2023-10-08T22:29:09Z TRACE ckb_light_client::protocols::light_client] peer SessionId(7097): copy prove state from peer SessionId(6201) [2023-10-08T22:29:09Z TRACE ckb_light_client::protocols::light_client] check points for peer SessionId(2) in [5443,5443] [2023-10-08T22:29:09Z TRACE ckb_light_client::protocols::light_client] check points for peer SessionId(23) in [5443,5443] [2023-10-08T22:29:09Z TRACE ckb_light_client::protocols::light_client] check points for peer SessionId(7097) in [5443,5443] [2023-10-08T22:29:09Z TRACE ckb_light_client::protocols::light_client] check points for peer SessionId(7094) in [5443,5443] [2023-10-08T22:29:09Z TRACE ckb_light_client::protocols::light_client] check points for peer SessionId(6201) in [5443,5443] [2023-10-08T22:29:09Z TRACE ckb_light_client::protocols::light_client] check points for peer SessionId(9265) in [5443,5443] [2023-10-08T22:29:09Z TRACE ckb_light_client::protocols::light_client] check points for peer SessionId(9262) in [5443,5443] [2023-10-08T22:29:09Z TRACE ckb_light_client::protocols::light_client] check points for peer SessionId(9261) in [5443,5443] [2023-10-08T22:29:09Z TRACE ckb_light_client::protocols::light_client] requires 4 peers for finalizing check points and got 8 [2023-10-08T22:29:09Z TRACE ckb_light_client::protocols::light_client] finalized check point is 5443, 0x5f388b30206fe7324bfaeec95ef15b7c791fe02d408a251aeba38d270eb3de5d [2023-10-08T22:29:09Z TRACE ckb_light_client::protocols::light_client] new last check point will be less than or equal to 5443 [2023-10-08T22:29:09Z TRACE ckb_light_client::protocols::light_client] no check point is found which could be finalized thread 'GlobalRt-0' panicked at 'index out of bounds: the len is 0 but the index is 2755', src/protocols/filter/components/block_filters_process.rs:159:39 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace [2023-10-08T22:29:09Z INFO ckb_network::network] Ban peer "/ip4/*.*.*.*/tcp/8111/p2p/***********************************************" for 300 seconds, reason: protocol ProtocolId(121) panic when process peer message ```