Skip to content
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Parity Bridges Common.
// Parity Bridges Common is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity Bridges Common is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
//! Bridge relayers registration and slashing scheme.
//!
//! There is an option to add a refund-relayer signed extension that will compensate
//! relayer costs of the message delivery and confirmation transactions (as well as
//! required finality proofs). This extension boosts priority of message delivery
//! transactions, based on the number of bundled messages. So transaction with more
//! messages has larger priority than the transaction with less messages.
//! See `bridge_runtime_common::priority_calculator` for details;
//!
//! This encourages relayers to include more messages to their delivery transactions.
//! At the same time, we are not verifying storage proofs before boosting
//! priority. Instead, we simply trust relayer, when it says that transaction delivers
//! `N` messages.
//!
//! This allows relayers to submit transactions which declare large number of bundled
//! transactions to receive priority boost for free, potentially pushing actual delivery
//! transactions from the block (or even transaction queue). Such transactions are
//! not free, but their cost is relatively small.
//!
//! To alleviate that, we only boost transactions of relayers that have some stake
//! that guarantees that their transactions are valid. Such relayers get priority
//! for free, but they risk to lose their stake.
use crate::RewardsAccountParams;
use codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_runtime::{
traits::{Get, Zero},
DispatchError, DispatchResult,
};
/// Either explicit account reference or `RewardsAccountParams`.
#[derive(Clone, Debug)]
pub enum ExplicitOrAccountParams<AccountId> {
/// Explicit account reference.
Explicit(AccountId),
/// Account, referenced using `RewardsAccountParams`.
Params(RewardsAccountParams),
}
impl<AccountId> From<RewardsAccountParams> for ExplicitOrAccountParams<AccountId> {
fn from(params: RewardsAccountParams) -> Self {
ExplicitOrAccountParams::Params(params)
}
}
/// Relayer registration.
#[derive(Copy, Clone, Debug, Decode, Encode, Eq, PartialEq, TypeInfo, MaxEncodedLen)]
pub struct Registration<BlockNumber, Balance> {
/// The last block number, where this registration is considered active.
///
/// Relayer has an option to renew his registration (this may be done before it
/// is spoiled as well). Starting from block `valid_till + 1`, relayer may `deregister`
/// himself and get his stake back.
///
/// Please keep in mind that priority boost stops working some blocks before the
/// registration ends (see [`StakeAndSlash::RequiredRegistrationLease`]).
pub valid_till: BlockNumber,
/// Active relayer stake, which is mapped to the relayer reserved balance.
///
/// If `stake` is less than the [`StakeAndSlash::RequiredStake`], the registration
/// is considered inactive even if `valid_till + 1` is not yet reached.
pub stake: Balance,
}
/// Relayer stake-and-slash mechanism.
pub trait StakeAndSlash<AccountId, BlockNumber, Balance> {
/// The stake that the relayer must have to have its transactions boosted.
type RequiredStake: Get<Balance>;
/// Required **remaining** registration lease to be able to get transaction priority boost.
///
/// If the difference between registration's `valid_till` and the current block number
/// is less than the `RequiredRegistrationLease`, it becomes inactive and relayer transaction
/// won't get priority boost. This period exists, because priority is calculated when
/// transaction is placed to the queue (and it is reevaluated periodically) and then some time
/// may pass before transaction will be included into the block.
type RequiredRegistrationLease: Get<BlockNumber>;
/// Reserve the given amount at relayer account.
fn reserve(relayer: &AccountId, amount: Balance) -> DispatchResult;
/// `Unreserve` the given amount from relayer account.
///
/// Returns amount that we have failed to `unreserve`.
fn unreserve(relayer: &AccountId, amount: Balance) -> Balance;
/// Slash up to `amount` from reserved balance of account `relayer` and send funds to given
/// `beneficiary`.
///
/// Returns `Ok(_)` with non-zero balance if we have failed to repatriate some portion of stake.
fn repatriate_reserved(
relayer: &AccountId,
beneficiary: ExplicitOrAccountParams<AccountId>,
amount: Balance,
) -> Result<Balance, DispatchError>;
}
impl<AccountId, BlockNumber, Balance> StakeAndSlash<AccountId, BlockNumber, Balance> for ()
where
Balance: Default + Zero,
BlockNumber: Default,
{
type RequiredStake = ();
type RequiredRegistrationLease = ();
fn reserve(_relayer: &AccountId, _amount: Balance) -> DispatchResult {
Ok(())
}
fn unreserve(_relayer: &AccountId, _amount: Balance) -> Balance {
Zero::zero()
}
fn repatriate_reserved(
_relayer: &AccountId,
_beneficiary: ExplicitOrAccountParams<AccountId>,
_amount: Balance,
) -> Result<Balance, DispatchError> {
Ok(Zero::zero())
}
}
[package]
name = "bp-runtime"
description = "Primitives that may be used at (bridges) runtime level."
version = "0.7.0"
authors.workspace = true
edition.workspace = true
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
[lints]
workspace = true
[dependencies]
codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false }
hash-db = { version = "0.16.0", default-features = false }
impl-trait-for-tuples = "0.2.2"
log = { workspace = true }
num-traits = { version = "0.2", default-features = false }
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }
serde = { features = ["alloc", "derive"], workspace = true }
# Substrate Dependencies
frame-support = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
frame-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
sp-io = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false, features = ["serde"] }
sp-state-machine = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
sp-std = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
sp-trie = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
trie-db = { version = "0.28.0", default-features = false }
[dev-dependencies]
hex-literal = "0.4"
[features]
default = ["std"]
std = [
"codec/std",
"frame-support/std",
"frame-system/std",
"hash-db/std",
"log/std",
"num-traits/std",
"scale-info/std",
"serde/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-state-machine/std",
"sp-std/std",
"sp-trie/std",
"trie-db/std",
]
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Parity Bridges Common.
// Parity Bridges Common is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity Bridges Common is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
use crate::{ChainId, HeaderIdProvider};
use codec::{Codec, Decode, Encode, MaxEncodedLen};
use frame_support::{weights::Weight, Parameter};
use num_traits::{AsPrimitive, Bounded, CheckedSub, Saturating, SaturatingAdd, Zero};
use sp_runtime::{
traits::{
AtLeast32Bit, AtLeast32BitUnsigned, Hash as HashT, Header as HeaderT, MaybeDisplay,
MaybeSerialize, MaybeSerializeDeserialize, Member, SimpleBitOps, Verify,
},
FixedPointOperand,
};
use sp_std::{convert::TryFrom, fmt::Debug, hash::Hash, str::FromStr, vec, vec::Vec};
/// Chain call, that is either SCALE-encoded, or decoded.
#[derive(Debug, Clone, PartialEq)]
pub enum EncodedOrDecodedCall<ChainCall> {
/// The call that is SCALE-encoded.
///
/// This variant is used when we the chain runtime is not bundled with the relay, but
/// we still need the represent call in some RPC calls or transactions.
Encoded(Vec<u8>),
/// The decoded call.
Decoded(ChainCall),
}
impl<ChainCall: Clone + Codec> EncodedOrDecodedCall<ChainCall> {
/// Returns decoded call.
pub fn to_decoded(&self) -> Result<ChainCall, codec::Error> {
match self {
Self::Encoded(ref encoded_call) =>
ChainCall::decode(&mut &encoded_call[..]).map_err(Into::into),
Self::Decoded(ref decoded_call) => Ok(decoded_call.clone()),
}
}
/// Converts self to decoded call.
pub fn into_decoded(self) -> Result<ChainCall, codec::Error> {
match self {
Self::Encoded(encoded_call) =>
ChainCall::decode(&mut &encoded_call[..]).map_err(Into::into),
Self::Decoded(decoded_call) => Ok(decoded_call),
}
}
/// Converts self to encoded call.
pub fn into_encoded(self) -> Vec<u8> {
match self {
Self::Encoded(encoded_call) => encoded_call,
Self::Decoded(decoded_call) => decoded_call.encode(),
}
}
}
impl<ChainCall> From<ChainCall> for EncodedOrDecodedCall<ChainCall> {
fn from(call: ChainCall) -> EncodedOrDecodedCall<ChainCall> {
EncodedOrDecodedCall::Decoded(call)
}
}
impl<ChainCall: Decode> Decode for EncodedOrDecodedCall<ChainCall> {
fn decode<I: codec::Input>(input: &mut I) -> Result<Self, codec::Error> {
// having encoded version is better than decoded, because decoding isn't required
// everywhere and for mocked calls it may lead to **unneeded** errors
match input.remaining_len()? {
Some(remaining_len) => {
let mut encoded_call = vec![0u8; remaining_len];
input.read(&mut encoded_call)?;
Ok(EncodedOrDecodedCall::Encoded(encoded_call))
},
None => Ok(EncodedOrDecodedCall::Decoded(ChainCall::decode(input)?)),
}
}
}
impl<ChainCall: Encode> Encode for EncodedOrDecodedCall<ChainCall> {
fn encode(&self) -> Vec<u8> {
match *self {
Self::Encoded(ref encoded_call) => encoded_call.clone(),
Self::Decoded(ref decoded_call) => decoded_call.encode(),
}
}
}
// dummy implementation to satisfy `SignedPayload` requirements
impl<ChainCall> sp_runtime::traits::Dispatchable for EncodedOrDecodedCall<ChainCall> {
type RuntimeOrigin = ();
type Config = ();
type Info = ();
type PostInfo = ();
fn dispatch(self, _origin: ()) -> sp_runtime::DispatchResultWithInfo<()> {
unreachable!("never used by relayer; qed")
}
}
/// Minimal Substrate-based chain representation that may be used from no_std environment.
pub trait Chain: Send + Sync + 'static {
/// Chain id.
const ID: ChainId;
/// A type that fulfills the abstract idea of what a Substrate block number is.
// Constraits come from the associated Number type of `sp_runtime::traits::Header`
// See here for more info:
// https://crates.parity.io/sp_runtime/traits/trait.Header.html#associatedtype.Number
//
// Note that the `AsPrimitive<usize>` trait is required by the GRANDPA justification
// verifier, and is not usually part of a Substrate Header's Number type.
type BlockNumber: Parameter
+ Member
+ MaybeSerializeDeserialize
+ Hash
+ Copy
+ Default
+ MaybeDisplay
+ AtLeast32BitUnsigned
+ FromStr
+ AsPrimitive<usize>
+ Default
+ Saturating
+ MaxEncodedLen;
/// A type that fulfills the abstract idea of what a Substrate hash is.
// Constraits come from the associated Hash type of `sp_runtime::traits::Header`
// See here for more info:
// https://crates.parity.io/sp_runtime/traits/trait.Header.html#associatedtype.Hash
type Hash: Parameter
+ Member
+ MaybeSerializeDeserialize
+ Hash
+ Ord
+ Copy
+ MaybeDisplay
+ Default
+ SimpleBitOps
+ AsRef<[u8]>
+ AsMut<[u8]>
+ MaxEncodedLen;
/// A type that fulfills the abstract idea of what a Substrate hasher (a type
/// that produces hashes) is.
// Constraits come from the associated Hashing type of `sp_runtime::traits::Header`
// See here for more info:
// https://crates.parity.io/sp_runtime/traits/trait.Header.html#associatedtype.Hashing
type Hasher: HashT<Output = Self::Hash>;
/// A type that fulfills the abstract idea of what a Substrate header is.
// See here for more info:
// https://crates.parity.io/sp_runtime/traits/trait.Header.html
type Header: Parameter
+ HeaderT<Number = Self::BlockNumber, Hash = Self::Hash>
+ HeaderIdProvider<Self::Header>
+ MaybeSerializeDeserialize;
/// The user account identifier type for the runtime.
type AccountId: Parameter
+ Member
+ MaybeSerializeDeserialize
+ Debug
+ MaybeDisplay
+ Ord
+ MaxEncodedLen;
/// Balance of an account in native tokens.
///
/// The chain may support multiple tokens, but this particular type is for token that is used
/// to pay for transaction dispatch, to reward different relayers (headers, messages), etc.
type Balance: AtLeast32BitUnsigned
+ FixedPointOperand
+ Parameter
+ Member
+ MaybeSerializeDeserialize
+ Clone
+ Copy
+ Bounded
+ CheckedSub
+ PartialOrd
+ SaturatingAdd
+ Zero
+ TryFrom<sp_core::U256>
+ MaxEncodedLen;
/// Nonce of a transaction used by the chain.
type Nonce: Parameter
+ Member
+ MaybeSerialize
+ Debug
+ Default
+ MaybeDisplay
+ MaybeSerializeDeserialize
+ AtLeast32Bit
+ Copy
+ MaxEncodedLen;
/// Signature type, used on this chain.
type Signature: Parameter + Verify;
/// Get the maximum size (in bytes) of a Normal extrinsic at this chain.
fn max_extrinsic_size() -> u32;
/// Get the maximum weight (compute time) that a Normal extrinsic at this chain can use.
fn max_extrinsic_weight() -> Weight;
}
/// A trait that provides the type of the underlying chain.
pub trait UnderlyingChainProvider: Send + Sync + 'static {
/// Underlying chain type.
type Chain: Chain;
}
impl<T> Chain for T
where
T: Send + Sync + 'static + UnderlyingChainProvider,
{
const ID: ChainId = <T::Chain as Chain>::ID;
type BlockNumber = <T::Chain as Chain>::BlockNumber;
type Hash = <T::Chain as Chain>::Hash;
type Hasher = <T::Chain as Chain>::Hasher;
type Header = <T::Chain as Chain>::Header;
type AccountId = <T::Chain as Chain>::AccountId;
type Balance = <T::Chain as Chain>::Balance;
type Nonce = <T::Chain as Chain>::Nonce;
type Signature = <T::Chain as Chain>::Signature;
fn max_extrinsic_size() -> u32 {
<T::Chain as Chain>::max_extrinsic_size()
}
fn max_extrinsic_weight() -> Weight {
<T::Chain as Chain>::max_extrinsic_weight()
}
}
/// Minimal parachain representation that may be used from no_std environment.
pub trait Parachain: Chain {
/// Parachain identifier.
const PARACHAIN_ID: u32;
/// Maximal size of the parachain header.
///
/// This isn't a strict limit. The relayer may submit larger headers and the
/// pallet will accept the call. The limit is only used to compute whether
/// the refund can be made.
const MAX_HEADER_SIZE: u32;
}
impl<T> Parachain for T
where
T: Chain + UnderlyingChainProvider,
<T as UnderlyingChainProvider>::Chain: Parachain,
{
const PARACHAIN_ID: u32 = <<T as UnderlyingChainProvider>::Chain as Parachain>::PARACHAIN_ID;
const MAX_HEADER_SIZE: u32 =
<<T as UnderlyingChainProvider>::Chain as Parachain>::MAX_HEADER_SIZE;
}
/// Adapter for `Get<u32>` to access `PARACHAIN_ID` from `trait Parachain`
pub struct ParachainIdOf<Para>(sp_std::marker::PhantomData<Para>);
impl<Para: Parachain> frame_support::traits::Get<u32> for ParachainIdOf<Para> {
fn get() -> u32 {
Para::PARACHAIN_ID
}
}
/// Underlying chain type.
pub type UnderlyingChainOf<C> = <C as UnderlyingChainProvider>::Chain;
/// Block number used by the chain.
pub type BlockNumberOf<C> = <C as Chain>::BlockNumber;
/// Hash type used by the chain.
pub type HashOf<C> = <C as Chain>::Hash;
/// Hasher type used by the chain.
pub type HasherOf<C> = <C as Chain>::Hasher;
/// Header type used by the chain.
pub type HeaderOf<C> = <C as Chain>::Header;
/// Account id type used by the chain.
pub type AccountIdOf<C> = <C as Chain>::AccountId;
/// Balance type used by the chain.
pub type BalanceOf<C> = <C as Chain>::Balance;
/// Transaction nonce type used by the chain.
pub type NonceOf<C> = <C as Chain>::Nonce;
/// Signature type used by the chain.
pub type SignatureOf<C> = <C as Chain>::Signature;
/// Account public type used by the chain.
pub type AccountPublicOf<C> = <SignatureOf<C> as Verify>::Signer;
/// Transaction era used by the chain.
pub type TransactionEraOf<C> = crate::TransactionEra<BlockNumberOf<C>, HashOf<C>>;
/// Convenience macro that declares bridge finality runtime apis and related constants for a chain.
/// This includes:
/// - chain-specific bridge runtime APIs:
/// - `<ThisChain>FinalityApi`
/// - constants that are stringified names of runtime API methods:
/// - `BEST_FINALIZED_<THIS_CHAIN>_HEADER_METHOD`
/// - `<THIS_CHAIN>_ACCEPTED_<CONSENSUS>_FINALITY_PROOFS_METHOD`
/// The name of the chain has to be specified in snake case (e.g. `bridge_hub_polkadot`).
#[macro_export]
macro_rules! decl_bridge_finality_runtime_apis {
($chain: ident $(, $consensus: ident => $justification_type: ty)?) => {
bp_runtime::paste::item! {
mod [<$chain _finality_api>] {
use super::*;
/// Name of the `<ThisChain>FinalityApi::best_finalized` runtime method.
pub const [<BEST_FINALIZED_ $chain:upper _HEADER_METHOD>]: &str =
stringify!([<$chain:camel FinalityApi_best_finalized>]);
/// Name of the `<ThisChain>FinalityApi::free_headers_interval` runtime method.
pub const [<FREE_HEADERS_INTERVAL_FOR_ $chain:upper _METHOD>]: &str =
stringify!([<$chain:camel FinalityApi_free_headers_interval>]);
$(
/// Name of the `<ThisChain>FinalityApi::accepted_<consensus>_finality_proofs`
/// runtime method.
pub const [<$chain:upper _SYNCED_HEADERS_ $consensus:upper _INFO_METHOD>]: &str =
stringify!([<$chain:camel FinalityApi_synced_headers_ $consensus:lower _info>]);
)?
sp_api::decl_runtime_apis! {
/// API for querying information about the finalized chain headers.
///
/// This API is implemented by runtimes that are receiving messages from this chain, not by this
/// chain's runtime itself.
pub trait [<$chain:camel FinalityApi>] {
/// Returns number and hash of the best finalized header known to the bridge module.
fn best_finalized() -> Option<bp_runtime::HeaderId<Hash, BlockNumber>>;
/// Returns free headers interval, if it is configured in the runtime.
/// The caller expects that his transactions for every `N`th header
/// (where `N` is the configured interval) will be fee-free.
///
/// See [`pallet_bridge_grandpa::Config::FreeHeadersInterval`] for details.
fn free_headers_interval() -> Option<BlockNumber>;
$(
/// Returns the justifications accepted in the current block.
fn [<synced_headers_ $consensus:lower _info>](
) -> sp_std::vec::Vec<$justification_type>;
)?
}
}
}
pub use [<$chain _finality_api>]::*;
}
};
($chain: ident, grandpa) => {
decl_bridge_finality_runtime_apis!($chain, grandpa => bp_header_chain::StoredHeaderGrandpaInfo<Header>);
};
}
/// Convenience macro that declares bridge messages runtime apis and related constants for a chain.
/// This includes:
/// - chain-specific bridge runtime APIs:
/// - `To<ThisChain>OutboundLaneApi`
/// - `From<ThisChain>InboundLaneApi`
/// - constants that are stringified names of runtime API methods:
/// - `FROM_<THIS_CHAIN>_MESSAGE_DETAILS_METHOD`,
/// The name of the chain has to be specified in snake case (e.g. `bridge_hub_polkadot`).
#[macro_export]
macro_rules! decl_bridge_messages_runtime_apis {
($chain: ident) => {
bp_runtime::paste::item! {
mod [<$chain _messages_api>] {
use super::*;
/// Name of the `To<ThisChain>OutboundLaneApi::message_details` runtime method.
pub const [<TO_ $chain:upper _MESSAGE_DETAILS_METHOD>]: &str =
stringify!([<To $chain:camel OutboundLaneApi_message_details>]);
/// Name of the `From<ThisChain>InboundLaneApi::message_details` runtime method.
pub const [<FROM_ $chain:upper _MESSAGE_DETAILS_METHOD>]: &str =
stringify!([<From $chain:camel InboundLaneApi_message_details>]);
sp_api::decl_runtime_apis! {
/// Outbound message lane API for messages that are sent to this chain.
///
/// This API is implemented by runtimes that are receiving messages from this chain, not by this
/// chain's runtime itself.
pub trait [<To $chain:camel OutboundLaneApi>] {
/// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all
/// messages in given inclusive range.
///
/// If some (or all) messages are missing from the storage, they'll also will
/// be missing from the resulting vector. The vector is ordered by the nonce.
fn message_details(
lane: bp_messages::LaneId,
begin: bp_messages::MessageNonce,
end: bp_messages::MessageNonce,
) -> sp_std::vec::Vec<bp_messages::OutboundMessageDetails>;
}
/// Inbound message lane API for messages sent by this chain.
///
/// This API is implemented by runtimes that are receiving messages from this chain, not by this
/// chain's runtime itself.
///
/// Entries of the resulting vector are matching entries of the `messages` vector. Entries of the
/// `messages` vector may (and need to) be read using `To<ThisChain>OutboundLaneApi::message_details`.
pub trait [<From $chain:camel InboundLaneApi>] {
/// Return details of given inbound messages.
fn message_details(
lane: bp_messages::LaneId,
messages: sp_std::vec::Vec<(bp_messages::MessagePayload, bp_messages::OutboundMessageDetails)>,
) -> sp_std::vec::Vec<bp_messages::InboundMessageDetails>;
}
}
}
pub use [<$chain _messages_api>]::*;
}
};
}
/// Convenience macro that declares bridge finality runtime apis, bridge messages runtime apis
/// and related constants for a chain.
/// The name of the chain has to be specified in snake case (e.g. `bridge_hub_polkadot`).
#[macro_export]
macro_rules! decl_bridge_runtime_apis {
($chain: ident $(, $consensus: ident)?) => {
bp_runtime::decl_bridge_finality_runtime_apis!($chain $(, $consensus)?);
bp_runtime::decl_bridge_messages_runtime_apis!($chain);
};
}
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Parity Bridges Common.
// Parity Bridges Common is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity Bridges Common is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
//! Primitives that may be used for creating signed extensions for indirect runtimes.
use codec::{Compact, Decode, Encode};
use impl_trait_for_tuples::impl_for_tuples;
use scale_info::{StaticTypeInfo, TypeInfo};
use sp_runtime::{
impl_tx_ext_default,
traits::{Dispatchable, TransactionExtension, TransactionExtensionBase},
transaction_validity::TransactionValidityError,
};
use sp_std::{fmt::Debug, marker::PhantomData};
/// Trait that describes some properties of a `TransactionExtension` that are needed in order to
/// send a transaction to the chain.
pub trait TransactionExtensionSchema:
Encode + Decode + Debug + Eq + Clone + StaticTypeInfo
{
/// A type of the data encoded as part of the transaction.
type Payload: Encode + Decode + Debug + Eq + Clone + StaticTypeInfo;
/// Parameters which are part of the payload used to produce transaction signature,
/// but don't end up in the transaction itself (i.e. inherent part of the runtime).
type Implicit: Encode + Decode + Debug + Eq + Clone + StaticTypeInfo;
}
impl TransactionExtensionSchema for () {
type Payload = ();
type Implicit = ();
}
/// An implementation of `TransactionExtensionSchema` using generic params.
#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq, TypeInfo)]
pub struct GenericTransactionExtensionSchema<P, S>(PhantomData<(P, S)>);
impl<P, S> TransactionExtensionSchema for GenericTransactionExtensionSchema<P, S>
where
P: Encode + Decode + Debug + Eq + Clone + StaticTypeInfo,
S: Encode + Decode + Debug + Eq + Clone + StaticTypeInfo,
{
type Payload = P;
type Implicit = S;
}
/// The `TransactionExtensionSchema` for `frame_system::CheckNonZeroSender`.
pub type CheckNonZeroSender = GenericTransactionExtensionSchema<(), ()>;
/// The `TransactionExtensionSchema` for `frame_system::CheckSpecVersion`.
pub type CheckSpecVersion = GenericTransactionExtensionSchema<(), u32>;
/// The `TransactionExtensionSchema` for `frame_system::CheckTxVersion`.
pub type CheckTxVersion = GenericTransactionExtensionSchema<(), u32>;
/// The `TransactionExtensionSchema` for `frame_system::CheckGenesis`.
pub type CheckGenesis<Hash> = GenericTransactionExtensionSchema<(), Hash>;
/// The `TransactionExtensionSchema` for `frame_system::CheckEra`.
pub type CheckEra<Hash> = GenericTransactionExtensionSchema<sp_runtime::generic::Era, Hash>;
/// The `TransactionExtensionSchema` for `frame_system::CheckNonce`.
pub type CheckNonce<TxNonce> = GenericTransactionExtensionSchema<Compact<TxNonce>, ()>;
/// The `TransactionExtensionSchema` for `frame_system::CheckWeight`.
pub type CheckWeight = GenericTransactionExtensionSchema<(), ()>;
/// The `TransactionExtensionSchema` for `pallet_transaction_payment::ChargeTransactionPayment`.
pub type ChargeTransactionPayment<Balance> =
GenericTransactionExtensionSchema<Compact<Balance>, ()>;
/// The `TransactionExtensionSchema` for `polkadot-runtime-common::PrevalidateAttests`.
pub type PrevalidateAttests = GenericTransactionExtensionSchema<(), ()>;
/// The `TransactionExtensionSchema` for `BridgeRejectObsoleteHeadersAndMessages`.
pub type BridgeRejectObsoleteHeadersAndMessages = GenericTransactionExtensionSchema<(), ()>;
/// The `TransactionExtensionSchema` for `RefundBridgedParachainMessages`.
/// This schema is dedicated for `RefundBridgedParachainMessages` signed extension as
/// wildcard/placeholder, which relies on the scale encoding for `()` or `((), ())`, or `((), (),
/// ())` is the same. So runtime can contains any kind of tuple:
/// `(BridgeRefundBridgeHubRococoMessages)`
/// `(BridgeRefundBridgeHubRococoMessages, BridgeRefundBridgeHubWestendMessages)`
/// `(BridgeRefundParachainMessages1, ..., BridgeRefundParachainMessagesN)`
pub type RefundBridgedParachainMessagesSchema = GenericTransactionExtensionSchema<(), ()>;
#[impl_for_tuples(1, 12)]
impl TransactionExtensionSchema for Tuple {
for_tuples!( type Payload = ( #( Tuple::Payload ),* ); );
for_tuples!( type Implicit = ( #( Tuple::Implicit ),* ); );
}
/// A simplified version of signed extensions meant for producing signed transactions
/// and signed payloads in the client code.
#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
pub struct GenericTransactionExtension<S: TransactionExtensionSchema> {
/// A payload that is included in the transaction.
pub payload: S::Payload,
#[codec(skip)]
// It may be set to `None` if extensions are decoded. We are never reconstructing transactions
// (and it makes no sense to do that) => decoded version of `TransactionExtensions` is only
// used to read fields of the `payload`. And when resigning transaction, we're reconstructing
// `TransactionExtensions` from scratch.
implicit: Option<S::Implicit>,
}
impl<S: TransactionExtensionSchema> GenericTransactionExtension<S> {
/// Create new `GenericTransactionExtension` object.
pub fn new(payload: S::Payload, implicit: Option<S::Implicit>) -> Self {
Self { payload, implicit }
}
}
impl<S> TransactionExtensionBase for GenericTransactionExtension<S>
where
S: TransactionExtensionSchema,
S::Payload: Send + Sync,
S::Implicit: Send + Sync,
{
const IDENTIFIER: &'static str = "Not needed.";
type Implicit = S::Implicit;
fn implicit(&self) -> Result<Self::Implicit, TransactionValidityError> {
// we shall not ever see this error in relay, because we are never signing decoded
// transactions. Instead we're constructing and signing new transactions. So the error code
// is kinda random here
self.implicit
.clone()
.ok_or(frame_support::unsigned::TransactionValidityError::Unknown(
frame_support::unsigned::UnknownTransaction::Custom(0xFF),
))
}
}
impl<S, C, Context> TransactionExtension<C, Context> for GenericTransactionExtension<S>
where
C: Dispatchable,
S: TransactionExtensionSchema,
S::Payload: Send + Sync,
S::Implicit: Send + Sync,
{
type Pre = ();
type Val = ();
impl_tx_ext_default!(C; Context; validate prepare);
}
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Parity Bridges Common.
// Parity Bridges Common is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity Bridges Common is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
//! Primitives that may be used at (bridges) runtime level.
#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)]
use codec::{Decode, Encode, FullCodec, MaxEncodedLen};
use frame_support::{
pallet_prelude::DispatchResult, weights::Weight, PalletError, StorageHasher, StorageValue,
};
use frame_system::RawOrigin;
use scale_info::TypeInfo;
use serde::{Deserialize, Serialize};
use sp_core::storage::StorageKey;
use sp_runtime::{
traits::{BadOrigin, Header as HeaderT, UniqueSaturatedInto},
RuntimeDebug,
};
use sp_std::{convert::TryFrom, fmt::Debug, ops::RangeInclusive, vec, vec::Vec};
pub use chain::{
AccountIdOf, AccountPublicOf, BalanceOf, BlockNumberOf, Chain, EncodedOrDecodedCall, HashOf,
HasherOf, HeaderOf, NonceOf, Parachain, ParachainIdOf, SignatureOf, TransactionEraOf,
UnderlyingChainOf, UnderlyingChainProvider,
};
pub use frame_support::storage::storage_prefix as storage_value_final_key;
use num_traits::{CheckedAdd, CheckedSub, One, SaturatingAdd, Zero};
pub use storage_proof::{
record_all_keys as record_all_trie_keys, Error as StorageProofError,
ProofSize as StorageProofSize, RawStorageProof, StorageProofChecker,
};
pub use storage_types::BoundedStorageValue;
#[cfg(feature = "std")]
pub use storage_proof::craft_valid_storage_proof;
pub mod extensions;
pub mod messages;
mod chain;
mod storage_proof;
mod storage_types;
// Re-export macro to aviod include paste dependency everywhere
pub use sp_runtime::paste;
/// Use this when something must be shared among all instances.
pub const NO_INSTANCE_ID: ChainId = [0, 0, 0, 0];
/// Generic header Id.
#[derive(
RuntimeDebug,
Default,
Clone,
Encode,
Decode,
Copy,
Eq,
Hash,
MaxEncodedLen,
PartialEq,
PartialOrd,
Ord,
TypeInfo,
)]
pub struct HeaderId<Hash, Number>(pub Number, pub Hash);
impl<Hash: Copy, Number: Copy> HeaderId<Hash, Number> {
/// Return header number.
pub fn number(&self) -> Number {
self.0
}
/// Return header hash.
pub fn hash(&self) -> Hash {
self.1
}
}
/// Header id used by the chain.
pub type HeaderIdOf<C> = HeaderId<HashOf<C>, BlockNumberOf<C>>;
/// Generic header id provider.
pub trait HeaderIdProvider<Header: HeaderT> {
/// Get the header id.
fn id(&self) -> HeaderId<Header::Hash, Header::Number>;
/// Get the header id for the parent block.
fn parent_id(&self) -> Option<HeaderId<Header::Hash, Header::Number>>;
}
impl<Header: HeaderT> HeaderIdProvider<Header> for Header {
fn id(&self) -> HeaderId<Header::Hash, Header::Number> {
HeaderId(*self.number(), self.hash())
}
fn parent_id(&self) -> Option<HeaderId<Header::Hash, Header::Number>> {
self.number()
.checked_sub(&One::one())
.map(|parent_number| HeaderId(parent_number, *self.parent_hash()))
}
}
/// Unique identifier of the chain.
///
/// In addition to its main function (identifying the chain), this type may also be used to
/// identify module instance. We have a bunch of pallets that may be used in different bridges. E.g.
/// messages pallet may be deployed twice in the same runtime to bridge ThisChain with Chain1 and
/// Chain2. Sometimes we need to be able to identify deployed instance dynamically. This type may be
/// used for that.
pub type ChainId = [u8; 4];
/// Anything that has size.
pub trait Size {
/// Return size of this object (in bytes).
fn size(&self) -> u32;
}
impl Size for () {
fn size(&self) -> u32 {
0
}
}
impl Size for Vec<u8> {
fn size(&self) -> u32 {
self.len() as _
}
}
/// Pre-computed size.
pub struct PreComputedSize(pub usize);
impl Size for PreComputedSize {
fn size(&self) -> u32 {
u32::try_from(self.0).unwrap_or(u32::MAX)
}
}
/// Era of specific transaction.
#[derive(RuntimeDebug, Clone, Copy, PartialEq)]
pub enum TransactionEra<BlockNumber, BlockHash> {
/// Transaction is immortal.
Immortal,
/// Transaction is valid for a given number of blocks, starting from given block.
Mortal(HeaderId<BlockHash, BlockNumber>, u32),
}
impl<BlockNumber: Copy + UniqueSaturatedInto<u64>, BlockHash: Copy>
TransactionEra<BlockNumber, BlockHash>
{
/// Prepare transaction era, based on mortality period and current best block number.
pub fn new(
best_block_id: HeaderId<BlockHash, BlockNumber>,
mortality_period: Option<u32>,
) -> Self {
mortality_period
.map(|mortality_period| TransactionEra::Mortal(best_block_id, mortality_period))
.unwrap_or(TransactionEra::Immortal)
}
/// Create new immortal transaction era.
pub fn immortal() -> Self {
TransactionEra::Immortal
}
/// Returns mortality period if transaction is mortal.
pub fn mortality_period(&self) -> Option<u32> {
match *self {
TransactionEra::Immortal => None,
TransactionEra::Mortal(_, period) => Some(period),
}
}
/// Returns era that is used by FRAME-based runtimes.
pub fn frame_era(&self) -> sp_runtime::generic::Era {
match *self {
TransactionEra::Immortal => sp_runtime::generic::Era::immortal(),
// `unique_saturated_into` is fine here - mortality `u64::MAX` is not something we
// expect to see on any chain
TransactionEra::Mortal(header_id, period) =>
sp_runtime::generic::Era::mortal(period as _, header_id.0.unique_saturated_into()),
}
}
/// Returns header hash that needs to be included in the signature payload.
pub fn signed_payload(&self, genesis_hash: BlockHash) -> BlockHash {
match *self {
TransactionEra::Immortal => genesis_hash,
TransactionEra::Mortal(header_id, _) => header_id.1,
}
}
}
/// This is a copy of the
/// `frame_support::storage::generator::StorageMap::storage_map_final_key` for maps based
/// on selected hasher.
///
/// We're using it because to call `storage_map_final_key` directly, we need access to the runtime
/// and pallet instance, which (sometimes) is impossible.
pub fn storage_map_final_key<H: StorageHasher>(
pallet_prefix: &str,
map_name: &str,
key: &[u8],
) -> StorageKey {
let key_hashed = H::hash(key);
let pallet_prefix_hashed = frame_support::Twox128::hash(pallet_prefix.as_bytes());
let storage_prefix_hashed = frame_support::Twox128::hash(map_name.as_bytes());
let mut final_key = Vec::with_capacity(
pallet_prefix_hashed.len() + storage_prefix_hashed.len() + key_hashed.as_ref().len(),
);
final_key.extend_from_slice(&pallet_prefix_hashed[..]);
final_key.extend_from_slice(&storage_prefix_hashed[..]);
final_key.extend_from_slice(key_hashed.as_ref());
StorageKey(final_key)
}
/// This is how a storage key of storage value is computed.
///
/// Copied from `frame_support::storage::storage_prefix`.
pub fn storage_value_key(pallet_prefix: &str, value_name: &str) -> StorageKey {
let pallet_hash = sp_io::hashing::twox_128(pallet_prefix.as_bytes());
let storage_hash = sp_io::hashing::twox_128(value_name.as_bytes());
let mut final_key = vec![0u8; 32];
final_key[..16].copy_from_slice(&pallet_hash);
final_key[16..].copy_from_slice(&storage_hash);
StorageKey(final_key)
}
/// Can be use to access the runtime storage key of a `StorageMap`.
pub trait StorageMapKeyProvider {
/// The name of the variable that holds the `StorageMap`.
const MAP_NAME: &'static str;
/// The same as `StorageMap::Hasher1`.
type Hasher: StorageHasher;
/// The same as `StorageMap::Key1`.
type Key: FullCodec;
/// The same as `StorageMap::Value`.
type Value: FullCodec;
/// This is a copy of the
/// `frame_support::storage::generator::StorageMap::storage_map_final_key`.
///
/// We're using it because to call `storage_map_final_key` directly, we need access
/// to the runtime and pallet instance, which (sometimes) is impossible.
fn final_key(pallet_prefix: &str, key: &Self::Key) -> StorageKey {
storage_map_final_key::<Self::Hasher>(pallet_prefix, Self::MAP_NAME, &key.encode())
}
}
/// Can be use to access the runtime storage key of a `StorageDoubleMap`.
pub trait StorageDoubleMapKeyProvider {
/// The name of the variable that holds the `StorageDoubleMap`.
const MAP_NAME: &'static str;
/// The same as `StorageDoubleMap::Hasher1`.
type Hasher1: StorageHasher;
/// The same as `StorageDoubleMap::Key1`.
type Key1: FullCodec;
/// The same as `StorageDoubleMap::Hasher2`.
type Hasher2: StorageHasher;
/// The same as `StorageDoubleMap::Key2`.
type Key2: FullCodec;
/// The same as `StorageDoubleMap::Value`.
type Value: FullCodec;
/// This is a copy of the
/// `frame_support::storage::generator::StorageDoubleMap::storage_double_map_final_key`.
///
/// We're using it because to call `storage_double_map_final_key` directly, we need access
/// to the runtime and pallet instance, which (sometimes) is impossible.
fn final_key(pallet_prefix: &str, key1: &Self::Key1, key2: &Self::Key2) -> StorageKey {
let key1_hashed = Self::Hasher1::hash(&key1.encode());
let key2_hashed = Self::Hasher2::hash(&key2.encode());
let pallet_prefix_hashed = frame_support::Twox128::hash(pallet_prefix.as_bytes());
let storage_prefix_hashed = frame_support::Twox128::hash(Self::MAP_NAME.as_bytes());
let mut final_key = Vec::with_capacity(
pallet_prefix_hashed.len() +
storage_prefix_hashed.len() +
key1_hashed.as_ref().len() +
key2_hashed.as_ref().len(),
);
final_key.extend_from_slice(&pallet_prefix_hashed[..]);
final_key.extend_from_slice(&storage_prefix_hashed[..]);
final_key.extend_from_slice(key1_hashed.as_ref());
final_key.extend_from_slice(key2_hashed.as_ref());
StorageKey(final_key)
}
}
/// Error generated by the `OwnedBridgeModule` trait.
#[derive(Encode, Decode, PartialEq, Eq, TypeInfo, PalletError)]
pub enum OwnedBridgeModuleError {
/// All pallet operations are halted.
Halted,
}
/// Operating mode for a bridge module.
pub trait OperatingMode: Send + Copy + Debug + FullCodec {
/// Returns true if the bridge module is halted.
fn is_halted(&self) -> bool;
}
/// Basic operating modes for a bridges module (Normal/Halted).
#[derive(
Encode,
Decode,
Clone,
Copy,
PartialEq,
Eq,
RuntimeDebug,
TypeInfo,
MaxEncodedLen,
Serialize,
Deserialize,
)]
pub enum BasicOperatingMode {
/// Normal mode, when all operations are allowed.
Normal,
/// The pallet is halted. All operations (except operating mode change) are prohibited.
Halted,
}
impl Default for BasicOperatingMode {
fn default() -> Self {
Self::Normal
}
}
impl OperatingMode for BasicOperatingMode {
fn is_halted(&self) -> bool {
*self == BasicOperatingMode::Halted
}
}
/// Bridge module that has owner and operating mode
pub trait OwnedBridgeModule<T: frame_system::Config> {
/// The target that will be used when publishing logs related to this module.
const LOG_TARGET: &'static str;
/// A storage entry that holds the module `Owner` account.
type OwnerStorage: StorageValue<T::AccountId, Query = Option<T::AccountId>>;
/// Operating mode type of the pallet.
type OperatingMode: OperatingMode;
/// A storage value that holds the pallet operating mode.
type OperatingModeStorage: StorageValue<Self::OperatingMode, Query = Self::OperatingMode>;
/// Check if the module is halted.
fn is_halted() -> bool {
Self::OperatingModeStorage::get().is_halted()
}
/// Ensure that the origin is either root, or `PalletOwner`.
fn ensure_owner_or_root(origin: T::RuntimeOrigin) -> Result<(), BadOrigin> {
match origin.into() {
Ok(RawOrigin::Root) => Ok(()),
Ok(RawOrigin::Signed(ref signer))
if Self::OwnerStorage::get().as_ref() == Some(signer) =>
Ok(()),
_ => Err(BadOrigin),
}
}
/// Ensure that the module is not halted.
fn ensure_not_halted() -> Result<(), OwnedBridgeModuleError> {
match Self::is_halted() {
true => Err(OwnedBridgeModuleError::Halted),
false => Ok(()),
}
}
/// Change the owner of the module.
fn set_owner(origin: T::RuntimeOrigin, maybe_owner: Option<T::AccountId>) -> DispatchResult {
Self::ensure_owner_or_root(origin)?;
match maybe_owner {
Some(owner) => {
Self::OwnerStorage::put(&owner);
log::info!(target: Self::LOG_TARGET, "Setting pallet Owner to: {:?}", owner);
},
None => {
Self::OwnerStorage::kill();
log::info!(target: Self::LOG_TARGET, "Removed Owner of pallet.");
},
}
Ok(())
}
/// Halt or resume all/some module operations.
fn set_operating_mode(
origin: T::RuntimeOrigin,
operating_mode: Self::OperatingMode,
) -> DispatchResult {
Self::ensure_owner_or_root(origin)?;
Self::OperatingModeStorage::put(operating_mode);
log::info!(target: Self::LOG_TARGET, "Setting operating mode to {:?}.", operating_mode);
Ok(())
}
}
/// All extra operations with weights that we need in bridges.
pub trait WeightExtraOps {
/// Checked division of individual components of two weights.
///
/// Divides components and returns minimal division result. Returns `None` if one
/// of `other` weight components is zero.
fn min_components_checked_div(&self, other: Weight) -> Option<u64>;
}
impl WeightExtraOps for Weight {
fn min_components_checked_div(&self, other: Weight) -> Option<u64> {
Some(sp_std::cmp::min(
self.ref_time().checked_div(other.ref_time())?,
self.proof_size().checked_div(other.proof_size())?,
))
}
}
/// Trait that provides a static `str`.
pub trait StaticStrProvider {
/// Static string.
const STR: &'static str;
}
/// A macro that generates `StaticStrProvider` with the string set to its stringified argument.
#[macro_export]
macro_rules! generate_static_str_provider {
($str:expr) => {
$crate::paste::item! {
pub struct [<Str $str>];
impl $crate::StaticStrProvider for [<Str $str>] {
const STR: &'static str = stringify!($str);
}
}
};
}
/// Error message that is only dispayable in `std` environment.
#[derive(Encode, Decode, Clone, Eq, PartialEq, PalletError, TypeInfo)]
#[scale_info(skip_type_params(T))]
pub struct StrippableError<T> {
_phantom_data: sp_std::marker::PhantomData<T>,
#[codec(skip)]
#[cfg(feature = "std")]
message: String,
}
impl<T: Debug> From<T> for StrippableError<T> {
fn from(_err: T) -> Self {
Self {
_phantom_data: Default::default(),
#[cfg(feature = "std")]
message: format!("{:?}", _err),
}
}
}
impl<T> Debug for StrippableError<T> {
#[cfg(feature = "std")]
fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result {
f.write_str(&self.message)
}
#[cfg(not(feature = "std"))]
fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result {
f.write_str("Stripped error")
}
}
/// A trait defining helper methods for `RangeInclusive` (start..=end)
pub trait RangeInclusiveExt<Idx> {
/// Computes the length of the `RangeInclusive`, checking for underflow and overflow.
fn checked_len(&self) -> Option<Idx>;
/// Computes the length of the `RangeInclusive`, saturating in case of underflow or overflow.
fn saturating_len(&self) -> Idx;
}
impl<Idx> RangeInclusiveExt<Idx> for RangeInclusive<Idx>
where
Idx: CheckedSub + CheckedAdd + SaturatingAdd + One + Zero,
{
fn checked_len(&self) -> Option<Idx> {
self.end()
.checked_sub(self.start())
.and_then(|len| len.checked_add(&Idx::one()))
}
fn saturating_len(&self) -> Idx {
let len = match self.end().checked_sub(self.start()) {
Some(len) => len,
None => return Idx::zero(),
};
len.saturating_add(&Idx::one())
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn storage_value_key_works() {
assert_eq!(
storage_value_key("PalletTransactionPayment", "NextFeeMultiplier"),
StorageKey(
hex_literal::hex!(
"f0e954dfcca51a255ab12c60c789256a3f2edf3bdf381debe331ab7446addfdc"
)
.to_vec()
),
);
}
#[test]
fn generate_static_str_provider_works() {
generate_static_str_provider!(Test);
assert_eq!(StrTest::STR, "Test");
}
}
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Parity Bridges Common.
// Parity Bridges Common is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity Bridges Common is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
//! Primitives that may be used by different message delivery and dispatch mechanisms.
use codec::{Decode, Encode};
use frame_support::weights::Weight;
use scale_info::TypeInfo;
use sp_runtime::RuntimeDebug;
/// Message dispatch result.
#[derive(Encode, Decode, RuntimeDebug, Clone, PartialEq, Eq, TypeInfo)]
pub struct MessageDispatchResult<DispatchLevelResult> {
/// Unspent dispatch weight. This weight that will be deducted from total delivery transaction
/// weight, thus reducing the transaction cost. This shall not be zero in (at least) two cases:
///
/// 1) if message has been dispatched successfully, but post-dispatch weight is less than the
/// weight, declared by the message sender;
/// 2) if message has not been dispatched at all.
pub unspent_weight: Weight,
/// Fine-grained result of single message dispatch (for better diagnostic purposes)
pub dispatch_level_result: DispatchLevelResult,
}
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Parity Bridges Common.
// Parity Bridges Common is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity Bridges Common is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
//! Logic for checking Substrate storage proofs.
use crate::StrippableError;
use codec::{Decode, Encode};
use frame_support::PalletError;
use hash_db::{HashDB, Hasher, EMPTY_PREFIX};
use scale_info::TypeInfo;
use sp_std::{boxed::Box, collections::btree_set::BTreeSet, vec::Vec};
use sp_trie::{
read_trie_value, LayoutV1, MemoryDB, Recorder, StorageProof, Trie, TrieConfiguration,
TrieDBBuilder, TrieError, TrieHash,
};
/// Raw storage proof type (just raw trie nodes).
pub type RawStorageProof = Vec<Vec<u8>>;
/// Storage proof size requirements.
///
/// This is currently used by benchmarks when generating storage proofs.
#[derive(Clone, Copy, Debug)]
pub enum ProofSize {
/// The proof is expected to be minimal. If value size may be changed, then it is expected to
/// have given size.
Minimal(u32),
/// The proof is expected to have at least given size and grow by increasing value that is
/// stored in the trie.
HasLargeLeaf(u32),
}
/// This struct is used to read storage values from a subset of a Merklized database. The "proof"
/// is a subset of the nodes in the Merkle structure of the database, so that it provides
/// authentication against a known Merkle root as well as the values in the
/// database themselves.
pub struct StorageProofChecker<H>
where
H: Hasher,
{
proof_nodes_count: usize,
root: H::Out,
db: MemoryDB<H>,
recorder: Recorder<LayoutV1<H>>,
}
impl<H> StorageProofChecker<H>
where
H: Hasher,
{
/// Constructs a new storage proof checker.
///
/// This returns an error if the given proof is invalid with respect to the given root.
pub fn new(root: H::Out, proof: RawStorageProof) -> Result<Self, Error> {
// 1. we don't want extra items in the storage proof
// 2. `StorageProof` is storing all trie nodes in the `BTreeSet`
//
// => someone could simply add duplicate items to the proof and we won't be
// able to detect that by just using `StorageProof`
//
// => let's check it when we are converting our "raw proof" into `StorageProof`
let proof_nodes_count = proof.len();
let proof = StorageProof::new(proof);
if proof_nodes_count != proof.iter_nodes().count() {
return Err(Error::DuplicateNodesInProof)
}
let db = proof.into_memory_db();
if !db.contains(&root, EMPTY_PREFIX) {
return Err(Error::StorageRootMismatch)
}
let recorder = Recorder::default();
let checker = StorageProofChecker { proof_nodes_count, root, db, recorder };
Ok(checker)
}
/// Returns error if the proof has some nodes that are left intact by previous `read_value`
/// calls.
pub fn ensure_no_unused_nodes(mut self) -> Result<(), Error> {
let visited_nodes = self
.recorder
.drain()
.into_iter()
.map(|record| record.data)
.collect::<BTreeSet<_>>();
let visited_nodes_count = visited_nodes.len();
if self.proof_nodes_count == visited_nodes_count {
Ok(())
} else {
Err(Error::UnusedNodesInTheProof)
}
}
/// Reads a value from the available subset of storage. If the value cannot be read due to an
/// incomplete or otherwise invalid proof, this function returns an error.
pub fn read_value(&mut self, key: &[u8]) -> Result<Option<Vec<u8>>, Error> {
// LayoutV1 or LayoutV0 is identical for proof that only read values.
read_trie_value::<LayoutV1<H>, _>(&self.db, &self.root, key, Some(&mut self.recorder), None)
.map_err(|_| Error::StorageValueUnavailable)
}
/// Reads and decodes a value from the available subset of storage. If the value cannot be read
/// due to an incomplete or otherwise invalid proof, this function returns an error. If value is
/// read, but decoding fails, this function returns an error.
pub fn read_and_decode_value<T: Decode>(&mut self, key: &[u8]) -> Result<Option<T>, Error> {
self.read_value(key).and_then(|v| {
v.map(|v| T::decode(&mut &v[..]).map_err(|e| Error::StorageValueDecodeFailed(e.into())))
.transpose()
})
}
/// Reads and decodes a value from the available subset of storage. If the value cannot be read
/// due to an incomplete or otherwise invalid proof, or if the value is `None`, this function
/// returns an error. If value is read, but decoding fails, this function returns an error.
pub fn read_and_decode_mandatory_value<T: Decode>(&mut self, key: &[u8]) -> Result<T, Error> {
self.read_and_decode_value(key)?.ok_or(Error::StorageValueEmpty)
}
/// Reads and decodes a value from the available subset of storage. If the value cannot be read
/// due to an incomplete or otherwise invalid proof, this function returns `Ok(None)`.
/// If value is read, but decoding fails, this function returns an error.
pub fn read_and_decode_opt_value<T: Decode>(&mut self, key: &[u8]) -> Result<Option<T>, Error> {
match self.read_and_decode_value(key) {
Ok(outbound_lane_data) => Ok(outbound_lane_data),
Err(Error::StorageValueUnavailable) => Ok(None),
Err(e) => Err(e),
}
}
}
/// Storage proof related errors.
#[derive(Encode, Decode, Clone, Eq, PartialEq, PalletError, Debug, TypeInfo)]
pub enum Error {
/// Duplicate trie nodes are found in the proof.
DuplicateNodesInProof,
/// Unused trie nodes are found in the proof.
UnusedNodesInTheProof,
/// Expected storage root is missing from the proof.
StorageRootMismatch,
/// Unable to reach expected storage value using provided trie nodes.
StorageValueUnavailable,
/// The storage value is `None`.
StorageValueEmpty,
/// Failed to decode storage value.
StorageValueDecodeFailed(StrippableError<codec::Error>),
}
/// Return valid storage proof and state root.
///
/// NOTE: This should only be used for **testing**.
#[cfg(feature = "std")]
pub fn craft_valid_storage_proof() -> (sp_core::H256, RawStorageProof) {
use sp_state_machine::{backend::Backend, prove_read, InMemoryBackend};
let state_version = sp_runtime::StateVersion::default();
// construct storage proof
let backend = <InMemoryBackend<sp_core::Blake2Hasher>>::from((
vec![
(None, vec![(b"key1".to_vec(), Some(b"value1".to_vec()))]),
(None, vec![(b"key2".to_vec(), Some(b"value2".to_vec()))]),
(None, vec![(b"key3".to_vec(), Some(b"value3".to_vec()))]),
(None, vec![(b"key4".to_vec(), Some((42u64, 42u32, 42u16, 42u8).encode()))]),
// Value is too big to fit in a branch node
(None, vec![(b"key11".to_vec(), Some(vec![0u8; 32]))]),
],
state_version,
));
let root = backend.storage_root(std::iter::empty(), state_version).0;
let proof =
prove_read(backend, &[&b"key1"[..], &b"key2"[..], &b"key4"[..], &b"key22"[..]]).unwrap();
(root, proof.into_nodes().into_iter().collect())
}
/// Record all keys for a given root.
pub fn record_all_keys<L: TrieConfiguration, DB>(
db: &DB,
root: &TrieHash<L>,
) -> Result<RawStorageProof, Box<TrieError<L>>>
where
DB: hash_db::HashDBRef<L::Hash, trie_db::DBValue>,
{
let mut recorder = Recorder::<L>::new();
let trie = TrieDBBuilder::<L>::new(db, root).with_recorder(&mut recorder).build();
for x in trie.iter()? {
let (key, _) = x?;
trie.get(&key)?;
}
// recorder may record the same trie node multiple times and we don't want duplicate nodes
// in our proofs => let's deduplicate it by collecting to the BTreeSet first
Ok(recorder
.drain()
.into_iter()
.map(|n| n.data.to_vec())
.collect::<BTreeSet<_>>()
.into_iter()
.collect())
}
#[cfg(test)]
pub mod tests {
use super::*;
use codec::Encode;
#[test]
fn storage_proof_check() {
let (root, proof) = craft_valid_storage_proof();
// check proof in runtime
let mut checker =
<StorageProofChecker<sp_core::Blake2Hasher>>::new(root, proof.clone()).unwrap();
assert_eq!(checker.read_value(b"key1"), Ok(Some(b"value1".to_vec())));
assert_eq!(checker.read_value(b"key2"), Ok(Some(b"value2".to_vec())));
assert_eq!(checker.read_value(b"key4"), Ok(Some((42u64, 42u32, 42u16, 42u8).encode())));
assert_eq!(checker.read_value(b"key11111"), Err(Error::StorageValueUnavailable));
assert_eq!(checker.read_value(b"key22"), Ok(None));
assert_eq!(checker.read_and_decode_value(b"key4"), Ok(Some((42u64, 42u32, 42u16, 42u8))),);
assert!(matches!(
checker.read_and_decode_value::<[u8; 64]>(b"key4"),
Err(Error::StorageValueDecodeFailed(_)),
));
// checking proof against invalid commitment fails
assert_eq!(
<StorageProofChecker<sp_core::Blake2Hasher>>::new(sp_core::H256::random(), proof).err(),
Some(Error::StorageRootMismatch)
);
}
#[test]
fn proof_with_duplicate_items_is_rejected() {
let (root, mut proof) = craft_valid_storage_proof();
proof.push(proof.first().unwrap().clone());
assert_eq!(
StorageProofChecker::<sp_core::Blake2Hasher>::new(root, proof).map(drop),
Err(Error::DuplicateNodesInProof),
);
}
#[test]
fn proof_with_unused_items_is_rejected() {
let (root, proof) = craft_valid_storage_proof();
let mut checker =
StorageProofChecker::<sp_core::Blake2Hasher>::new(root, proof.clone()).unwrap();
checker.read_value(b"key1").unwrap();
checker.read_value(b"key2").unwrap();
checker.read_value(b"key4").unwrap();
checker.read_value(b"key22").unwrap();
assert_eq!(checker.ensure_no_unused_nodes(), Ok(()));
let checker = StorageProofChecker::<sp_core::Blake2Hasher>::new(root, proof).unwrap();
assert_eq!(checker.ensure_no_unused_nodes(), Err(Error::UnusedNodesInTheProof));
}
}
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Parity Bridges Common.
// Parity Bridges Common is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity Bridges Common is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
//! Wrapper for a runtime storage value that checks if value exceeds given maximum
//! during conversion.
use codec::{Decode, Encode, MaxEncodedLen};
use frame_support::traits::Get;
use scale_info::{Type, TypeInfo};
use sp_runtime::RuntimeDebug;
use sp_std::{marker::PhantomData, ops::Deref};
/// Error that is returned when the value size exceeds maximal configured size.
#[derive(RuntimeDebug)]
pub struct MaximalSizeExceededError {
/// Size of the value.
pub value_size: usize,
/// Maximal configured size.
pub maximal_size: usize,
}
/// A bounded runtime storage value.
#[derive(Clone, Decode, Encode, Eq, PartialEq)]
pub struct BoundedStorageValue<B, V> {
value: V,
_phantom: PhantomData<B>,
}
impl<B, V: sp_std::fmt::Debug> sp_std::fmt::Debug for BoundedStorageValue<B, V> {
fn fmt(&self, fmt: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result {
self.value.fmt(fmt)
}
}
impl<B: Get<u32>, V: Encode> BoundedStorageValue<B, V> {
/// Construct `BoundedStorageValue` from the underlying `value` with all required checks.
///
/// Returns error if value size exceeds given bounds.
pub fn try_from_inner(value: V) -> Result<Self, MaximalSizeExceededError> {
// this conversion is heavy (since we do encoding here), so we may want to optimize it later
// (e.g. by introducing custom Encode implementation, and turning `BoundedStorageValue` into
// `enum BoundedStorageValue { Decoded(V), Encoded(Vec<u8>) }`)
let value_size = value.encoded_size();
let maximal_size = B::get() as usize;
if value_size > maximal_size {
Err(MaximalSizeExceededError { value_size, maximal_size })
} else {
Ok(BoundedStorageValue { value, _phantom: Default::default() })
}
}
/// Convert into the inner type
pub fn into_inner(self) -> V {
self.value
}
}
impl<B, V> Deref for BoundedStorageValue<B, V> {
type Target = V;
fn deref(&self) -> &Self::Target {
&self.value
}
}
impl<B: 'static, V: TypeInfo + 'static> TypeInfo for BoundedStorageValue<B, V> {
type Identity = Self;
fn type_info() -> Type {
V::type_info()
}
}
impl<B: Get<u32>, V: Encode> MaxEncodedLen for BoundedStorageValue<B, V> {
fn max_encoded_len() -> usize {
B::get() as usize
}
}
[package]
name = "bp-test-utils"
version = "0.7.0"
description = "Utilities for testing substrate-based runtime bridge code"
authors.workspace = true
edition.workspace = true
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
[lints]
workspace = true
[dependencies]
bp-header-chain = { path = "../header-chain", default-features = false }
bp-parachains = { path = "../parachains", default-features = false }
bp-polkadot-core = { path = "../polkadot-core", default-features = false }
bp-runtime = { path = "../runtime", default-features = false }
codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false }
ed25519-dalek = { version = "2.1", default-features = false }
finality-grandpa = { version = "0.16.2", default-features = false }
sp-application-crypto = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
sp-std = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
sp-trie = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
[features]
default = ["std"]
std = [
"bp-header-chain/std",
"bp-parachains/std",
"bp-polkadot-core/std",
"bp-runtime/std",
"codec/std",
"ed25519-dalek/std",
"finality-grandpa/std",
"sp-application-crypto/std",
"sp-consensus-grandpa/std",
"sp-core/std",
"sp-runtime/std",
"sp-std/std",
"sp-trie/std",
]
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Parity Bridges Common.
// Parity Bridges Common is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity Bridges Common is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
//! Utilities for working with test accounts.
use bp_header_chain::{justification::JustificationVerificationContext, AuthoritySet};
use codec::Encode;
use ed25519_dalek::{Signature, SigningKey, VerifyingKey};
use finality_grandpa::voter_set::VoterSet;
use sp_consensus_grandpa::{AuthorityId, AuthorityList, AuthorityWeight, SetId};
use sp_runtime::RuntimeDebug;
use sp_std::prelude::*;
/// Set of test accounts with friendly names: Alice.
pub const ALICE: Account = Account(0);
/// Set of test accounts with friendly names: Bob.
pub const BOB: Account = Account(1);
/// Set of test accounts with friendly names: Charlie.
pub const CHARLIE: Account = Account(2);
/// Set of test accounts with friendly names: Dave.
pub const DAVE: Account = Account(3);
/// Set of test accounts with friendly names: Eve.
pub const EVE: Account = Account(4);
/// Set of test accounts with friendly names: Ferdie.
pub const FERDIE: Account = Account(5);
/// A test account which can be used to sign messages.
#[derive(RuntimeDebug, Clone, Copy)]
pub struct Account(pub u16);
impl Account {
/// Returns public key of this account.
pub fn public(&self) -> VerifyingKey {
self.pair().verifying_key()
}
/// Returns key pair, used to sign data on behalf of this account.
pub fn pair(&self) -> SigningKey {
let data = self.0.encode();
let mut bytes = [0_u8; 32];
bytes[0..data.len()].copy_from_slice(&data);
SigningKey::from_bytes(&bytes)
}
/// Generate a signature of given message.
pub fn sign(&self, msg: &[u8]) -> Signature {
use ed25519_dalek::Signer;
self.pair().sign(msg)
}
}
impl From<Account> for AuthorityId {
fn from(p: Account) -> Self {
sp_application_crypto::UncheckedFrom::unchecked_from(p.public().to_bytes())
}
}
/// Get a valid set of voters for a Grandpa round.
pub fn voter_set() -> VoterSet<AuthorityId> {
VoterSet::new(authority_list()).unwrap()
}
/// Get a valid justification verification context for a GRANDPA round.
pub fn verification_context(set_id: SetId) -> JustificationVerificationContext {
AuthoritySet { authorities: authority_list(), set_id }.try_into().unwrap()
}
/// Convenience function to get a list of Grandpa authorities.
pub fn authority_list() -> AuthorityList {
test_keyring().iter().map(|(id, w)| (AuthorityId::from(*id), *w)).collect()
}
/// Get the corresponding identities from the keyring for the "standard" authority set.
pub fn test_keyring() -> Vec<(Account, AuthorityWeight)> {
vec![(ALICE, 1), (BOB, 1), (CHARLIE, 1)]
}
/// Get a list of "unique" accounts.
pub fn accounts(len: u16) -> Vec<Account> {
(0..len).map(Account).collect()
}
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Parity Bridges Common.
// Parity Bridges Common is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity Bridges Common is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
//! Utilities for testing runtime code.
#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)]
use bp_header_chain::justification::{required_justification_precommits, GrandpaJustification};
use bp_parachains::parachain_head_storage_key_at_source;
use bp_polkadot_core::parachains::{ParaHash, ParaHead, ParaHeadsProof, ParaId};
use bp_runtime::record_all_trie_keys;
use codec::Encode;
use sp_consensus_grandpa::{AuthorityId, AuthoritySignature, AuthorityWeight, SetId};
use sp_runtime::traits::{Header as HeaderT, One, Zero};
use sp_std::prelude::*;
use sp_trie::{trie_types::TrieDBMutBuilderV1, LayoutV1, MemoryDB, TrieMut};
// Re-export all our test account utilities
pub use keyring::*;
mod keyring;
/// GRANDPA round number used across tests.
pub const TEST_GRANDPA_ROUND: u64 = 1;
/// GRANDPA validators set id used across tests.
pub const TEST_GRANDPA_SET_ID: SetId = 1;
/// Name of the `Paras` pallet used across tests.
pub const PARAS_PALLET_NAME: &str = "Paras";
/// Configuration parameters when generating test GRANDPA justifications.
#[derive(Clone)]
pub struct JustificationGeneratorParams<H> {
/// The header which we want to finalize.
pub header: H,
/// The GRANDPA round number for the current authority set.
pub round: u64,
/// The current authority set ID.
pub set_id: SetId,
/// The current GRANDPA authority set.
///
/// The size of the set will determine the number of pre-commits in our justification.
pub authorities: Vec<(Account, AuthorityWeight)>,
/// The total number of precommit ancestors in the `votes_ancestries` field our justification.
///
/// These may be distributed among many forks.
pub ancestors: u32,
/// The number of forks.
///
/// Useful for creating a "worst-case" scenario in which each authority is on its own fork.
pub forks: u32,
}
impl<H: HeaderT> Default for JustificationGeneratorParams<H> {
fn default() -> Self {
let required_signatures = required_justification_precommits(test_keyring().len() as _);
Self {
header: test_header(One::one()),
round: TEST_GRANDPA_ROUND,
set_id: TEST_GRANDPA_SET_ID,
authorities: test_keyring().into_iter().take(required_signatures as _).collect(),
ancestors: 2,
forks: 1,
}
}
}
/// Make a valid GRANDPA justification with sensible defaults
pub fn make_default_justification<H: HeaderT>(header: &H) -> GrandpaJustification<H> {
let params = JustificationGeneratorParams::<H> { header: header.clone(), ..Default::default() };
make_justification_for_header(params)
}
/// Generate justifications in a way where we are able to tune the number of pre-commits
/// and vote ancestries which are included in the justification.
///
/// This is useful for benchmarkings where we want to generate valid justifications with
/// a specific number of pre-commits (tuned with the number of "authorities") and/or a specific
/// number of vote ancestries (tuned with the "votes" parameter).
///
/// Note: This needs at least three authorities or else the verifier will complain about
/// being given an invalid commit.
pub fn make_justification_for_header<H: HeaderT>(
params: JustificationGeneratorParams<H>,
) -> GrandpaJustification<H> {
let JustificationGeneratorParams { header, round, set_id, authorities, mut ancestors, forks } =
params;
let (target_hash, target_number) = (header.hash(), *header.number());
let mut votes_ancestries = vec![];
let mut precommits = vec![];
assert!(forks != 0, "Need at least one fork to have a chain..");
assert!(
forks as usize <= authorities.len(),
"If we have more forks than authorities we can't create valid pre-commits for all the forks."
);
// Roughly, how many vote ancestries do we want per fork
let target_depth = (ancestors + forks - 1) / forks;
let mut unsigned_precommits = vec![];
for i in 0..forks {
let depth = if ancestors >= target_depth {
ancestors -= target_depth;
target_depth
} else {
ancestors
};
// Note: Adding 1 to account for the target header
let chain = generate_chain(i, depth + 1, &header);
// We don't include our finality target header in the vote ancestries
for child in &chain[1..] {
votes_ancestries.push(child.clone());
}
// The header we need to use when pre-committing is the one at the highest height
// on our chain.
let precommit_candidate = chain.last().map(|h| (h.hash(), *h.number())).unwrap();
unsigned_precommits.push(precommit_candidate);
}
for (i, (id, _weight)) in authorities.iter().enumerate() {
// Assign authorities to sign pre-commits in a round-robin fashion
let target = unsigned_precommits[i % forks as usize];
let precommit = signed_precommit::<H>(id, target, round, set_id);
precommits.push(precommit);
}
GrandpaJustification {
round,
commit: finality_grandpa::Commit { target_hash, target_number, precommits },
votes_ancestries,
}
}
fn generate_chain<H: HeaderT>(fork_id: u32, depth: u32, ancestor: &H) -> Vec<H> {
let mut headers = vec![ancestor.clone()];
for i in 1..depth {
let parent = &headers[(i - 1) as usize];
let (hash, num) = (parent.hash(), *parent.number());
let mut header = test_header::<H>(num + One::one());
header.set_parent_hash(hash);
// Modifying the digest so headers at the same height but in different forks have different
// hashes
header.digest_mut().logs.push(sp_runtime::DigestItem::Other(fork_id.encode()));
headers.push(header);
}
headers
}
/// Make valid proof for parachain `heads`
pub fn prepare_parachain_heads_proof<H: HeaderT>(
heads: Vec<(u32, ParaHead)>,
) -> (H::Hash, ParaHeadsProof, Vec<(ParaId, ParaHash)>) {
let mut parachains = Vec::with_capacity(heads.len());
let mut root = Default::default();
let mut mdb = MemoryDB::default();
{
let mut trie = TrieDBMutBuilderV1::<H::Hashing>::new(&mut mdb, &mut root).build();
for (parachain, head) in heads {
let storage_key =
parachain_head_storage_key_at_source(PARAS_PALLET_NAME, ParaId(parachain));
trie.insert(&storage_key.0, &head.encode())
.map_err(|_| "TrieMut::insert has failed")
.expect("TrieMut::insert should not fail in tests");
parachains.push((ParaId(parachain), head.hash()));
}
}
// generate storage proof to be delivered to This chain
let storage_proof = record_all_trie_keys::<LayoutV1<H::Hashing>, _>(&mdb, &root)
.map_err(|_| "record_all_trie_keys has failed")
.expect("record_all_trie_keys should not fail in benchmarks");
(root, ParaHeadsProof { storage_proof }, parachains)
}
/// Create signed precommit with given target.
pub fn signed_precommit<H: HeaderT>(
signer: &Account,
target: (H::Hash, H::Number),
round: u64,
set_id: SetId,
) -> finality_grandpa::SignedPrecommit<H::Hash, H::Number, AuthoritySignature, AuthorityId> {
let precommit = finality_grandpa::Precommit { target_hash: target.0, target_number: target.1 };
let encoded = sp_consensus_grandpa::localized_payload(
round,
set_id,
&finality_grandpa::Message::Precommit(precommit.clone()),
);
let signature = signer.sign(&encoded);
let raw_signature: Vec<u8> = signature.to_bytes().into();
// Need to wrap our signature and id types that they match what our `SignedPrecommit` is
// expecting
let signature = AuthoritySignature::try_from(raw_signature).expect(
"We know our Keypair is good,
so our signature must also be good.",
);
let id = (*signer).into();
finality_grandpa::SignedPrecommit { precommit, signature, id }
}
/// Get a header for testing.
///
/// The correct parent hash will be used if given a non-zero header.
pub fn test_header<H: HeaderT>(number: H::Number) -> H {
let default = |num| {
H::new(num, Default::default(), Default::default(), Default::default(), Default::default())
};
let mut header = default(number);
if number != Zero::zero() {
let parent_hash = default(number - One::one()).hash();
header.set_parent_hash(parent_hash);
}
header
}
/// Get a header for testing with given `state_root`.
///
/// The correct parent hash will be used if given a non-zero header.
pub fn test_header_with_root<H: HeaderT>(number: H::Number, state_root: H::Hash) -> H {
let mut header: H = test_header(number);
header.set_state_root(state_root);
header
}
/// Convenience function for generating a Header ID at a given block number.
pub fn header_id<H: HeaderT>(index: u8) -> (H::Hash, H::Number) {
(test_header::<H>(index.into()).hash(), index.into())
}
#[macro_export]
/// Adds methods for testing the `set_owner()` and `set_operating_mode()` for a pallet.
/// Some values are hardcoded like:
/// - `run_test()`
/// - `Pallet::<TestRuntime>`
/// - `PalletOwner::<TestRuntime>`
/// - `PalletOperatingMode::<TestRuntime>`
/// While this is not ideal, all the pallets use the same names, so it works for the moment.
/// We can revisit this in the future if anything changes.
macro_rules! generate_owned_bridge_module_tests {
($normal_operating_mode: expr, $halted_operating_mode: expr) => {
#[test]
fn test_set_owner() {
run_test(|| {
PalletOwner::<TestRuntime>::put(1);
// The root should be able to change the owner.
assert_ok!(Pallet::<TestRuntime>::set_owner(RuntimeOrigin::root(), Some(2)));
assert_eq!(PalletOwner::<TestRuntime>::get(), Some(2));
// The owner should be able to change the owner.
assert_ok!(Pallet::<TestRuntime>::set_owner(RuntimeOrigin::signed(2), Some(3)));
assert_eq!(PalletOwner::<TestRuntime>::get(), Some(3));
// Other users shouldn't be able to change the owner.
assert_noop!(
Pallet::<TestRuntime>::set_owner(RuntimeOrigin::signed(1), Some(4)),
DispatchError::BadOrigin
);
assert_eq!(PalletOwner::<TestRuntime>::get(), Some(3));
});
}
#[test]
fn test_set_operating_mode() {
run_test(|| {
PalletOwner::<TestRuntime>::put(1);
PalletOperatingMode::<TestRuntime>::put($normal_operating_mode);
// The root should be able to halt the pallet.
assert_ok!(Pallet::<TestRuntime>::set_operating_mode(
RuntimeOrigin::root(),
$halted_operating_mode
));
assert_eq!(PalletOperatingMode::<TestRuntime>::get(), $halted_operating_mode);
// The root should be able to resume the pallet.
assert_ok!(Pallet::<TestRuntime>::set_operating_mode(
RuntimeOrigin::root(),
$normal_operating_mode
));
assert_eq!(PalletOperatingMode::<TestRuntime>::get(), $normal_operating_mode);
// The owner should be able to halt the pallet.
assert_ok!(Pallet::<TestRuntime>::set_operating_mode(
RuntimeOrigin::signed(1),
$halted_operating_mode
));
assert_eq!(PalletOperatingMode::<TestRuntime>::get(), $halted_operating_mode);
// The owner should be able to resume the pallet.
assert_ok!(Pallet::<TestRuntime>::set_operating_mode(
RuntimeOrigin::signed(1),
$normal_operating_mode
));
assert_eq!(PalletOperatingMode::<TestRuntime>::get(), $normal_operating_mode);
// Other users shouldn't be able to halt the pallet.
assert_noop!(
Pallet::<TestRuntime>::set_operating_mode(
RuntimeOrigin::signed(2),
$halted_operating_mode
),
DispatchError::BadOrigin
);
assert_eq!(PalletOperatingMode::<TestRuntime>::get(), $normal_operating_mode);
// Other users shouldn't be able to resume the pallet.
PalletOperatingMode::<TestRuntime>::put($halted_operating_mode);
assert_noop!(
Pallet::<TestRuntime>::set_operating_mode(
RuntimeOrigin::signed(2),
$normal_operating_mode
),
DispatchError::BadOrigin
);
assert_eq!(PalletOperatingMode::<TestRuntime>::get(), $halted_operating_mode);
});
}
};
}
[package]
name = "bp-xcm-bridge-hub-router"
description = "Primitives of the xcm-bridge-hub fee pallet."
version = "0.6.0"
authors.workspace = true
edition.workspace = true
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
[lints]
workspace = true
[dependencies]
codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["bit-vec", "derive"] }
scale-info = { version = "2.10.0", default-features = false, features = ["bit-vec", "derive"] }
# Substrate Dependencies
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
[features]
default = ["std"]
std = ["codec/std", "scale-info/std", "sp-core/std", "sp-runtime/std"]
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Parity Bridges Common.
// Parity Bridges Common is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity Bridges Common is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
//! Primitives of the `xcm-bridge-hub-router` pallet.
#![cfg_attr(not(feature = "std"), no_std)]
use codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_core::H256;
use sp_runtime::{FixedU128, RuntimeDebug};
/// Minimal delivery fee factor.
pub const MINIMAL_DELIVERY_FEE_FACTOR: FixedU128 = FixedU128::from_u32(1);
/// XCM channel status provider that may report whether it is congested or not.
///
/// By channel we mean the physical channel that is used to deliver messages of one
/// of the bridge queues.
pub trait XcmChannelStatusProvider {
/// Returns true if the channel is currently congested.
fn is_congested() -> bool;
}
impl XcmChannelStatusProvider for () {
fn is_congested() -> bool {
false
}
}
/// Current status of the bridge.
#[derive(Clone, Decode, Encode, Eq, PartialEq, TypeInfo, MaxEncodedLen, RuntimeDebug)]
pub struct BridgeState {
/// Current delivery fee factor.
pub delivery_fee_factor: FixedU128,
/// Bridge congestion flag.
pub is_congested: bool,
}
impl Default for BridgeState {
fn default() -> BridgeState {
BridgeState { delivery_fee_factor: MINIMAL_DELIVERY_FEE_FACTOR, is_congested: false }
}
}
/// A minimized version of `pallet-xcm-bridge-hub-router::Call` that can be used without a runtime.
#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
#[allow(non_camel_case_types)]
pub enum XcmBridgeHubRouterCall {
/// `pallet-xcm-bridge-hub-router::Call::report_bridge_status`
#[codec(index = 0)]
report_bridge_status { bridge_id: H256, is_congested: bool },
}
[package]
name = "bp-xcm-bridge-hub"
description = "Primitives of the xcm-bridge-hub pallet."
version = "0.2.0"
authors.workspace = true
edition.workspace = true
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
[lints]
workspace = true
[dependencies]
# Substrate Dependencies
sp-std = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
[features]
default = ["std"]
std = ["sp-std/std"]
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
// This file is part of Parity Bridges Common.
// Parity Bridges Common is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity Bridges Common is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
//! Primitives of the xcm-bridge-hub pallet.
#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)]
/// Encoded XCM blob. We expect the bridge messages pallet to use this blob type for both inbound
/// and outbound payloads.
pub type XcmAsPlainPayload = sp_std::vec::Vec<u8>;
[package]
name = "relay-bridge-hub-kusama-client"
version = "0.1.0"
authors = ["Parity Technologies <[email protected]>"]
edition = "2021"
authors.workspace = true
edition.workspace = true
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
repository.workspace = true
[lints]
workspace = true
[dependencies]
codec = { package = "parity-scale-codec", version = "3.1.5", features = ["derive"] }
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }
#relay-substrate-client = { path = "../client-substrate" }
subxt = { version = "0.32.1", default-features = false, features = ["native"] }
codec = { package = "parity-scale-codec", version = "3.6.1", features = ["derive"] }
scale-info = { version = "2.11.1", default-features = false, features = ["derive"] }
subxt = { version = "0.35.3", default-features = false, features = ["native"] }
# Bridge dependencies
bp-bridge-hub-kusama = { path = "../../primitives/chain-bridge-hub-kusama" }
bp-header-chain = { path = "../../primitives/header-chain" }
bp-messages = { path = "../../primitives/messages" }
bp-parachains = { path = "../../primitives/parachains" }
bp-polkadot = { path = "../../primitives/chain-polkadot" }
bp-polkadot-core = { path = "../../primitives/polkadot-core" }
bridge-runtime-common = { path = "../../bin/runtime-common" }
relay-substrate-client = { path = "../client-substrate" }
bp-bridge-hub-kusama = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
bp-header-chain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
bp-messages = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
bp-parachains = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
bp-polkadot = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
bp-polkadot-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
bridge-runtime-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
relay-substrate-client = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
# Substrate Dependencies
......
......@@ -17,7 +17,7 @@
//! Autogenerated runtime API
//! THIS FILE WAS AUTOGENERATED USING parity-bridges-common::runtime-codegen
//! EXECUTED COMMAND: target/debug/runtime-codegen --from-node-url
//! wss://kusama-bridge-hub-rpc.polkadot.io
//! wss://kusama-bridge-hub-rpc.polkadot.io/
#[allow(dead_code, unused_imports, non_camel_case_types)]
#[allow(clippy::all)]
......@@ -31,6 +31,11 @@ pub mod api {
use super::runtime_types;
pub mod bounded_collections {
use super::runtime_types;
pub mod bounded_btree_set {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct BoundedBTreeSet<_0>(pub ::std::vec::Vec<_0>);
}
pub mod bounded_vec {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
......@@ -244,6 +249,23 @@ pub mod api {
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct StrippableError;
}
pub mod bridge_hub_common {
use super::runtime_types;
pub mod message_queue {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum AggregateMessageOrigin {
#[codec(index = 0)]
Here,
#[codec(index = 1)]
Parent,
#[codec(index = 2)]
Sibling(runtime_types::polkadot_parachain_primitives::primitives::Id),
#[codec(index = 3)]
Snowbridge(runtime_types::snowbridge_core::ChannelId),
}
}
}
pub mod bridge_hub_kusama_runtime {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
......@@ -273,6 +295,8 @@ pub mod api {
ParachainSystem(runtime_types::cumulus_pallet_parachain_system::pallet::Call),
#[codec(index = 2)]
Timestamp(runtime_types::pallet_timestamp::pallet::Call),
#[codec(index = 3)]
ParachainInfo(runtime_types::staging_parachain_info::pallet::Call),
#[codec(index = 10)]
Balances(runtime_types::pallet_balances::pallet::Call),
#[codec(index = 21)]
......@@ -283,6 +307,8 @@ pub mod api {
XcmpQueue(runtime_types::cumulus_pallet_xcmp_queue::pallet::Call),
#[codec(index = 31)]
PolkadotXcm(runtime_types::pallet_xcm::pallet::Call),
#[codec(index = 32)]
CumulusXcm(runtime_types::cumulus_pallet_xcm::pallet::Call),
#[codec(index = 33)]
DmpQueue(runtime_types::cumulus_pallet_dmp_queue::pallet::Call),
#[codec(index = 40)]
......@@ -297,6 +323,20 @@ pub mod api {
BridgePolkadotParachains(runtime_types::pallet_bridge_parachains::pallet::Call),
#[codec(index = 53)]
BridgePolkadotMessages(runtime_types::pallet_bridge_messages::pallet::Call),
#[codec(index = 80)]
EthereumInboundQueue(runtime_types::snowbridge_pallet_inbound_queue::pallet::Call),
#[codec(index = 81)]
EthereumOutboundQueue(
runtime_types::snowbridge_pallet_outbound_queue::pallet::Call,
),
#[codec(index = 82)]
EthereumBeaconClient(
runtime_types::snowbridge_pallet_ethereum_client::pallet::Call,
),
#[codec(index = 83)]
EthereumSystem(runtime_types::snowbridge_pallet_system::pallet::Call),
#[codec(index = 175)]
MessageQueue(runtime_types::pallet_message_queue::pallet::Call),
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum RuntimeError {
......@@ -314,10 +354,6 @@ pub mod api {
XcmpQueue(runtime_types::cumulus_pallet_xcmp_queue::pallet::Error),
#[codec(index = 31)]
PolkadotXcm(runtime_types::pallet_xcm::pallet::Error),
#[codec(index = 32)]
CumulusXcm(runtime_types::cumulus_pallet_xcm::pallet::Error),
#[codec(index = 33)]
DmpQueue(runtime_types::cumulus_pallet_dmp_queue::pallet::Error),
#[codec(index = 40)]
Utility(runtime_types::pallet_utility::pallet::Error),
#[codec(index = 41)]
......@@ -330,6 +366,20 @@ pub mod api {
BridgePolkadotParachains(runtime_types::pallet_bridge_parachains::pallet::Error),
#[codec(index = 53)]
BridgePolkadotMessages(runtime_types::pallet_bridge_messages::pallet::Error),
#[codec(index = 80)]
EthereumInboundQueue(runtime_types::snowbridge_pallet_inbound_queue::pallet::Error),
#[codec(index = 81)]
EthereumOutboundQueue(
runtime_types::snowbridge_pallet_outbound_queue::pallet::Error,
),
#[codec(index = 82)]
EthereumBeaconClient(
runtime_types::snowbridge_pallet_ethereum_client::pallet::Error,
),
#[codec(index = 83)]
EthereumSystem(runtime_types::snowbridge_pallet_system::pallet::Error),
#[codec(index = 175)]
MessageQueue(runtime_types::pallet_message_queue::pallet::Error),
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum RuntimeEvent {
......@@ -365,6 +415,20 @@ pub mod api {
BridgePolkadotParachains(runtime_types::pallet_bridge_parachains::pallet::Event),
#[codec(index = 53)]
BridgePolkadotMessages(runtime_types::pallet_bridge_messages::pallet::Event),
#[codec(index = 80)]
EthereumInboundQueue(runtime_types::snowbridge_pallet_inbound_queue::pallet::Event),
#[codec(index = 81)]
EthereumOutboundQueue(
runtime_types::snowbridge_pallet_outbound_queue::pallet::Event,
),
#[codec(index = 82)]
EthereumBeaconClient(
runtime_types::snowbridge_pallet_ethereum_client::pallet::Event,
),
#[codec(index = 83)]
EthereumSystem(runtime_types::snowbridge_pallet_system::pallet::Event),
#[codec(index = 175)]
MessageQueue(runtime_types::pallet_message_queue::pallet::Event),
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum RuntimeHoldReason {}
......@@ -392,7 +456,7 @@ pub mod api {
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct RefundBridgedParachainMessages;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct RefundTransactionExtensionAdapter<_0>(pub _0);
pub struct RefundSignedExtensionAdapter<_0>(pub _0);
}
}
pub mod cumulus_pallet_dmp_queue {
......@@ -400,65 +464,56 @@ pub mod api {
pub mod pallet {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Call {
#[codec(index = 0)]
service_overweight {
index: ::core::primitive::u64,
weight_limit: ::sp_weights::Weight,
},
}
pub enum Call {}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Error {
pub enum Event {
#[codec(index = 0)]
Unknown,
StartedExport,
#[codec(index = 1)]
OverLimit,
Exported { page: ::core::primitive::u32 },
#[codec(index = 2)]
ExportFailed { page: ::core::primitive::u32 },
#[codec(index = 3)]
CompletedExport,
#[codec(index = 4)]
StartedOverweightExport,
#[codec(index = 5)]
ExportedOverweight { index: ::core::primitive::u64 },
#[codec(index = 6)]
ExportOverweightFailed { index: ::core::primitive::u64 },
#[codec(index = 7)]
CompletedOverweightExport,
#[codec(index = 8)]
StartedCleanup,
#[codec(index = 9)]
CleanedSome { keys_removed: ::core::primitive::u32 },
#[codec(index = 10)]
Completed { error: ::core::primitive::bool },
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Event {
pub enum MigrationState {
#[codec(index = 0)]
InvalidFormat { message_hash: [::core::primitive::u8; 32usize] },
NotStarted,
#[codec(index = 1)]
UnsupportedVersion { message_hash: [::core::primitive::u8; 32usize] },
StartedExport { next_begin_used: ::core::primitive::u32 },
#[codec(index = 2)]
ExecutedDownward {
message_hash: [::core::primitive::u8; 32usize],
message_id: [::core::primitive::u8; 32usize],
outcome: runtime_types::xcm::v3::traits::Outcome,
},
CompletedExport,
#[codec(index = 3)]
WeightExhausted {
message_hash: [::core::primitive::u8; 32usize],
message_id: [::core::primitive::u8; 32usize],
remaining_weight: ::sp_weights::Weight,
required_weight: ::sp_weights::Weight,
},
StartedOverweightExport { next_overweight_index: ::core::primitive::u64 },
#[codec(index = 4)]
OverweightEnqueued {
message_hash: [::core::primitive::u8; 32usize],
message_id: [::core::primitive::u8; 32usize],
overweight_index: ::core::primitive::u64,
required_weight: ::sp_weights::Weight,
},
CompletedOverweightExport,
#[codec(index = 5)]
OverweightServiced {
overweight_index: ::core::primitive::u64,
weight_used: ::sp_weights::Weight,
StartedCleanup {
cursor: ::core::option::Option<
runtime_types::bounded_collections::bounded_vec::BoundedVec<
::core::primitive::u8,
>,
>,
},
#[codec(index = 6)]
MaxMessagesExhausted { message_hash: [::core::primitive::u8; 32usize] },
Completed,
}
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct ConfigData {
pub max_individual: ::sp_weights::Weight,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct PageIndexData {
pub begin_used: ::core::primitive::u32,
pub end_used: ::core::primitive::u32,
pub overweight_count: ::core::primitive::u64,
}
}
pub mod cumulus_pallet_parachain_system {
use super::runtime_types;
......@@ -495,15 +550,13 @@ pub mod api {
#[codec(index = 2)]
ValidationFunctionDiscarded,
#[codec(index = 3)]
UpgradeAuthorized { code_hash: ::subxt::utils::H256 },
#[codec(index = 4)]
DownwardMessagesReceived { count: ::core::primitive::u32 },
#[codec(index = 5)]
#[codec(index = 4)]
DownwardMessagesProcessed {
weight_used: ::sp_weights::Weight,
dmq_head: ::subxt::utils::H256,
},
#[codec(index = 6)]
#[codec(index = 5)]
UpwardMessageSent {
message_hash: ::core::option::Option<[::core::primitive::u8; 32usize]>,
},
......@@ -533,18 +586,13 @@ pub mod api {
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct UsedBandwidth { pub ump_msg_count : :: core :: primitive :: u32 , pub ump_total_bytes : :: core :: primitive :: u32 , pub hrmp_outgoing : :: subxt :: utils :: KeyedVec < runtime_types :: polkadot_parachain_primitives :: primitives :: Id , runtime_types :: cumulus_pallet_parachain_system :: unincluded_segment :: HrmpChannelUpdate > , }
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct CodeUpgradeAuthorization {
pub code_hash: ::subxt::utils::H256,
pub check_version: ::core::primitive::bool,
}
}
pub mod cumulus_pallet_xcm {
use super::runtime_types;
pub mod pallet {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Error {}
pub enum Call {}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Event {
#[codec(index = 0)]
......@@ -554,7 +602,7 @@ pub mod api {
#[codec(index = 2)]
ExecutedDownward(
[::core::primitive::u8; 32usize],
runtime_types::xcm::v3::traits::Outcome,
runtime_types::staging_xcm::v4::traits::Outcome,
),
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
......@@ -572,11 +620,6 @@ pub mod api {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Call {
#[codec(index = 0)]
service_overweight {
index: ::core::primitive::u64,
weight_limit: ::sp_weights::Weight,
},
#[codec(index = 1)]
suspend_xcm_execution,
#[codec(index = 2)]
......@@ -587,75 +630,23 @@ pub mod api {
update_drop_threshold { new: ::core::primitive::u32 },
#[codec(index = 5)]
update_resume_threshold { new: ::core::primitive::u32 },
#[codec(index = 6)]
update_threshold_weight { new: ::sp_weights::Weight },
#[codec(index = 7)]
update_weight_restrict_decay { new: ::sp_weights::Weight },
#[codec(index = 8)]
update_xcmp_max_individual_weight { new: ::sp_weights::Weight },
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Error {
#[codec(index = 0)]
FailedToSend,
BadQueueConfig,
#[codec(index = 1)]
BadXcmOrigin,
AlreadySuspended,
#[codec(index = 2)]
BadXcm,
#[codec(index = 3)]
BadOverweightIndex,
#[codec(index = 4)]
WeightOverLimit,
AlreadyResumed,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Event {
#[codec(index = 0)]
Success {
message_hash: [::core::primitive::u8; 32usize],
message_id: [::core::primitive::u8; 32usize],
weight: ::sp_weights::Weight,
},
#[codec(index = 1)]
Fail {
message_hash: [::core::primitive::u8; 32usize],
message_id: [::core::primitive::u8; 32usize],
error: runtime_types::xcm::v3::traits::Error,
weight: ::sp_weights::Weight,
},
#[codec(index = 2)]
BadVersion { message_hash: [::core::primitive::u8; 32usize] },
#[codec(index = 3)]
BadFormat { message_hash: [::core::primitive::u8; 32usize] },
#[codec(index = 4)]
XcmpMessageSent { message_hash: [::core::primitive::u8; 32usize] },
#[codec(index = 5)]
OverweightEnqueued {
sender: runtime_types::polkadot_parachain_primitives::primitives::Id,
sent_at: ::core::primitive::u32,
index: ::core::primitive::u64,
required: ::sp_weights::Weight,
},
#[codec(index = 6)]
OverweightServiced { index: ::core::primitive::u64, used: ::sp_weights::Weight },
}
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct InboundChannelDetails {
pub sender: runtime_types::polkadot_parachain_primitives::primitives::Id,
pub state: runtime_types::cumulus_pallet_xcmp_queue::InboundState,
pub message_metadata: ::std::vec::Vec<(
::core::primitive::u32,
runtime_types::polkadot_parachain_primitives::primitives::XcmpMessageFormat,
)>,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum InboundState {
#[codec(index = 0)]
Ok,
#[codec(index = 1)]
Suspended,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct OutboundChannelDetails {
pub recipient: runtime_types::polkadot_parachain_primitives::primitives::Id,
pub state: runtime_types::cumulus_pallet_xcmp_queue::OutboundState,
......@@ -675,9 +666,6 @@ pub mod api {
pub suspend_threshold: ::core::primitive::u32,
pub drop_threshold: ::core::primitive::u32,
pub resume_threshold: ::core::primitive::u32,
pub threshold_weight: ::sp_weights::Weight,
pub weight_restrict_decay: ::sp_weights::Weight,
pub xcmp_max_individual_weight: ::sp_weights::Weight,
}
}
pub mod cumulus_primitives_core {
......@@ -791,6 +779,22 @@ pub mod api {
}
pub mod traits {
use super::runtime_types;
pub mod messages {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum ProcessMessageError {
#[codec(index = 0)]
BadFormat,
#[codec(index = 1)]
Corrupt,
#[codec(index = 2)]
Unsupported,
#[codec(index = 3)]
Overweight(::sp_weights::Weight),
#[codec(index = 4)]
Yield,
}
}
pub mod tokens {
use super::runtime_types;
pub mod misc {
......@@ -900,6 +904,12 @@ pub mod api {
},
#[codec(index = 7)]
remark_with_event { remark: ::std::vec::Vec<::core::primitive::u8> },
#[codec(index = 9)]
authorize_upgrade { code_hash: ::subxt::utils::H256 },
#[codec(index = 10)]
authorize_upgrade_without_checks { code_hash: ::subxt::utils::H256 },
#[codec(index = 11)]
apply_authorized_upgrade { code: ::std::vec::Vec<::core::primitive::u8> },
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Error {
......@@ -915,6 +925,10 @@ pub mod api {
NonZeroRefCount,
#[codec(index = 5)]
CallFiltered,
#[codec(index = 6)]
NothingAuthorized,
#[codec(index = 7)]
Unauthorized,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Event {
......@@ -935,6 +949,11 @@ pub mod api {
KilledAccount { account: ::sp_core::crypto::AccountId32 },
#[codec(index = 5)]
Remarked { sender: ::sp_core::crypto::AccountId32, hash: ::subxt::utils::H256 },
#[codec(index = 6)]
UpgradeAuthorized {
code_hash: ::subxt::utils::H256,
check_version: ::core::primitive::bool,
},
}
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
......@@ -946,6 +965,11 @@ pub mod api {
pub data: _1,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct CodeUpgradeAuthorization {
pub code_hash: ::subxt::utils::H256,
pub check_version: ::core::primitive::bool,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct EventRecord<_0, _1> {
pub phase: runtime_types::frame_system::Phase,
pub event: _0,
......@@ -1010,6 +1034,12 @@ pub mod api {
#[codec(compact)]
new_free: ::core::primitive::u128,
},
#[codec(index = 9)]
force_adjust_total_issuance {
direction: runtime_types::pallet_balances::types::AdjustmentDirection,
#[codec(compact)]
delta: ::core::primitive::u128,
},
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Error {
......@@ -1033,6 +1063,10 @@ pub mod api {
TooManyHolds,
#[codec(index = 9)]
TooManyFreezes,
#[codec(index = 10)]
IssuanceDeactivated,
#[codec(index = 11)]
DeltaZero,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Event {
......@@ -1115,6 +1149,11 @@ pub mod api {
Frozen { who: ::sp_core::crypto::AccountId32, amount: ::core::primitive::u128 },
#[codec(index = 20)]
Thawed { who: ::sp_core::crypto::AccountId32, amount: ::core::primitive::u128 },
#[codec(index = 21)]
TotalIssuanceForced {
old: ::core::primitive::u128,
new: ::core::primitive::u128,
},
}
}
pub mod types {
......@@ -1127,6 +1166,13 @@ pub mod api {
pub flags: runtime_types::pallet_balances::types::ExtraFlags,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum AdjustmentDirection {
#[codec(index = 0)]
Increase,
#[codec(index = 1)]
Decrease,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct BalanceLock<_0> {
pub id: [::core::primitive::u8; 8usize],
pub amount: _0,
......@@ -1271,7 +1317,7 @@ pub mod api {
# [codec (index = 0)] set_owner { new_owner : :: core :: option :: Option < :: sp_core :: crypto :: AccountId32 > , } , # [codec (index = 1)] set_operating_mode { operating_mode : runtime_types :: bp_messages :: MessagesOperatingMode , } , # [codec (index = 2)] receive_messages_proof { relayer_id_at_bridged_chain : :: sp_core :: crypto :: AccountId32 , proof : :: bridge_runtime_common :: messages :: target :: FromBridgedChainMessagesProof < :: subxt :: utils :: H256 > , messages_count : :: core :: primitive :: u32 , dispatch_weight : :: sp_weights :: Weight , } , # [codec (index = 3)] receive_messages_delivery_proof { proof : :: bridge_runtime_common :: messages :: source :: FromBridgedChainMessagesDeliveryProof < :: subxt :: utils :: H256 > , relayers_state : :: bp_messages :: UnrewardedRelayersState , } , }
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Error {
# [codec (index = 0)] NotOperatingNormally , # [codec (index = 1)] InactiveOutboundLane , # [codec (index = 2)] MessageDispatchInactive , # [codec (index = 3)] MessageRejectedByChainVerifier (runtime_types :: bp_messages :: VerificationError ,) , # [codec (index = 4)] MessageRejectedByLaneVerifier (runtime_types :: bp_messages :: VerificationError ,) , # [codec (index = 5)] MessageRejectedByPallet (runtime_types :: bp_messages :: VerificationError ,) , # [codec (index = 6)] FailedToWithdrawMessageFee , # [codec (index = 7)] TooManyMessagesInTheProof , # [codec (index = 8)] InvalidMessagesProof , # [codec (index = 9)] InvalidMessagesDeliveryProof , # [codec (index = 10)] InvalidUnrewardedRelayersState , # [codec (index = 11)] InsufficientDispatchWeight , # [codec (index = 12)] MessageIsNotYetSent , # [codec (index = 13)] ReceivalConfirmation (runtime_types :: pallet_bridge_messages :: outbound_lane :: ReceivalConfirmationError ,) , # [codec (index = 14)] BridgeModule (runtime_types :: bp_runtime :: OwnedBridgeModuleError ,) , }
# [codec (index = 0)] NotOperatingNormally , # [codec (index = 1)] InactiveOutboundLane , # [codec (index = 2)] MessageDispatchInactive , # [codec (index = 3)] MessageRejectedByChainVerifier (runtime_types :: bp_messages :: VerificationError ,) , # [codec (index = 4)] MessageRejectedByPallet (runtime_types :: bp_messages :: VerificationError ,) , # [codec (index = 5)] FailedToWithdrawMessageFee , # [codec (index = 6)] TooManyMessagesInTheProof , # [codec (index = 7)] InvalidMessagesProof , # [codec (index = 8)] InvalidMessagesDeliveryProof , # [codec (index = 9)] InvalidUnrewardedRelayersState , # [codec (index = 10)] InsufficientDispatchWeight , # [codec (index = 11)] MessageIsNotYetSent , # [codec (index = 12)] ReceivalConfirmation (runtime_types :: pallet_bridge_messages :: outbound_lane :: ReceivalConfirmationError ,) , # [codec (index = 13)] BridgeModule (runtime_types :: bp_runtime :: OwnedBridgeModuleError ,) , }
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Event {
# [codec (index = 0)] MessageAccepted { lane_id : runtime_types :: bp_messages :: LaneId , nonce : :: core :: primitive :: u64 , } , # [codec (index = 1)] MessagesReceived (:: std :: vec :: Vec < runtime_types :: bp_messages :: ReceivedMessages < runtime_types :: bridge_runtime_common :: messages_xcm_extension :: XcmBlobMessageDispatchResult > > ,) , # [codec (index = 2)] MessagesDelivered { lane_id : runtime_types :: bp_messages :: LaneId , messages : runtime_types :: bp_messages :: DeliveredMessages , } , }
......@@ -1378,12 +1424,18 @@ pub mod api {
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Event {
#[codec(index = 0)]
RewardPaid {
RewardRegistered {
relayer: ::sp_core::crypto::AccountId32,
rewards_account_params: runtime_types::bp_relayers::RewardsAccountParams,
reward: ::core::primitive::u128,
},
#[codec(index = 1)]
RewardPaid {
relayer: ::sp_core::crypto::AccountId32,
rewards_account_params: runtime_types::bp_relayers::RewardsAccountParams,
reward: ::core::primitive::u128,
},
#[codec(index = 2)]
RegistrationUpdated {
relayer: ::sp_core::crypto::AccountId32,
registration: runtime_types::bp_relayers::registration::Registration<
......@@ -1391,9 +1443,9 @@ pub mod api {
::core::primitive::u128,
>,
},
#[codec(index = 2)]
Deregistered { relayer: ::sp_core::crypto::AccountId32 },
#[codec(index = 3)]
Deregistered { relayer: ::sp_core::crypto::AccountId32 },
#[codec(index = 4)]
SlashedAndDeregistered {
relayer: ::sp_core::crypto::AccountId32,
registration: runtime_types::bp_relayers::registration::Registration<
......@@ -1424,6 +1476,13 @@ pub mod api {
add_invulnerable { who: ::sp_core::crypto::AccountId32 },
#[codec(index = 6)]
remove_invulnerable { who: ::sp_core::crypto::AccountId32 },
#[codec(index = 7)]
update_bond { new_deposit: ::core::primitive::u128 },
#[codec(index = 8)]
take_candidate_slot {
deposit: ::core::primitive::u128,
target: ::sp_core::crypto::AccountId32,
},
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct CandidateInfo<_0, _1> {
......@@ -1450,6 +1509,22 @@ pub mod api {
NoAssociatedValidatorId,
#[codec(index = 8)]
ValidatorNotRegistered,
#[codec(index = 9)]
InsertToCandidateListFailed,
#[codec(index = 10)]
RemoveFromCandidateListFailed,
#[codec(index = 11)]
DepositTooLow,
#[codec(index = 12)]
UpdateCandidateListFailed,
#[codec(index = 13)]
InsufficientBond,
#[codec(index = 14)]
TargetIsNotCandidate,
#[codec(index = 15)]
IdenticalDeposit,
#[codec(index = 16)]
InvalidUnreserve,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Event {
......@@ -1471,12 +1546,125 @@ pub mod api {
deposit: ::core::primitive::u128,
},
#[codec(index = 6)]
CandidateRemoved { account_id: ::sp_core::crypto::AccountId32 },
CandidateBondUpdated {
account_id: ::sp_core::crypto::AccountId32,
deposit: ::core::primitive::u128,
},
#[codec(index = 7)]
CandidateRemoved { account_id: ::sp_core::crypto::AccountId32 },
#[codec(index = 8)]
CandidateReplaced {
old: ::sp_core::crypto::AccountId32,
new: ::sp_core::crypto::AccountId32,
deposit: ::core::primitive::u128,
},
#[codec(index = 9)]
InvalidInvulnerableSkipped { account_id: ::sp_core::crypto::AccountId32 },
}
}
}
pub mod pallet_message_queue {
use super::runtime_types;
pub mod pallet {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Call {
#[codec(index = 0)]
reap_page {
message_origin:
runtime_types::bridge_hub_common::message_queue::AggregateMessageOrigin,
page_index: ::core::primitive::u32,
},
#[codec(index = 1)]
execute_overweight {
message_origin:
runtime_types::bridge_hub_common::message_queue::AggregateMessageOrigin,
page: ::core::primitive::u32,
index: ::core::primitive::u32,
weight_limit: ::sp_weights::Weight,
},
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Error {
#[codec(index = 0)]
NotReapable,
#[codec(index = 1)]
NoPage,
#[codec(index = 2)]
NoMessage,
#[codec(index = 3)]
AlreadyProcessed,
#[codec(index = 4)]
Queued,
#[codec(index = 5)]
InsufficientWeight,
#[codec(index = 6)]
TemporarilyUnprocessable,
#[codec(index = 7)]
QueuePaused,
#[codec(index = 8)]
RecursiveDisallowed,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Event {
#[codec(index = 0)]
ProcessingFailed {
id: ::subxt::utils::H256,
origin:
runtime_types::bridge_hub_common::message_queue::AggregateMessageOrigin,
error: runtime_types::frame_support::traits::messages::ProcessMessageError,
},
#[codec(index = 1)]
Processed {
id: ::subxt::utils::H256,
origin:
runtime_types::bridge_hub_common::message_queue::AggregateMessageOrigin,
weight_used: ::sp_weights::Weight,
success: ::core::primitive::bool,
},
#[codec(index = 2)]
OverweightEnqueued {
id: [::core::primitive::u8; 32usize],
origin:
runtime_types::bridge_hub_common::message_queue::AggregateMessageOrigin,
page_index: ::core::primitive::u32,
message_index: ::core::primitive::u32,
},
#[codec(index = 3)]
PageReaped {
origin:
runtime_types::bridge_hub_common::message_queue::AggregateMessageOrigin,
index: ::core::primitive::u32,
},
}
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct BookState<_0> {
pub begin: ::core::primitive::u32,
pub end: ::core::primitive::u32,
pub count: ::core::primitive::u32,
pub ready_neighbours:
::core::option::Option<runtime_types::pallet_message_queue::Neighbours<_0>>,
pub message_count: ::core::primitive::u64,
pub size: ::core::primitive::u64,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct Neighbours<_0> {
pub prev: _0,
pub next: _0,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct Page<_0> {
pub remaining: _0,
pub remaining_size: _0,
pub first_index: _0,
pub first: _0,
pub last: _0,
pub heap: runtime_types::bounded_collections::bounded_vec::BoundedVec<
::core::primitive::u8,
>,
}
}
pub mod pallet_multisig {
use super::runtime_types;
pub mod pallet {
......@@ -1776,21 +1964,21 @@ pub mod api {
pub enum Call {
#[codec(index = 0)]
send {
dest: ::std::boxed::Box<runtime_types::xcm::VersionedMultiLocation>,
dest: ::std::boxed::Box<runtime_types::xcm::VersionedLocation>,
message: ::std::boxed::Box<runtime_types::xcm::VersionedXcm>,
},
#[codec(index = 1)]
teleport_assets {
dest: ::std::boxed::Box<runtime_types::xcm::VersionedMultiLocation>,
beneficiary: ::std::boxed::Box<runtime_types::xcm::VersionedMultiLocation>,
assets: ::std::boxed::Box<runtime_types::xcm::VersionedMultiAssets>,
dest: ::std::boxed::Box<runtime_types::xcm::VersionedLocation>,
beneficiary: ::std::boxed::Box<runtime_types::xcm::VersionedLocation>,
assets: ::std::boxed::Box<runtime_types::xcm::VersionedAssets>,
fee_asset_item: ::core::primitive::u32,
},
#[codec(index = 2)]
reserve_transfer_assets {
dest: ::std::boxed::Box<runtime_types::xcm::VersionedMultiLocation>,
beneficiary: ::std::boxed::Box<runtime_types::xcm::VersionedMultiLocation>,
assets: ::std::boxed::Box<runtime_types::xcm::VersionedMultiAssets>,
dest: ::std::boxed::Box<runtime_types::xcm::VersionedLocation>,
beneficiary: ::std::boxed::Box<runtime_types::xcm::VersionedLocation>,
assets: ::std::boxed::Box<runtime_types::xcm::VersionedAssets>,
fee_asset_item: ::core::primitive::u32,
},
#[codec(index = 3)]
......@@ -1800,9 +1988,8 @@ pub mod api {
},
#[codec(index = 4)]
force_xcm_version {
location: ::std::boxed::Box<
runtime_types::staging_xcm::v3::multilocation::MultiLocation,
>,
location:
::std::boxed::Box<runtime_types::staging_xcm::v4::location::Location>,
version: ::core::primitive::u32,
},
#[codec(index = 5)]
......@@ -1811,30 +1998,43 @@ pub mod api {
},
#[codec(index = 6)]
force_subscribe_version_notify {
location: ::std::boxed::Box<runtime_types::xcm::VersionedMultiLocation>,
location: ::std::boxed::Box<runtime_types::xcm::VersionedLocation>,
},
#[codec(index = 7)]
force_unsubscribe_version_notify {
location: ::std::boxed::Box<runtime_types::xcm::VersionedMultiLocation>,
location: ::std::boxed::Box<runtime_types::xcm::VersionedLocation>,
},
#[codec(index = 8)]
limited_reserve_transfer_assets {
dest: ::std::boxed::Box<runtime_types::xcm::VersionedMultiLocation>,
beneficiary: ::std::boxed::Box<runtime_types::xcm::VersionedMultiLocation>,
assets: ::std::boxed::Box<runtime_types::xcm::VersionedMultiAssets>,
dest: ::std::boxed::Box<runtime_types::xcm::VersionedLocation>,
beneficiary: ::std::boxed::Box<runtime_types::xcm::VersionedLocation>,
assets: ::std::boxed::Box<runtime_types::xcm::VersionedAssets>,
fee_asset_item: ::core::primitive::u32,
weight_limit: runtime_types::xcm::v3::WeightLimit,
},
#[codec(index = 9)]
limited_teleport_assets {
dest: ::std::boxed::Box<runtime_types::xcm::VersionedMultiLocation>,
beneficiary: ::std::boxed::Box<runtime_types::xcm::VersionedMultiLocation>,
assets: ::std::boxed::Box<runtime_types::xcm::VersionedMultiAssets>,
dest: ::std::boxed::Box<runtime_types::xcm::VersionedLocation>,
beneficiary: ::std::boxed::Box<runtime_types::xcm::VersionedLocation>,
assets: ::std::boxed::Box<runtime_types::xcm::VersionedAssets>,
fee_asset_item: ::core::primitive::u32,
weight_limit: runtime_types::xcm::v3::WeightLimit,
},
#[codec(index = 10)]
force_suspension { suspended: ::core::primitive::bool },
#[codec(index = 11)]
transfer_assets {
dest: ::std::boxed::Box<runtime_types::xcm::VersionedLocation>,
beneficiary: ::std::boxed::Box<runtime_types::xcm::VersionedLocation>,
assets: ::std::boxed::Box<runtime_types::xcm::VersionedAssets>,
fee_asset_item: ::core::primitive::u32,
weight_limit: runtime_types::xcm::v3::WeightLimit,
},
#[codec(index = 12)]
claim_assets {
assets: ::std::boxed::Box<runtime_types::xcm::VersionedAssets>,
beneficiary: ::std::boxed::Box<runtime_types::xcm::VersionedLocation>,
},
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Error {
......@@ -1865,7 +2065,7 @@ pub mod api {
#[codec(index = 12)]
AlreadySubscribed,
#[codec(index = 13)]
InvalidAsset,
CannotCheckOutTeleport,
#[codec(index = 14)]
LowBalance,
#[codec(index = 15)]
......@@ -1878,27 +2078,37 @@ pub mod api {
LockNotFound,
#[codec(index = 19)]
InUse,
#[codec(index = 20)]
InvalidAssetNotConcrete,
#[codec(index = 21)]
InvalidAssetUnknownReserve,
#[codec(index = 22)]
InvalidAssetUnsupportedReserve,
#[codec(index = 23)]
TooManyReserves,
#[codec(index = 24)]
LocalExecutionIncomplete,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Event {
#[codec(index = 0)]
Attempted { outcome: runtime_types::xcm::v3::traits::Outcome },
Attempted { outcome: runtime_types::staging_xcm::v4::traits::Outcome },
#[codec(index = 1)]
Sent {
origin: runtime_types::staging_xcm::v3::multilocation::MultiLocation,
destination: runtime_types::staging_xcm::v3::multilocation::MultiLocation,
message: runtime_types::xcm::v3::Xcm,
origin: runtime_types::staging_xcm::v4::location::Location,
destination: runtime_types::staging_xcm::v4::location::Location,
message: runtime_types::staging_xcm::v4::Xcm,
message_id: [::core::primitive::u8; 32usize],
},
#[codec(index = 2)]
UnexpectedResponse {
origin: runtime_types::staging_xcm::v3::multilocation::MultiLocation,
origin: runtime_types::staging_xcm::v4::location::Location,
query_id: ::core::primitive::u64,
},
#[codec(index = 3)]
ResponseReady {
query_id: ::core::primitive::u64,
response: runtime_types::xcm::v3::Response,
response: runtime_types::staging_xcm::v4::Response,
},
#[codec(index = 4)]
Notified {
......@@ -1928,15 +2138,15 @@ pub mod api {
},
#[codec(index = 8)]
InvalidResponder {
origin: runtime_types::staging_xcm::v3::multilocation::MultiLocation,
origin: runtime_types::staging_xcm::v4::location::Location,
query_id: ::core::primitive::u64,
expected_location: ::core::option::Option<
runtime_types::staging_xcm::v3::multilocation::MultiLocation,
runtime_types::staging_xcm::v4::location::Location,
>,
},
#[codec(index = 9)]
InvalidResponderVersion {
origin: runtime_types::staging_xcm::v3::multilocation::MultiLocation,
origin: runtime_types::staging_xcm::v4::location::Location,
query_id: ::core::primitive::u64,
},
#[codec(index = 10)]
......@@ -1944,98 +2154,99 @@ pub mod api {
#[codec(index = 11)]
AssetsTrapped {
hash: ::subxt::utils::H256,
origin: runtime_types::staging_xcm::v3::multilocation::MultiLocation,
assets: runtime_types::xcm::VersionedMultiAssets,
origin: runtime_types::staging_xcm::v4::location::Location,
assets: runtime_types::xcm::VersionedAssets,
},
#[codec(index = 12)]
VersionChangeNotified {
destination: runtime_types::staging_xcm::v3::multilocation::MultiLocation,
destination: runtime_types::staging_xcm::v4::location::Location,
result: ::core::primitive::u32,
cost: runtime_types::xcm::v3::multiasset::MultiAssets,
cost: runtime_types::staging_xcm::v4::asset::Assets,
message_id: [::core::primitive::u8; 32usize],
},
#[codec(index = 13)]
SupportedVersionChanged {
location: runtime_types::staging_xcm::v3::multilocation::MultiLocation,
location: runtime_types::staging_xcm::v4::location::Location,
version: ::core::primitive::u32,
},
#[codec(index = 14)]
NotifyTargetSendFail {
location: runtime_types::staging_xcm::v3::multilocation::MultiLocation,
location: runtime_types::staging_xcm::v4::location::Location,
query_id: ::core::primitive::u64,
error: runtime_types::xcm::v3::traits::Error,
},
#[codec(index = 15)]
NotifyTargetMigrationFail {
location: runtime_types::xcm::VersionedMultiLocation,
location: runtime_types::xcm::VersionedLocation,
query_id: ::core::primitive::u64,
},
#[codec(index = 16)]
InvalidQuerierVersion {
origin: runtime_types::staging_xcm::v3::multilocation::MultiLocation,
origin: runtime_types::staging_xcm::v4::location::Location,
query_id: ::core::primitive::u64,
},
#[codec(index = 17)]
InvalidQuerier {
origin: runtime_types::staging_xcm::v3::multilocation::MultiLocation,
origin: runtime_types::staging_xcm::v4::location::Location,
query_id: ::core::primitive::u64,
expected_querier:
runtime_types::staging_xcm::v3::multilocation::MultiLocation,
expected_querier: runtime_types::staging_xcm::v4::location::Location,
maybe_actual_querier: ::core::option::Option<
runtime_types::staging_xcm::v3::multilocation::MultiLocation,
runtime_types::staging_xcm::v4::location::Location,
>,
},
#[codec(index = 18)]
VersionNotifyStarted {
destination: runtime_types::staging_xcm::v3::multilocation::MultiLocation,
cost: runtime_types::xcm::v3::multiasset::MultiAssets,
destination: runtime_types::staging_xcm::v4::location::Location,
cost: runtime_types::staging_xcm::v4::asset::Assets,
message_id: [::core::primitive::u8; 32usize],
},
#[codec(index = 19)]
VersionNotifyRequested {
destination: runtime_types::staging_xcm::v3::multilocation::MultiLocation,
cost: runtime_types::xcm::v3::multiasset::MultiAssets,
destination: runtime_types::staging_xcm::v4::location::Location,
cost: runtime_types::staging_xcm::v4::asset::Assets,
message_id: [::core::primitive::u8; 32usize],
},
#[codec(index = 20)]
VersionNotifyUnrequested {
destination: runtime_types::staging_xcm::v3::multilocation::MultiLocation,
cost: runtime_types::xcm::v3::multiasset::MultiAssets,
destination: runtime_types::staging_xcm::v4::location::Location,
cost: runtime_types::staging_xcm::v4::asset::Assets,
message_id: [::core::primitive::u8; 32usize],
},
#[codec(index = 21)]
FeesPaid {
paying: runtime_types::staging_xcm::v3::multilocation::MultiLocation,
fees: runtime_types::xcm::v3::multiasset::MultiAssets,
paying: runtime_types::staging_xcm::v4::location::Location,
fees: runtime_types::staging_xcm::v4::asset::Assets,
},
#[codec(index = 22)]
AssetsClaimed {
hash: ::subxt::utils::H256,
origin: runtime_types::staging_xcm::v3::multilocation::MultiLocation,
assets: runtime_types::xcm::VersionedMultiAssets,
origin: runtime_types::staging_xcm::v4::location::Location,
assets: runtime_types::xcm::VersionedAssets,
},
#[codec(index = 23)]
VersionMigrationFinished { version: ::core::primitive::u32 },
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Origin {
#[codec(index = 0)]
Xcm(runtime_types::staging_xcm::v3::multilocation::MultiLocation),
Xcm(runtime_types::staging_xcm::v4::location::Location),
#[codec(index = 1)]
Response(runtime_types::staging_xcm::v3::multilocation::MultiLocation),
Response(runtime_types::staging_xcm::v4::location::Location),
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum QueryStatus<_0> {
#[codec(index = 0)]
Pending {
responder: runtime_types::xcm::VersionedMultiLocation,
responder: runtime_types::xcm::VersionedLocation,
maybe_match_querier:
::core::option::Option<runtime_types::xcm::VersionedMultiLocation>,
::core::option::Option<runtime_types::xcm::VersionedLocation>,
maybe_notify:
::core::option::Option<(::core::primitive::u8, ::core::primitive::u8)>,
timeout: _0,
},
#[codec(index = 1)]
VersionNotifier {
origin: runtime_types::xcm::VersionedMultiLocation,
origin: runtime_types::xcm::VersionedLocation,
is_active: ::core::primitive::bool,
},
#[codec(index = 2)]
......@@ -2044,8 +2255,8 @@ pub mod api {
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct RemoteLockedFungibleRecord<_0> {
pub amount: ::core::primitive::u128,
pub owner: runtime_types::xcm::VersionedMultiLocation,
pub locker: runtime_types::xcm::VersionedMultiLocation,
pub owner: runtime_types::xcm::VersionedLocation,
pub locker: runtime_types::xcm::VersionedLocation,
pub consumers: runtime_types::bounded_collections::bounded_vec::BoundedVec<(
_0,
::core::primitive::u128,
......@@ -2101,15 +2312,6 @@ pub mod api {
pub struct Id(pub ::core::primitive::u32);
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct ValidationCode(pub ::std::vec::Vec<::core::primitive::u8>);
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum XcmpMessageFormat {
#[codec(index = 0)]
ConcatenatedVersionedXcm,
#[codec(index = 1)]
ConcatenatedEncodedBlob,
#[codec(index = 2)]
Signals,
}
}
}
pub mod polkadot_primitives {
......@@ -2169,339 +2371,1739 @@ pub mod api {
}
}
}
pub mod sp_arithmetic {
pub mod primitive_types {
use super::runtime_types;
pub mod fixed_point {
use super::runtime_types;
#[derive(
:: codec :: Decode,
:: codec :: Encode,
:: subxt :: ext :: codec :: CompactAs,
Clone,
Debug,
PartialEq,
)]
pub struct FixedU128(pub ::core::primitive::u128);
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum ArithmeticError {
#[codec(index = 0)]
Underflow,
#[codec(index = 1)]
Overflow,
#[codec(index = 2)]
DivisionByZero,
}
pub struct U256(pub [::core::primitive::u64; 4usize]);
}
pub mod sp_consensus_aura {
pub mod snowbridge_amcl {
use super::runtime_types;
pub mod sr25519 {
pub mod bls381 {
use super::runtime_types;
pub mod app_sr25519 {
pub mod big {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct Public(pub runtime_types::sp_core::sr25519::Public);
pub struct Big {
pub w: [::core::primitive::i32; 14usize],
}
}
pub mod ecp {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct ECP {
pub x: runtime_types::snowbridge_amcl::bls381::fp::FP,
pub y: runtime_types::snowbridge_amcl::bls381::fp::FP,
pub z: runtime_types::snowbridge_amcl::bls381::fp::FP,
}
}
pub mod fp {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct FP {
pub x: runtime_types::snowbridge_amcl::bls381::big::Big,
pub xes: ::core::primitive::i32,
}
}
}
}
pub mod sp_consensus_grandpa {
pub mod snowbridge_beacon_primitives {
use super::runtime_types;
pub mod app {
pub mod bls {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct Public(pub runtime_types::sp_core::ed25519::Public);
pub enum BlsError {
#[codec(index = 0)]
InvalidSignature,
#[codec(index = 1)]
InvalidPublicKey,
#[codec(index = 2)]
InvalidAggregatePublicKeys,
#[codec(index = 3)]
SignatureVerificationFailed,
}
}
pub mod types {
use super::runtime_types;
pub mod deneb {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct ExecutionPayloadHeader {
pub parent_hash: ::subxt::utils::H256,
pub fee_recipient: ::subxt::utils::H160,
pub state_root: ::subxt::utils::H256,
pub receipts_root: ::subxt::utils::H256,
pub logs_bloom: ::std::vec::Vec<::core::primitive::u8>,
pub prev_randao: ::subxt::utils::H256,
pub block_number: ::core::primitive::u64,
pub gas_limit: ::core::primitive::u64,
pub gas_used: ::core::primitive::u64,
pub timestamp: ::core::primitive::u64,
pub extra_data: ::std::vec::Vec<::core::primitive::u8>,
pub base_fee_per_gas: runtime_types::primitive_types::U256,
pub block_hash: ::subxt::utils::H256,
pub transactions_root: ::subxt::utils::H256,
pub withdrawals_root: ::subxt::utils::H256,
pub blob_gas_used: ::core::primitive::u64,
pub excess_blob_gas: ::core::primitive::u64,
}
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct Signature(pub runtime_types::sp_core::ed25519::Signature);
pub struct BeaconHeader {
pub slot: ::core::primitive::u64,
pub proposer_index: ::core::primitive::u64,
pub parent_root: ::subxt::utils::H256,
pub state_root: ::subxt::utils::H256,
pub body_root: ::subxt::utils::H256,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct CompactBeaconState {
#[codec(compact)]
pub slot: ::core::primitive::u64,
pub block_roots_root: ::subxt::utils::H256,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct CompactExecutionHeader {
pub parent_hash: ::subxt::utils::H256,
#[codec(compact)]
pub block_number: ::core::primitive::u64,
pub state_root: ::subxt::utils::H256,
pub receipts_root: ::subxt::utils::H256,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct ExecutionHeaderState {
pub beacon_block_root: ::subxt::utils::H256,
pub beacon_slot: ::core::primitive::u64,
pub block_hash: ::subxt::utils::H256,
pub block_number: ::core::primitive::u64,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct ExecutionPayloadHeader {
pub parent_hash: ::subxt::utils::H256,
pub fee_recipient: ::subxt::utils::H160,
pub state_root: ::subxt::utils::H256,
pub receipts_root: ::subxt::utils::H256,
pub logs_bloom: ::std::vec::Vec<::core::primitive::u8>,
pub prev_randao: ::subxt::utils::H256,
pub block_number: ::core::primitive::u64,
pub gas_limit: ::core::primitive::u64,
pub gas_used: ::core::primitive::u64,
pub timestamp: ::core::primitive::u64,
pub extra_data: ::std::vec::Vec<::core::primitive::u8>,
pub base_fee_per_gas: runtime_types::primitive_types::U256,
pub block_hash: ::subxt::utils::H256,
pub transactions_root: ::subxt::utils::H256,
pub withdrawals_root: ::subxt::utils::H256,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct Fork {
pub version: [::core::primitive::u8; 4usize],
pub epoch: ::core::primitive::u64,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct ForkVersions {
pub genesis: runtime_types::snowbridge_beacon_primitives::types::Fork,
pub altair: runtime_types::snowbridge_beacon_primitives::types::Fork,
pub bellatrix: runtime_types::snowbridge_beacon_primitives::types::Fork,
pub capella: runtime_types::snowbridge_beacon_primitives::types::Fork,
pub deneb: runtime_types::snowbridge_beacon_primitives::types::Fork,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct PublicKey(pub [::core::primitive::u8; 48usize]);
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct Signature(pub [::core::primitive::u8; 96usize]);
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct SyncAggregate {
pub sync_committee_bits: [::core::primitive::u8; 64usize],
pub sync_committee_signature:
runtime_types::snowbridge_beacon_primitives::types::Signature,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct SyncCommittee {
pub pubkeys:
[runtime_types::snowbridge_beacon_primitives::types::PublicKey; 512usize],
pub aggregate_pubkey:
runtime_types::snowbridge_beacon_primitives::types::PublicKey,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct SyncCommitteePrepared {
pub root: ::subxt::utils::H256,
pub pubkeys: ::std::boxed::Box<
[runtime_types::snowbridge_milagro_bls::keys::PublicKey; 512usize],
>,
pub aggregate_pubkey: runtime_types::snowbridge_milagro_bls::keys::PublicKey,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum VersionedExecutionPayloadHeader {
# [codec (index = 0)] Capella (runtime_types :: snowbridge_beacon_primitives :: types :: ExecutionPayloadHeader ,) , # [codec (index = 1)] Deneb (runtime_types :: snowbridge_beacon_primitives :: types :: deneb :: ExecutionPayloadHeader ,) , }
}
pub mod updates {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct AncestryProof {
pub header_branch: ::std::vec::Vec<::subxt::utils::H256>,
pub finalized_block_root: ::subxt::utils::H256,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct CheckpointUpdate {
pub header: runtime_types::snowbridge_beacon_primitives::types::BeaconHeader,
pub current_sync_committee:
runtime_types::snowbridge_beacon_primitives::types::SyncCommittee,
pub current_sync_committee_branch: ::std::vec::Vec<::subxt::utils::H256>,
pub validators_root: ::subxt::utils::H256,
pub block_roots_root: ::subxt::utils::H256,
pub block_roots_branch: ::std::vec::Vec<::subxt::utils::H256>,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct ExecutionHeaderUpdate { pub header : runtime_types :: snowbridge_beacon_primitives :: types :: BeaconHeader , pub ancestry_proof : :: core :: option :: Option < runtime_types :: snowbridge_beacon_primitives :: updates :: AncestryProof > , pub execution_header : runtime_types :: snowbridge_beacon_primitives :: types :: VersionedExecutionPayloadHeader , pub execution_branch : :: std :: vec :: Vec < :: subxt :: utils :: H256 > , }
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct NextSyncCommitteeUpdate {
pub next_sync_committee:
runtime_types::snowbridge_beacon_primitives::types::SyncCommittee,
pub next_sync_committee_branch: ::std::vec::Vec<::subxt::utils::H256>,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct Update { pub attested_header : runtime_types :: snowbridge_beacon_primitives :: types :: BeaconHeader , pub sync_aggregate : runtime_types :: snowbridge_beacon_primitives :: types :: SyncAggregate , pub signature_slot : :: core :: primitive :: u64 , pub next_sync_committee_update : :: core :: option :: Option < runtime_types :: snowbridge_beacon_primitives :: updates :: NextSyncCommitteeUpdate > , pub finalized_header : runtime_types :: snowbridge_beacon_primitives :: types :: BeaconHeader , pub finality_branch : :: std :: vec :: Vec < :: subxt :: utils :: H256 > , pub block_roots_root : :: subxt :: utils :: H256 , pub block_roots_branch : :: std :: vec :: Vec < :: subxt :: utils :: H256 > , }
}
}
pub mod sp_consensus_slots {
use super::runtime_types;
#[derive(
:: codec :: Decode,
:: codec :: Encode,
:: subxt :: ext :: codec :: CompactAs,
Clone,
Debug,
PartialEq,
)]
pub struct Slot(pub ::core::primitive::u64);
#[derive(
:: codec :: Decode,
:: codec :: Encode,
:: subxt :: ext :: codec :: CompactAs,
Clone,
Debug,
PartialEq,
)]
pub struct SlotDuration(pub ::core::primitive::u64);
}
pub mod sp_core {
pub mod snowbridge_core {
use super::runtime_types;
pub mod crypto {
pub mod inbound {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct KeyTypeId(pub [::core::primitive::u8; 4usize]);
pub struct Log {
pub address: ::subxt::utils::H160,
pub topics: ::std::vec::Vec<::subxt::utils::H256>,
pub data: ::std::vec::Vec<::core::primitive::u8>,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct Message {
pub event_log: runtime_types::snowbridge_core::inbound::Log,
pub proof: runtime_types::snowbridge_core::inbound::Proof,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct Proof {
pub block_hash: ::subxt::utils::H256,
pub tx_index: ::core::primitive::u32,
pub data: (
::std::vec::Vec<::std::vec::Vec<::core::primitive::u8>>,
::std::vec::Vec<::std::vec::Vec<::core::primitive::u8>>,
),
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum VerificationError {
#[codec(index = 0)]
HeaderNotFound,
#[codec(index = 1)]
LogNotFound,
#[codec(index = 2)]
InvalidLog,
#[codec(index = 3)]
InvalidProof,
}
}
pub mod ecdsa {
pub mod operating_mode {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct Signature(pub [::core::primitive::u8; 65usize]);
pub enum BasicOperatingMode {
#[codec(index = 0)]
Normal,
#[codec(index = 1)]
Halted,
}
}
pub mod ed25519 {
pub mod outbound {
use super::runtime_types;
pub mod v1 {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum AgentExecuteCommand {
#[codec(index = 0)]
TransferToken {
token: ::subxt::utils::H160,
recipient: ::subxt::utils::H160,
amount: ::core::primitive::u128,
},
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Command {
#[codec(index = 0)]
AgentExecute {
agent_id: ::subxt::utils::H256,
command:
runtime_types::snowbridge_core::outbound::v1::AgentExecuteCommand,
},
#[codec(index = 1)]
Upgrade {
impl_address: ::subxt::utils::H160,
impl_code_hash: ::subxt::utils::H256,
initializer: ::core::option::Option<
runtime_types::snowbridge_core::outbound::v1::Initializer,
>,
},
#[codec(index = 2)]
CreateAgent { agent_id: ::subxt::utils::H256 },
#[codec(index = 3)]
CreateChannel {
channel_id: runtime_types::snowbridge_core::ChannelId,
agent_id: ::subxt::utils::H256,
mode: runtime_types::snowbridge_core::outbound::v1::OperatingMode,
},
#[codec(index = 4)]
UpdateChannel {
channel_id: runtime_types::snowbridge_core::ChannelId,
mode: runtime_types::snowbridge_core::outbound::v1::OperatingMode,
},
#[codec(index = 5)]
SetOperatingMode {
mode: runtime_types::snowbridge_core::outbound::v1::OperatingMode,
},
#[codec(index = 6)]
TransferNativeFromAgent {
agent_id: ::subxt::utils::H256,
recipient: ::subxt::utils::H160,
amount: ::core::primitive::u128,
},
#[codec(index = 7)]
SetTokenTransferFees {
create_asset_xcm: ::core::primitive::u128,
transfer_asset_xcm: ::core::primitive::u128,
register_token: runtime_types::primitive_types::U256,
},
#[codec(index = 8)]
SetPricingParameters {
exchange_rate: runtime_types::snowbridge_core::pricing::UD60x18,
delivery_cost: ::core::primitive::u128,
multiplier: runtime_types::snowbridge_core::pricing::UD60x18,
},
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct Initializer {
pub params: ::std::vec::Vec<::core::primitive::u8>,
pub maximum_required_gas: ::core::primitive::u64,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum OperatingMode {
#[codec(index = 0)]
Normal,
#[codec(index = 1)]
RejectingOutboundMessages,
}
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct Public(pub [::core::primitive::u8; 32usize]);
pub struct Fee<_0> {
pub local: _0,
pub remote: _0,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct Signature(pub [::core::primitive::u8; 64usize]);
pub enum SendError {
#[codec(index = 0)]
MessageTooLarge,
#[codec(index = 1)]
Halted,
#[codec(index = 2)]
InvalidChannel,
}
}
pub mod sr25519 {
pub mod pricing {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct Public(pub [::core::primitive::u8; 32usize]);
pub struct PricingParameters<_0> {
pub exchange_rate: runtime_types::sp_arithmetic::fixed_point::FixedU128,
pub rewards: runtime_types::snowbridge_core::pricing::Rewards<_0>,
pub fee_per_gas: runtime_types::primitive_types::U256,
pub multiplier: runtime_types::sp_arithmetic::fixed_point::FixedU128,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct Signature(pub [::core::primitive::u8; 64usize]);
pub struct Rewards<_0> {
pub local: _0,
pub remote: runtime_types::primitive_types::U256,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct UD60x18(pub runtime_types::primitive_types::U256);
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct OpaqueMetadata(pub ::std::vec::Vec<::core::primitive::u8>);
pub struct Channel {
pub agent_id: ::subxt::utils::H256,
pub para_id: runtime_types::polkadot_parachain_primitives::primitives::Id,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Void {}
pub struct ChannelId(pub [::core::primitive::u8; 32usize]);
}
pub mod sp_inherents {
pub mod snowbridge_milagro_bls {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct CheckInherentsResult {
pub okay: ::core::primitive::bool,
pub fatal_error: ::core::primitive::bool,
pub errors: runtime_types::sp_inherents::InherentData,
pub mod keys {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct PublicKey {
pub point: runtime_types::snowbridge_amcl::bls381::ecp::ECP,
}
}
}
pub mod snowbridge_outbound_queue_merkle_tree {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct InherentData {
pub data: ::subxt::utils::KeyedVec<
[::core::primitive::u8; 8usize],
::std::vec::Vec<::core::primitive::u8>,
>,
pub struct MerkleProof {
pub root: ::subxt::utils::H256,
pub proof: ::std::vec::Vec<::subxt::utils::H256>,
pub number_of_leaves: ::core::primitive::u64,
pub leaf_index: ::core::primitive::u64,
pub leaf: ::subxt::utils::H256,
}
}
pub mod sp_runtime {
pub mod snowbridge_pallet_ethereum_client {
use super::runtime_types;
pub mod generic {
use super::runtime_types;
pub mod block {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct Block<_0, _1> {
pub header: _0,
pub extrinsics: ::std::vec::Vec<_1>,
}
}
pub mod digest {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum DigestItem {
#[codec(index = 6)]
PreRuntime(
[::core::primitive::u8; 4usize],
::std::vec::Vec<::core::primitive::u8>,
),
#[codec(index = 4)]
Consensus(
[::core::primitive::u8; 4usize],
::std::vec::Vec<::core::primitive::u8>,
),
#[codec(index = 5)]
Seal(
[::core::primitive::u8; 4usize],
::std::vec::Vec<::core::primitive::u8>,
),
#[codec(index = 0)]
Other(::std::vec::Vec<::core::primitive::u8>),
#[codec(index = 8)]
RuntimeEnvironmentUpdated,
}
}
}
pub mod transaction_validity {
pub mod pallet {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum InvalidTransaction {
pub enum Call {
# [codec (index = 0)] force_checkpoint { update : :: std :: boxed :: Box < runtime_types :: snowbridge_beacon_primitives :: updates :: CheckpointUpdate > , } , # [codec (index = 1)] submit { update : :: std :: boxed :: Box < runtime_types :: snowbridge_beacon_primitives :: updates :: Update > , } , # [codec (index = 2)] submit_execution_header { update : :: std :: boxed :: Box < runtime_types :: snowbridge_beacon_primitives :: updates :: ExecutionHeaderUpdate > , } , # [codec (index = 3)] set_operating_mode { mode : runtime_types :: snowbridge_core :: operating_mode :: BasicOperatingMode , } , }
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Error {
#[codec(index = 0)]
Call,
SkippedSyncCommitteePeriod,
#[codec(index = 1)]
Payment,
IrrelevantUpdate,
#[codec(index = 2)]
Future,
NotBootstrapped,
#[codec(index = 3)]
Stale,
SyncCommitteeParticipantsNotSupermajority,
#[codec(index = 4)]
BadProof,
InvalidHeaderMerkleProof,
#[codec(index = 5)]
AncientBirthBlock,
InvalidSyncCommitteeMerkleProof,
#[codec(index = 6)]
ExhaustsResources,
InvalidExecutionHeaderProof,
#[codec(index = 7)]
Custom(::core::primitive::u8),
InvalidAncestryMerkleProof,
#[codec(index = 8)]
BadMandatory,
InvalidBlockRootsRootMerkleProof,
#[codec(index = 9)]
MandatoryValidation,
InvalidFinalizedHeaderGap,
#[codec(index = 10)]
BadSigner,
HeaderNotFinalized,
#[codec(index = 11)]
BlockBodyHashTreeRootFailed,
#[codec(index = 12)]
HeaderHashTreeRootFailed,
#[codec(index = 13)]
SyncCommitteeHashTreeRootFailed,
#[codec(index = 14)]
SigningRootHashTreeRootFailed,
#[codec(index = 15)]
ForkDataHashTreeRootFailed,
#[codec(index = 16)]
ExpectedFinalizedHeaderNotStored,
#[codec(index = 17)]
BLSPreparePublicKeysFailed,
#[codec(index = 18)]
BLSVerificationFailed(
runtime_types::snowbridge_beacon_primitives::bls::BlsError,
),
#[codec(index = 19)]
InvalidUpdateSlot,
#[codec(index = 20)]
InvalidSyncCommitteeUpdate,
#[codec(index = 21)]
ExecutionHeaderTooFarBehind,
#[codec(index = 22)]
ExecutionHeaderSkippedBlock,
#[codec(index = 23)]
Halted,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Event {
#[codec(index = 0)]
BeaconHeaderImported {
block_hash: ::subxt::utils::H256,
slot: ::core::primitive::u64,
},
#[codec(index = 1)]
ExecutionHeaderImported {
block_hash: ::subxt::utils::H256,
block_number: ::core::primitive::u64,
},
#[codec(index = 2)]
SyncCommitteeUpdated { period: ::core::primitive::u64 },
#[codec(index = 3)]
OperatingModeChanged {
mode: runtime_types::snowbridge_core::operating_mode::BasicOperatingMode,
},
}
}
}
pub mod snowbridge_pallet_inbound_queue {
use super::runtime_types;
pub mod pallet {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Call {
#[codec(index = 0)]
submit { message: runtime_types::snowbridge_core::inbound::Message },
#[codec(index = 1)]
set_operating_mode {
mode: runtime_types::snowbridge_core::operating_mode::BasicOperatingMode,
},
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Error {
#[codec(index = 0)]
InvalidGateway,
#[codec(index = 1)]
InvalidEnvelope,
#[codec(index = 2)]
InvalidNonce,
#[codec(index = 3)]
InvalidPayload,
#[codec(index = 4)]
InvalidChannel,
#[codec(index = 5)]
MaxNonceReached,
#[codec(index = 6)]
InvalidAccountConversion,
#[codec(index = 7)]
Halted,
#[codec(index = 8)]
Verification(runtime_types::snowbridge_core::inbound::VerificationError),
#[codec(index = 9)]
Send(runtime_types::snowbridge_pallet_inbound_queue::pallet::SendError),
#[codec(index = 10)]
ConvertMessage(
runtime_types::snowbridge_router_primitives::inbound::ConvertMessageError,
),
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Event {
#[codec(index = 0)]
MessageReceived {
channel_id: runtime_types::snowbridge_core::ChannelId,
nonce: ::core::primitive::u64,
message_id: [::core::primitive::u8; 32usize],
fee_burned: ::core::primitive::u128,
},
#[codec(index = 1)]
OperatingModeChanged {
mode: runtime_types::snowbridge_core::operating_mode::BasicOperatingMode,
},
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum SendError {
#[codec(index = 0)]
NotApplicable,
#[codec(index = 1)]
NotRoutable,
#[codec(index = 2)]
Transport,
#[codec(index = 3)]
DestinationUnsupported,
#[codec(index = 4)]
ExceedsMaxMessageSize,
#[codec(index = 5)]
MissingArgument,
#[codec(index = 6)]
Fees,
}
}
}
pub mod snowbridge_pallet_outbound_queue {
use super::runtime_types;
pub mod pallet {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Call {
#[codec(index = 0)]
set_operating_mode {
mode: runtime_types::snowbridge_core::operating_mode::BasicOperatingMode,
},
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Error {
#[codec(index = 0)]
MessageTooLarge,
#[codec(index = 1)]
Halted,
#[codec(index = 2)]
InvalidChannel,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Event {
#[codec(index = 0)]
MessageQueued { id: ::subxt::utils::H256 },
#[codec(index = 1)]
MessageAccepted { id: ::subxt::utils::H256, nonce: ::core::primitive::u64 },
#[codec(index = 2)]
MessagesCommitted { root: ::subxt::utils::H256, count: ::core::primitive::u64 },
#[codec(index = 3)]
OperatingModeChanged {
mode: runtime_types::snowbridge_core::operating_mode::BasicOperatingMode,
},
}
}
pub mod types {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct CommittedMessage {
pub channel_id: runtime_types::snowbridge_core::ChannelId,
#[codec(compact)]
pub nonce: ::core::primitive::u64,
pub command: ::core::primitive::u8,
pub params: ::std::vec::Vec<::core::primitive::u8>,
#[codec(compact)]
pub max_dispatch_gas: ::core::primitive::u64,
#[codec(compact)]
pub max_fee_per_gas: ::core::primitive::u128,
#[codec(compact)]
pub reward: ::core::primitive::u128,
pub id: ::subxt::utils::H256,
}
}
}
pub mod snowbridge_pallet_system {
use super::runtime_types;
pub mod pallet {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Call {
#[codec(index = 0)]
upgrade {
impl_address: ::subxt::utils::H160,
impl_code_hash: ::subxt::utils::H256,
initializer: ::core::option::Option<
runtime_types::snowbridge_core::outbound::v1::Initializer,
>,
},
#[codec(index = 1)]
set_operating_mode {
mode: runtime_types::snowbridge_core::outbound::v1::OperatingMode,
},
#[codec(index = 2)]
set_pricing_parameters {
params: runtime_types::snowbridge_core::pricing::PricingParameters<
::core::primitive::u128,
>,
},
#[codec(index = 3)]
create_agent,
#[codec(index = 4)]
create_channel {
mode: runtime_types::snowbridge_core::outbound::v1::OperatingMode,
},
#[codec(index = 5)]
update_channel {
mode: runtime_types::snowbridge_core::outbound::v1::OperatingMode,
},
#[codec(index = 6)]
force_update_channel {
channel_id: runtime_types::snowbridge_core::ChannelId,
mode: runtime_types::snowbridge_core::outbound::v1::OperatingMode,
},
#[codec(index = 7)]
transfer_native_from_agent {
recipient: ::subxt::utils::H160,
amount: ::core::primitive::u128,
},
#[codec(index = 8)]
force_transfer_native_from_agent {
location: ::std::boxed::Box<runtime_types::xcm::VersionedLocation>,
recipient: ::subxt::utils::H160,
amount: ::core::primitive::u128,
},
#[codec(index = 9)]
set_token_transfer_fees {
create_asset_xcm: ::core::primitive::u128,
transfer_asset_xcm: ::core::primitive::u128,
register_token: runtime_types::primitive_types::U256,
},
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Error {
#[codec(index = 0)]
LocationConversionFailed,
#[codec(index = 1)]
AgentAlreadyCreated,
#[codec(index = 2)]
NoAgent,
#[codec(index = 3)]
ChannelAlreadyCreated,
#[codec(index = 4)]
NoChannel,
#[codec(index = 5)]
UnsupportedLocationVersion,
#[codec(index = 6)]
InvalidLocation,
#[codec(index = 7)]
Send(runtime_types::snowbridge_core::outbound::SendError),
#[codec(index = 8)]
InvalidTokenTransferFees,
#[codec(index = 9)]
InvalidPricingParameters,
#[codec(index = 10)]
InvalidUpgradeParameters,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Event {
#[codec(index = 0)]
Upgrade {
impl_address: ::subxt::utils::H160,
impl_code_hash: ::subxt::utils::H256,
initializer_params_hash: ::core::option::Option<::subxt::utils::H256>,
},
#[codec(index = 1)]
CreateAgent {
location:
::std::boxed::Box<runtime_types::staging_xcm::v4::location::Location>,
agent_id: ::subxt::utils::H256,
},
#[codec(index = 2)]
CreateChannel {
channel_id: runtime_types::snowbridge_core::ChannelId,
agent_id: ::subxt::utils::H256,
},
#[codec(index = 3)]
UpdateChannel {
channel_id: runtime_types::snowbridge_core::ChannelId,
mode: runtime_types::snowbridge_core::outbound::v1::OperatingMode,
},
#[codec(index = 4)]
SetOperatingMode {
mode: runtime_types::snowbridge_core::outbound::v1::OperatingMode,
},
#[codec(index = 5)]
TransferNativeFromAgent {
agent_id: ::subxt::utils::H256,
recipient: ::subxt::utils::H160,
amount: ::core::primitive::u128,
},
#[codec(index = 6)]
SetTokenTransferFees {
create_asset_xcm: ::core::primitive::u128,
transfer_asset_xcm: ::core::primitive::u128,
register_token: runtime_types::primitive_types::U256,
},
#[codec(index = 7)]
PricingParametersChanged {
params: runtime_types::snowbridge_core::pricing::PricingParameters<
::core::primitive::u128,
>,
},
}
}
}
pub mod snowbridge_router_primitives {
use super::runtime_types;
pub mod inbound {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum ConvertMessageError {
#[codec(index = 0)]
UnsupportedVersion,
}
}
}
pub mod sp_arithmetic {
use super::runtime_types;
pub mod fixed_point {
use super::runtime_types;
#[derive(
:: codec :: Decode,
:: codec :: Encode,
:: subxt :: ext :: codec :: CompactAs,
Clone,
Debug,
PartialEq,
)]
pub struct FixedU128(pub ::core::primitive::u128);
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum ArithmeticError {
#[codec(index = 0)]
Underflow,
#[codec(index = 1)]
Overflow,
#[codec(index = 2)]
DivisionByZero,
}
}
pub mod sp_consensus_aura {
use super::runtime_types;
pub mod sr25519 {
use super::runtime_types;
pub mod app_sr25519 {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct Public(pub runtime_types::sp_core::sr25519::Public);
}
}
}
pub mod sp_consensus_grandpa {
use super::runtime_types;
pub mod app {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct Public(pub runtime_types::sp_core::ed25519::Public);
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct Signature(pub runtime_types::sp_core::ed25519::Signature);
}
}
pub mod sp_consensus_slots {
use super::runtime_types;
#[derive(
:: codec :: Decode,
:: codec :: Encode,
:: subxt :: ext :: codec :: CompactAs,
Clone,
Debug,
PartialEq,
)]
pub struct Slot(pub ::core::primitive::u64);
#[derive(
:: codec :: Decode,
:: codec :: Encode,
:: subxt :: ext :: codec :: CompactAs,
Clone,
Debug,
PartialEq,
)]
pub struct SlotDuration(pub ::core::primitive::u64);
}
pub mod sp_core {
use super::runtime_types;
pub mod crypto {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct KeyTypeId(pub [::core::primitive::u8; 4usize]);
}
pub mod ecdsa {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct Signature(pub [::core::primitive::u8; 65usize]);
}
pub mod ed25519 {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct Public(pub [::core::primitive::u8; 32usize]);
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct Signature(pub [::core::primitive::u8; 64usize]);
}
pub mod sr25519 {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct Public(pub [::core::primitive::u8; 32usize]);
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct Signature(pub [::core::primitive::u8; 64usize]);
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct OpaqueMetadata(pub ::std::vec::Vec<::core::primitive::u8>);
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Void {}
}
pub mod sp_inherents {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct CheckInherentsResult {
pub okay: ::core::primitive::bool,
pub fatal_error: ::core::primitive::bool,
pub errors: runtime_types::sp_inherents::InherentData,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct InherentData {
pub data: ::subxt::utils::KeyedVec<
[::core::primitive::u8; 8usize],
::std::vec::Vec<::core::primitive::u8>,
>,
}
}
pub mod sp_runtime {
use super::runtime_types;
pub mod generic {
use super::runtime_types;
pub mod block {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct Block<_0, _1> {
pub header: _0,
pub extrinsics: ::std::vec::Vec<_1>,
}
}
pub mod digest {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum DigestItem {
#[codec(index = 6)]
PreRuntime(
[::core::primitive::u8; 4usize],
::std::vec::Vec<::core::primitive::u8>,
),
#[codec(index = 4)]
Consensus(
[::core::primitive::u8; 4usize],
::std::vec::Vec<::core::primitive::u8>,
),
#[codec(index = 5)]
Seal(
[::core::primitive::u8; 4usize],
::std::vec::Vec<::core::primitive::u8>,
),
#[codec(index = 0)]
Other(::std::vec::Vec<::core::primitive::u8>),
#[codec(index = 8)]
RuntimeEnvironmentUpdated,
}
}
}
pub mod transaction_validity {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum InvalidTransaction {
#[codec(index = 0)]
Call,
#[codec(index = 1)]
Payment,
#[codec(index = 2)]
Future,
#[codec(index = 3)]
Stale,
#[codec(index = 4)]
BadProof,
#[codec(index = 5)]
AncientBirthBlock,
#[codec(index = 6)]
ExhaustsResources,
#[codec(index = 7)]
Custom(::core::primitive::u8),
#[codec(index = 8)]
BadMandatory,
#[codec(index = 9)]
MandatoryValidation,
#[codec(index = 10)]
BadSigner,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum TransactionSource {
#[codec(index = 0)]
InBlock,
#[codec(index = 1)]
Local,
#[codec(index = 2)]
External,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum TransactionValidityError {
#[codec(index = 0)]
Invalid(runtime_types::sp_runtime::transaction_validity::InvalidTransaction),
#[codec(index = 1)]
Unknown(runtime_types::sp_runtime::transaction_validity::UnknownTransaction),
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum UnknownTransaction {
#[codec(index = 0)]
CannotLookup,
#[codec(index = 1)]
NoUnsignedValidator,
#[codec(index = 2)]
Custom(::core::primitive::u8),
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct ValidTransaction {
pub priority: ::core::primitive::u64,
pub requires: ::std::vec::Vec<::std::vec::Vec<::core::primitive::u8>>,
pub provides: ::std::vec::Vec<::std::vec::Vec<::core::primitive::u8>>,
pub longevity: ::core::primitive::u64,
pub propagate: ::core::primitive::bool,
}
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum DispatchError {
#[codec(index = 0)]
Other,
#[codec(index = 1)]
CannotLookup,
#[codec(index = 2)]
BadOrigin,
#[codec(index = 3)]
Module(runtime_types::sp_runtime::ModuleError),
#[codec(index = 4)]
ConsumerRemaining,
#[codec(index = 5)]
NoProviders,
#[codec(index = 6)]
TooManyConsumers,
#[codec(index = 7)]
Token(runtime_types::sp_runtime::TokenError),
#[codec(index = 8)]
Arithmetic(runtime_types::sp_arithmetic::ArithmeticError),
#[codec(index = 9)]
Transactional(runtime_types::sp_runtime::TransactionalError),
#[codec(index = 10)]
Exhausted,
#[codec(index = 11)]
Corruption,
#[codec(index = 12)]
Unavailable,
#[codec(index = 13)]
RootNotAllowed,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct ModuleError {
pub index: ::core::primitive::u8,
pub error: [::core::primitive::u8; 4usize],
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum MultiSignature {
#[codec(index = 0)]
Ed25519(runtime_types::sp_core::ed25519::Signature),
#[codec(index = 1)]
Sr25519(runtime_types::sp_core::sr25519::Signature),
#[codec(index = 2)]
Ecdsa(runtime_types::sp_core::ecdsa::Signature),
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum TokenError {
#[codec(index = 0)]
FundsUnavailable,
#[codec(index = 1)]
OnlyProvider,
#[codec(index = 2)]
BelowMinimum,
#[codec(index = 3)]
CannotCreate,
#[codec(index = 4)]
UnknownAsset,
#[codec(index = 5)]
Frozen,
#[codec(index = 6)]
Unsupported,
#[codec(index = 7)]
CannotCreateHold,
#[codec(index = 8)]
NotExpendable,
#[codec(index = 9)]
Blocked,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum TransactionalError {
#[codec(index = 0)]
LimitReached,
#[codec(index = 1)]
NoLayer,
}
}
pub mod sp_trie {
use super::runtime_types;
pub mod storage_proof {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct StorageProof {
pub trie_nodes: ::std::vec::Vec<::std::vec::Vec<::core::primitive::u8>>,
}
}
}
pub mod sp_version {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct RuntimeVersion {
pub spec_name: ::std::string::String,
pub impl_name: ::std::string::String,
pub authoring_version: ::core::primitive::u32,
pub spec_version: ::core::primitive::u32,
pub impl_version: ::core::primitive::u32,
pub apis:
::std::vec::Vec<([::core::primitive::u8; 8usize], ::core::primitive::u32)>,
pub transaction_version: ::core::primitive::u32,
pub state_version: ::core::primitive::u8,
}
}
pub mod sp_weights {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct RuntimeDbWeight {
pub read: ::core::primitive::u64,
pub write: ::core::primitive::u64,
}
}
pub mod staging_parachain_info {
use super::runtime_types;
pub mod pallet {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Call {}
}
}
pub mod staging_xcm {
use super::runtime_types;
pub mod v3 {
use super::runtime_types;
pub mod multilocation {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct MultiLocation {
pub parents: ::core::primitive::u8,
pub interior: runtime_types::xcm::v3::junctions::Junctions,
}
}
}
pub mod v4 {
use super::runtime_types;
pub mod asset {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct Asset {
pub id: runtime_types::staging_xcm::v4::asset::AssetId,
pub fun: runtime_types::staging_xcm::v4::asset::Fungibility,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum AssetFilter {
#[codec(index = 0)]
Definite(runtime_types::staging_xcm::v4::asset::Assets),
#[codec(index = 1)]
Wild(runtime_types::staging_xcm::v4::asset::WildAsset),
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct AssetId(pub runtime_types::staging_xcm::v4::location::Location);
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum AssetInstance {
#[codec(index = 0)]
Undefined,
#[codec(index = 1)]
Index(#[codec(compact)] ::core::primitive::u128),
#[codec(index = 2)]
Array4([::core::primitive::u8; 4usize]),
#[codec(index = 3)]
Array8([::core::primitive::u8; 8usize]),
#[codec(index = 4)]
Array16([::core::primitive::u8; 16usize]),
#[codec(index = 5)]
Array32([::core::primitive::u8; 32usize]),
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct Assets(
pub ::std::vec::Vec<runtime_types::staging_xcm::v4::asset::Asset>,
);
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Fungibility {
#[codec(index = 0)]
Fungible(#[codec(compact)] ::core::primitive::u128),
#[codec(index = 1)]
NonFungible(runtime_types::staging_xcm::v4::asset::AssetInstance),
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum WildAsset {
#[codec(index = 0)]
All,
#[codec(index = 1)]
AllOf {
id: runtime_types::staging_xcm::v4::asset::AssetId,
fun: runtime_types::staging_xcm::v4::asset::WildFungibility,
},
#[codec(index = 2)]
AllCounted(#[codec(compact)] ::core::primitive::u32),
#[codec(index = 3)]
AllOfCounted {
id: runtime_types::staging_xcm::v4::asset::AssetId,
fun: runtime_types::staging_xcm::v4::asset::WildFungibility,
#[codec(compact)]
count: ::core::primitive::u32,
},
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum WildFungibility {
#[codec(index = 0)]
Fungible,
#[codec(index = 1)]
NonFungible,
}
}
pub mod junction {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Junction {
#[codec(index = 0)]
Parachain(#[codec(compact)] ::core::primitive::u32),
#[codec(index = 1)]
AccountId32 {
network: ::core::option::Option<
runtime_types::staging_xcm::v4::junction::NetworkId,
>,
id: [::core::primitive::u8; 32usize],
},
#[codec(index = 2)]
AccountIndex64 {
network: ::core::option::Option<
runtime_types::staging_xcm::v4::junction::NetworkId,
>,
#[codec(compact)]
index: ::core::primitive::u64,
},
#[codec(index = 3)]
AccountKey20 {
network: ::core::option::Option<
runtime_types::staging_xcm::v4::junction::NetworkId,
>,
key: [::core::primitive::u8; 20usize],
},
#[codec(index = 4)]
PalletInstance(::core::primitive::u8),
#[codec(index = 5)]
GeneralIndex(#[codec(compact)] ::core::primitive::u128),
#[codec(index = 6)]
GeneralKey {
length: ::core::primitive::u8,
data: [::core::primitive::u8; 32usize],
},
#[codec(index = 7)]
OnlyChild,
#[codec(index = 8)]
Plurality {
id: runtime_types::xcm::v3::junction::BodyId,
part: runtime_types::xcm::v3::junction::BodyPart,
},
#[codec(index = 9)]
GlobalConsensus(runtime_types::staging_xcm::v4::junction::NetworkId),
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum NetworkId {
#[codec(index = 0)]
ByGenesis([::core::primitive::u8; 32usize]),
#[codec(index = 1)]
ByFork {
block_number: ::core::primitive::u64,
block_hash: [::core::primitive::u8; 32usize],
},
#[codec(index = 2)]
Polkadot,
#[codec(index = 3)]
Kusama,
#[codec(index = 4)]
Westend,
#[codec(index = 5)]
Rococo,
#[codec(index = 6)]
Wococo,
#[codec(index = 7)]
Ethereum {
#[codec(compact)]
chain_id: ::core::primitive::u64,
},
#[codec(index = 8)]
BitcoinCore,
#[codec(index = 9)]
BitcoinCash,
#[codec(index = 10)]
PolkadotBulletin,
}
}
pub mod junctions {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Junctions {
#[codec(index = 0)]
Here,
#[codec(index = 1)]
X1([runtime_types::staging_xcm::v4::junction::Junction; 1usize]),
#[codec(index = 2)]
X2([runtime_types::staging_xcm::v4::junction::Junction; 2usize]),
#[codec(index = 3)]
X3([runtime_types::staging_xcm::v4::junction::Junction; 3usize]),
#[codec(index = 4)]
X4([runtime_types::staging_xcm::v4::junction::Junction; 4usize]),
#[codec(index = 5)]
X5([runtime_types::staging_xcm::v4::junction::Junction; 5usize]),
#[codec(index = 6)]
X6([runtime_types::staging_xcm::v4::junction::Junction; 6usize]),
#[codec(index = 7)]
X7([runtime_types::staging_xcm::v4::junction::Junction; 7usize]),
#[codec(index = 8)]
X8([runtime_types::staging_xcm::v4::junction::Junction; 8usize]),
}
}
pub mod location {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct Location {
pub parents: ::core::primitive::u8,
pub interior: runtime_types::staging_xcm::v4::junctions::Junctions,
}
}
pub mod traits {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Outcome {
#[codec(index = 0)]
Complete { used: ::sp_weights::Weight },
#[codec(index = 1)]
Incomplete {
used: ::sp_weights::Weight,
error: runtime_types::xcm::v3::traits::Error,
},
#[codec(index = 2)]
Error { error: runtime_types::xcm::v3::traits::Error },
}
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Instruction {
#[codec(index = 0)]
WithdrawAsset(runtime_types::staging_xcm::v4::asset::Assets),
#[codec(index = 1)]
ReserveAssetDeposited(runtime_types::staging_xcm::v4::asset::Assets),
#[codec(index = 2)]
ReceiveTeleportedAsset(runtime_types::staging_xcm::v4::asset::Assets),
#[codec(index = 3)]
QueryResponse {
#[codec(compact)]
query_id: ::core::primitive::u64,
response: runtime_types::staging_xcm::v4::Response,
max_weight: ::sp_weights::Weight,
querier: ::core::option::Option<
runtime_types::staging_xcm::v4::location::Location,
>,
},
#[codec(index = 4)]
TransferAsset {
assets: runtime_types::staging_xcm::v4::asset::Assets,
beneficiary: runtime_types::staging_xcm::v4::location::Location,
},
#[codec(index = 5)]
TransferReserveAsset {
assets: runtime_types::staging_xcm::v4::asset::Assets,
dest: runtime_types::staging_xcm::v4::location::Location,
xcm: runtime_types::staging_xcm::v4::Xcm,
},
#[codec(index = 6)]
Transact {
origin_kind: runtime_types::xcm::v2::OriginKind,
require_weight_at_most: ::sp_weights::Weight,
call: runtime_types::xcm::double_encoded::DoubleEncoded,
},
#[codec(index = 7)]
HrmpNewChannelOpenRequest {
#[codec(compact)]
sender: ::core::primitive::u32,
#[codec(compact)]
max_message_size: ::core::primitive::u32,
#[codec(compact)]
max_capacity: ::core::primitive::u32,
},
#[codec(index = 8)]
HrmpChannelAccepted {
#[codec(compact)]
recipient: ::core::primitive::u32,
},
#[codec(index = 9)]
HrmpChannelClosing {
#[codec(compact)]
initiator: ::core::primitive::u32,
#[codec(compact)]
sender: ::core::primitive::u32,
#[codec(compact)]
recipient: ::core::primitive::u32,
},
#[codec(index = 10)]
ClearOrigin,
#[codec(index = 11)]
DescendOrigin(runtime_types::staging_xcm::v4::junctions::Junctions),
#[codec(index = 12)]
ReportError(runtime_types::staging_xcm::v4::QueryResponseInfo),
#[codec(index = 13)]
DepositAsset {
assets: runtime_types::staging_xcm::v4::asset::AssetFilter,
beneficiary: runtime_types::staging_xcm::v4::location::Location,
},
#[codec(index = 14)]
DepositReserveAsset {
assets: runtime_types::staging_xcm::v4::asset::AssetFilter,
dest: runtime_types::staging_xcm::v4::location::Location,
xcm: runtime_types::staging_xcm::v4::Xcm,
},
#[codec(index = 15)]
ExchangeAsset {
give: runtime_types::staging_xcm::v4::asset::AssetFilter,
want: runtime_types::staging_xcm::v4::asset::Assets,
maximal: ::core::primitive::bool,
},
#[codec(index = 16)]
InitiateReserveWithdraw {
assets: runtime_types::staging_xcm::v4::asset::AssetFilter,
reserve: runtime_types::staging_xcm::v4::location::Location,
xcm: runtime_types::staging_xcm::v4::Xcm,
},
#[codec(index = 17)]
InitiateTeleport {
assets: runtime_types::staging_xcm::v4::asset::AssetFilter,
dest: runtime_types::staging_xcm::v4::location::Location,
xcm: runtime_types::staging_xcm::v4::Xcm,
},
#[codec(index = 18)]
ReportHolding {
response_info: runtime_types::staging_xcm::v4::QueryResponseInfo,
assets: runtime_types::staging_xcm::v4::asset::AssetFilter,
},
#[codec(index = 19)]
BuyExecution {
fees: runtime_types::staging_xcm::v4::asset::Asset,
weight_limit: runtime_types::xcm::v3::WeightLimit,
},
#[codec(index = 20)]
RefundSurplus,
#[codec(index = 21)]
SetErrorHandler(runtime_types::staging_xcm::v4::Xcm),
#[codec(index = 22)]
SetAppendix(runtime_types::staging_xcm::v4::Xcm),
#[codec(index = 23)]
ClearError,
#[codec(index = 24)]
ClaimAsset {
assets: runtime_types::staging_xcm::v4::asset::Assets,
ticket: runtime_types::staging_xcm::v4::location::Location,
},
#[codec(index = 25)]
Trap(#[codec(compact)] ::core::primitive::u64),
#[codec(index = 26)]
SubscribeVersion {
#[codec(compact)]
query_id: ::core::primitive::u64,
max_response_weight: ::sp_weights::Weight,
},
#[codec(index = 27)]
UnsubscribeVersion,
#[codec(index = 28)]
BurnAsset(runtime_types::staging_xcm::v4::asset::Assets),
#[codec(index = 29)]
ExpectAsset(runtime_types::staging_xcm::v4::asset::Assets),
#[codec(index = 30)]
ExpectOrigin(
::core::option::Option<runtime_types::staging_xcm::v4::location::Location>,
),
#[codec(index = 31)]
ExpectError(
::core::option::Option<(
::core::primitive::u32,
runtime_types::xcm::v3::traits::Error,
)>,
),
#[codec(index = 32)]
ExpectTransactStatus(runtime_types::xcm::v3::MaybeErrorCode),
#[codec(index = 33)]
QueryPallet {
module_name: ::std::vec::Vec<::core::primitive::u8>,
response_info: runtime_types::staging_xcm::v4::QueryResponseInfo,
},
#[codec(index = 34)]
ExpectPallet {
#[codec(compact)]
index: ::core::primitive::u32,
name: ::std::vec::Vec<::core::primitive::u8>,
module_name: ::std::vec::Vec<::core::primitive::u8>,
#[codec(compact)]
crate_major: ::core::primitive::u32,
#[codec(compact)]
min_crate_minor: ::core::primitive::u32,
},
#[codec(index = 35)]
ReportTransactStatus(runtime_types::staging_xcm::v4::QueryResponseInfo),
#[codec(index = 36)]
ClearTransactStatus,
#[codec(index = 37)]
UniversalOrigin(runtime_types::staging_xcm::v4::junction::Junction),
#[codec(index = 38)]
ExportMessage {
network: runtime_types::staging_xcm::v4::junction::NetworkId,
destination: runtime_types::staging_xcm::v4::junctions::Junctions,
xcm: runtime_types::staging_xcm::v4::Xcm,
},
#[codec(index = 39)]
LockAsset {
asset: runtime_types::staging_xcm::v4::asset::Asset,
unlocker: runtime_types::staging_xcm::v4::location::Location,
},
#[codec(index = 40)]
UnlockAsset {
asset: runtime_types::staging_xcm::v4::asset::Asset,
target: runtime_types::staging_xcm::v4::location::Location,
},
#[codec(index = 41)]
NoteUnlockable {
asset: runtime_types::staging_xcm::v4::asset::Asset,
owner: runtime_types::staging_xcm::v4::location::Location,
},
#[codec(index = 42)]
RequestUnlock {
asset: runtime_types::staging_xcm::v4::asset::Asset,
locker: runtime_types::staging_xcm::v4::location::Location,
},
#[codec(index = 43)]
SetFeesMode { jit_withdraw: ::core::primitive::bool },
#[codec(index = 44)]
SetTopic([::core::primitive::u8; 32usize]),
#[codec(index = 45)]
ClearTopic,
#[codec(index = 46)]
AliasOrigin(runtime_types::staging_xcm::v4::location::Location),
#[codec(index = 47)]
UnpaidExecution {
weight_limit: runtime_types::xcm::v3::WeightLimit,
check_origin: ::core::option::Option<
runtime_types::staging_xcm::v4::location::Location,
>,
},
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Instruction2 {
#[codec(index = 0)]
WithdrawAsset(runtime_types::staging_xcm::v4::asset::Assets),
#[codec(index = 1)]
ReserveAssetDeposited(runtime_types::staging_xcm::v4::asset::Assets),
#[codec(index = 2)]
ReceiveTeleportedAsset(runtime_types::staging_xcm::v4::asset::Assets),
#[codec(index = 3)]
QueryResponse {
#[codec(compact)]
query_id: ::core::primitive::u64,
response: runtime_types::staging_xcm::v4::Response,
max_weight: ::sp_weights::Weight,
querier: ::core::option::Option<
runtime_types::staging_xcm::v4::location::Location,
>,
},
#[codec(index = 4)]
TransferAsset {
assets: runtime_types::staging_xcm::v4::asset::Assets,
beneficiary: runtime_types::staging_xcm::v4::location::Location,
},
#[codec(index = 5)]
TransferReserveAsset {
assets: runtime_types::staging_xcm::v4::asset::Assets,
dest: runtime_types::staging_xcm::v4::location::Location,
xcm: runtime_types::staging_xcm::v4::Xcm,
},
#[codec(index = 6)]
Transact {
origin_kind: runtime_types::xcm::v2::OriginKind,
require_weight_at_most: ::sp_weights::Weight,
call: runtime_types::xcm::double_encoded::DoubleEncoded2,
},
#[codec(index = 7)]
HrmpNewChannelOpenRequest {
#[codec(compact)]
sender: ::core::primitive::u32,
#[codec(compact)]
max_message_size: ::core::primitive::u32,
#[codec(compact)]
max_capacity: ::core::primitive::u32,
},
#[codec(index = 8)]
HrmpChannelAccepted {
#[codec(compact)]
recipient: ::core::primitive::u32,
},
#[codec(index = 9)]
HrmpChannelClosing {
#[codec(compact)]
initiator: ::core::primitive::u32,
#[codec(compact)]
sender: ::core::primitive::u32,
#[codec(compact)]
recipient: ::core::primitive::u32,
},
#[codec(index = 10)]
ClearOrigin,
#[codec(index = 11)]
DescendOrigin(runtime_types::staging_xcm::v4::junctions::Junctions),
#[codec(index = 12)]
ReportError(runtime_types::staging_xcm::v4::QueryResponseInfo),
#[codec(index = 13)]
DepositAsset {
assets: runtime_types::staging_xcm::v4::asset::AssetFilter,
beneficiary: runtime_types::staging_xcm::v4::location::Location,
},
#[codec(index = 14)]
DepositReserveAsset {
assets: runtime_types::staging_xcm::v4::asset::AssetFilter,
dest: runtime_types::staging_xcm::v4::location::Location,
xcm: runtime_types::staging_xcm::v4::Xcm,
},
#[codec(index = 15)]
ExchangeAsset {
give: runtime_types::staging_xcm::v4::asset::AssetFilter,
want: runtime_types::staging_xcm::v4::asset::Assets,
maximal: ::core::primitive::bool,
},
#[codec(index = 16)]
InitiateReserveWithdraw {
assets: runtime_types::staging_xcm::v4::asset::AssetFilter,
reserve: runtime_types::staging_xcm::v4::location::Location,
xcm: runtime_types::staging_xcm::v4::Xcm,
},
#[codec(index = 17)]
InitiateTeleport {
assets: runtime_types::staging_xcm::v4::asset::AssetFilter,
dest: runtime_types::staging_xcm::v4::location::Location,
xcm: runtime_types::staging_xcm::v4::Xcm,
},
#[codec(index = 18)]
ReportHolding {
response_info: runtime_types::staging_xcm::v4::QueryResponseInfo,
assets: runtime_types::staging_xcm::v4::asset::AssetFilter,
},
#[codec(index = 19)]
BuyExecution {
fees: runtime_types::staging_xcm::v4::asset::Asset,
weight_limit: runtime_types::xcm::v3::WeightLimit,
},
#[codec(index = 20)]
RefundSurplus,
#[codec(index = 21)]
SetErrorHandler(runtime_types::staging_xcm::v4::Xcm2),
#[codec(index = 22)]
SetAppendix(runtime_types::staging_xcm::v4::Xcm2),
#[codec(index = 23)]
ClearError,
#[codec(index = 24)]
ClaimAsset {
assets: runtime_types::staging_xcm::v4::asset::Assets,
ticket: runtime_types::staging_xcm::v4::location::Location,
},
#[codec(index = 25)]
Trap(#[codec(compact)] ::core::primitive::u64),
#[codec(index = 26)]
SubscribeVersion {
#[codec(compact)]
query_id: ::core::primitive::u64,
max_response_weight: ::sp_weights::Weight,
},
#[codec(index = 27)]
UnsubscribeVersion,
#[codec(index = 28)]
BurnAsset(runtime_types::staging_xcm::v4::asset::Assets),
#[codec(index = 29)]
ExpectAsset(runtime_types::staging_xcm::v4::asset::Assets),
#[codec(index = 30)]
ExpectOrigin(
::core::option::Option<runtime_types::staging_xcm::v4::location::Location>,
),
#[codec(index = 31)]
ExpectError(
::core::option::Option<(
::core::primitive::u32,
runtime_types::xcm::v3::traits::Error,
)>,
),
#[codec(index = 32)]
ExpectTransactStatus(runtime_types::xcm::v3::MaybeErrorCode),
#[codec(index = 33)]
QueryPallet {
module_name: ::std::vec::Vec<::core::primitive::u8>,
response_info: runtime_types::staging_xcm::v4::QueryResponseInfo,
},
#[codec(index = 34)]
ExpectPallet {
#[codec(compact)]
index: ::core::primitive::u32,
name: ::std::vec::Vec<::core::primitive::u8>,
module_name: ::std::vec::Vec<::core::primitive::u8>,
#[codec(compact)]
crate_major: ::core::primitive::u32,
#[codec(compact)]
min_crate_minor: ::core::primitive::u32,
},
#[codec(index = 35)]
ReportTransactStatus(runtime_types::staging_xcm::v4::QueryResponseInfo),
#[codec(index = 36)]
ClearTransactStatus,
#[codec(index = 37)]
UniversalOrigin(runtime_types::staging_xcm::v4::junction::Junction),
#[codec(index = 38)]
ExportMessage {
network: runtime_types::staging_xcm::v4::junction::NetworkId,
destination: runtime_types::staging_xcm::v4::junctions::Junctions,
xcm: runtime_types::staging_xcm::v4::Xcm,
},
#[codec(index = 39)]
LockAsset {
asset: runtime_types::staging_xcm::v4::asset::Asset,
unlocker: runtime_types::staging_xcm::v4::location::Location,
},
#[codec(index = 40)]
UnlockAsset {
asset: runtime_types::staging_xcm::v4::asset::Asset,
target: runtime_types::staging_xcm::v4::location::Location,
},
#[codec(index = 41)]
NoteUnlockable {
asset: runtime_types::staging_xcm::v4::asset::Asset,
owner: runtime_types::staging_xcm::v4::location::Location,
},
#[codec(index = 42)]
RequestUnlock {
asset: runtime_types::staging_xcm::v4::asset::Asset,
locker: runtime_types::staging_xcm::v4::location::Location,
},
#[codec(index = 43)]
SetFeesMode { jit_withdraw: ::core::primitive::bool },
#[codec(index = 44)]
SetTopic([::core::primitive::u8; 32usize]),
#[codec(index = 45)]
ClearTopic,
#[codec(index = 46)]
AliasOrigin(runtime_types::staging_xcm::v4::location::Location),
#[codec(index = 47)]
UnpaidExecution {
weight_limit: runtime_types::xcm::v3::WeightLimit,
check_origin: ::core::option::Option<
runtime_types::staging_xcm::v4::location::Location,
>,
},
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum TransactionSource {
#[codec(index = 0)]
InBlock,
#[codec(index = 1)]
Local,
#[codec(index = 2)]
External,
pub struct PalletInfo {
#[codec(compact)]
pub index: ::core::primitive::u32,
pub name: runtime_types::bounded_collections::bounded_vec::BoundedVec<
::core::primitive::u8,
>,
pub module_name: runtime_types::bounded_collections::bounded_vec::BoundedVec<
::core::primitive::u8,
>,
#[codec(compact)]
pub major: ::core::primitive::u32,
#[codec(compact)]
pub minor: ::core::primitive::u32,
#[codec(compact)]
pub patch: ::core::primitive::u32,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum TransactionValidityError {
#[codec(index = 0)]
Invalid(runtime_types::sp_runtime::transaction_validity::InvalidTransaction),
#[codec(index = 1)]
Unknown(runtime_types::sp_runtime::transaction_validity::UnknownTransaction),
pub struct QueryResponseInfo {
pub destination: runtime_types::staging_xcm::v4::location::Location,
#[codec(compact)]
pub query_id: ::core::primitive::u64,
pub max_weight: ::sp_weights::Weight,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum UnknownTransaction {
pub enum Response {
#[codec(index = 0)]
CannotLookup,
Null,
#[codec(index = 1)]
NoUnsignedValidator,
Assets(runtime_types::staging_xcm::v4::asset::Assets),
#[codec(index = 2)]
Custom(::core::primitive::u8),
ExecutionResult(
::core::option::Option<(
::core::primitive::u32,
runtime_types::xcm::v3::traits::Error,
)>,
),
#[codec(index = 3)]
Version(::core::primitive::u32),
#[codec(index = 4)]
PalletsInfo(
runtime_types::bounded_collections::bounded_vec::BoundedVec<
runtime_types::staging_xcm::v4::PalletInfo,
>,
),
#[codec(index = 5)]
DispatchResult(runtime_types::xcm::v3::MaybeErrorCode),
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct ValidTransaction {
pub priority: ::core::primitive::u64,
pub requires: ::std::vec::Vec<::std::vec::Vec<::core::primitive::u8>>,
pub provides: ::std::vec::Vec<::std::vec::Vec<::core::primitive::u8>>,
pub longevity: ::core::primitive::u64,
pub propagate: ::core::primitive::bool,
}
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum DispatchError {
#[codec(index = 0)]
Other,
#[codec(index = 1)]
CannotLookup,
#[codec(index = 2)]
BadOrigin,
#[codec(index = 3)]
Module(runtime_types::sp_runtime::ModuleError),
#[codec(index = 4)]
ConsumerRemaining,
#[codec(index = 5)]
NoProviders,
#[codec(index = 6)]
TooManyConsumers,
#[codec(index = 7)]
Token(runtime_types::sp_runtime::TokenError),
#[codec(index = 8)]
Arithmetic(runtime_types::sp_arithmetic::ArithmeticError),
#[codec(index = 9)]
Transactional(runtime_types::sp_runtime::TransactionalError),
#[codec(index = 10)]
Exhausted,
#[codec(index = 11)]
Corruption,
#[codec(index = 12)]
Unavailable,
#[codec(index = 13)]
RootNotAllowed,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct ModuleError {
pub index: ::core::primitive::u8,
pub error: [::core::primitive::u8; 4usize],
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum MultiSignature {
#[codec(index = 0)]
Ed25519(runtime_types::sp_core::ed25519::Signature),
#[codec(index = 1)]
Sr25519(runtime_types::sp_core::sr25519::Signature),
#[codec(index = 2)]
Ecdsa(runtime_types::sp_core::ecdsa::Signature),
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum TokenError {
#[codec(index = 0)]
FundsUnavailable,
#[codec(index = 1)]
OnlyProvider,
#[codec(index = 2)]
BelowMinimum,
#[codec(index = 3)]
CannotCreate,
#[codec(index = 4)]
UnknownAsset,
#[codec(index = 5)]
Frozen,
#[codec(index = 6)]
Unsupported,
#[codec(index = 7)]
CannotCreateHold,
#[codec(index = 8)]
NotExpendable,
#[codec(index = 9)]
Blocked,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum TransactionalError {
#[codec(index = 0)]
LimitReached,
#[codec(index = 1)]
NoLayer,
}
}
pub mod sp_trie {
use super::runtime_types;
pub mod storage_proof {
use super::runtime_types;
pub struct Xcm(pub ::std::vec::Vec<runtime_types::staging_xcm::v4::Instruction>);
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct StorageProof {
pub trie_nodes: ::std::vec::Vec<::std::vec::Vec<::core::primitive::u8>>,
}
}
}
pub mod sp_version {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct RuntimeVersion {
pub spec_name: ::std::string::String,
pub impl_name: ::std::string::String,
pub authoring_version: ::core::primitive::u32,
pub spec_version: ::core::primitive::u32,
pub impl_version: ::core::primitive::u32,
pub apis:
::std::vec::Vec<([::core::primitive::u8; 8usize], ::core::primitive::u32)>,
pub transaction_version: ::core::primitive::u32,
pub state_version: ::core::primitive::u8,
}
}
pub mod sp_weights {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct RuntimeDbWeight {
pub read: ::core::primitive::u64,
pub write: ::core::primitive::u64,
}
}
pub mod staging_xcm {
use super::runtime_types;
pub mod v3 {
use super::runtime_types;
pub mod multilocation {
use super::runtime_types;
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub struct MultiLocation {
pub parents: ::core::primitive::u8,
pub interior: runtime_types::xcm::v3::junctions::Junctions,
}
}
pub struct Xcm2(pub ::std::vec::Vec<runtime_types::staging_xcm::v4::Instruction2>);
}
}
pub mod xcm {
......@@ -3276,6 +4878,8 @@ pub mod api {
BitcoinCore,
#[codec(index = 9)]
BitcoinCash,
#[codec(index = 10)]
PolkadotBulletin,
}
}
pub mod junctions {
......@@ -3503,15 +5107,6 @@ pub mod api {
#[codec(index = 39)]
ExceedsStackLimit,
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Outcome {
#[codec(index = 0)]
Complete(::sp_weights::Weight),
#[codec(index = 1)]
Incomplete(::sp_weights::Weight, runtime_types::xcm::v3::traits::Error),
#[codec(index = 2)]
Error(runtime_types::xcm::v3::traits::Error),
}
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum Instruction {
......@@ -4012,20 +5607,26 @@ pub mod api {
pub enum VersionedAssetId {
#[codec(index = 3)]
V3(runtime_types::xcm::v3::multiasset::AssetId),
#[codec(index = 4)]
V4(runtime_types::staging_xcm::v4::asset::AssetId),
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum VersionedMultiAssets {
pub enum VersionedAssets {
#[codec(index = 1)]
V2(runtime_types::xcm::v2::multiasset::MultiAssets),
#[codec(index = 3)]
V3(runtime_types::xcm::v3::multiasset::MultiAssets),
#[codec(index = 4)]
V4(runtime_types::staging_xcm::v4::asset::Assets),
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum VersionedMultiLocation {
pub enum VersionedLocation {
#[codec(index = 1)]
V2(runtime_types::xcm::v2::multilocation::MultiLocation),
#[codec(index = 3)]
V3(runtime_types::staging_xcm::v3::multilocation::MultiLocation),
#[codec(index = 4)]
V4(runtime_types::staging_xcm::v4::location::Location),
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum VersionedResponse {
......@@ -4033,6 +5634,8 @@ pub mod api {
V2(runtime_types::xcm::v2::Response),
#[codec(index = 3)]
V3(runtime_types::xcm::v3::Response),
#[codec(index = 4)]
V4(runtime_types::staging_xcm::v4::Response),
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum VersionedXcm {
......@@ -4040,6 +5643,8 @@ pub mod api {
V2(runtime_types::xcm::v2::Xcm),
#[codec(index = 3)]
V3(runtime_types::xcm::v3::Xcm),
#[codec(index = 4)]
V4(runtime_types::staging_xcm::v4::Xcm),
}
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
pub enum VersionedXcm2 {
......@@ -4047,6 +5652,8 @@ pub mod api {
V2(runtime_types::xcm::v2::Xcm2),
#[codec(index = 3)]
V3(runtime_types::xcm::v3::Xcm2),
#[codec(index = 4)]
V4(runtime_types::staging_xcm::v4::Xcm2),
}
}
}
......
......@@ -18,13 +18,14 @@
pub mod codegen_runtime;
use bp_bridge_hub_kusama::{TransactionExtension, AVERAGE_BLOCK_INTERVAL};
use bp_polkadot::SuffixedCommonTransactionExtensionExt;
use bp_bridge_hub_kusama::{SignedExtension, AVERAGE_BLOCK_INTERVAL};
use bp_polkadot::SuffixedCommonSignedExtensionExt;
use codec::Encode;
use relay_substrate_client::{
calls::UtilityCall as MockUtilityCall, Chain, ChainWithBalances, ChainWithMessages,
ChainWithTransactions, ChainWithUtilityPallet, Error as SubstrateError,
MockedRuntimeUtilityPallet, SignParam, UnderlyingChainProvider, UnsignedTransaction,
ChainWithRuntimeVersion, ChainWithTransactions, ChainWithUtilityPallet,
Error as SubstrateError, MockedRuntimeUtilityPallet, SignParam, SimpleRuntimeVersion,
UnderlyingChainProvider, UnsignedTransaction,
};
use sp_core::{storage::StorageKey, Pair};
use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount};
......@@ -36,8 +37,7 @@ pub type RuntimeCall = runtime_types::bridge_hub_kusama_runtime::RuntimeCall;
pub type BridgeMessagesCall = runtime_types::pallet_bridge_messages::pallet::Call;
pub type BridgeGrandpaCall = runtime_types::pallet_bridge_grandpa::pallet::Call;
pub type BridgeParachainCall = runtime_types::pallet_bridge_parachains::pallet::Call;
type UncheckedExtrinsic =
bp_bridge_hub_kusama::UncheckedExtrinsic<RuntimeCall, TransactionExtension>;
type UncheckedExtrinsic = bp_bridge_hub_kusama::UncheckedExtrinsic<RuntimeCall, SignedExtension>;
type UtilityCall = runtime_types::pallet_utility::pallet::Call;
/// Kusama chain definition
......@@ -89,7 +89,7 @@ impl ChainWithTransactions for BridgeHubKusama {
) -> Result<Self::SignedTransaction, SubstrateError> {
let raw_payload = SignedPayload::new(
unsigned.call,
TransactionExtension::from_params(
SignedExtension::from_params(
param.spec_version,
param.transaction_version,
unsigned.era,
......@@ -122,3 +122,8 @@ impl ChainWithMessages for BridgeHubKusama {
const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
bp_bridge_hub_kusama::FROM_BRIDGE_HUB_KUSAMA_MESSAGE_DETAILS_METHOD;
}
impl ChainWithRuntimeVersion for BridgeHubKusama {
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> =
Some(SimpleRuntimeVersion { spec_version: 1_002_000, transaction_version: 4 });
}
[package]
name = "relay-bridge-hub-polkadot-client"
version = "0.1.0"
authors = ["Parity Technologies <[email protected]>"]
edition = "2021"
authors.workspace = true
edition.workspace = true
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
repository.workspace = true
[lints]
workspace = true
[dependencies]
codec = { package = "parity-scale-codec", version = "3.1.5", features = ["derive"] }
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }
subxt = { version = "0.32.1", default-features = false, features = ["native"] }
codec = { package = "parity-scale-codec", version = "3.6.1", features = ["derive"] }
scale-info = { version = "2.11.1", default-features = false, features = ["derive"] }
subxt = { version = "0.35.3", default-features = false, features = ["native"] }
# Bridge dependencies
bp-bridge-hub-polkadot = { path = "../../primitives/chain-bridge-hub-polkadot" }
bp-header-chain = { path = "../../primitives/header-chain" }
bp-messages = { path = "../../primitives/messages" }
bp-parachains = { path = "../../primitives/parachains" }
bp-polkadot = { path = "../../primitives/chain-polkadot" }
bp-polkadot-core = { path = "../../primitives/polkadot-core" }
bp-kusama = { path = "../../primitives/chain-kusama" }
bp-runtime = { path = "../../primitives/runtime" }
bridge-runtime-common = { path = "../../bin/runtime-common" }
relay-substrate-client = { path = "../client-substrate" }
bp-bridge-hub-polkadot = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
bp-header-chain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
bp-messages = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
bp-parachains = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
bp-polkadot = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
bp-polkadot-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
bp-kusama = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
bp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
bridge-runtime-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
relay-substrate-client = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
# Substrate Dependencies
......