From f0b7ecf1dd2cc9af825f797fdcb5fd65b425fab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Wed, 6 Dec 2023 09:50:06 +0100 Subject: [PATCH 1/6] Yeah --- Cargo.lock | 30 ++++++++++++++----- Cargo.toml | 1 + cumulus/client/parachain-inherent/Cargo.toml | 30 +++++++++++++++++++ .../parachain-inherent/src/lib.rs} | 7 +++-- .../parachain-inherent/src/mock.rs | 0 .../primitives/parachain-inherent/Cargo.toml | 16 ---------- .../primitives/parachain-inherent/src/lib.rs | 9 ------ 7 files changed, 59 insertions(+), 34 deletions(-) create mode 100644 cumulus/client/parachain-inherent/Cargo.toml rename cumulus/{primitives/parachain-inherent/src/client_side.rs => client/parachain-inherent/src/lib.rs} (96%) rename cumulus/{primitives => client}/parachain-inherent/src/mock.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 7bec4ad24ba2..285238c8671a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3458,6 +3458,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" @@ -3729,22 +3752,15 @@ dependencies = [ name = "cumulus-primitives-parachain-inherent" 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]] diff --git a/Cargo.toml b/Cargo.toml index 5fb7c0f2315b..41873e477b2e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,6 +41,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", diff --git a/cumulus/client/parachain-inherent/Cargo.toml b/cumulus/client/parachain-inherent/Cargo.toml new file mode 100644 index 000000000000..15c35826f927 --- /dev/null +++ b/cumulus/client/parachain-inherent/Cargo.toml @@ -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 = { version = "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" } diff --git a/cumulus/primitives/parachain-inherent/src/client_side.rs b/cumulus/client/parachain-inherent/src/lib.rs similarity index 96% rename from cumulus/primitives/parachain-inherent/src/client_side.rs rename to cumulus/client/parachain-inherent/src/lib.rs index 52987d2da44c..831cf7f18c9e 100644 --- a/cumulus/primitives/parachain-inherent/src/client_side.rs +++ b/cumulus/client/parachain-inherent/src/lib.rs @@ -16,14 +16,17 @@ //! 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}, ParaId, PersistedValidationData, }; +use cumulus_primitives_parachain_inherent::{ParachainInherentData, INHERENT_IDENTIFIER}; use cumulus_relay_chain_interface::RelayChainInterface; +mod mock; +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 @@ -185,7 +188,7 @@ impl sp_inherents::InherentDataProvider for ParachainInherentData { &self, inherent_data: &mut sp_inherents::InherentData, ) -> Result<(), sp_inherents::Error> { - inherent_data.put_data(crate::INHERENT_IDENTIFIER, &self) + inherent_data.put_data(INHERENT_IDENTIFIER, &self) } async fn try_handle_error( diff --git a/cumulus/primitives/parachain-inherent/src/mock.rs b/cumulus/client/parachain-inherent/src/mock.rs similarity index 100% rename from cumulus/primitives/parachain-inherent/src/mock.rs rename to cumulus/client/parachain-inherent/src/mock.rs diff --git a/cumulus/primitives/parachain-inherent/Cargo.toml b/cumulus/primitives/parachain-inherent/Cargo.toml index 5d3c72a59f91..b4bcd051364d 100644 --- a/cumulus/primitives/parachain-inherent/Cargo.toml +++ b/cumulus/primitives/parachain-inherent/Cargo.toml @@ -7,44 +7,28 @@ description = "Inherent that needs to be present in every parachain block. Conta license = "Apache-2.0" [dependencies] -async-trait = { version = "0.1.73", 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"] 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", ] diff --git a/cumulus/primitives/parachain-inherent/src/lib.rs b/cumulus/primitives/parachain-inherent/src/lib.rs index 08407023bb46..b21bf9e230a9 100644 --- a/cumulus/primitives/parachain-inherent/src/lib.rs +++ b/cumulus/primitives/parachain-inherent/src/lib.rs @@ -36,15 +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")] -pub use 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"; From a10c6f3c9a06a311bddaa14b11115a98628f8eba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Sun, 24 Dec 2023 09:15:20 +0100 Subject: [PATCH 2/6] Fix most of the stuff --- Cargo.lock | 1 + cumulus/client/parachain-inherent/Cargo.toml | 2 +- cumulus/client/parachain-inherent/src/lib.rs | 40 +++++++++---------- cumulus/client/parachain-inherent/src/mock.rs | 5 ++- .../primitives/parachain-inherent/Cargo.toml | 2 + .../primitives/parachain-inherent/src/lib.rs | 24 +++++++++++ 6 files changed, 50 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 285238c8671a..7857b27ff62c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3752,6 +3752,7 @@ dependencies = [ name = "cumulus-primitives-parachain-inherent" version = "0.1.0" dependencies = [ + "async-trait", "cumulus-primitives-core", "parity-scale-codec", "scale-info", diff --git a/cumulus/client/parachain-inherent/Cargo.toml b/cumulus/client/parachain-inherent/Cargo.toml index 15c35826f927..b6d477519ecc 100644 --- a/cumulus/client/parachain-inherent/Cargo.toml +++ b/cumulus/client/parachain-inherent/Cargo.toml @@ -7,7 +7,7 @@ description = "Inherent that needs to be present in every parachain block. Conta license = "Apache-2.0" [dependencies] -async-trait = { version = "0.1.73" } +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" } diff --git a/cumulus/client/parachain-inherent/src/lib.rs b/cumulus/client/parachain-inherent/src/lib.rs index 831cf7f18c9e..4eae7573f588 100644 --- a/cumulus/client/parachain-inherent/src/lib.rs +++ b/cumulus/client/parachain-inherent/src/lib.rs @@ -21,10 +21,11 @@ use cumulus_primitives_core::{ relay_chain::{self, Hash as PHash, HrmpChannelId}, ParaId, PersistedValidationData, }; -use cumulus_primitives_parachain_inherent::{ParachainInherentData, INHERENT_IDENTIFIER}; 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"; @@ -135,11 +136,26 @@ async fn collect_relay_storage_proof( .ok() } -impl ParachainInherentData { +/// Extension trait for [`ParachainInherentData`]. +/// +/// Provides the [`create_at`](Self::create_at) function for constructing a +/// [`ParachainInherentData`] at a particular relay parent. +#[async_trait::async_trait] +pub trait ParachainInherentDataExt { /// Create the [`ParachainInherentData`] at the given `relay_parent`. /// /// Returns `None` if the creation failed. - pub async fn create_at( + async fn create_at( + relay_parent: PHash, + relay_chain_interface: &impl RelayChainInterface, + validation_data: &PersistedValidationData, + para_id: ParaId, + ) -> Option; +} + +#[async_trait::async_trait] +impl ParachainInherentDataExt for ParachainInherentData { + async fn create_at( relay_parent: PHash, relay_chain_interface: &impl RelayChainInterface, validation_data: &PersistedValidationData, @@ -181,21 +197,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(INHERENT_IDENTIFIER, &self) - } - - async fn try_handle_error( - &self, - _: &sp_inherents::InherentIdentifier, - _: &[u8], - ) -> Option> { - None - } -} diff --git a/cumulus/client/parachain-inherent/src/mock.rs b/cumulus/client/parachain-inherent/src/mock.rs index e40cb49acddd..7af10a661e09 100644 --- a/cumulus/client/parachain-inherent/src/mock.rs +++ b/cumulus/client/parachain-inherent/src/mock.rs @@ -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> 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> 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 diff --git a/cumulus/primitives/parachain-inherent/Cargo.toml b/cumulus/primitives/parachain-inherent/Cargo.toml index b4bcd051364d..d06b8b0e24a2 100644 --- a/cumulus/primitives/parachain-inherent/Cargo.toml +++ b/cumulus/primitives/parachain-inherent/Cargo.toml @@ -7,6 +7,7 @@ description = "Inherent that needs to be present in every parachain block. Conta license = "Apache-2.0" [dependencies] +async-trait = { version = "0.1.73", 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"] } @@ -24,6 +25,7 @@ cumulus-primitives-core = { path = "../core", default-features = false } [features] default = ["std"] std = [ + "async-trait", "codec/std", "cumulus-primitives-core/std", "scale-info/std", diff --git a/cumulus/primitives/parachain-inherent/src/lib.rs b/cumulus/primitives/parachain-inherent/src/lib.rs index b21bf9e230a9..ea1d9735a8ee 100644 --- a/cumulus/primitives/parachain-inherent/src/lib.rs +++ b/cumulus/primitives/parachain-inherent/src/lib.rs @@ -61,6 +61,25 @@ pub struct ParachainInherentData { pub horizontal_messages: BTreeMap>, } +#[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> { + 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 @@ -77,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 { From 518f8555e52dca1e38c6848543083228b8dca104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Sun, 24 Dec 2023 10:07:25 +0100 Subject: [PATCH 3/6] Finish it --- Cargo.lock | 6 +++--- cumulus/client/consensus/aura/Cargo.toml | 2 +- cumulus/client/consensus/aura/src/collator.rs | 4 ++-- cumulus/client/parachain-inherent/src/lib.rs | 21 ++++--------------- cumulus/polkadot-parachain/Cargo.toml | 2 +- cumulus/polkadot-parachain/src/service.rs | 2 +- cumulus/test/service/Cargo.toml | 2 +- cumulus/test/service/src/bench_utils.rs | 2 +- cumulus/test/service/src/lib.rs | 2 +- 9 files changed, 15 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9bc5cfe78cfe..196003c40746 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3625,9 +3625,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", @@ -4319,11 +4319,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", @@ -13054,10 +13054,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", diff --git a/cumulus/client/consensus/aura/Cargo.toml b/cumulus/client/consensus/aura/Cargo.toml index 4c20911c645d..d022fe4df7e5 100644 --- a/cumulus/client/consensus/aura/Cargo.toml +++ b/cumulus/client/consensus/aura/Cargo.toml @@ -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 diff --git a/cumulus/client/consensus/aura/src/collator.rs b/cumulus/client/consensus/aura/src/collator.rs index b00c3952e2bc..1ca4527cfc32 100644 --- a/cumulus/client/consensus/aura/src/collator.rs +++ b/cumulus/client/consensus/aura/src/collator.rs @@ -33,7 +33,7 @@ use cumulus_client_consensus_proposer::ProposerInterface; use cumulus_primitives_core::{ relay_chain::Hash as PHash, DigestItem, ParachainBlockData, PersistedValidationData, }; -use cumulus_primitives_parachain_inherent::ParachainInherentData; +use cumulus_client_parachain_inherent::{ ParachainInherentData, ParachainInherentDataProvider }; use cumulus_relay_chain_interface::RelayChainInterface; use polkadot_node_primitives::{Collation, MaybeCompressedPoV}; @@ -124,7 +124,7 @@ where parent_hash: Block::Hash, timestamp: impl Into>, ) -> Result<(ParachainInherentData, InherentData), Box> { - let paras_inherent_data = ParachainInherentData::create_at( + let paras_inherent_data = ParachainInherentDataProvider::create_at( relay_parent, &self.relay_client, validation_data, diff --git a/cumulus/client/parachain-inherent/src/lib.rs b/cumulus/client/parachain-inherent/src/lib.rs index 4eae7573f588..57353638e197 100644 --- a/cumulus/client/parachain-inherent/src/lib.rs +++ b/cumulus/client/parachain-inherent/src/lib.rs @@ -136,26 +136,13 @@ async fn collect_relay_storage_proof( .ok() } -/// Extension trait for [`ParachainInherentData`]. -/// -/// Provides the [`create_at`](Self::create_at) function for constructing a -/// [`ParachainInherentData`] at a particular relay parent. -#[async_trait::async_trait] -pub trait ParachainInherentDataExt { +pub struct ParachainInherentDataProvider; + +impl ParachainInherentDataProvider { /// Create the [`ParachainInherentData`] at the given `relay_parent`. /// /// Returns `None` if the creation failed. - async fn create_at( - relay_parent: PHash, - relay_chain_interface: &impl RelayChainInterface, - validation_data: &PersistedValidationData, - para_id: ParaId, - ) -> Option; -} - -#[async_trait::async_trait] -impl ParachainInherentDataExt for ParachainInherentData { - async fn create_at( + pub async fn create_at( relay_parent: PHash, relay_chain_interface: &impl RelayChainInterface, validation_data: &PersistedValidationData, diff --git a/cumulus/polkadot-parachain/Cargo.toml b/cumulus/polkadot-parachain/Cargo.toml index c2b3b92b23f8..02624dcdbc18 100644 --- a/cumulus/polkadot-parachain/Cargo.toml +++ b/cumulus/polkadot-parachain/Cargo.toml @@ -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" diff --git a/cumulus/polkadot-parachain/src/service.rs b/cumulus/polkadot-parachain/src/service.rs index 77978a49f561..232944e20166 100644 --- a/cumulus/polkadot-parachain/src/service.rs +++ b/cumulus/polkadot-parachain/src/service.rs @@ -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, diff --git a/cumulus/test/service/Cargo.toml b/cumulus/test/service/Cargo.toml index c6d82191a9ed..caf89b8a130c 100644 --- a/cumulus/test/service/Cargo.toml +++ b/cumulus/test/service/Cargo.toml @@ -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" } diff --git a/cumulus/test/service/src/bench_utils.rs b/cumulus/test/service/src/bench_utils.rs index 1894835caec8..4ace894b392a 100644 --- a/cumulus/test/service/src/bench_utils.rs +++ b/cumulus/test/service/src/bench_utils.rs @@ -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, diff --git a/cumulus/test/service/src/lib.rs b/cumulus/test/service/src/lib.rs index 586c4603c76a..ab0bd4b33e0c 100644 --- a/cumulus/test/service/src/lib.rs +++ b/cumulus/test/service/src/lib.rs @@ -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, From 394d5e44e7f7c84357e2dac300e268e3e1d827d4 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Sun, 24 Dec 2023 16:22:03 +0000 Subject: [PATCH 4/6] ".git/.scripts/commands/fmt/fmt.sh" --- cumulus/client/consensus/aura/src/collator.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cumulus/client/consensus/aura/src/collator.rs b/cumulus/client/consensus/aura/src/collator.rs index 1ca4527cfc32..22691f70e3c1 100644 --- a/cumulus/client/consensus/aura/src/collator.rs +++ b/cumulus/client/consensus/aura/src/collator.rs @@ -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_client_parachain_inherent::{ ParachainInherentData, ParachainInherentDataProvider }; use cumulus_relay_chain_interface::RelayChainInterface; use polkadot_node_primitives::{Collation, MaybeCompressedPoV}; From cab21553c5339f2ee7a621c84f06256820ee27e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Wed, 27 Dec 2023 10:16:42 +0100 Subject: [PATCH 5/6] Update docs --- cumulus/primitives/parachain-inherent/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cumulus/primitives/parachain-inherent/src/lib.rs b/cumulus/primitives/parachain-inherent/src/lib.rs index ea1d9735a8ee..75a56693958e 100644 --- a/cumulus/primitives/parachain-inherent/src/lib.rs +++ b/cumulus/primitives/parachain-inherent/src/lib.rs @@ -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)] From ef74c9a6b19354a61d425ec4bffb091a3291306d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Fri, 5 Jan 2024 20:54:40 +0100 Subject: [PATCH 6/6] Adds prdoc --- prdoc/pr_2803.prdoc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 prdoc/pr_2803.prdoc diff --git a/prdoc/pr_2803.prdoc b/prdoc/pr_2803.prdoc new file mode 100644 index 000000000000..1ddd3dd677a1 --- /dev/null +++ b/prdoc/pr_2803.prdoc @@ -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"