mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 14:01:06 +00:00
Merge branch 'master' into gav-xcm-v3
This commit is contained in:
+14
-16
@@ -5,32 +5,30 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
# Substrate dependencies
|
||||
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ "derive" ] }
|
||||
|
||||
# Substrate
|
||||
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
sp-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
sp-trie = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
|
||||
# Polkadot dependencies
|
||||
# Polkadot
|
||||
polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
||||
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
||||
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
||||
polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
||||
|
||||
# Other dependencies
|
||||
impl-trait-for-tuples = "0.2.1"
|
||||
codec = { package = "parity-scale-codec", version = "2.3.0", default-features = false, features = [ "derive" ] }
|
||||
|
||||
[features]
|
||||
default = [ "std" ]
|
||||
std = [
|
||||
"codec/std",
|
||||
"sp-std/std",
|
||||
"polkadot-primitives/std",
|
||||
"polkadot-parachain/std",
|
||||
"polkadot-core-primitives/std",
|
||||
"sp-runtime/std",
|
||||
"sp-trie/std",
|
||||
"sp-api/std",
|
||||
"frame-support/std",
|
||||
"sp-api/std",
|
||||
"sp-runtime/std",
|
||||
"sp-std/std",
|
||||
"sp-trie/std",
|
||||
"polkadot-core-primitives/std",
|
||||
"polkadot-parachain/std",
|
||||
"polkadot-primitives/std",
|
||||
]
|
||||
|
||||
+48
-13
@@ -19,12 +19,13 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
use polkadot_parachain::primitives::HeadData;
|
||||
use sp_runtime::{traits::Block as BlockT, RuntimeDebug};
|
||||
use sp_std::prelude::*;
|
||||
|
||||
pub use polkadot_core_primitives::InboundDownwardMessage;
|
||||
pub use polkadot_parachain::primitives::{
|
||||
DmpMessageHandler, Id as ParaId, UpwardMessage, ValidationParams, XcmpMessageFormat,
|
||||
DmpMessageHandler, Id as ParaId, IsSystem, UpwardMessage, ValidationParams, XcmpMessageFormat,
|
||||
XcmpMessageHandler,
|
||||
};
|
||||
pub use polkadot_primitives::v1::{
|
||||
@@ -138,12 +139,6 @@ pub enum ServiceQuality {
|
||||
Fast,
|
||||
}
|
||||
|
||||
/// A trait which is called when the validation data is set.
|
||||
#[impl_trait_for_tuples::impl_for_tuples(30)]
|
||||
pub trait OnValidationData {
|
||||
fn on_validation_data(data: &PersistedValidationData);
|
||||
}
|
||||
|
||||
/// The parachain block that is created by a collator.
|
||||
///
|
||||
/// This is send as PoV (proof of validity block) to the relay-chain validators. There it will be
|
||||
@@ -200,8 +195,10 @@ impl<B: BlockT> ParachainBlockData<B> {
|
||||
}
|
||||
|
||||
/// Information about a collation.
|
||||
///
|
||||
/// This was used in version 1 of the [`CollectCollationInfo`] runtime api.
|
||||
#[derive(Clone, Debug, codec::Decode, codec::Encode, PartialEq)]
|
||||
pub struct CollationInfo {
|
||||
pub struct CollationInfoV1 {
|
||||
/// Messages destined to be interpreted by the Relay chain itself.
|
||||
pub upward_messages: Vec<UpwardMessage>,
|
||||
/// The horizontal messages sent by the parachain.
|
||||
@@ -214,10 +211,48 @@ pub struct CollationInfo {
|
||||
pub hrmp_watermark: relay_chain::v1::BlockNumber,
|
||||
}
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
/// Runtime api to collect information about a collation.
|
||||
pub trait CollectCollationInfo {
|
||||
/// Collect information about a collation.
|
||||
fn collect_collation_info() -> CollationInfo;
|
||||
impl CollationInfoV1 {
|
||||
/// Convert into the latest version of the [`CollationInfo`] struct.
|
||||
pub fn into_latest(self, head_data: HeadData) -> CollationInfo {
|
||||
CollationInfo {
|
||||
upward_messages: self.upward_messages,
|
||||
horizontal_messages: self.horizontal_messages,
|
||||
new_validation_code: self.new_validation_code,
|
||||
processed_downward_messages: self.processed_downward_messages,
|
||||
hrmp_watermark: self.hrmp_watermark,
|
||||
head_data,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Information about a collation.
|
||||
#[derive(Clone, Debug, codec::Decode, codec::Encode, PartialEq)]
|
||||
pub struct CollationInfo {
|
||||
/// Messages destined to be interpreted by the Relay chain itself.
|
||||
pub upward_messages: Vec<UpwardMessage>,
|
||||
/// The horizontal messages sent by the parachain.
|
||||
pub horizontal_messages: Vec<OutboundHrmpMessage>,
|
||||
/// New validation code.
|
||||
pub new_validation_code: Option<relay_chain::v1::ValidationCode>,
|
||||
/// The number of messages processed from the DMQ.
|
||||
pub processed_downward_messages: u32,
|
||||
/// The mark which specifies the block number up to which all inbound HRMP messages are processed.
|
||||
pub hrmp_watermark: relay_chain::v1::BlockNumber,
|
||||
/// The head data, aka encoded header, of the block that corresponds to the collation.
|
||||
pub head_data: HeadData,
|
||||
}
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
/// Runtime api to collect information about a collation.
|
||||
#[api_version(2)]
|
||||
pub trait CollectCollationInfo {
|
||||
/// Collect information about a collation.
|
||||
#[changed_in(2)]
|
||||
fn collect_collation_info() -> CollationInfoV1;
|
||||
/// Collect information about a collation.
|
||||
///
|
||||
/// The given `header` is the header of the built block for that
|
||||
/// we are collecting the collation info for.
|
||||
fn collect_collation_info(header: &Block::Header) -> CollationInfo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,27 +5,26 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
# Substrate dependencies
|
||||
sp-inherents = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
sc-client-api = { git = "https://github.com/paritytech/substrate", optional = true , branch = "master" }
|
||||
sp-runtime = { git = "https://github.com/paritytech/substrate", optional = true , branch = "master" }
|
||||
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
sp-state-machine = { git = "https://github.com/paritytech/substrate", optional = true , branch = "master" }
|
||||
sp-trie = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
sp-api = { git = "https://github.com/paritytech/substrate", optional = true , branch = "master" }
|
||||
sp-storage = { git = "https://github.com/paritytech/substrate", optional = true , branch = "master" }
|
||||
|
||||
# Cumulus dependencies
|
||||
cumulus-primitives-core = { path = "../core", default-features = false }
|
||||
cumulus-test-relay-sproof-builder = { path = "../../test/relay-sproof-builder", optional = true }
|
||||
cumulus-relay-chain-interface = { path = "../../client/relay-chain-interface", optional = true }
|
||||
|
||||
# Other dependencies
|
||||
async-trait = { version = "0.1.42", optional = true }
|
||||
codec = { package = "parity-scale-codec", version = "2.3.0", default-features = false, features = [ "derive" ] }
|
||||
scale-info = { version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
tracing = { version = "0.1.22", optional = true }
|
||||
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ "derive" ] }
|
||||
scale-info = { version = "2.0.0", default-features = false, features = ["derive"] }
|
||||
tracing = { version = "0.1.31", optional = true }
|
||||
|
||||
# Substrate
|
||||
sc-client-api = { git = "https://github.com/paritytech/substrate", optional = true, branch = "master" }
|
||||
sp-api = { git = "https://github.com/paritytech/substrate", optional = true, branch = "master" }
|
||||
sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
sp-inherents = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
sp-runtime = { git = "https://github.com/paritytech/substrate", optional = true, branch = "master" }
|
||||
sp-state-machine = { git = "https://github.com/paritytech/substrate", optional = true, branch = "master" }
|
||||
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
sp-storage = { git = "https://github.com/paritytech/substrate", optional = true, branch = "master" }
|
||||
sp-trie = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
|
||||
# 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" ]
|
||||
@@ -33,18 +32,17 @@ std = [
|
||||
"async-trait",
|
||||
"codec/std",
|
||||
"scale-info/std",
|
||||
"cumulus-primitives-core/std",
|
||||
"sp-inherents/std",
|
||||
"sp-core/std",
|
||||
"sp-trie/std",
|
||||
"sp-std/std",
|
||||
"sp-state-machine",
|
||||
"tracing",
|
||||
"sp-runtime",
|
||||
"sc-client-api",
|
||||
"sp-api",
|
||||
"sp-core/std",
|
||||
"sp-inherents/std",
|
||||
"sp-runtime",
|
||||
"sp-state-machine",
|
||||
"sp-std/std",
|
||||
"sp-storage",
|
||||
"cumulus-test-relay-sproof-builder",
|
||||
"sp-trie/std",
|
||||
"cumulus-primitives-core/std",
|
||||
"cumulus-relay-chain-interface",
|
||||
"cumulus-test-relay-sproof-builder"
|
||||
"cumulus-test-relay-sproof-builder",
|
||||
]
|
||||
|
||||
@@ -23,25 +23,24 @@ use cumulus_primitives_core::{
|
||||
ParaId, PersistedValidationData,
|
||||
};
|
||||
use cumulus_relay_chain_interface::RelayChainInterface;
|
||||
use sp_runtime::generic::BlockId;
|
||||
|
||||
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.
|
||||
fn collect_relay_storage_proof(
|
||||
async fn collect_relay_storage_proof(
|
||||
relay_chain_interface: &impl RelayChainInterface,
|
||||
para_id: ParaId,
|
||||
relay_parent: PHash,
|
||||
) -> Option<sp_state_machine::StorageProof> {
|
||||
use relay_chain::well_known_keys as relay_well_known_keys;
|
||||
|
||||
let relay_parent_block_id = BlockId::Hash(relay_parent);
|
||||
let ingress_channels = relay_chain_interface
|
||||
.get_storage_by_key(
|
||||
&relay_parent_block_id,
|
||||
relay_parent,
|
||||
&relay_well_known_keys::hrmp_ingress_channel_index(para_id),
|
||||
)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
tracing::error!(
|
||||
target: LOG_TARGET,
|
||||
@@ -67,9 +66,10 @@ fn collect_relay_storage_proof(
|
||||
|
||||
let egress_channels = relay_chain_interface
|
||||
.get_storage_by_key(
|
||||
&relay_parent_block_id,
|
||||
relay_parent,
|
||||
&relay_well_known_keys::hrmp_egress_channel_index(para_id),
|
||||
)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
tracing::error!(
|
||||
target: LOG_TARGET,
|
||||
@@ -108,26 +108,57 @@ fn collect_relay_storage_proof(
|
||||
relay_well_known_keys::hrmp_channels(HrmpChannelId { sender: para_id, recipient })
|
||||
}));
|
||||
|
||||
relay_chain_interface.prove_read(&relay_parent_block_id, &relevant_keys).ok()?
|
||||
relay_chain_interface
|
||||
.prove_read(relay_parent, &relevant_keys)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
tracing::error!(
|
||||
target: LOG_TARGET,
|
||||
relay_parent = ?relay_parent,
|
||||
error = ?e,
|
||||
"Cannot obtain read proof from relay chain.",
|
||||
);
|
||||
})
|
||||
.ok()
|
||||
}
|
||||
|
||||
impl ParachainInherentData {
|
||||
/// Create the [`ParachainInherentData`] at the given `relay_parent`.
|
||||
///
|
||||
/// Returns `None` if the creation failed.
|
||||
pub fn create_at(
|
||||
pub async fn create_at(
|
||||
relay_parent: PHash,
|
||||
relay_chain_interface: &impl RelayChainInterface,
|
||||
validation_data: &PersistedValidationData,
|
||||
para_id: ParaId,
|
||||
) -> Option<ParachainInherentData> {
|
||||
let relay_chain_state =
|
||||
collect_relay_storage_proof(relay_chain_interface, para_id, relay_parent)?;
|
||||
collect_relay_storage_proof(relay_chain_interface, para_id, relay_parent).await?;
|
||||
|
||||
let downward_messages =
|
||||
relay_chain_interface.retrieve_dmq_contents(para_id, relay_parent)?;
|
||||
let downward_messages = relay_chain_interface
|
||||
.retrieve_dmq_contents(para_id, relay_parent)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
tracing::error!(
|
||||
target: LOG_TARGET,
|
||||
relay_parent = ?relay_parent,
|
||||
error = ?e,
|
||||
"An error occured during requesting the downward messages.",
|
||||
);
|
||||
})
|
||||
.ok()?;
|
||||
let horizontal_messages = relay_chain_interface
|
||||
.retrieve_all_inbound_hrmp_channel_contents(para_id, relay_parent)?;
|
||||
.retrieve_all_inbound_hrmp_channel_contents(para_id, relay_parent)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
tracing::error!(
|
||||
target: LOG_TARGET,
|
||||
relay_parent = ?relay_parent,
|
||||
error = ?e,
|
||||
"An error occured during requesting the inbound HRMP messages.",
|
||||
);
|
||||
})
|
||||
.ok()?;
|
||||
|
||||
Some(ParachainInherentData {
|
||||
downward_messages,
|
||||
|
||||
@@ -6,33 +6,34 @@ edition = "2021"
|
||||
description = "Provides timestamp related functionality for parachains."
|
||||
|
||||
[dependencies]
|
||||
# Substrate dependencies
|
||||
sp-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ "derive" ] }
|
||||
futures = "0.3.5"
|
||||
|
||||
# Substrate
|
||||
sp-inherents = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
sp-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
|
||||
# Cumulus dependencies
|
||||
# Cumulus
|
||||
cumulus-primitives-core = { path = "../core", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
# Substrate dependencies
|
||||
sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
# Cumulus dependencies
|
||||
# Substrate
|
||||
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
# Cumulus
|
||||
cumulus-test-client = { path = "../../test/client" }
|
||||
cumulus-test-relay-sproof-builder = { path = "../../test/relay-sproof-builder" }
|
||||
|
||||
# Other deps
|
||||
codec = { package = "parity-scale-codec", version = "2.3.0", default-features = false, features = [ "derive" ] }
|
||||
futures = "0.3.5"
|
||||
|
||||
[features]
|
||||
default = [ "std" ]
|
||||
std = [
|
||||
"sp-timestamp/std",
|
||||
"sp-inherents/std",
|
||||
"sp-std/std",
|
||||
"sp-timestamp/std",
|
||||
"cumulus-primitives-core/std",
|
||||
]
|
||||
|
||||
@@ -5,35 +5,34 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
# Substrate dependencies
|
||||
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ "derive" ] }
|
||||
|
||||
# Substrate
|
||||
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
sp-trie = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
|
||||
# Polkadot dependencies
|
||||
# Polkadot
|
||||
polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
||||
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
||||
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
||||
polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
||||
xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
||||
|
||||
# Cumulus
|
||||
cumulus-primitives-core = { path = "../core", default-features = false }
|
||||
|
||||
# Other dependencies
|
||||
codec = { package = "parity-scale-codec", version = "2.3.0", default-features = false, features = [ "derive" ] }
|
||||
|
||||
|
||||
[features]
|
||||
default = [ "std" ]
|
||||
std = [
|
||||
"codec/std",
|
||||
"sp-std/std",
|
||||
"polkadot-primitives/std",
|
||||
"polkadot-parachain/std",
|
||||
"polkadot-core-primitives/std",
|
||||
"sp-runtime/std",
|
||||
"sp-trie/std",
|
||||
"frame-support/std",
|
||||
"sp-runtime/std",
|
||||
"sp-std/std",
|
||||
"sp-trie/std",
|
||||
"polkadot-core-primitives/std",
|
||||
"polkadot-parachain/std",
|
||||
"polkadot-primitives/std",
|
||||
"cumulus-primitives-core/std",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user