fix race in light_peer_imports_header_from_announce (#4579)

This commit is contained in:
Svyatoslav Nikolsky
2020-01-10 01:28:04 +03:00
committed by Gavin Wood
parent bc3d283e78
commit f372fa4d72
6 changed files with 76 additions and 29 deletions
+3 -2
View File
@@ -153,7 +153,7 @@ impl<E, H, B: BlockT, S: BlockchainStorage<B>> LightDataChecker<E, H, B, S> {
// all the checks are sharing the same storage
let storage = create_proof_check_backend_storage(remote_roots_proof);
// we remote_roots.keys() are sorted => we can use this to group changes tries roots
// remote_roots.keys() are sorted => we can use this to group changes tries roots
// that are belongs to the same CHT
let blocks = remote_roots.keys().cloned();
cht::for_each_cht_group::<B::Header, _, _, _>(cht_size, blocks, |mut storage, _, cht_blocks| {
@@ -162,7 +162,8 @@ impl<E, H, B: BlockT, S: BlockchainStorage<B>> LightDataChecker<E, H, B, S> {
// when required header has been pruned (=> replaced with CHT)
let first_block = cht_blocks.first().cloned()
.expect("for_each_cht_group never calls callback with empty groups");
let local_cht_root = self.blockchain.storage().changes_trie_cht_root(cht_size, first_block)?;
let local_cht_root = self.blockchain.storage().changes_trie_cht_root(cht_size, first_block)?
.ok_or(ClientError::InvalidCHTProof)?;
// check changes trie root for every block within CHT range
for block in cht_blocks {