Skip to content
Draft
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
5 changes: 5 additions & 0 deletions cumulus/client/parachain-inherent/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ async fn collect_relay_storage_proof(
relevant_keys.extend(egress_channels.into_iter().map(|recipient| {
relay_well_known_keys::hrmp_channels(HrmpChannelId { sender: para_id, recipient })
}));
// TODO: maybe here? can we pass somehow `predefined_sibling_para_id`?
// TODO: maybe we can collect all hrmp sender/receipient paraId by default withtout need to change configuration?
// for sibling_para_id in predefined_sibling_para_id {
// relevant_keys.extend(relay_well_known_keys::para_head(sibling_para_id));
// }

relay_chain_interface
.prove_read(relay_parent, &relevant_keys)
Expand Down
9 changes: 9 additions & 0 deletions cumulus/pallets/parachain-system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,15 @@ pub mod pallet {
)
.expect("Invalid relay chain state proof");

/// This reads actual para head for `T::SelfParaId::get()`
log::error!("PARA_HEAD: {:?}", relay_state_proof.read_included_para_head());
/// TODO: I would like to acheive something like this, 2001 can be replaced with some onchain configuration
let sibling_para_head_from_relaychain_state_proof = relay_state_proof.read_sibling_para_head(2001.into());
log::error!("SIBLING_PARA_HEAD: {:?}", sibling_para_head_from_relaychain_state_proof);
// TODO: add some callback similar as T::OnSystemEvent (or reuse this one)
// TODO: custom pallet, can store those in some list/map or whatever
T::OnSiblingParaHead(sibling_para_head_from_relaychain_state_proof);

// Update the desired maximum capacity according to the consensus hook.
let (consensus_hook_weight, capacity) =
T::ConsensusHook::on_state_proof(&relay_state_proof);
Expand Down
6 changes: 6 additions & 0 deletions cumulus/pallets/parachain-system/src/relay_state_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,12 @@ impl RelayChainStateProof {
.map_err(Error::ParaHead)
}

/// TODO: read from the `RelayChainStateProof` trie
pub fn read_sibling_para_head(&self, sibling_para_id: ParaId) -> Result<Option<relay_chain::HeadData>, Error> {
read_optional_entry(&self.trie_backend, &relay_chain::well_known_keys::para_head(sibling_para_id))
.map_err(Error::ParaHead)
}

/// Read the [`Slot`](relay_chain::Slot) from the relay chain state proof.
///
/// The slot is slot of the relay chain block this state proof was extracted from.
Expand Down
12 changes: 10 additions & 2 deletions cumulus/polkadot-omni-node/lib/src/nodes/aura.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,11 @@ where

let client_for_aura = client.clone();
let params = SlotBasedParams {
create_inherent_data_providers: move |_, ()| async move { Ok(()) },
create_inherent_data_providers: move |db_hash, ()| {
// TODO: add here custom provider, which will read some runtime api/storage for set of paraIds and get their para heads?
// TODO: if we chanage this, how can we release this? As a breaking change?
async move { Ok(()) }
},
block_import,
para_client: client.clone(),
para_backend: backend.clone(),
Expand Down Expand Up @@ -461,7 +465,11 @@ where
let params = aura::ParamsWithExport {
export_pov: node_extra_args.export_pov,
params: AuraParams {
create_inherent_data_providers: move |_, ()| async move { Ok(()) },
create_inherent_data_providers: move |db_hash, ()| {
// TODO: add here custom provider, which will read some runtime api/storage for set of paraIds and get their para heads?
// TODO: if we chanage this, how can we release this? As a breaking change?
async move { Ok(()) }
},
block_import,
para_client: client.clone(),
para_backend: backend,
Expand Down
2 changes: 1 addition & 1 deletion cumulus/primitives/parachain-inherent/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub struct ParachainInherentData {
/// - the relay dispatch queue sizes
/// - the list of egress HRMP channels (in the list of recipients form)
/// - the metadata for the egress HRMP channels
pub relay_chain_state: sp_trie::StorageProof,
pub relay_chain_state: sp_trie::StorageProof, // TODO: how to add here predefined sibling para heads (with state roots)?
/// Downward messages in the order they were sent.
pub downward_messages: Vec<InboundDownwardMessage>,
/// HRMP messages grouped by channels. The messages in the inner vec must be in order they
Expand Down
Loading