Skip to content

Commit

Permalink
improve MockValidationDataInherentDataProvider to support async back…
Browse files Browse the repository at this point in the history
…ing (paritytech#4442)

Support async backing in `--dev` mode

This PR improve the relay mock `MockValidationDataInherentDataProvider`
to mach expectations of async backing runtimes.

* Add para_head in the mock relay proof
* Add relay slot in the mock relay proof 

fix paritytech#4437
  • Loading branch information
librelois authored and TarekkMA committed Aug 2, 2024
1 parent 21bc5fe commit fa8031d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
7 changes: 5 additions & 2 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 Down Expand Up @@ -165,11 +168,11 @@ impl<R: Send + Sync + GenerateRandomness<u64>> InherentDataProvider
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 as u64).into();
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();
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 fa8031d

Please sign in to comment.