Skip to content

Commit 7480f63

Browse files
authored
BHK/P alignments (paritytech#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
1 parent ce97a2c commit 7480f63

File tree

18 files changed

+58
-45
lines changed

18 files changed

+58
-45
lines changed

bridges/bin/millau/runtime/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,6 @@ impl pallet_bridge_messages::Config<WithRialtoParachainMessagesInstance> for Run
501501

502502
parameter_types! {
503503
pub const RialtoParachainMessagesLane: bp_messages::LaneId = rialto_parachain_messages::XCM_LANE;
504-
pub const RialtoParachainId: u32 = bp_rialto_parachain::RIALTO_PARACHAIN_ID;
505504
pub const RialtoParasPalletName: &'static str = bp_rialto::PARAS_PALLET_NAME;
506505
pub const WestendParasPalletName: &'static str = bp_westend::PARAS_PALLET_NAME;
507506
pub const MaxRialtoParaHeadDataSize: u32 = bp_rialto::MAX_NESTED_PARACHAIN_HEAD_DATA_SIZE;
@@ -602,7 +601,7 @@ bp_runtime::generate_static_str_provider!(BridgeRefundRialtoPara2000Lane0Msgs);
602601
pub type PriorityBoostPerMessage = ConstU64<324_316_715>;
603602
pub type BridgeRefundRialtoParachainMessages = RefundBridgedParachainMessages<
604603
Runtime,
605-
RefundableParachain<WithRialtoParachainsInstance, RialtoParachainId>,
604+
RefundableParachain<WithRialtoParachainsInstance, bp_rialto_parachain::RialtoParachain>,
606605
RefundableMessagesLane<WithRialtoParachainMessagesInstance, RialtoParachainMessagesLane>,
607606
ActualFeeRefund<Runtime>,
608607
PriorityBoostPerMessage,

bridges/bin/rialto-parachain/runtime/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ pub type XcmOriginToTransactDispatchOrigin = (
390390
// using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for
391391
// foreign chains who want to have a local sovereign account on this chain which they control.
392392
SovereignSignedViaLocation<LocationToAccountId, RuntimeOrigin>,
393-
// Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when
393+
// Native converter for Relay-chain (Parent) location; will convert to a `Relay` origin when
394394
// recognised.
395395
RelayChainAsNative<RelayOrigin, RuntimeOrigin>,
396396
// Native converter for sibling Parachains; will convert to a `SiblingPara` origin when

bridges/bin/runtime-common/Cargo.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@ sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", d
4040
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
4141

4242
# Polkadot dependencies
43-
pallet-xcm = { git = "https://github.com/paritytech/polkadot", branch = "master", default-features = false }
4443
xcm = { git = "https://github.com/paritytech/polkadot", branch = "master", default-features = false }
4544
xcm-builder = { git = "https://github.com/paritytech/polkadot", branch = "master", default-features = false }
46-
xcm-executor = { git = "https://github.com/paritytech/polkadot", branch = "master", default-features = false }
4745

4846
[dev-dependencies]
4947
bp-test-utils = { path = "../../primitives/test-utils" }
@@ -68,7 +66,6 @@ std = [
6866
"pallet-bridge-relayers/std",
6967
"pallet-transaction-payment/std",
7068
"pallet-utility/std",
71-
"pallet-xcm/std",
7269
"scale-info/std",
7370
"sp-api/std",
7471
"sp-core/std",
@@ -78,13 +75,12 @@ std = [
7875
"sp-trie/std",
7976
"xcm/std",
8077
"xcm-builder/std",
81-
"xcm-executor/std",
8278
]
8379
runtime-benchmarks = [
8480
"pallet-bridge-grandpa/runtime-benchmarks",
8581
"pallet-bridge-messages/runtime-benchmarks",
8682
"pallet-bridge-parachains/runtime-benchmarks",
87-
"pallet-xcm/runtime-benchmarks",
83+
"pallet-bridge-relayers/runtime-benchmarks",
8884
"xcm-builder/runtime-benchmarks",
8985
]
9086
integrity-test = [

bridges/bin/runtime-common/src/refund_relayer_extension.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use crate::messages_call_ext::{
2424
};
2525
use bp_messages::{LaneId, MessageNonce};
2626
use bp_relayers::{RewardsAccountOwner, RewardsAccountParams};
27-
use bp_runtime::{RangeInclusiveExt, StaticStrProvider};
27+
use bp_runtime::{Parachain, ParachainIdOf, RangeInclusiveExt, StaticStrProvider};
2828
use codec::{Decode, Encode};
2929
use frame_support::{
3030
dispatch::{CallableCallFor, DispatchInfo, Dispatchable, PostDispatchInfo},
@@ -71,16 +71,27 @@ pub trait RefundableParachainId {
7171
}
7272

7373
/// Default implementation of `RefundableParachainId`.
74-
pub struct RefundableParachain<Instance, Id>(PhantomData<(Instance, Id)>);
74+
pub struct DefaultRefundableParachainId<Instance, Id>(PhantomData<(Instance, Id)>);
7575

76-
impl<Instance, Id> RefundableParachainId for RefundableParachain<Instance, Id>
76+
impl<Instance, Id> RefundableParachainId for DefaultRefundableParachainId<Instance, Id>
7777
where
7878
Id: Get<u32>,
7979
{
8080
type Instance = Instance;
8181
type Id = Id;
8282
}
8383

84+
/// Implementation of `RefundableParachainId` for `trait Parachain`.
85+
pub struct RefundableParachain<Instance, Para>(PhantomData<(Instance, Para)>);
86+
87+
impl<Instance, Para> RefundableParachainId for RefundableParachain<Instance, Para>
88+
where
89+
Para: Parachain,
90+
{
91+
type Instance = Instance;
92+
type Id = ParachainIdOf<Para>;
93+
}
94+
8495
/// Trait identifying a bridged messages lane. A relayer might be refunded for delivering messages
8596
/// coming from this lane.
8697
pub trait RefundableMessagesLaneId {
@@ -682,7 +693,7 @@ mod tests {
682693
bp_runtime::generate_static_str_provider!(TestExtension);
683694
type TestExtension = RefundBridgedParachainMessages<
684695
TestRuntime,
685-
RefundableParachain<(), TestParachain>,
696+
DefaultRefundableParachainId<(), TestParachain>,
686697
RefundableMessagesLane<(), TestLaneId>,
687698
ActualFeeRefund<TestRuntime>,
688699
ConstU64<1>,

bridges/modules/parachains/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,10 @@ pub mod pallet {
394394
Some(parachain_head_data) => parachain_head_data,
395395
None => {
396396
log::trace!(
397-
target: LOG_TARGET,
398-
"The head of parachain {:?} has been provided, but it is not tracked by the pallet",
399-
parachain,
400-
);
397+
target: LOG_TARGET,
398+
"The head of parachain {:?} has been provided, but it is not tracked by the pallet",
399+
parachain,
400+
);
401401
Self::deposit_event(Event::UntrackedParachainRejected { parachain });
402402
continue
403403
},

bridges/primitives/chain-bridge-hub-kusama/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,10 @@ pub type Address = MultiAddress<AccountId, ()>;
7272
pub const BRIDGE_HUB_KUSAMA_PARACHAIN_ID: u32 = 1002;
7373

7474
/// Name of the With-BridgeHubKusama messages pallet instance that is deployed at bridged chains.
75-
// TODO: check me (https://github.com/paritytech/parity-bridges-common/issues/1945)
7675
pub const WITH_BRIDGE_HUB_KUSAMA_MESSAGES_PALLET_NAME: &str = "BridgeKusamaMessages";
7776

7877
/// Name of the With-BridgeHubKusama bridge-relayers pallet instance that is deployed at bridged
7978
/// chains.
80-
// TODO: check me (https://github.com/paritytech/parity-bridges-common/issues/1945)
8179
pub const WITH_BRIDGE_HUB_KUSAMA_RELAYERS_PALLET_NAME: &str = "BridgeRelayers";
8280

8381
decl_bridge_finality_runtime_apis!(bridge_hub_kusama);

bridges/primitives/chain-bridge-hub-polkadot/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,13 @@ impl Parachain for BridgeHubPolkadot {
5959
}
6060

6161
/// Identifier of BridgeHubPolkadot in the Polkadot relay chain.
62-
// TODO: check me (https://github.com/paritytech/parity-bridges-common/issues/1945)
6362
pub const BRIDGE_HUB_POLKADOT_PARACHAIN_ID: u32 = 1002;
6463

6564
/// Name of the With-BridgeHubPolkadot messages pallet instance that is deployed at bridged chains.
66-
// TODO: check me (https://github.com/paritytech/parity-bridges-common/issues/1945)
6765
pub const WITH_BRIDGE_HUB_POLKADOT_MESSAGES_PALLET_NAME: &str = "BridgePolkadotMessages";
6866

6967
/// Name of the With-BridgeHubPolkadot bridge-relayers pallet instance that is deployed at bridged
7068
/// chains.
71-
// TODO: check me (https://github.com/paritytech/parity-bridges-common/issues/1945)
7269
pub const WITH_BRIDGE_HUB_POLKADOT_RELAYERS_PALLET_NAME: &str = "BridgeRelayers";
7370

7471
decl_bridge_finality_runtime_apis!(bridge_hub_polkadot);

bridges/primitives/chain-kusama/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,11 @@ pub const PARAS_PALLET_NAME: &str = "Paras";
6262
/// Name of the With-Kusama GRANDPA pallet instance that is deployed at bridged chains.
6363
pub const WITH_KUSAMA_GRANDPA_PALLET_NAME: &str = "BridgeKusamaGrandpa";
6464

65+
/// Maximal size of encoded `bp_parachains::ParaStoredHeaderData` structure among all Polkadot
66+
/// parachains.
67+
///
68+
/// It includes the block number and state root, so it shall be near 40 bytes, but let's have some
69+
/// reserve.
70+
pub const MAX_NESTED_PARACHAIN_HEAD_DATA_SIZE: u32 = 128;
71+
6572
decl_bridge_finality_runtime_apis!(kusama);

bridges/primitives/chain-polkadot/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,11 @@ pub const PARAS_PALLET_NAME: &str = "Paras";
6262
/// Name of the With-Polkadot GRANDPA pallet instance that is deployed at bridged chains.
6363
pub const WITH_POLKADOT_GRANDPA_PALLET_NAME: &str = "BridgePolkadotGrandpa";
6464

65+
/// Maximal size of encoded `bp_parachains::ParaStoredHeaderData` structure among all Polkadot
66+
/// parachains.
67+
///
68+
/// It includes the block number and state root, so it shall be near 40 bytes, but let's have some
69+
/// reserve.
70+
pub const MAX_NESTED_PARACHAIN_HEAD_DATA_SIZE: u32 = 128;
71+
6572
decl_bridge_finality_runtime_apis!(polkadot);

bridges/primitives/polkadot-core/src/parachains.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
//!
1919
//! Even though this (bridges) repository references polkadot repository, we can't
2020
//! reference polkadot crates from pallets. That's because bridges repository is
21-
//! included in the polkadot repository and included pallets are used by polkadot
22-
//! chains. Having pallets that are referencing polkadot, would mean that there may
21+
//! included in the Cumulus repository and included pallets are used by Cumulus
22+
//! parachains. Having pallets that are referencing polkadot, would mean that there may
2323
//! be two versions of polkadot crates included in the runtime. Which is bad.
2424
2525
use bp_runtime::{RawStorageProof, Size};

bridges/primitives/runtime/src/chain.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,14 @@ where
232232
const PARACHAIN_ID: u32 = <<T as UnderlyingChainProvider>::Chain as Parachain>::PARACHAIN_ID;
233233
}
234234

235+
/// Adapter for `Get<u32>` to access `PARACHAIN_ID` from `trait Parachain`
236+
pub struct ParachainIdOf<Para>(sp_std::marker::PhantomData<Para>);
237+
impl<Para: Parachain> frame_support::traits::Get<u32> for ParachainIdOf<Para> {
238+
fn get() -> u32 {
239+
Para::PARACHAIN_ID
240+
}
241+
}
242+
235243
/// Underlying chain type.
236244
pub type UnderlyingChainOf<C> = <C as UnderlyingChainProvider>::Chain;
237245

bridges/primitives/runtime/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ use sp_std::{convert::TryFrom, fmt::Debug, ops::RangeInclusive, vec, vec::Vec};
3131

3232
pub use chain::{
3333
AccountIdOf, AccountPublicOf, BalanceOf, BlockNumberOf, Chain, EncodedOrDecodedCall, HashOf,
34-
HasherOf, HeaderOf, IndexOf, Parachain, SignatureOf, TransactionEraOf, UnderlyingChainOf,
35-
UnderlyingChainProvider,
34+
HasherOf, HeaderOf, IndexOf, Parachain, ParachainIdOf, SignatureOf, TransactionEraOf,
35+
UnderlyingChainOf, UnderlyingChainProvider,
3636
};
3737
pub use frame_support::storage::storage_prefix as storage_value_final_key;
3838
use num_traits::{CheckedAdd, CheckedSub, One, SaturatingAdd, Zero};
@@ -95,7 +95,7 @@ pub const BRIDGE_HUB_WOCOCO_CHAIN_ID: ChainId = *b"bhwo";
9595
pub const BRIDGE_HUB_KUSAMA_CHAIN_ID: ChainId = *b"bhks";
9696

9797
/// BridgeHubPolkadot chain id.
98-
pub const BRIDGE_HUB_POLKADOT_CHAIN_ID: ChainId = *b"bhwo";
98+
pub const BRIDGE_HUB_POLKADOT_CHAIN_ID: ChainId = *b"bhpd";
9999

100100
/// Generic header Id.
101101
#[derive(

bridges/relays/bin-substrate/src/chains/kusama.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ impl CliChain for Kusama {
2626
}
2727

2828
impl CliChain for BridgeHubKusama {
29-
// TODO: fix me (https://github.com/paritytech/parity-bridges-common/issues/1945)
3029
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> =
31-
Some(SimpleRuntimeVersion { spec_version: 4242, transaction_version: 42 });
30+
Some(SimpleRuntimeVersion { spec_version: 9410, transaction_version: 21 });
3231
}

bridges/relays/bin-substrate/src/chains/polkadot.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ impl CliChain for Polkadot {
2626
}
2727

2828
impl CliChain for BridgeHubPolkadot {
29-
// TODO: fix me (https://github.com/paritytech/parity-bridges-common/issues/1945)
3029
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> =
31-
Some(SimpleRuntimeVersion { spec_version: 4242, transaction_version: 42 });
30+
Some(SimpleRuntimeVersion { spec_version: 9410, transaction_version: 22 });
3231
}

bridges/relays/client-bridge-hub-kusama/src/runtime_wrapper.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,13 @@ pub enum Call {
5454
Utility(UtilityCall<Call>),
5555

5656
/// Polkadot bridge pallet.
57-
// TODO: the index is wrong (https://github.com/paritytech/parity-bridges-common/issues/1945)
58-
#[codec(index = 41)]
57+
#[codec(index = 51)]
5958
BridgePolkadotGrandpa(BridgePolkadotGrandpaCall),
6059
/// Polkadot parachain bridge pallet.
61-
// TODO: the index is wrong (https://github.com/paritytech/parity-bridges-common/issues/1945)
62-
#[codec(index = 42)]
60+
#[codec(index = 52)]
6361
BridgePolkadotParachain(BridgeParachainCall),
6462
/// Polkadot messages bridge pallet.
65-
// TODO: the index is wrong (https://github.com/paritytech/parity-bridges-common/issues/1945)
66-
#[codec(index = 46)]
63+
#[codec(index = 53)]
6764
BridgePolkadotMessages(BridgePolkadotMessagesCall),
6865
}
6966

bridges/relays/client-bridge-hub-polkadot/src/runtime_wrapper.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,13 @@ pub enum Call {
5353
Utility(UtilityCall<Call>),
5454

5555
/// Kusama bridge pallet.
56-
// TODO: the index is wrong (https://github.com/paritytech/parity-bridges-common/issues/1945)
57-
#[codec(index = 43)]
56+
#[codec(index = 51)]
5857
BridgeKusamaGrandpa(BridgeKusamaGrandpaCall),
5958
/// Kusama parachain bridge pallet.
60-
// TODO: the index is wrong (https://github.com/paritytech/parity-bridges-common/issues/1945)
61-
#[codec(index = 44)]
59+
#[codec(index = 52)]
6260
BridgeKusamaParachain(BridgeParachainCall),
6361
/// Kusama messages bridge pallet.
64-
// TODO: the index is wrong (https://github.com/paritytech/parity-bridges-common/issues/1945)
65-
#[codec(index = 45)]
62+
#[codec(index = 53)]
6663
BridgeKusamaMessages(BridgeKusamaMessagesCall),
6764
}
6865

@@ -114,6 +111,6 @@ mod tests {
114111

115112
// encode call as hex string
116113
let hex_encoded_call = format!("0x{:?}", HexDisplay::from(&Encode::encode(&tx)));
117-
assert_eq!(hex_encoded_call, "0x2b01ae4a25acf250d72ed02c149ecc7dd3c9ee976d41a2888fc551de8064521dc01d2d0192b965f0656a4e0e5fc0167da2d4b5ee72b3be2c1583c4c1e5236c8c12aa141bd2c0afaab32de0cb8f7f0d89217e37c5ea302c1ffb5a7a83e10d20f12c32874d0000060000000000000000");
114+
assert_eq!(hex_encoded_call, "0x3301ae4a25acf250d72ed02c149ecc7dd3c9ee976d41a2888fc551de8064521dc01d2d0192b965f0656a4e0e5fc0167da2d4b5ee72b3be2c1583c4c1e5236c8c12aa141bd2c0afaab32de0cb8f7f0d89217e37c5ea302c1ffb5a7a83e10d20f12c32874d0000060000000000000000");
118115
}
119116
}

bridges/relays/client-kusama/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,5 @@ impl ChainWithBalances for Kusama {
5555

5656
impl RelayChain for Kusama {
5757
const PARAS_PALLET_NAME: &'static str = bp_kusama::PARAS_PALLET_NAME;
58-
// TODO: check me (https://github.com/paritytech/parity-bridges-common/issues/1945)
5958
const PARACHAINS_FINALITY_PALLET_NAME: &'static str = "BridgeKusamaParachain";
6059
}

bridges/relays/client-polkadot/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,5 @@ impl ChainWithBalances for Polkadot {
5555

5656
impl RelayChain for Polkadot {
5757
const PARAS_PALLET_NAME: &'static str = bp_polkadot::PARAS_PALLET_NAME;
58-
// TODO: check me (https://github.com/paritytech/parity-bridges-common/issues/1945)
5958
const PARACHAINS_FINALITY_PALLET_NAME: &'static str = "BridgePolkadotParachain";
6059
}

0 commit comments

Comments
 (0)