diff --git a/cumulus/client/parachain-inherent/src/lib.rs b/cumulus/client/parachain-inherent/src/lib.rs index 0bb436a876b4f..22cbe529ace81 100644 --- a/cumulus/client/parachain-inherent/src/lib.rs +++ b/cumulus/client/parachain-inherent/src/lib.rs @@ -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) diff --git a/cumulus/pallets/parachain-system/src/lib.rs b/cumulus/pallets/parachain-system/src/lib.rs index 624f91e7fdfb3..720c2a586c688 100644 --- a/cumulus/pallets/parachain-system/src/lib.rs +++ b/cumulus/pallets/parachain-system/src/lib.rs @@ -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); diff --git a/cumulus/pallets/parachain-system/src/relay_state_snapshot.rs b/cumulus/pallets/parachain-system/src/relay_state_snapshot.rs index 323aaf6503808..4b3a5a962aa95 100644 --- a/cumulus/pallets/parachain-system/src/relay_state_snapshot.rs +++ b/cumulus/pallets/parachain-system/src/relay_state_snapshot.rs @@ -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, 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. diff --git a/cumulus/polkadot-omni-node/lib/src/nodes/aura.rs b/cumulus/polkadot-omni-node/lib/src/nodes/aura.rs index cd0e35d0d0699..9f7b238547a98 100644 --- a/cumulus/polkadot-omni-node/lib/src/nodes/aura.rs +++ b/cumulus/polkadot-omni-node/lib/src/nodes/aura.rs @@ -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(), @@ -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, diff --git a/cumulus/primitives/parachain-inherent/src/lib.rs b/cumulus/primitives/parachain-inherent/src/lib.rs index 127a03b652591..7462b6ba669ca 100644 --- a/cumulus/primitives/parachain-inherent/src/lib.rs +++ b/cumulus/primitives/parachain-inherent/src/lib.rs @@ -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, /// HRMP messages grouped by channels. The messages in the inner vec must be in order they