Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Mass rename relay_parent_storage_root
Browse files Browse the repository at this point in the history
  • Loading branch information
pepyakin committed Feb 2, 2021
1 parent 410ed3d commit b259a74
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions parachain-system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ decl_module! {
let (host_config, relevant_messaging_state) =
relay_state_snapshot::extract_from_proof(
T::SelfParaId::get(),
vfp.relay_storage_root,
vfp.relay_parent_storage_root,
relay_chain_state
)
.map_err(|err| {
Expand Down Expand Up @@ -1124,11 +1124,11 @@ mod tests {
if let Some(ref hook) = self.relay_sproof_builder_hook {
hook(self, *n as RelayChainBlockNumber, &mut sproof_builder);
}
let (relay_storage_root, relay_chain_state) =
let (relay_parent_storage_root, relay_chain_state) =
sproof_builder.into_state_root_and_proof();
let mut vfp = PersistedValidationData {
relay_parent_number: *n as RelayChainBlockNumber,
relay_storage_root,
relay_parent_storage_root,
..Default::default()
};
if let Some(ref hook) = self.persisted_validation_data_hook {
Expand Down
6 changes: 3 additions & 3 deletions parachain-system/src/relay_state_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ where
/// of the current parachain and the expected storage root the proof should stem from.
pub fn extract_from_proof(
para_id: ParaId,
relay_storage_root: relay_chain::v1::Hash,
relay_parent_storage_root: relay_chain::v1::Hash,
proof: StorageProof,
) -> Result<(AbridgedHostConfiguration, MessagingStateSnapshot), Error> {
let db = proof.into_memory_db::<HashFor<relay_chain::Block>>();
if !db.contains(&relay_storage_root, EMPTY_PREFIX) {
if !db.contains(&relay_parent_storage_root, EMPTY_PREFIX) {
return Err(Error::RootMismatch);
}
let backend = TrieBackend::new(db, relay_storage_root);
let backend = TrieBackend::new(db, relay_parent_storage_root);

let host_config: AbridgedHostConfiguration = read_entry(
&backend,
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/validate_block/implementation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ impl<'a, B: BlockT> WitnessExt<'a, B> {
validation_data.relay_parent_number,
);
assert_eq!(
self.params.relay_storage_root,
validation_data.relay_storage_root,
self.params.relay_parent_storage_root,
validation_data.relay_parent_storage_root,
);
}
}
Expand Down
22 changes: 11 additions & 11 deletions runtime/src/validate_block/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ use codec::{Decode, Encode};
fn call_validate_block(
parent_head: Header,
block_data: ParachainBlockData<Block>,
relay_storage_root: Hash,
relay_parent_storage_root: Hash,
) -> Result<Header> {
let mut ext = TestExternalities::default();
let mut ext_ext = ext.ext();
let params = ValidationParams {
block_data: BlockData(block_data.encode()),
parent_head: HeadData(parent_head.encode()),
relay_parent_number: 1,
relay_storage_root,
relay_parent_storage_root,
}
.encode();

Expand Down Expand Up @@ -85,7 +85,7 @@ fn create_test_client() -> (Client, LongestChain) {
struct TestBlockData {
block: Block,
witness: sp_trie::StorageProof,
relay_storage_root: Hash,
relay_parent_storage_root: Hash,
}

fn build_block_with_witness(
Expand All @@ -94,7 +94,7 @@ fn build_block_with_witness(
parent_head: Header,
) -> TestBlockData {
let sproof_builder = RelayStateSproofBuilder::default();
let (relay_storage_root, _) = sproof_builder.clone().into_state_root_and_proof();
let (relay_parent_storage_root, _) = sproof_builder.clone().into_state_root_and_proof();
let block_id = BlockId::Hash(client.info().best_hash);
let mut builder = client.init_block_builder_at(
&block_id,
Expand All @@ -117,7 +117,7 @@ fn build_block_with_witness(
witness: built_block
.proof
.expect("We enabled proof recording before."),
relay_storage_root,
relay_parent_storage_root,
}
}

Expand All @@ -130,13 +130,13 @@ fn validate_block_no_extra_extrinsics() {
let TestBlockData {
block,
witness,
relay_storage_root,
relay_parent_storage_root,
} = build_block_with_witness(&client, vec![], parent_head.clone());
let (header, extrinsics) = block.deconstruct();

let block_data = ParachainBlockData::new(header.clone(), extrinsics, witness);

let res_header = call_validate_block(parent_head, block_data, relay_storage_root)
let res_header = call_validate_block(parent_head, block_data, relay_parent_storage_root)
.expect("Calls `validate_block`");
assert_eq!(header, res_header);
}
Expand All @@ -156,13 +156,13 @@ fn validate_block_with_extra_extrinsics() {
let TestBlockData {
block,
witness,
relay_storage_root,
relay_parent_storage_root,
} = build_block_with_witness(&client, extra_extrinsics, parent_head.clone());
let (header, extrinsics) = block.deconstruct();

let block_data = ParachainBlockData::new(header.clone(), extrinsics, witness);

let res_header = call_validate_block(parent_head, block_data, relay_storage_root)
let res_header = call_validate_block(parent_head, block_data, relay_parent_storage_root)
.expect("Calls `validate_block`");
assert_eq!(header, res_header);
}
Expand All @@ -177,12 +177,12 @@ fn validate_block_invalid_parent_hash() {
let TestBlockData {
block,
witness,
relay_storage_root,
relay_parent_storage_root,
} = build_block_with_witness(&client, vec![], parent_head.clone());
let (mut header, extrinsics) = block.deconstruct();
header.set_parent_hash(Hash::from_low_u64_be(1));

let block_data = ParachainBlockData::new(header, extrinsics, witness);
call_validate_block(parent_head, block_data, relay_storage_root)
call_validate_block(parent_head, block_data, relay_parent_storage_root)
.expect("Calls `validate_block`");
}
6 changes: 3 additions & 3 deletions test/client/src/block_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@ impl InitBlockBuilder for Client {
.put_data(sp_timestamp::INHERENT_IDENTIFIER, &timestamp)
.expect("Put timestamp failed");

let (relay_storage_root, relay_chain_state) =
let (relay_parent_storage_root, relay_chain_state) =
relay_sproof_builder.into_state_root_and_proof();

let mut validation_data = validation_data.unwrap_or_default();
assert_eq!(
validation_data.relay_storage_root,
validation_data.relay_parent_storage_root,
Default::default(),
"Overriding the relay storage root is not implemented",
);
validation_data.relay_storage_root = relay_storage_root;
validation_data.relay_parent_storage_root = relay_parent_storage_root;

inherent_data
.put_data(
Expand Down

0 comments on commit b259a74

Please sign in to comment.