mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 05:11:02 +00:00
cumulus-primitives-parachain-inherent: Split into two crates (#2803)
This splits `cumulus-primitives-parachain-inherent` into two crates, the previous `cumulus-primitives-parachain-inherent` and a new `cumulus-client-parachain-inherent`. The idea behind this is to move the `create_at` logic into the client crate. This removes quite a lot of unrelated dependencies from the runtime std build and thus, makes the compilation faster. On my Laptop the compilation is goes down by one minute for `asset-hub-rococo-runtime`. I also assume that the full build of the entire workspace probably can be speed-up a little bit, because more stuff can be compiled in parallel. --------- Co-authored-by: command-bot <>
This commit is contained in:
Generated
+26
-9
@@ -3626,9 +3626,9 @@ dependencies = [
|
||||
"cumulus-client-collator",
|
||||
"cumulus-client-consensus-common",
|
||||
"cumulus-client-consensus-proposer",
|
||||
"cumulus-client-parachain-inherent",
|
||||
"cumulus-primitives-aura",
|
||||
"cumulus-primitives-core",
|
||||
"cumulus-primitives-parachain-inherent",
|
||||
"cumulus-relay-chain-interface",
|
||||
"futures",
|
||||
"parity-scale-codec",
|
||||
@@ -3760,6 +3760,29 @@ dependencies = [
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cumulus-client-parachain-inherent"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"cumulus-primitives-core",
|
||||
"cumulus-primitives-parachain-inherent",
|
||||
"cumulus-relay-chain-interface",
|
||||
"cumulus-test-relay-sproof-builder",
|
||||
"parity-scale-codec",
|
||||
"sc-client-api",
|
||||
"scale-info",
|
||||
"sp-api",
|
||||
"sp-core",
|
||||
"sp-inherents",
|
||||
"sp-runtime",
|
||||
"sp-state-machine",
|
||||
"sp-std 8.0.0",
|
||||
"sp-storage 13.0.0",
|
||||
"sp-trie",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cumulus-client-pov-recovery"
|
||||
version = "0.1.0"
|
||||
@@ -4033,20 +4056,14 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"cumulus-primitives-core",
|
||||
"cumulus-relay-chain-interface",
|
||||
"cumulus-test-relay-sproof-builder",
|
||||
"parity-scale-codec",
|
||||
"sc-client-api",
|
||||
"scale-info",
|
||||
"sp-api",
|
||||
"sp-core",
|
||||
"sp-inherents",
|
||||
"sp-runtime",
|
||||
"sp-state-machine",
|
||||
"sp-std 8.0.0",
|
||||
"sp-storage 13.0.0",
|
||||
"sp-trie",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4303,11 +4320,11 @@ dependencies = [
|
||||
"cumulus-client-cli",
|
||||
"cumulus-client-consensus-common",
|
||||
"cumulus-client-consensus-relay-chain",
|
||||
"cumulus-client-parachain-inherent",
|
||||
"cumulus-client-pov-recovery",
|
||||
"cumulus-client-service",
|
||||
"cumulus-pallet-parachain-system",
|
||||
"cumulus-primitives-core",
|
||||
"cumulus-primitives-parachain-inherent",
|
||||
"cumulus-relay-chain-inprocess-interface",
|
||||
"cumulus-relay-chain-interface",
|
||||
"cumulus-relay-chain-minimal-node",
|
||||
@@ -13033,10 +13050,10 @@ dependencies = [
|
||||
"cumulus-client-consensus-common",
|
||||
"cumulus-client-consensus-proposer",
|
||||
"cumulus-client-consensus-relay-chain",
|
||||
"cumulus-client-parachain-inherent",
|
||||
"cumulus-client-service",
|
||||
"cumulus-primitives-aura",
|
||||
"cumulus-primitives-core",
|
||||
"cumulus-primitives-parachain-inherent",
|
||||
"cumulus-relay-chain-interface",
|
||||
"frame-benchmarking",
|
||||
"frame-benchmarking-cli",
|
||||
|
||||
@@ -57,6 +57,7 @@ members = [
|
||||
"cumulus/client/consensus/proposer",
|
||||
"cumulus/client/consensus/relay-chain",
|
||||
"cumulus/client/network",
|
||||
"cumulus/client/parachain-inherent",
|
||||
"cumulus/client/pov-recovery",
|
||||
"cumulus/client/relay-chain-inprocess-interface",
|
||||
"cumulus/client/relay-chain-interface",
|
||||
|
||||
@@ -41,9 +41,9 @@ substrate-prometheus-endpoint = { path = "../../../../substrate/utils/prometheus
|
||||
cumulus-client-consensus-common = { path = "../common" }
|
||||
cumulus-relay-chain-interface = { path = "../../relay-chain-interface" }
|
||||
cumulus-client-consensus-proposer = { path = "../proposer" }
|
||||
cumulus-client-parachain-inherent = { path = "../../../client/parachain-inherent" }
|
||||
cumulus-primitives-aura = { path = "../../../primitives/aura" }
|
||||
cumulus-primitives-core = { path = "../../../primitives/core" }
|
||||
cumulus-primitives-parachain-inherent = { path = "../../../primitives/parachain-inherent" }
|
||||
cumulus-client-collator = { path = "../../collator" }
|
||||
|
||||
# Polkadot
|
||||
|
||||
@@ -30,10 +30,10 @@ use cumulus_client_consensus_common::{
|
||||
self as consensus_common, ParachainBlockImportMarker, ParachainCandidate,
|
||||
};
|
||||
use cumulus_client_consensus_proposer::ProposerInterface;
|
||||
use cumulus_client_parachain_inherent::{ParachainInherentData, ParachainInherentDataProvider};
|
||||
use cumulus_primitives_core::{
|
||||
relay_chain::Hash as PHash, DigestItem, ParachainBlockData, PersistedValidationData,
|
||||
};
|
||||
use cumulus_primitives_parachain_inherent::ParachainInherentData;
|
||||
use cumulus_relay_chain_interface::RelayChainInterface;
|
||||
|
||||
use polkadot_node_primitives::{Collation, MaybeCompressedPoV};
|
||||
@@ -124,7 +124,7 @@ where
|
||||
parent_hash: Block::Hash,
|
||||
timestamp: impl Into<Option<Timestamp>>,
|
||||
) -> Result<(ParachainInherentData, InherentData), Box<dyn Error + Send + Sync + 'static>> {
|
||||
let paras_inherent_data = ParachainInherentData::create_at(
|
||||
let paras_inherent_data = ParachainInherentDataProvider::create_at(
|
||||
relay_parent,
|
||||
&self.relay_client,
|
||||
validation_data,
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
[package]
|
||||
name = "cumulus-client-parachain-inherent"
|
||||
version = "0.1.0"
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
description = "Inherent that needs to be present in every parachain block. Contains messages and a relay chain storage-proof."
|
||||
license = "Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
async-trait = "0.1.73"
|
||||
codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] }
|
||||
scale-info = { version = "2.10.0", features = ["derive"] }
|
||||
tracing = { version = "0.1.37" }
|
||||
|
||||
# Substrate
|
||||
sc-client-api = { path = "../../../substrate/client/api" }
|
||||
sp-api = { path = "../../../substrate/primitives/api" }
|
||||
sp-core = { path = "../../../substrate/primitives/core" }
|
||||
sp-inherents = { path = "../../../substrate/primitives/inherents" }
|
||||
sp-runtime = { path = "../../../substrate/primitives/runtime" }
|
||||
sp-state-machine = { path = "../../../substrate/primitives/state-machine" }
|
||||
sp-std = { path = "../../../substrate/primitives/std" }
|
||||
sp-storage = { path = "../../../substrate/primitives/storage" }
|
||||
sp-trie = { path = "../../../substrate/primitives/trie" }
|
||||
|
||||
# Cumulus
|
||||
cumulus-primitives-core = { path = "../../primitives/core" }
|
||||
cumulus-primitives-parachain-inherent = { path = "../../primitives/parachain-inherent" }
|
||||
cumulus-relay-chain-interface = { path = "../relay-chain-interface" }
|
||||
cumulus-test-relay-sproof-builder = { path = "../../test/relay-sproof-builder" }
|
||||
+8
-20
@@ -16,7 +16,6 @@
|
||||
|
||||
//! Client side code for generating the parachain inherent.
|
||||
|
||||
use crate::ParachainInherentData;
|
||||
use codec::Decode;
|
||||
use cumulus_primitives_core::{
|
||||
relay_chain::{self, Hash as PHash, HrmpChannelId},
|
||||
@@ -24,6 +23,11 @@ use cumulus_primitives_core::{
|
||||
};
|
||||
use cumulus_relay_chain_interface::RelayChainInterface;
|
||||
|
||||
mod mock;
|
||||
|
||||
pub use cumulus_primitives_parachain_inherent::{ParachainInherentData, INHERENT_IDENTIFIER};
|
||||
pub use mock::{MockValidationDataInherentDataProvider, MockXcmConfig};
|
||||
|
||||
const LOG_TARGET: &str = "parachain-inherent";
|
||||
|
||||
/// Collect the relevant relay chain state in form of a proof for putting it into the validation
|
||||
@@ -132,7 +136,9 @@ async fn collect_relay_storage_proof(
|
||||
.ok()
|
||||
}
|
||||
|
||||
impl ParachainInherentData {
|
||||
pub struct ParachainInherentDataProvider;
|
||||
|
||||
impl ParachainInherentDataProvider {
|
||||
/// Create the [`ParachainInherentData`] at the given `relay_parent`.
|
||||
///
|
||||
/// Returns `None` if the creation failed.
|
||||
@@ -178,21 +184,3 @@ impl ParachainInherentData {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl sp_inherents::InherentDataProvider for ParachainInherentData {
|
||||
async fn provide_inherent_data(
|
||||
&self,
|
||||
inherent_data: &mut sp_inherents::InherentData,
|
||||
) -> Result<(), sp_inherents::Error> {
|
||||
inherent_data.put_data(crate::INHERENT_IDENTIFIER, &self)
|
||||
}
|
||||
|
||||
async fn try_handle_error(
|
||||
&self,
|
||||
_: &sp_inherents::InherentIdentifier,
|
||||
_: &[u8],
|
||||
) -> Option<Result<(), sp_inherents::Error>> {
|
||||
None
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -19,6 +19,7 @@ use codec::Decode;
|
||||
use cumulus_primitives_core::{
|
||||
relay_chain, InboundDownwardMessage, InboundHrmpMessage, ParaId, PersistedValidationData,
|
||||
};
|
||||
use cumulus_primitives_parachain_inherent::MessageQueueChain;
|
||||
use sc_client_api::{Backend, StorageProvider};
|
||||
use sp_core::twox_128;
|
||||
use sp_inherents::{InherentData, InherentDataProvider};
|
||||
@@ -168,7 +169,7 @@ impl<R: Send + Sync + GenerateRandomness<u64>> InherentDataProvider
|
||||
|
||||
// Process the downward messages and set up the correct head
|
||||
let mut downward_messages = Vec::new();
|
||||
let mut dmq_mqc = crate::MessageQueueChain(self.xcm_config.starting_dmq_mqc_head);
|
||||
let mut dmq_mqc = MessageQueueChain::new(self.xcm_config.starting_dmq_mqc_head);
|
||||
for msg in &self.raw_downward_messages {
|
||||
let wrapped = InboundDownwardMessage { sent_at: relay_parent_number, msg: msg.clone() };
|
||||
|
||||
@@ -188,7 +189,7 @@ impl<R: Send + Sync + GenerateRandomness<u64>> InherentDataProvider
|
||||
|
||||
// Now iterate again, updating the heads as we go
|
||||
for (para_id, messages) in &horizontal_messages {
|
||||
let mut channel_mqc = crate::MessageQueueChain(
|
||||
let mut channel_mqc = MessageQueueChain::new(
|
||||
*self
|
||||
.xcm_config
|
||||
.starting_hrmp_mqc_heads
|
||||
@@ -102,10 +102,10 @@ cumulus-client-consensus-aura = { path = "../client/consensus/aura" }
|
||||
cumulus-client-consensus-relay-chain = { path = "../client/consensus/relay-chain" }
|
||||
cumulus-client-consensus-common = { path = "../client/consensus/common" }
|
||||
cumulus-client-consensus-proposer = { path = "../client/consensus/proposer" }
|
||||
cumulus-client-parachain-inherent = { path = "../client/parachain-inherent" }
|
||||
cumulus-client-service = { path = "../client/service" }
|
||||
cumulus-primitives-aura = { path = "../primitives/aura" }
|
||||
cumulus-primitives-core = { path = "../primitives/core" }
|
||||
cumulus-primitives-parachain-inherent = { path = "../primitives/parachain-inherent" }
|
||||
cumulus-relay-chain-interface = { path = "../client/relay-chain-interface" }
|
||||
color-print = "0.3.4"
|
||||
|
||||
|
||||
@@ -1085,7 +1085,7 @@ where
|
||||
let relay_chain_interface = relay_chain_interface.clone();
|
||||
async move {
|
||||
let parachain_inherent =
|
||||
cumulus_primitives_parachain_inherent::ParachainInherentData::create_at(
|
||||
cumulus_client_parachain_inherent::ParachainInherentDataProvider::create_at(
|
||||
relay_parent,
|
||||
&relay_chain_interface,
|
||||
&validation_data,
|
||||
|
||||
@@ -13,23 +13,17 @@ workspace = true
|
||||
async-trait = { version = "0.1.74", optional = true }
|
||||
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
|
||||
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }
|
||||
tracing = { version = "0.1.37", optional = true }
|
||||
|
||||
# Substrate
|
||||
sc-client-api = { path = "../../../substrate/client/api", optional = true }
|
||||
sp-api = { path = "../../../substrate/primitives/api", optional = true }
|
||||
sp-core = { path = "../../../substrate/primitives/core", default-features = false }
|
||||
sp-inherents = { path = "../../../substrate/primitives/inherents", default-features = false }
|
||||
sp-runtime = { path = "../../../substrate/primitives/runtime", optional = true }
|
||||
sp-state-machine = { path = "../../../substrate/primitives/state-machine", optional = true }
|
||||
sp-std = { path = "../../../substrate/primitives/std", default-features = false }
|
||||
sp-storage = { path = "../../../substrate/primitives/storage", optional = true }
|
||||
sp-trie = { path = "../../../substrate/primitives/trie", default-features = false }
|
||||
|
||||
# Cumulus
|
||||
cumulus-primitives-core = { path = "../core", default-features = false }
|
||||
cumulus-relay-chain-interface = { path = "../../client/relay-chain-interface", optional = true }
|
||||
cumulus-test-relay-sproof-builder = { path = "../../test/relay-sproof-builder", optional = true }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
@@ -37,17 +31,9 @@ std = [
|
||||
"async-trait",
|
||||
"codec/std",
|
||||
"cumulus-primitives-core/std",
|
||||
"cumulus-relay-chain-interface",
|
||||
"cumulus-test-relay-sproof-builder",
|
||||
"sc-client-api",
|
||||
"scale-info/std",
|
||||
"sp-api",
|
||||
"sp-core/std",
|
||||
"sp-inherents/std",
|
||||
"sp-runtime",
|
||||
"sp-state-machine",
|
||||
"sp-std/std",
|
||||
"sp-storage",
|
||||
"sp-trie/std",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
@@ -19,11 +19,11 @@
|
||||
//! The [`ParachainInherentData`] is the data that is passed by the collator to the parachain
|
||||
//! runtime. The runtime will use this data to execute messages from other parachains/the relay
|
||||
//! chain or to read data from the relay chain state. When the parachain is validated by a parachain
|
||||
//! validator on the relay chain, this data is checked for correctnes. If the data passed by the
|
||||
//! validator on the relay chain, this data is checked for correctness. If the data passed by the
|
||||
//! collator to the runtime isn't correct, the parachain candidate is considered invalid.
|
||||
//!
|
||||
//! Use [`ParachainInherentData::create_at`] to create the [`ParachainInherentData`] at a given
|
||||
//! relay chain block to include it in a parachain block.
|
||||
//! To create a [`ParachainInherentData`] for a specific relay chain block, there exists the
|
||||
//! `ParachainInherentDataExt` trait in `cumulus-client-parachain-inherent` that helps with this.
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
@@ -36,13 +36,6 @@ use scale_info::TypeInfo;
|
||||
use sp_inherents::InherentIdentifier;
|
||||
use sp_std::{collections::btree_map::BTreeMap, vec::Vec};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
mod client_side;
|
||||
#[cfg(feature = "std")]
|
||||
mod mock;
|
||||
#[cfg(feature = "std")]
|
||||
pub use mock::{MockValidationDataInherentDataProvider, MockXcmConfig};
|
||||
|
||||
/// The identifier for the parachain inherent.
|
||||
pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"sysi1337";
|
||||
|
||||
@@ -68,6 +61,25 @@ pub struct ParachainInherentData {
|
||||
pub horizontal_messages: BTreeMap<ParaId, Vec<InboundHrmpMessage>>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[async_trait::async_trait]
|
||||
impl sp_inherents::InherentDataProvider for ParachainInherentData {
|
||||
async fn provide_inherent_data(
|
||||
&self,
|
||||
inherent_data: &mut sp_inherents::InherentData,
|
||||
) -> Result<(), sp_inherents::Error> {
|
||||
inherent_data.put_data(INHERENT_IDENTIFIER, &self)
|
||||
}
|
||||
|
||||
async fn try_handle_error(
|
||||
&self,
|
||||
_: &sp_inherents::InherentIdentifier,
|
||||
_: &[u8],
|
||||
) -> Option<Result<(), sp_inherents::Error>> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// This struct provides ability to extend a message queue chain (MQC) and compute a new head.
|
||||
///
|
||||
/// MQC is an instance of a [hash chain] applied to a message queue. Using a hash chain it's
|
||||
@@ -84,6 +96,11 @@ pub struct ParachainInherentData {
|
||||
pub struct MessageQueueChain(RelayHash);
|
||||
|
||||
impl MessageQueueChain {
|
||||
/// Create a new instance initialized to `hash`.
|
||||
pub fn new(hash: RelayHash) -> Self {
|
||||
Self(hash)
|
||||
}
|
||||
|
||||
/// Extend the hash chain with an HRMP message. This method should be used only when
|
||||
/// this chain is tracking HRMP.
|
||||
pub fn extend_hrmp(&mut self, horizontal_message: &InboundHrmpMessage) -> &mut Self {
|
||||
|
||||
@@ -71,9 +71,9 @@ cumulus-client-cli = { path = "../../client/cli" }
|
||||
parachains-common = { path = "../../parachains/common" }
|
||||
cumulus-client-consensus-common = { path = "../../client/consensus/common" }
|
||||
cumulus-client-consensus-relay-chain = { path = "../../client/consensus/relay-chain" }
|
||||
cumulus-client-parachain-inherent = { path = "../../client/parachain-inherent" }
|
||||
cumulus-client-service = { path = "../../client/service" }
|
||||
cumulus-primitives-core = { path = "../../primitives/core" }
|
||||
cumulus-primitives-parachain-inherent = { path = "../../primitives/parachain-inherent" }
|
||||
cumulus-relay-chain-inprocess-interface = { path = "../../client/relay-chain-inprocess-interface" }
|
||||
cumulus-relay-chain-interface = { path = "../../client/relay-chain-interface" }
|
||||
cumulus-test-runtime = { path = "../runtime" }
|
||||
|
||||
@@ -19,8 +19,8 @@ use codec::Encode;
|
||||
use sc_block_builder::BlockBuilderBuilder;
|
||||
|
||||
use crate::{construct_extrinsic, Client as TestClient};
|
||||
use cumulus_client_parachain_inherent::ParachainInherentData;
|
||||
use cumulus_primitives_core::{relay_chain::AccountId, PersistedValidationData};
|
||||
use cumulus_primitives_parachain_inherent::ParachainInherentData;
|
||||
use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;
|
||||
use cumulus_test_runtime::{
|
||||
BalancesCall, GluttonCall, NodeBlock, SudoCall, UncheckedExtrinsic, WASM_BINARY,
|
||||
|
||||
@@ -447,7 +447,7 @@ where
|
||||
let relay_chain_interface = relay_chain_interface_for_closure.clone();
|
||||
async move {
|
||||
let parachain_inherent =
|
||||
cumulus_primitives_parachain_inherent::ParachainInherentData::create_at(
|
||||
cumulus_client_parachain_inherent::ParachainInherentDataProvider::create_at(
|
||||
relay_parent,
|
||||
&relay_chain_interface,
|
||||
&validation_data,
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
title: "cumulus-primitives-parachain-inherent: Split into two crates"
|
||||
|
||||
doc:
|
||||
- audience: Node Dev
|
||||
description: |
|
||||
This splits `cumulus-primitives-parachain-inherent` into two crates. The new crate is called
|
||||
`cumulus-client-parachain-inherent`. This is done to improve the compile time for runtimes,
|
||||
as they are not required anymore to pull in half of the node side at compile time.
|
||||
|
||||
To migrate your code you need to change
|
||||
`cumulus_primitives_parachain_inherent::ParachainInherentData::create_at` to
|
||||
`cumulus_client_parachain_inherent::ParachainInherentDataProvider::create_at`.
|
||||
Any other code should be compatible. The mocking code also moved to the new client crate and
|
||||
you may need to adapt your imports accordingly. Generally, replacing the old crate with the new
|
||||
crate fix most compile errors resulting from this pull request.
|
||||
|
||||
crates:
|
||||
- name: "cumulus-primitives-parachain-inherent"
|
||||
- name: "cumulus-client-parachain-inherent"
|
||||
Reference in New Issue
Block a user