Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Align BridgeHub runtimes with other SP runtimes + reused test for teleport native tokens + some nits #2449

Merged
merged 14 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ for `release-parachains-v0.9.270`
5. Clone `it/release-<version>-fast-sudo` from Polkadot
In case the branch does not exists (it is a manual process): cherry pick paritytech/polkadot@791c8b8 and run
`find . -type f -name "*.toml" -print0 | xargs -0 sed -i '' -e 's/polkadot-vX.X.X/polkadot-v<version>/g'`
6. `cargo build --release features --fast-runtime`
6. `cargo build --release --features fast-runtime`
7. Copy `./target/polkadot` into `./bin` (in Cumulus)
8. Run the tests:
- Statemint: `yarn zombienet-test -c ./examples/statemint/config.toml -t ./examples/statemint`
Expand Down
6 changes: 2 additions & 4 deletions pallets/parachain-system/src/validate_block/implementation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ use cumulus_primitives_core::{
};
use cumulus_primitives_parachain_inherent::ParachainInherentData;

use polkadot_parachain::primitives::{
HeadData, RelayChainBlockNumber, ValidationParams, ValidationResult,
};
use polkadot_parachain::primitives::{HeadData, RelayChainBlockNumber, ValidationResult};

use codec::Encode;

Expand Down Expand Up @@ -238,7 +236,7 @@ where
.expect("Could not find `set_validation_data` inherent")
}

/// Validate the given [`PersistedValidationData`] against the [`ValidationParams`].
/// Validate the given [`PersistedValidationData`] against the [`MemoryOptimizedValidationParams`].
fn validate_validation_data(
validation_data: &PersistedValidationData,
relay_parent_number: RelayChainBlockNumber,
Expand Down
10 changes: 5 additions & 5 deletions parachains/runtimes/assets/test-utils/src/test_cases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ macro_rules! include_teleports_for_native_asset_works(
const BOB: [u8; 32] = [2u8; 32];
let target_account = parachains_common::AccountId::from(BOB);

asset_test_utils::test_cases::teleports_for_native_asset_works::<
$crate::test_cases::teleports_for_native_asset_works::<
$runtime,
$xcm_config,
$checking_account,
Expand Down Expand Up @@ -598,7 +598,7 @@ macro_rules! include_teleports_for_foreign_assets_works(
const SOME_ASSET_OWNER: [u8; 32] = [5u8; 32];
let asset_owner = parachains_common::AccountId::from(SOME_ASSET_OWNER);

asset_test_utils::test_cases::teleports_for_foreign_assets_works::<
$crate::test_cases::teleports_for_foreign_assets_works::<
$runtime,
$xcm_config,
$checking_account,
Expand Down Expand Up @@ -715,7 +715,7 @@ macro_rules! include_asset_transactor_transfer_with_local_consensus_currency_wor
const BOB: [u8; 32] = [2u8; 32];
let target_account = parachains_common::AccountId::from(BOB);

asset_test_utils::test_cases::asset_transactor_transfer_with_local_consensus_currency_works::<
$crate::test_cases::asset_transactor_transfer_with_local_consensus_currency_works::<
$runtime,
$xcm_config
>(
Expand Down Expand Up @@ -969,7 +969,7 @@ macro_rules! include_asset_transactor_transfer_with_pallet_assets_instance_works
const CHARLIE: [u8; 32] = [3u8; 32];
let charlie_account = parachains_common::AccountId::from(CHARLIE);

asset_test_utils::test_cases::asset_transactor_transfer_with_pallet_assets_instance_works::<
$crate::test_cases::asset_transactor_transfer_with_pallet_assets_instance_works::<
$runtime,
$xcm_config,
$assets_pallet_instance,
Expand Down Expand Up @@ -1297,7 +1297,7 @@ macro_rules! include_create_and_manage_foreign_assets_for_local_consensus_parach
const BOB: [u8; 32] = [2u8; 32];
let bob_account = parachains_common::AccountId::from(BOB);

asset_test_utils::test_cases::create_and_manage_foreign_assets_for_local_consensus_parachain_assets_works::<
$crate::test_cases::create_and_manage_foreign_assets_for_local_consensus_parachain_assets_works::<
$runtime,
$xcm_config,
$weight_to_fee,
Expand Down
5 changes: 3 additions & 2 deletions parachains/runtimes/bridge-hubs/bridge-hub-kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ pallet-authorship = { git = "https://github.com/paritytech/substrate", default-f
pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-multisig = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-sudo = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
Expand Down Expand Up @@ -72,6 +71,9 @@ pallet-collator-selection = { path = "../../../../pallets/collator-selection", d
parachain-info = { path = "../../../../parachains/pallets/parachain-info", default-features = false }
parachains-common = { path = "../../../../parachains/common", default-features = false }

[dev-dependencies]
bridge-hub-test-utils = { path = "../test-utils"}

[features]
default = [
"std",
Expand Down Expand Up @@ -100,7 +102,6 @@ std = [
"pallet-collator-selection/std",
"pallet-multisig/std",
"pallet-session/std",
"pallet-sudo/std",
"pallet-timestamp/std",
"pallet-transaction-payment-rpc-runtime-api/std",
"pallet-transaction-payment/std",
Expand Down
5 changes: 0 additions & 5 deletions parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,6 @@ pub fn native_version() -> NativeVersion {

parameter_types! {
pub const Version: RuntimeVersion = VERSION;

// This part is copied from Substrate's `bin/node/runtime/src/lib.rs`.
// The `RuntimeBlockLength` and `RuntimeBlockWeights` exist here because the
// `DeletionWeightLimit` and `DeletionQueueDepth` depend on those to parameterize
// the lazy contract deletion.
pub RuntimeBlockLength: BlockLength =
BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,16 @@ pub type XcmOriginToTransactDispatchOrigin = (
// transaction from the Root origin.
ParentAsSuperuser<RuntimeOrigin>,
// Native signed account converter; this just converts an `AccountId32` origin into a normal
// `Origin::Signed` origin of the same 32-byte value.
// `RuntimeOrigin::Signed` origin of the same 32-byte value.
SignedAccountId32AsNative<RelayNetwork, RuntimeOrigin>,
// Xcm origins can be represented natively under the Xcm pallet's Xcm origin.
XcmPassthrough<RuntimeOrigin>,
);

match_types! {
// TODO: map gov2 origins here - after merge https://github.com/paritytech/cumulus/pull/1895
pub type ParentOrParentsExecutivePlurality: impl Contains<MultiLocation> = {
pub type ParentOrParentsPlurality: impl Contains<MultiLocation> = {
bkontur marked this conversation as resolved.
Show resolved Hide resolved
MultiLocation { parents: 1, interior: Here } |
MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Executive, .. }) }
MultiLocation { parents: 1, interior: X1(Plurality { .. }) }
};
pub type ParentOrSiblings: impl Contains<MultiLocation> = {
MultiLocation { parents: 1, interior: Here } |
Expand Down Expand Up @@ -165,10 +164,10 @@ pub type Barrier = DenyThenTry<
AllowKnownQueryResponses<PolkadotXcm>,
WithComputedOrigin<
(
// Allow anything to pay for execution.
// If the message is one that immediately attemps to pay for execution, then allow it.
AllowTopLevelPaidExecutionFrom<Everything>,
// Parent and its exec plurality get free execution.
AllowExplicitUnpaidExecutionFrom<ParentOrParentsExecutivePlurality>,
// Parent and its plurality (i.e. governance bodies) gets free execution.
bkontur marked this conversation as resolved.
Show resolved Hide resolved
AllowExplicitUnpaidExecutionFrom<ParentOrParentsPlurality>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we have Fellowship here as well as on the Polkadot hub?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did it according to statemine, but I think it is related to the fact that Kusama does not have Collectives parachain, polkadot's FellowsPlurality points to the Collectives parachain here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and iiuc this is one of future plans to bring FellowsPlurality from Polkadot to Kusama side over bridge

// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<ParentOrSiblings>,
),
Expand Down
55 changes: 55 additions & 0 deletions parachains/runtimes/bridge-hubs/bridge-hub-kusama/tests/tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright 2023 Parity Technologies (UK) Ltd.
// This file is part of Cumulus.

// Cumulus 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.

// Cumulus 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 Cumulus. If not, see <http://www.gnu.org/licenses/>.

pub use bridge_hub_kusama_runtime::{
constants::fee::WeightToFee, xcm_config::XcmConfig, Balances, ExistentialDeposit,
ParachainSystem, PolkadotXcm, Runtime, RuntimeEvent, SessionKeys,
};
use codec::Decode;
use frame_support::parameter_types;
use parachains_common::{AccountId, AuraId};

const ALICE: [u8; 32] = [1u8; 32];

parameter_types! {
pub CheckingAccount: AccountId = PolkadotXcm::check_account();
}

bridge_hub_test_utils::test_cases::include_teleports_for_native_asset_works!(
Runtime,
XcmConfig,
CheckingAccount,
WeightToFee,
ParachainSystem,
bridge_hub_test_utils::CollatorSessionKeys::new(
AccountId::from(ALICE),
AccountId::from(ALICE),
SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) }
),
ExistentialDeposit::get(),
Box::new(|runtime_event_encoded: Vec<u8>| {
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
Ok(RuntimeEvent::PolkadotXcm(event)) => Some(event),
_ => None,
}
}),
Box::new(|runtime_event_encoded: Vec<u8>| {
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
Ok(RuntimeEvent::XcmpQueue(event)) => Some(event),
_ => None,
}
})
);
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ pallet-authorship = { git = "https://github.com/paritytech/substrate", default-f
pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-multisig = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-sudo = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
Expand Down Expand Up @@ -72,6 +71,9 @@ pallet-collator-selection = { path = "../../../../pallets/collator-selection", d
parachain-info = { path = "../../../../parachains/pallets/parachain-info", default-features = false }
parachains-common = { path = "../../../../parachains/common", default-features = false }

[dev-dependencies]
bridge-hub-test-utils = { path = "../test-utils"}

[features]
default = [
"std",
Expand Down Expand Up @@ -100,7 +102,6 @@ std = [
"pallet-collator-selection/std",
"pallet-multisig/std",
"pallet-session/std",
"pallet-sudo/std",
"pallet-timestamp/std",
"pallet-transaction-payment-rpc-runtime-api/std",
"pallet-transaction-payment/std",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,6 @@ pub fn native_version() -> NativeVersion {

parameter_types! {
pub const Version: RuntimeVersion = VERSION;

// This part is copied from Substrate's `bin/node/runtime/src/lib.rs`.
// The `RuntimeBlockLength` and `RuntimeBlockWeights` exist here because the
// `DeletionWeightLimit` and `DeletionQueueDepth` depend on those to parameterize
// the lazy contract deletion.
pub RuntimeBlockLength: BlockLength =
BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,24 @@ pub type XcmOriginToTransactDispatchOrigin = (
// transaction from the Root origin.
ParentAsSuperuser<RuntimeOrigin>,
// Native signed account converter; this just converts an `AccountId32` origin into a normal
// `Origin::Signed` origin of the same 32-byte value.
// `RuntimeOrigin::Signed` origin of the same 32-byte value.
SignedAccountId32AsNative<RelayNetwork, RuntimeOrigin>,
// Xcm origins can be represented natively under the Xcm pallet's Xcm origin.
XcmPassthrough<RuntimeOrigin>,
);

match_types! {
// TODO: map gov2 origins here - after merge https://github.com/paritytech/cumulus/pull/1895
pub type ParentOrParentsExecutivePlurality: impl Contains<MultiLocation> = {
pub type ParentOrParentsPlurality: impl Contains<MultiLocation> = {
MultiLocation { parents: 1, interior: Here } |
MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Executive, .. }) }
MultiLocation { parents: 1, interior: X1(Plurality { .. }) }
};
pub type ParentOrSiblings: impl Contains<MultiLocation> = {
MultiLocation { parents: 1, interior: Here } |
MultiLocation { parents: 1, interior: X1(_) }
};
pub type FellowsPlurality: impl Contains<MultiLocation> = {
MultiLocation { parents: 1, interior: X2(Parachain(1001), Plurality { id: BodyId::Technical, ..}) }
};
}
/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
/// account for proof size weights.
Expand Down Expand Up @@ -165,10 +167,10 @@ pub type Barrier = DenyThenTry<
AllowKnownQueryResponses<PolkadotXcm>,
WithComputedOrigin<
(
// Allow anything to pay for execution.
// If the message is one that immediately attemps to pay for execution, then allow it.
AllowTopLevelPaidExecutionFrom<Everything>,
// Parent and its exec plurality get free execution.
AllowExplicitUnpaidExecutionFrom<ParentOrParentsExecutivePlurality>,
// Parent, its plurality (i.e. governance bodies) and Fellows plurality gets free execution.
bkontur marked this conversation as resolved.
Show resolved Hide resolved
AllowExplicitUnpaidExecutionFrom<(ParentOrParentsPlurality, FellowsPlurality)>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<ParentOrSiblings>,
),
Expand Down
Loading