Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
a45cafe
feat: xcm Publish instruction and executor integration
metricaez Dec 9, 2025
33d27a6
feat: unit for runtimes
metricaez Dec 10, 2025
75e9090
feat: pallet broadcaster impl
metricaez Dec 10, 2025
ad17d31
feat: pallet broadcaster clean up and benchmark fixes
metricaez Dec 10, 2025
7d8bca1
feat: rococo integration and adapter of broadcater handler
metricaez Dec 10, 2025
ff0d123
feat: test utils and generic xcm benchmark fix
metricaez Dec 10, 2025
a6df911
choir: better order and rococo integration of intializer
metricaez Dec 10, 2025
9b12a16
feat: fix benchmark generic
metricaez Dec 11, 2025
276bf5d
feat: KeyToIncludeInRelayProofApi
metricaez Dec 11, 2025
c5b6e13
feat: ProcessChildTrieData on parachain-system and pallet Subscriber
metricaez Dec 11, 2025
3a8ee6a
feat: pubsubConsumber and rococo parachain integration
metricaez Dec 11, 2025
6fc1e4e
feat: basic subscriber events, errors and cleanup
metricaez Dec 12, 2025
cfc4f03
feat: Subscriber tests
metricaez Dec 12, 2025
905e0f4
choir: better RelayStorageKey comments and naming
metricaez Dec 12, 2025
06bf975
choir: ProcessChildTrieData to RelayProofKeysProcessor for better naming
metricaez Dec 12, 2025
d7fe6fb
choir: better imports
metricaez Dec 12, 2025
b32b3a1
fix: Subscriber test
metricaez Dec 12, 2025
5e9e435
choir: unnecesary import
metricaez Dec 12, 2025
fdadcde
feat: slight generalization of Subscriber
metricaez Dec 12, 2025
ca51074
Revert "feat: slight generalization of Subscriber"
metricaez Dec 12, 2025
cb0b143
feat: cleanup messy sub weights and comments
metricaez Dec 12, 2025
ee80d7e
feat: more Subscriber optimizations
metricaez Dec 12, 2025
6824873
choir: Subscriber comments and optimization
metricaez Dec 12, 2025
82bc9c9
feat: Subscriber benchmarks first approach
metricaez Dec 12, 2025
16e46f5
choir: pubsubConsumer cleanup
metricaez Dec 12, 2025
de0cec4
feat: keys into hashes
metricaez Dec 13, 2025
39244bb
feat: enforce max storage per publisher
metricaez Dec 14, 2025
622b562
feat: early exit for empty data publishing
metricaez Dec 14, 2025
412da08
choir: same import syntax as crate
metricaez Dec 14, 2025
b94725c
choir: unify duplicated sproof generation code on Subscriber
metricaez Dec 14, 2025
a8bdf22
fix: fix Subscriber buggy benchmark
metricaez Dec 14, 2025
25d74b1
misc: build bench util
metricaez Dec 14, 2025
cfeee5a
fix: subscriber should not try to benchmark the handlers
metricaez Dec 15, 2025
152748c
feat: account for data valua in benchmark
metricaez Dec 15, 2025
2ec0304
feat: test utils and small optimization of Subs
metricaez Dec 15, 2025
835cd17
choir: some relevant comments on numbers and data
metricaez Dec 15, 2025
532c2a7
choir: simpler cargo of sub
metricaez Dec 15, 2025
5c65d31
fix: separation of test utils and empty proof for bench
metricaez Dec 15, 2025
036c915
choir: unnecesary flag
metricaez Dec 15, 2025
3f02cd9
feat: no std proof generation and ah westend benchmark
metricaez Dec 16, 2025
a3d403b
feat: weights and benchmark details
metricaez Dec 16, 2025
90eee06
choir: duplicated child info derivation
metricaez Dec 16, 2025
046b316
choir: separate weights of sub and misleading param of zombienet
metricaez Dec 16, 2025
a1a4207
fix: clippy and missing handler
metricaez Dec 16, 2025
55bd149
feat: integrations cleanup
metricaez Dec 16, 2025
1faddf8
feat: max out publish on runtimes and unit weight for broadcaster
metricaez Dec 16, 2025
df779cb
feat: refund weight
metricaez Dec 16, 2025
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
23 changes: 23 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ members = [
"cumulus/pallets/parachain-system/proc-macro",
"cumulus/pallets/session-benchmarking",
"cumulus/pallets/solo-to-para",
"cumulus/pallets/subscriber",
"cumulus/pallets/weight-reclaim",
"cumulus/pallets/xcm",
"cumulus/pallets/xcmp-queue",
Expand Down Expand Up @@ -748,6 +749,7 @@ cumulus-pallet-aura-ext = { path = "cumulus/pallets/aura-ext", default-features
cumulus-pallet-dmp-queue = { default-features = false, path = "cumulus/pallets/dmp-queue" }
cumulus-pallet-parachain-system = { path = "cumulus/pallets/parachain-system", default-features = false }
cumulus-pallet-parachain-system-proc-macro = { path = "cumulus/pallets/parachain-system/proc-macro", default-features = false }
cumulus-pallet-subscriber = { path = "cumulus/pallets/subscriber", default-features = false }
cumulus-pallet-session-benchmarking = { path = "cumulus/pallets/session-benchmarking", default-features = false }
cumulus-pallet-solo-to-para = { path = "cumulus/pallets/solo-to-para", default-features = false }
cumulus-pallet-weight-reclaim = { path = "cumulus/pallets/weight-reclaim", default-features = false }
Expand Down
4 changes: 4 additions & 0 deletions cumulus/client/consensus/aura/src/collator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ where
parent_hash: Block::Hash,
timestamp: impl Into<Option<Timestamp>>,
relay_parent_descendants: Option<RelayParentData>,
relay_proof_request: cumulus_primitives_core::RelayProofRequest,
collator_peer_id: PeerId,
) -> Result<(ParachainInherentData, InherentData), Box<dyn Error + Send + Sync + 'static>> {
let paras_inherent_data = ParachainInherentDataProvider::create_at(
Expand All @@ -188,6 +189,7 @@ where
.map(RelayParentData::into_inherent_descendant_list)
.unwrap_or_default(),
Vec::new(),
relay_proof_request,
collator_peer_id,
)
.await;
Expand Down Expand Up @@ -224,6 +226,7 @@ where
validation_data: &PersistedValidationData,
parent_hash: Block::Hash,
timestamp: impl Into<Option<Timestamp>>,
relay_proof_request: cumulus_primitives_core::RelayProofRequest,
collator_peer_id: PeerId,
) -> Result<(ParachainInherentData, InherentData), Box<dyn Error + Send + Sync + 'static>> {
self.create_inherent_data_with_rp_offset(
Expand All @@ -232,6 +235,7 @@ where
parent_hash,
timestamp,
None,
relay_proof_request,
collator_peer_id,
)
.await
Expand Down
1 change: 1 addition & 0 deletions cumulus/client/consensus/aura/src/collators/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ where
&validation_data,
parent_hash,
claim.timestamp(),
Default::default(),
params.collator_peer_id,
)
.await
Expand Down
17 changes: 12 additions & 5 deletions cumulus/client/consensus/aura/src/collators/lookahead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use codec::{Codec, Encode};
use cumulus_client_collator::service::ServiceInterface as CollatorServiceInterface;
use cumulus_client_consensus_common::{self as consensus_common, ParachainBlockImportMarker};
use cumulus_primitives_aura::AuraUnincludedSegmentApi;
use cumulus_primitives_core::{CollectCollationInfo, PersistedValidationData};
use cumulus_primitives_core::{CollectCollationInfo, KeyToIncludeInRelayProofApi, PersistedValidationData};
use cumulus_relay_chain_interface::RelayChainInterface;
use sp_consensus::Environment;

Expand Down Expand Up @@ -164,8 +164,10 @@ where
+ Send
+ Sync
+ 'static,
Client::Api:
AuraApi<Block, P::Public> + CollectCollationInfo<Block> + AuraUnincludedSegmentApi<Block>,
Client::Api: AuraApi<Block, P::Public>
+ CollectCollationInfo<Block>
+ AuraUnincludedSegmentApi<Block>
+ KeyToIncludeInRelayProofApi<Block>,
Backend: sc_client_api::Backend<Block> + 'static,
RClient: RelayChainInterface + Clone + 'static,
CIDP: CreateInherentDataProviders<Block, ()> + 'static,
Expand Down Expand Up @@ -216,8 +218,10 @@ where
+ Send
+ Sync
+ 'static,
Client::Api:
AuraApi<Block, P::Public> + CollectCollationInfo<Block> + AuraUnincludedSegmentApi<Block>,
Client::Api: AuraApi<Block, P::Public>
+ CollectCollationInfo<Block>
+ AuraUnincludedSegmentApi<Block>
+ KeyToIncludeInRelayProofApi<Block>,
Backend: sc_client_api::Backend<Block> + 'static,
RClient: RelayChainInterface + Clone + 'static,
CIDP: CreateInherentDataProviders<Block, ()> + 'static,
Expand Down Expand Up @@ -392,12 +396,15 @@ where

// Build and announce collations recursively until
// `can_build_upon` fails or building a collation fails.
let relay_proof_request = super::get_relay_proof_request(&*params.para_client, parent_hash);

let (parachain_inherent_data, other_inherent_data) = match collator
.create_inherent_data(
relay_parent,
&validation_data,
parent_hash,
slot_claim.timestamp(),
relay_proof_request,
params.collator_peer_id,
)
.await
Expand Down
32 changes: 31 additions & 1 deletion cumulus/client/consensus/aura/src/collators/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ use crate::collator::SlotClaim;
use codec::Codec;
use cumulus_client_consensus_common::{self as consensus_common, ParentSearchParams};
use cumulus_primitives_aura::{AuraUnincludedSegmentApi, Slot};
use cumulus_primitives_core::{relay_chain::Header as RelayHeader, BlockT};
use cumulus_primitives_core::{
relay_chain::Header as RelayHeader, BlockT, KeyToIncludeInRelayProofApi,
};
use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface};
use polkadot_node_subsystem::messages::{CollatorProtocolMessage, RuntimeApiRequest};
use polkadot_node_subsystem_util::runtime::ClaimQueueSnapshot;
Expand Down Expand Up @@ -662,6 +664,34 @@ mod tests {
}
}

/// Fetches relay chain storage proof requests from the parachain runtime.
///
/// Queries the runtime API to determine which relay chain storage keys
/// (both top-level and child trie keys) should be included in the relay chain state proof.
///
/// Falls back to an empty request if the runtime API call fails or is not implemented.
fn get_relay_proof_request<Block, Client>(
client: &Client,
parent_hash: Block::Hash,
) -> cumulus_primitives_core::RelayProofRequest
where
Block: BlockT,
Client: ProvideRuntimeApi<Block>,
Client::Api: KeyToIncludeInRelayProofApi<Block>,
{
client
.runtime_api()
.keys_to_prove(parent_hash)
.unwrap_or_else(|e| {
tracing::warn!(
target: crate::LOG_TARGET,
error = ?e,
"Failed to fetch relay proof requests from runtime, using empty request"
);
Default::default()
})
}

/// Holds a relay parent and its descendants.
pub struct RelayParentData {
/// The relay parent block header
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,14 +359,14 @@ where
relay_parent_storage_root: *relay_parent_header.state_root(),
max_pov_size: *max_pov_size,
};

let (parachain_inherent_data, other_inherent_data) = match collator
.create_inherent_data_with_rp_offset(
relay_parent,
&validation_data,
parent_hash,
slot_claim.timestamp(),
Some(rp_data),
Default::default(),
collator_peer_id,
)
.await
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,15 @@ impl RelayChainInterface for TestRelayClient {
unimplemented!("Not needed for test")
}

async fn prove_child_read(
&self,
_: RelayHash,
_: &cumulus_relay_chain_interface::ChildInfo,
_: &[Vec<u8>],
) -> RelayChainResult<sc_client_api::StorageProof> {
unimplemented!("Not needed for test")
}

async fn wait_for_block(&self, _: RelayHash) -> RelayChainResult<()> {
unimplemented!("Not needed for test")
}
Expand Down
91 changes: 90 additions & 1 deletion cumulus/client/parachain-inherent/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ pub use cumulus_primitives_parachain_inherent::{ParachainInherentData, INHERENT_
use cumulus_relay_chain_interface::RelayChainInterface;
pub use mock::{MockValidationDataInherentDataProvider, MockXcmConfig};
use sc_network_types::PeerId;
use sp_state_machine::StorageProof;
use sp_storage::ChildInfo;

const LOG_TARGET: &str = "parachain-inherent";

Expand Down Expand Up @@ -157,6 +159,84 @@ async fn collect_relay_storage_proof(
.ok()
}

/// Collect storage proofs for relay chain data.
///
/// Generates proofs for both top-level relay chain storage and child trie data.
/// Top-level keys are proven directly. Child trie roots are automatically included
/// from their standard storage locations (`:child_storage:default:` + identifier).
///
/// Returns a merged proof combining all requested data, or `None` if there are no requests.
async fn collect_relay_storage_proofs(
relay_chain_interface: &impl RelayChainInterface,
relay_parent: PHash,
relay_proof_request: cumulus_primitives_core::RelayProofRequest,
) -> Option<StorageProof> {
use cumulus_primitives_core::RelayStorageKey;

let cumulus_primitives_core::RelayProofRequest { keys } = relay_proof_request;

if keys.is_empty() {
return None;
}

let mut combined_proof: Option<StorageProof> = None;

// Group keys by storage type
let mut top_keys = Vec::new();
let mut child_keys: std::collections::BTreeMap<Vec<u8>, Vec<Vec<u8>>> =
std::collections::BTreeMap::new();

for key in keys {
match key {
RelayStorageKey::Top(k) => top_keys.push(k),
RelayStorageKey::Child { storage_key, key } => {
child_keys.entry(storage_key).or_default().push(key);
},
}
}

// Collect top-level storage proofs
if !top_keys.is_empty() {
match relay_chain_interface.prove_read(relay_parent, &top_keys).await {
Ok(top_proof) => {
combined_proof = Some(top_proof);
},
Err(e) => {
tracing::error!(
target: LOG_TARGET,
relay_parent = ?relay_parent,
error = ?e,
"Cannot obtain top-level storage proof from relay chain.",
);
},
}
}

// Collect child trie proofs
for (storage_key, data_keys) in child_keys {
let child_info = ChildInfo::new_default(&storage_key);
match relay_chain_interface.prove_child_read(relay_parent, &child_info, &data_keys).await {
Ok(child_proof) => {
combined_proof = match combined_proof {
None => Some(child_proof),
Some(existing) => Some(StorageProof::merge([existing, child_proof])),
};
},
Err(e) => {
tracing::error!(
target: LOG_TARGET,
relay_parent = ?relay_parent,
child_trie_id = ?child_info.storage_key(),
error = ?e,
"Cannot obtain child trie proof from relay chain.",
);
},
}
}

combined_proof
}

pub struct ParachainInherentDataProvider;

impl ParachainInherentDataProvider {
Expand All @@ -170,6 +250,7 @@ impl ParachainInherentDataProvider {
para_id: ParaId,
relay_parent_descendants: Vec<RelayHeader>,
additional_relay_state_keys: Vec<Vec<u8>>,
relay_proof_request: cumulus_primitives_core::RelayProofRequest,
collator_peer_id: PeerId,
) -> Option<ParachainInherentData> {
let collator_peer_id = ApprovedPeerId::try_from(collator_peer_id.to_bytes())
Expand All @@ -188,7 +269,7 @@ impl ParachainInherentDataProvider {
.iter()
.skip(1)
.any(sc_consensus_babe::contains_epoch_change::<RelayBlock>);
let relay_chain_state = collect_relay_storage_proof(
let mut relay_chain_state = collect_relay_storage_proof(
relay_chain_interface,
para_id,
relay_parent,
Expand All @@ -198,6 +279,14 @@ impl ParachainInherentDataProvider {
)
.await?;

// Collect additional requested storage proofs (top-level and child tries)
if let Some(additional_proofs) =
collect_relay_storage_proofs(relay_chain_interface, relay_parent, relay_proof_request)
.await
{
relay_chain_state = StorageProof::merge([relay_chain_state, additional_proofs]);
}

let downward_messages = relay_chain_interface
.retrieve_dmq_contents(para_id, relay_parent)
.await
Expand Down
12 changes: 12 additions & 0 deletions cumulus/client/relay-chain-inprocess-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,18 @@ impl RelayChainInterface for RelayChainInProcessInterface {
.map_err(RelayChainError::StateMachineError)
}

async fn prove_child_read(
&self,
relay_parent: PHash,
child_info: &cumulus_relay_chain_interface::ChildInfo,
child_keys: &[Vec<u8>],
) -> RelayChainResult<StorageProof> {
let state_backend = self.backend.state_at(relay_parent, TrieCacheContext::Untrusted)?;

sp_state_machine::prove_child_read(state_backend, child_info, child_keys)
.map_err(RelayChainError::StateMachineError)
}

/// Wait for a given relay chain block in an async way.
///
/// The caller needs to pass the hash of a block it waits for and the function will return when
Expand Down
1 change: 1 addition & 0 deletions cumulus/client/relay-chain-interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ sc-network = { workspace = true, default-features = true }
sp-api = { workspace = true, default-features = true }
sp-blockchain = { workspace = true, default-features = true }
sp-state-machine = { workspace = true, default-features = true }
sp-storage = { workspace = true, default-features = true }
sp-version = { workspace = true }

async-trait = { workspace = true }
Expand Down
Loading