Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
d5ca459
feat: KeyToIncludeInRelayProofApi
metricaez Dec 17, 2025
4882d6e
choir: shorter imports
metricaez Dec 17, 2025
fbd13f8
feat: better naming and batch merging of proofs
metricaez Dec 17, 2025
2f90953
feat: naming and comment suggestions
metricaez Dec 19, 2025
2d7717e
fix: name change occurences fix
metricaez Dec 19, 2025
6676373
feat: collect static keys and unify prove_read
metricaez Dec 19, 2025
0a02f4c
feat: move relay proof handler to OnSystemEvent
metricaez Dec 20, 2025
41f52af
feat: prove_child_read for relay rpc interface
metricaez Dec 20, 2025
d40f024
feat: imp KeyToIncludeInRelayProof for test pallet
metricaez Dec 22, 2025
95e0d0d
feat: xcm Publish instruction and executor integration
metricaez Dec 9, 2025
5a7d586
feat: unit for runtimes
metricaez Dec 10, 2025
8074c19
feat: pallet broadcaster impl
metricaez Dec 10, 2025
9cfdf85
feat: pallet broadcaster clean up and benchmark fixes
metricaez Dec 10, 2025
6747f9f
feat: rococo integration and adapter of broadcater handler
metricaez Dec 10, 2025
5ca4cca
feat: test utils and generic xcm benchmark fix
metricaez Dec 10, 2025
cde1f41
choir: better order and rococo integration of intializer
metricaez Dec 10, 2025
1e7d15a
feat: fix benchmark generic
metricaez Dec 11, 2025
83ae845
feat: KeyToIncludeInRelayProofApi
metricaez Dec 11, 2025
3a16834
feat: ProcessChildTrieData on parachain-system and pallet Subscriber
metricaez Dec 11, 2025
c1cd6d2
feat: pubsubConsumber and rococo parachain integration
metricaez Dec 11, 2025
381a19f
feat: basic subscriber events, errors and cleanup
metricaez Dec 12, 2025
994e373
feat: Subscriber tests
metricaez Dec 12, 2025
d9b9105
choir: better RelayStorageKey comments and naming
metricaez Dec 12, 2025
1ce3ed6
choir: ProcessChildTrieData to RelayProofKeysProcessor for better naming
metricaez Dec 12, 2025
0af5e7b
choir: better imports
metricaez Dec 12, 2025
ff36ca4
fix: Subscriber test
metricaez Dec 12, 2025
77f2316
choir: unnecesary import
metricaez Dec 12, 2025
fb0837a
feat: slight generalization of Subscriber
metricaez Dec 12, 2025
0a178ef
Revert "feat: slight generalization of Subscriber"
metricaez Dec 12, 2025
1876306
feat: cleanup messy sub weights and comments
metricaez Dec 12, 2025
a6126ed
feat: more Subscriber optimizations
metricaez Dec 12, 2025
153ca74
choir: Subscriber comments and optimization
metricaez Dec 12, 2025
fd941f5
feat: Subscriber benchmarks first approach
metricaez Dec 12, 2025
547cf93
choir: pubsubConsumer cleanup
metricaez Dec 12, 2025
b0897c4
feat: keys into hashes
metricaez Dec 13, 2025
6cf3911
feat: enforce max storage per publisher
metricaez Dec 14, 2025
99af690
feat: early exit for empty data publishing
metricaez Dec 14, 2025
f9bbc8a
choir: same import syntax as crate
metricaez Dec 14, 2025
0299cf5
choir: unify duplicated sproof generation code on Subscriber
metricaez Dec 14, 2025
eff6d7a
fix: fix Subscriber buggy benchmark
metricaez Dec 14, 2025
ebef1e6
misc: build bench util
metricaez Dec 14, 2025
6f18d65
fix: subscriber should not try to benchmark the handlers
metricaez Dec 15, 2025
d186b81
feat: account for data valua in benchmark
metricaez Dec 15, 2025
9e20d8d
feat: test utils and small optimization of Subs
metricaez Dec 15, 2025
00033c4
choir: some relevant comments on numbers and data
metricaez Dec 15, 2025
b6ce109
choir: simpler cargo of sub
metricaez Dec 15, 2025
6ee245e
fix: separation of test utils and empty proof for bench
metricaez Dec 15, 2025
b471ec0
choir: unnecesary flag
metricaez Dec 15, 2025
aaca0cf
feat: no std proof generation and ah westend benchmark
metricaez Dec 16, 2025
65541b6
feat: weights and benchmark details
metricaez Dec 16, 2025
fdc88d6
choir: duplicated child info derivation
metricaez Dec 16, 2025
8653f15
choir: separate weights of sub and misleading param of zombienet
metricaez Dec 16, 2025
509051c
fix: clippy and missing handler
metricaez Dec 16, 2025
58f0a91
feat: integrations cleanup
metricaez Dec 16, 2025
227b73b
feat: max out publish on runtimes and unit weight for broadcaster
metricaez Dec 16, 2025
fbf9cf4
feat: refund weight
metricaez Dec 16, 2025
3532a81
feat: KeyToIncludeInRelayProofApi
metricaez Dec 17, 2025
304cff2
choir: shorter imports
metricaez Dec 17, 2025
75d3b9a
feat: better naming and batch merging of proofs
metricaez Dec 17, 2025
ec75413
choir: minor comment fix
metricaez Dec 18, 2025
a783730
choir: more comments cleanup
metricaez Dec 18, 2025
0995d2b
Merge branch 'feat/keys-to-proof-api' into feat/pubsub-rev1225
metricaez Dec 22, 2025
d0c9c2f
fix: fix parachain-inherent after merge
metricaez Dec 22, 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
24 changes: 24 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
5 changes: 5 additions & 0 deletions cumulus/client/consensus/aura/src/collator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use cumulus_client_consensus_common::{
use cumulus_client_parachain_inherent::{ParachainInherentData, ParachainInherentDataProvider};
use cumulus_primitives_core::{
relay_chain::Hash as PHash, DigestItem, ParachainBlockData, PersistedValidationData,
RelayProofRequest,
};
use cumulus_relay_chain_interface::RelayChainInterface;
use sc_client_api::BackendTransaction;
Expand Down Expand Up @@ -177,6 +178,7 @@ where
parent_hash: Block::Hash,
timestamp: impl Into<Option<Timestamp>>,
relay_parent_descendants: Option<RelayParentData>,
relay_proof_request: 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 +190,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 +227,7 @@ where
validation_data: &PersistedValidationData,
parent_hash: Block::Hash,
timestamp: impl Into<Option<Timestamp>>,
relay_proof_request: 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 +236,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, KeyToIncludeInRelayProof, 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>
+ KeyToIncludeInRelayProof<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>
+ KeyToIncludeInRelayProof<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, KeyToIncludeInRelayProof, RelayProofRequest,
};
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,
) -> RelayProofRequest
where
Block: BlockT,
Client: ProvideRuntimeApi<Block>,
Client::Api: KeyToIncludeInRelayProof<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
105 changes: 89 additions & 16 deletions cumulus/client/parachain-inherent/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,26 @@ use cumulus_primitives_core::{
self, ApprovedPeerId, Block as RelayBlock, Hash as PHash, Header as RelayHeader,
HrmpChannelId,
},
ParaId, PersistedValidationData,
ParaId, PersistedValidationData, RelayProofRequest, RelayStorageKey,
};
pub use cumulus_primitives_parachain_inherent::{ParachainInherentData, INHERENT_IDENTIFIER};
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";

/// Collect the relevant relay chain state in form of a proof for putting it into the validation
/// data inherent.
async fn collect_relay_storage_proof(
/// Builds the list of static relay chain storage keys that are always needed for parachain
/// validation.
async fn get_static_relay_storage_keys(
relay_chain_interface: &impl RelayChainInterface,
para_id: ParaId,
relay_parent: PHash,
include_authorities: bool,
include_next_authorities: bool,
additional_relay_state_keys: Vec<Vec<u8>>,
) -> Option<sp_state_machine::StorageProof> {
) -> Option<Vec<Vec<u8>>> {
use relay_chain::well_known_keys as relay_well_known_keys;

let ingress_channels = relay_chain_interface
Expand Down Expand Up @@ -136,25 +137,95 @@ async fn collect_relay_storage_proof(
relevant_keys.push(relay_well_known_keys::NEXT_AUTHORITIES.to_vec());
}

// Add additional relay state keys
Some(relevant_keys)
}

/// Collect the relevant relay chain state in form of a proof for putting it into the validation
/// data inherent.
async fn collect_relay_storage_proof(
relay_chain_interface: &impl RelayChainInterface,
para_id: ParaId,
relay_parent: PHash,
include_authorities: bool,
include_next_authorities: bool,
additional_relay_state_keys: Vec<Vec<u8>>,
relay_proof_request: RelayProofRequest,
) -> Option<StorageProof> {
// Get static keys that are always needed
let mut all_top_keys = get_static_relay_storage_keys(
relay_chain_interface,
para_id,
relay_parent,
include_authorities,
include_next_authorities,
)
.await?;

// Add additional_relay_state_keys
let unique_keys: Vec<Vec<u8>> = additional_relay_state_keys
.into_iter()
.filter(|key| !relevant_keys.contains(key))
.filter(|key| !all_top_keys.contains(key))
.collect();
relevant_keys.extend(unique_keys);
all_top_keys.extend(unique_keys);

relay_chain_interface
.prove_read(relay_parent, &relevant_keys)
.await
.map_err(|e| {
// Group requested keys by storage type
let RelayProofRequest { keys } = relay_proof_request;
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) => {
if !all_top_keys.contains(&k) {
all_top_keys.push(k);
}
},
RelayStorageKey::Child { storage_key, key } => {
child_keys.entry(storage_key).or_default().push(key);
},
}
}

// Collect all storage proofs
let mut all_proofs = Vec::new();

// Collect top-level storage proof.
match relay_chain_interface.prove_read(relay_parent, &all_top_keys).await {
Ok(top_proof) => {
all_proofs.push(top_proof);
},
Err(e) => {
tracing::error!(
target: LOG_TARGET,
relay_parent = ?relay_parent,
error = ?e,
"Cannot obtain read proof from relay chain.",
"Cannot obtain relay chain storage proof.",
);
})
.ok()
return None;
},
}

// 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) => {
all_proofs.push(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.",
);
},
}
}

// Merge all proofs
Some(StorageProof::merge(all_proofs))
}

pub struct ParachainInherentDataProvider;
Expand All @@ -170,6 +241,7 @@ impl ParachainInherentDataProvider {
para_id: ParaId,
relay_parent_descendants: Vec<RelayHeader>,
additional_relay_state_keys: Vec<Vec<u8>>,
relay_proof_request: RelayProofRequest,
collator_peer_id: PeerId,
) -> Option<ParachainInherentData> {
let collator_peer_id = ApprovedPeerId::try_from(collator_peer_id.to_bytes())
Expand All @@ -195,6 +267,7 @@ impl ParachainInherentDataProvider {
!relay_parent_descendants.is_empty(),
include_next_authorities,
additional_relay_state_keys,
relay_proof_request,
)
.await?;

Expand Down
Loading