mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 21:01:02 +00:00
BHK/P alignments (#2115)
* Constants * Unused import? * Cargo.lock * Unused deps * TODO: fix doc or reimport? * Try to aviod redefine para_id constant for `RefundableParachainId` * Checked and removed TODOs
This commit is contained in:
committed by
Bastian Köcher
parent
d479232c34
commit
7188765244
@@ -501,7 +501,6 @@ impl pallet_bridge_messages::Config<WithRialtoParachainMessagesInstance> for Run
|
||||
|
||||
parameter_types! {
|
||||
pub const RialtoParachainMessagesLane: bp_messages::LaneId = rialto_parachain_messages::XCM_LANE;
|
||||
pub const RialtoParachainId: u32 = bp_rialto_parachain::RIALTO_PARACHAIN_ID;
|
||||
pub const RialtoParasPalletName: &'static str = bp_rialto::PARAS_PALLET_NAME;
|
||||
pub const WestendParasPalletName: &'static str = bp_westend::PARAS_PALLET_NAME;
|
||||
pub const MaxRialtoParaHeadDataSize: u32 = bp_rialto::MAX_NESTED_PARACHAIN_HEAD_DATA_SIZE;
|
||||
@@ -602,7 +601,7 @@ bp_runtime::generate_static_str_provider!(BridgeRefundRialtoPara2000Lane0Msgs);
|
||||
pub type PriorityBoostPerMessage = ConstU64<324_316_715>;
|
||||
pub type BridgeRefundRialtoParachainMessages = RefundBridgedParachainMessages<
|
||||
Runtime,
|
||||
RefundableParachain<WithRialtoParachainsInstance, RialtoParachainId>,
|
||||
RefundableParachain<WithRialtoParachainsInstance, bp_rialto_parachain::RialtoParachain>,
|
||||
RefundableMessagesLane<WithRialtoParachainMessagesInstance, RialtoParachainMessagesLane>,
|
||||
ActualFeeRefund<Runtime>,
|
||||
PriorityBoostPerMessage,
|
||||
|
||||
@@ -390,7 +390,7 @@ pub type XcmOriginToTransactDispatchOrigin = (
|
||||
// using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for
|
||||
// foreign chains who want to have a local sovereign account on this chain which they control.
|
||||
SovereignSignedViaLocation<LocationToAccountId, RuntimeOrigin>,
|
||||
// Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when
|
||||
// Native converter for Relay-chain (Parent) location; will convert to a `Relay` origin when
|
||||
// recognised.
|
||||
RelayChainAsNative<RelayOrigin, RuntimeOrigin>,
|
||||
// Native converter for sibling Parachains; will convert to a `SiblingPara` origin when
|
||||
|
||||
@@ -40,10 +40,8 @@ sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", d
|
||||
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
|
||||
# Polkadot dependencies
|
||||
pallet-xcm = { git = "https://github.com/paritytech/polkadot", branch = "master", default-features = false }
|
||||
xcm = { git = "https://github.com/paritytech/polkadot", branch = "master", default-features = false }
|
||||
xcm-builder = { git = "https://github.com/paritytech/polkadot", branch = "master", default-features = false }
|
||||
xcm-executor = { git = "https://github.com/paritytech/polkadot", branch = "master", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
bp-test-utils = { path = "../../primitives/test-utils" }
|
||||
@@ -68,7 +66,6 @@ std = [
|
||||
"pallet-bridge-relayers/std",
|
||||
"pallet-transaction-payment/std",
|
||||
"pallet-utility/std",
|
||||
"pallet-xcm/std",
|
||||
"scale-info/std",
|
||||
"sp-api/std",
|
||||
"sp-core/std",
|
||||
@@ -78,13 +75,12 @@ std = [
|
||||
"sp-trie/std",
|
||||
"xcm/std",
|
||||
"xcm-builder/std",
|
||||
"xcm-executor/std",
|
||||
]
|
||||
runtime-benchmarks = [
|
||||
"pallet-bridge-grandpa/runtime-benchmarks",
|
||||
"pallet-bridge-messages/runtime-benchmarks",
|
||||
"pallet-bridge-parachains/runtime-benchmarks",
|
||||
"pallet-xcm/runtime-benchmarks",
|
||||
"pallet-bridge-relayers/runtime-benchmarks",
|
||||
"xcm-builder/runtime-benchmarks",
|
||||
]
|
||||
integrity-test = [
|
||||
|
||||
@@ -24,7 +24,7 @@ use crate::messages_call_ext::{
|
||||
};
|
||||
use bp_messages::{LaneId, MessageNonce};
|
||||
use bp_relayers::{RewardsAccountOwner, RewardsAccountParams};
|
||||
use bp_runtime::{RangeInclusiveExt, StaticStrProvider};
|
||||
use bp_runtime::{Parachain, ParachainIdOf, RangeInclusiveExt, StaticStrProvider};
|
||||
use codec::{Decode, Encode};
|
||||
use frame_support::{
|
||||
dispatch::{CallableCallFor, DispatchInfo, Dispatchable, PostDispatchInfo},
|
||||
@@ -71,9 +71,9 @@ pub trait RefundableParachainId {
|
||||
}
|
||||
|
||||
/// Default implementation of `RefundableParachainId`.
|
||||
pub struct RefundableParachain<Instance, Id>(PhantomData<(Instance, Id)>);
|
||||
pub struct DefaultRefundableParachainId<Instance, Id>(PhantomData<(Instance, Id)>);
|
||||
|
||||
impl<Instance, Id> RefundableParachainId for RefundableParachain<Instance, Id>
|
||||
impl<Instance, Id> RefundableParachainId for DefaultRefundableParachainId<Instance, Id>
|
||||
where
|
||||
Id: Get<u32>,
|
||||
{
|
||||
@@ -81,6 +81,17 @@ where
|
||||
type Id = Id;
|
||||
}
|
||||
|
||||
/// Implementation of `RefundableParachainId` for `trait Parachain`.
|
||||
pub struct RefundableParachain<Instance, Para>(PhantomData<(Instance, Para)>);
|
||||
|
||||
impl<Instance, Para> RefundableParachainId for RefundableParachain<Instance, Para>
|
||||
where
|
||||
Para: Parachain,
|
||||
{
|
||||
type Instance = Instance;
|
||||
type Id = ParachainIdOf<Para>;
|
||||
}
|
||||
|
||||
/// Trait identifying a bridged messages lane. A relayer might be refunded for delivering messages
|
||||
/// coming from this lane.
|
||||
pub trait RefundableMessagesLaneId {
|
||||
@@ -682,7 +693,7 @@ mod tests {
|
||||
bp_runtime::generate_static_str_provider!(TestExtension);
|
||||
type TestExtension = RefundBridgedParachainMessages<
|
||||
TestRuntime,
|
||||
RefundableParachain<(), TestParachain>,
|
||||
DefaultRefundableParachainId<(), TestParachain>,
|
||||
RefundableMessagesLane<(), TestLaneId>,
|
||||
ActualFeeRefund<TestRuntime>,
|
||||
ConstU64<1>,
|
||||
|
||||
@@ -72,12 +72,10 @@ pub type Address = MultiAddress<AccountId, ()>;
|
||||
pub const BRIDGE_HUB_KUSAMA_PARACHAIN_ID: u32 = 1002;
|
||||
|
||||
/// Name of the With-BridgeHubKusama messages pallet instance that is deployed at bridged chains.
|
||||
// TODO: check me (https://github.com/paritytech/parity-bridges-common/issues/1945)
|
||||
pub const WITH_BRIDGE_HUB_KUSAMA_MESSAGES_PALLET_NAME: &str = "BridgeKusamaMessages";
|
||||
|
||||
/// Name of the With-BridgeHubKusama bridge-relayers pallet instance that is deployed at bridged
|
||||
/// chains.
|
||||
// TODO: check me (https://github.com/paritytech/parity-bridges-common/issues/1945)
|
||||
pub const WITH_BRIDGE_HUB_KUSAMA_RELAYERS_PALLET_NAME: &str = "BridgeRelayers";
|
||||
|
||||
decl_bridge_finality_runtime_apis!(bridge_hub_kusama);
|
||||
|
||||
@@ -59,16 +59,13 @@ impl Parachain for BridgeHubPolkadot {
|
||||
}
|
||||
|
||||
/// Identifier of BridgeHubPolkadot in the Polkadot relay chain.
|
||||
// TODO: check me (https://github.com/paritytech/parity-bridges-common/issues/1945)
|
||||
pub const BRIDGE_HUB_POLKADOT_PARACHAIN_ID: u32 = 1002;
|
||||
|
||||
/// Name of the With-BridgeHubPolkadot messages pallet instance that is deployed at bridged chains.
|
||||
// TODO: check me (https://github.com/paritytech/parity-bridges-common/issues/1945)
|
||||
pub const WITH_BRIDGE_HUB_POLKADOT_MESSAGES_PALLET_NAME: &str = "BridgePolkadotMessages";
|
||||
|
||||
/// Name of the With-BridgeHubPolkadot bridge-relayers pallet instance that is deployed at bridged
|
||||
/// chains.
|
||||
// TODO: check me (https://github.com/paritytech/parity-bridges-common/issues/1945)
|
||||
pub const WITH_BRIDGE_HUB_POLKADOT_RELAYERS_PALLET_NAME: &str = "BridgeRelayers";
|
||||
|
||||
decl_bridge_finality_runtime_apis!(bridge_hub_polkadot);
|
||||
|
||||
@@ -62,4 +62,11 @@ pub const PARAS_PALLET_NAME: &str = "Paras";
|
||||
/// Name of the With-Kusama GRANDPA pallet instance that is deployed at bridged chains.
|
||||
pub const WITH_KUSAMA_GRANDPA_PALLET_NAME: &str = "BridgeKusamaGrandpa";
|
||||
|
||||
/// Maximal size of encoded `bp_parachains::ParaStoredHeaderData` structure among all Polkadot
|
||||
/// parachains.
|
||||
///
|
||||
/// It includes the block number and state root, so it shall be near 40 bytes, but let's have some
|
||||
/// reserve.
|
||||
pub const MAX_NESTED_PARACHAIN_HEAD_DATA_SIZE: u32 = 128;
|
||||
|
||||
decl_bridge_finality_runtime_apis!(kusama);
|
||||
|
||||
@@ -62,4 +62,11 @@ pub const PARAS_PALLET_NAME: &str = "Paras";
|
||||
/// Name of the With-Polkadot GRANDPA pallet instance that is deployed at bridged chains.
|
||||
pub const WITH_POLKADOT_GRANDPA_PALLET_NAME: &str = "BridgePolkadotGrandpa";
|
||||
|
||||
/// Maximal size of encoded `bp_parachains::ParaStoredHeaderData` structure among all Polkadot
|
||||
/// parachains.
|
||||
///
|
||||
/// It includes the block number and state root, so it shall be near 40 bytes, but let's have some
|
||||
/// reserve.
|
||||
pub const MAX_NESTED_PARACHAIN_HEAD_DATA_SIZE: u32 = 128;
|
||||
|
||||
decl_bridge_finality_runtime_apis!(polkadot);
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
//!
|
||||
//! Even though this (bridges) repository references polkadot repository, we can't
|
||||
//! reference polkadot crates from pallets. That's because bridges repository is
|
||||
//! included in the polkadot repository and included pallets are used by polkadot
|
||||
//! chains. Having pallets that are referencing polkadot, would mean that there may
|
||||
//! included in the Cumulus repository and included pallets are used by Cumulus
|
||||
//! parachains. Having pallets that are referencing polkadot, would mean that there may
|
||||
//! be two versions of polkadot crates included in the runtime. Which is bad.
|
||||
|
||||
use bp_runtime::{RawStorageProof, Size};
|
||||
|
||||
@@ -232,6 +232,14 @@ where
|
||||
const PARACHAIN_ID: u32 = <<T as UnderlyingChainProvider>::Chain as Parachain>::PARACHAIN_ID;
|
||||
}
|
||||
|
||||
/// 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;
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@ use sp_std::{convert::TryFrom, fmt::Debug, ops::RangeInclusive, vec, vec::Vec};
|
||||
|
||||
pub use chain::{
|
||||
AccountIdOf, AccountPublicOf, BalanceOf, BlockNumberOf, Chain, EncodedOrDecodedCall, HashOf,
|
||||
HasherOf, HeaderOf, IndexOf, Parachain, SignatureOf, TransactionEraOf, UnderlyingChainOf,
|
||||
UnderlyingChainProvider,
|
||||
HasherOf, HeaderOf, IndexOf, 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};
|
||||
@@ -95,7 +95,7 @@ pub const BRIDGE_HUB_WOCOCO_CHAIN_ID: ChainId = *b"bhwo";
|
||||
pub const BRIDGE_HUB_KUSAMA_CHAIN_ID: ChainId = *b"bhks";
|
||||
|
||||
/// BridgeHubPolkadot chain id.
|
||||
pub const BRIDGE_HUB_POLKADOT_CHAIN_ID: ChainId = *b"bhwo";
|
||||
pub const BRIDGE_HUB_POLKADOT_CHAIN_ID: ChainId = *b"bhpd";
|
||||
|
||||
/// Generic header Id.
|
||||
#[derive(
|
||||
|
||||
@@ -26,7 +26,6 @@ impl CliChain for Kusama {
|
||||
}
|
||||
|
||||
impl CliChain for BridgeHubKusama {
|
||||
// TODO: fix me (https://github.com/paritytech/parity-bridges-common/issues/1945)
|
||||
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> =
|
||||
Some(SimpleRuntimeVersion { spec_version: 4242, transaction_version: 42 });
|
||||
Some(SimpleRuntimeVersion { spec_version: 9410, transaction_version: 21 });
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ impl CliChain for Polkadot {
|
||||
}
|
||||
|
||||
impl CliChain for BridgeHubPolkadot {
|
||||
// TODO: fix me (https://github.com/paritytech/parity-bridges-common/issues/1945)
|
||||
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> =
|
||||
Some(SimpleRuntimeVersion { spec_version: 4242, transaction_version: 42 });
|
||||
Some(SimpleRuntimeVersion { spec_version: 9410, transaction_version: 22 });
|
||||
}
|
||||
|
||||
@@ -54,16 +54,13 @@ pub enum Call {
|
||||
Utility(UtilityCall<Call>),
|
||||
|
||||
/// Polkadot bridge pallet.
|
||||
// TODO: the index is wrong (https://github.com/paritytech/parity-bridges-common/issues/1945)
|
||||
#[codec(index = 41)]
|
||||
#[codec(index = 51)]
|
||||
BridgePolkadotGrandpa(BridgePolkadotGrandpaCall),
|
||||
/// Polkadot parachain bridge pallet.
|
||||
// TODO: the index is wrong (https://github.com/paritytech/parity-bridges-common/issues/1945)
|
||||
#[codec(index = 42)]
|
||||
#[codec(index = 52)]
|
||||
BridgePolkadotParachain(BridgeParachainCall),
|
||||
/// Polkadot messages bridge pallet.
|
||||
// TODO: the index is wrong (https://github.com/paritytech/parity-bridges-common/issues/1945)
|
||||
#[codec(index = 46)]
|
||||
#[codec(index = 53)]
|
||||
BridgePolkadotMessages(BridgePolkadotMessagesCall),
|
||||
}
|
||||
|
||||
|
||||
@@ -53,16 +53,13 @@ pub enum Call {
|
||||
Utility(UtilityCall<Call>),
|
||||
|
||||
/// Kusama bridge pallet.
|
||||
// TODO: the index is wrong (https://github.com/paritytech/parity-bridges-common/issues/1945)
|
||||
#[codec(index = 43)]
|
||||
#[codec(index = 51)]
|
||||
BridgeKusamaGrandpa(BridgeKusamaGrandpaCall),
|
||||
/// Kusama parachain bridge pallet.
|
||||
// TODO: the index is wrong (https://github.com/paritytech/parity-bridges-common/issues/1945)
|
||||
#[codec(index = 44)]
|
||||
#[codec(index = 52)]
|
||||
BridgeKusamaParachain(BridgeParachainCall),
|
||||
/// Kusama messages bridge pallet.
|
||||
// TODO: the index is wrong (https://github.com/paritytech/parity-bridges-common/issues/1945)
|
||||
#[codec(index = 45)]
|
||||
#[codec(index = 53)]
|
||||
BridgeKusamaMessages(BridgeKusamaMessagesCall),
|
||||
}
|
||||
|
||||
@@ -114,6 +111,6 @@ mod tests {
|
||||
|
||||
// encode call as hex string
|
||||
let hex_encoded_call = format!("0x{:?}", HexDisplay::from(&Encode::encode(&tx)));
|
||||
assert_eq!(hex_encoded_call, "0x2b01ae4a25acf250d72ed02c149ecc7dd3c9ee976d41a2888fc551de8064521dc01d2d0192b965f0656a4e0e5fc0167da2d4b5ee72b3be2c1583c4c1e5236c8c12aa141bd2c0afaab32de0cb8f7f0d89217e37c5ea302c1ffb5a7a83e10d20f12c32874d0000060000000000000000");
|
||||
assert_eq!(hex_encoded_call, "0x3301ae4a25acf250d72ed02c149ecc7dd3c9ee976d41a2888fc551de8064521dc01d2d0192b965f0656a4e0e5fc0167da2d4b5ee72b3be2c1583c4c1e5236c8c12aa141bd2c0afaab32de0cb8f7f0d89217e37c5ea302c1ffb5a7a83e10d20f12c32874d0000060000000000000000");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,5 @@ impl ChainWithBalances for Kusama {
|
||||
|
||||
impl RelayChain for Kusama {
|
||||
const PARAS_PALLET_NAME: &'static str = bp_kusama::PARAS_PALLET_NAME;
|
||||
// TODO: check me (https://github.com/paritytech/parity-bridges-common/issues/1945)
|
||||
const PARACHAINS_FINALITY_PALLET_NAME: &'static str = "BridgeKusamaParachain";
|
||||
}
|
||||
|
||||
@@ -55,6 +55,5 @@ impl ChainWithBalances for Polkadot {
|
||||
|
||||
impl RelayChain for Polkadot {
|
||||
const PARAS_PALLET_NAME: &'static str = bp_polkadot::PARAS_PALLET_NAME;
|
||||
// TODO: check me (https://github.com/paritytech/parity-bridges-common/issues/1945)
|
||||
const PARACHAINS_FINALITY_PALLET_NAME: &'static str = "BridgePolkadotParachain";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user