Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions prdoc/pr_5686.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
title: "sync: Remove checking of the extrinsics root"

doc:
- audience: Node Dev
description: |
Remove checking the extrinsics root as part of the sync code.
With the introduction of `system_version` and the possibility to use the `V1`
layout for the trie when calculating the extrinsics root, it would require the
sync code to fetch the runtime version first before knowing which layout to use
when building the extrinsic root.
The extrinsics root is still checked when executing a block on chain.

crates:
- name: sc-network-sync
bump: patch
22 changes: 1 addition & 21 deletions substrate/client/network/sync/src/strategy/chain_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ use crate::{
LOG_TARGET,
};

use codec::Encode;
use log::{debug, error, info, trace, warn};
use prometheus_endpoint::{register, Gauge, PrometheusError, Registry, U64};
use sc_client_api::{blockchain::BlockGap, BlockBackend, ProofProvider};
Expand All @@ -57,8 +56,7 @@ use sp_blockchain::{Error as ClientError, HeaderBackend, HeaderMetadata};
use sp_consensus::{BlockOrigin, BlockStatus};
use sp_runtime::{
traits::{
Block as BlockT, CheckedSub, Hash, HashingFor, Header as HeaderT, NumberFor, One,
SaturatedConversion, Zero,
Block as BlockT, CheckedSub, Header as HeaderT, NumberFor, One, SaturatedConversion, Zero,
},
EncodedJustification, Justifications,
};
Expand Down Expand Up @@ -2305,24 +2303,6 @@ pub fn validate_blocks<Block: BlockT>(
return Err(BadPeer(*peer_id, rep::BAD_BLOCK));
}
}
if let (Some(header), Some(body)) = (&b.header, &b.body) {
let expected = *header.extrinsics_root();
let got = HashingFor::<Block>::ordered_trie_root(
body.iter().map(Encode::encode).collect(),
sp_runtime::StateVersion::V0,
);
if expected != got {
debug!(
target: LOG_TARGET,
"Bad extrinsic root for a block {} received from {}. Expected {:?}, got {:?}",
b.hash,
peer_id,
expected,
got,
);
return Err(BadPeer(*peer_id, rep::BAD_BLOCK));
}
}
}

Ok(blocks.first().and_then(|b| b.header.as_ref()).map(|h| *h.number()))
Expand Down