Skip to content

Commit

Permalink
Merge branch 'master' into kiz-cleanup-polkadot-parachain-bin
Browse files Browse the repository at this point in the history
  • Loading branch information
kianenigma committed May 14, 2024
2 parents 1d66ddf + 115c247 commit 9d8e5f6
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,23 +175,19 @@ function run_finality_relay() {
RUST_LOG=runtime=trace,rpc=trace,bridge=trace \
$relayer_path relay-headers rococo-to-bridge-hub-westend \
--only-free-headers \
--source-host localhost \
--source-port 9942 \
--source-uri ws://localhost:9942 \
--source-version-mode Auto \
--target-host localhost \
--target-port 8945 \
--target-uri ws://localhost:8945 \
--target-version-mode Auto \
--target-signer //Charlie \
--target-transactions-mortality 4&

RUST_LOG=runtime=trace,rpc=trace,bridge=trace \
$relayer_path relay-headers westend-to-bridge-hub-rococo \
--only-free-headers \
--source-host localhost \
--source-port 9945 \
--source-uri ws://localhost:9945 \
--source-version-mode Auto \
--target-host localhost \
--target-port 8943 \
--target-uri ws://localhost:8943 \
--target-version-mode Auto \
--target-signer //Charlie \
--target-transactions-mortality 4
Expand All @@ -203,23 +199,19 @@ function run_parachains_relay() {
RUST_LOG=runtime=trace,rpc=trace,bridge=trace \
$relayer_path relay-parachains rococo-to-bridge-hub-westend \
--only-free-headers \
--source-host localhost \
--source-port 9942 \
--source-uri ws://localhost:9942 \
--source-version-mode Auto \
--target-host localhost \
--target-port 8945 \
--target-uri ws://localhost:8945 \
--target-version-mode Auto \
--target-signer //Dave \
--target-transactions-mortality 4&

RUST_LOG=runtime=trace,rpc=trace,bridge=trace \
$relayer_path relay-parachains westend-to-bridge-hub-rococo \
--only-free-headers \
--source-host localhost \
--source-port 9945 \
--source-uri ws://localhost:9945 \
--source-version-mode Auto \
--target-host localhost \
--target-port 8943 \
--target-uri ws://localhost:8943 \
--target-version-mode Auto \
--target-signer //Dave \
--target-transactions-mortality 4
Expand All @@ -230,27 +222,23 @@ function run_messages_relay() {

RUST_LOG=runtime=trace,rpc=trace,bridge=trace \
$relayer_path relay-messages bridge-hub-rococo-to-bridge-hub-westend \
--source-host localhost \
--source-port 8943 \
--source-uri ws://localhost:8943 \
--source-version-mode Auto \
--source-signer //Eve \
--source-transactions-mortality 4 \
--target-host localhost \
--target-port 8945 \
--target-uri ws://localhost:8945 \
--target-version-mode Auto \
--target-signer //Eve \
--target-transactions-mortality 4 \
--lane $LANE_ID&

RUST_LOG=runtime=trace,rpc=trace,bridge=trace \
$relayer_path relay-messages bridge-hub-westend-to-bridge-hub-rococo \
--source-host localhost \
--source-port 8945 \
--source-uri ws://localhost:8945 \
--source-version-mode Auto \
--source-signer //Ferdie \
--source-transactions-mortality 4 \
--target-host localhost \
--target-port 8943 \
--target-uri ws://localhost:8943 \
--target-version-mode Auto \
--target-signer //Ferdie \
--target-transactions-mortality 4 \
Expand Down
18 changes: 14 additions & 4 deletions cumulus/client/parachain-inherent/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ use std::collections::BTreeMap;

use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;

/// Relay chain slot duration, in milliseconds.
pub const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000;

/// Inherent data provider that supplies mocked validation data.
///
/// This is useful when running a node that is not actually backed by any relay chain.
Expand All @@ -45,6 +48,8 @@ use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;
pub struct MockValidationDataInherentDataProvider<R = ()> {
/// The current block number of the local block chain (the parachain)
pub current_para_block: u32,
/// The current block head data of the local block chain (the parachain)
pub current_para_block_head: Option<cumulus_primitives_core::relay_chain::HeadData>,
/// The relay block in which this parachain appeared to start. This will be the relay block
/// number in para block #P1
pub relay_offset: u32,
Expand Down Expand Up @@ -159,14 +164,16 @@ impl<R: Send + Sync + GenerateRandomness<u64>> InherentDataProvider
&self,
inherent_data: &mut InherentData,
) -> Result<(), sp_inherents::Error> {
// Calculate the mocked relay block based on the current para block
let relay_parent_number =
self.relay_offset + self.relay_blocks_per_para_block * self.current_para_block;

// Use the "sproof" (spoof proof) builder to build valid mock state root and proof.
let mut sproof_builder =
RelayStateSproofBuilder { para_id: self.xcm_config.para_id, ..Default::default() };

// Calculate the mocked relay block based on the current para block
let relay_parent_number =
self.relay_offset + self.relay_blocks_per_para_block * self.current_para_block;
sproof_builder.current_slot =
((relay_parent_number / RELAY_CHAIN_SLOT_DURATION_MILLIS) as u64).into();

// Process the downward messages and set up the correct head
let mut downward_messages = Vec::new();
let mut dmq_mqc = MessageQueueChain::new(self.xcm_config.starting_dmq_mqc_head);
Expand Down Expand Up @@ -217,6 +224,9 @@ impl<R: Send + Sync + GenerateRandomness<u64>> InherentDataProvider
sproof_builder.additional_key_values = key_values.clone()
}

// Inject current para block head, if any
sproof_builder.included_para_head = self.current_para_block_head.clone();

let (relay_parent_storage_root, proof) = sproof_builder.into_state_root_and_proof();

inherent_data.put_data(
Expand Down
13 changes: 13 additions & 0 deletions prdoc/pr_4442.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json

title: Improve mock relay in --dev mode to support async backing

doc:
- audience: Node Dev
description: |
Support async backing in --dev mode. Improve the relay mock MockValidationDataInherentDataProvider to mach expectations of async backing runtimes.

crates:
- name: cumulus-client-parachain-inherent
bump: patch

0 comments on commit 9d8e5f6

Please sign in to comment.