Skip to content

Commit

Permalink
Merge branch 'bko-bump-to-1.7' into sv-pk-bridge-snowbridge
Browse files Browse the repository at this point in the history
  • Loading branch information
claravanstaden authored and claravanstaden committed Mar 1, 2024
2 parents 3b54eae + efe60b9 commit db374a6
Show file tree
Hide file tree
Showing 16 changed files with 157 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

mod genesis;
pub use genesis::{genesis, ED, PARA_ID_A, PARA_ID_B};
pub use penpal_runtime::xcm_config::{LocalTeleportableToAssetHubV3, XcmConfig};
pub use penpal_runtime::xcm_config::{LocalTeleportableToAssetHub, XcmConfig};

// Substrate
use frame_support::traits::OnInitialize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@
// limitations under the License.

use crate::*;
use kusama_system_emulated_network::penpal_emulated_chain::LocalTeleportableToAssetHubV3 as PenpalLocalTeleportableToAssetHubV3;
use kusama_system_emulated_network::penpal_emulated_chain::LocalTeleportableToAssetHub as PenpalLocalTeleportableToAssetHub;
use sp_runtime::ModuleError;
use system_parachains_constants::kusama::currency::SYSTEM_PARA_EXISTENTIAL_DEPOSIT;

#[test]
fn swap_locally_on_chain_using_local_assets() {
let asset_native = Box::new(asset_hub_kusama_runtime::xcm_config::KsmLocationV3::get());
let asset_native = Box::new(
v3::Location::try_from(asset_hub_kusama_runtime::xcm_config::KsmLocation::get())
.expect("conversion works"),
);
let asset_one = Box::new(v3::Location::new(
0,
[
Expand Down Expand Up @@ -116,9 +119,14 @@ fn swap_locally_on_chain_using_local_assets() {

#[test]
fn swap_locally_on_chain_using_foreign_assets() {
let asset_native = Box::new(asset_hub_kusama_runtime::xcm_config::KsmLocationV3::get());
let asset_native = Box::new(
v3::Location::try_from(asset_hub_kusama_runtime::xcm_config::KsmLocation::get())
.expect("conversion works"),
);

let ah_as_seen_by_penpal = PenpalA::sibling_location_of(AssetHubKusama::para_id());
let asset_location_on_penpal = PenpalLocalTeleportableToAssetHubV3::get();
let asset_location_on_penpal =
v3::Location::try_from(PenpalLocalTeleportableToAssetHub::get()).expect("conversion works");
let asset_id_on_penpal = match asset_location_on_penpal.last() {
Some(v3::Junction::GeneralIndex(id)) => *id as u32,
_ => unreachable!(),
Expand Down Expand Up @@ -242,11 +250,14 @@ fn swap_locally_on_chain_using_foreign_assets() {

#[test]
fn cannot_create_pool_from_pool_assets() {
let asset_native = asset_hub_kusama_runtime::xcm_config::KsmLocationV3::get();
let mut asset_one = asset_hub_kusama_runtime::xcm_config::PoolAssetsPalletLocationV3::get();
asset_one
.append_with(v3::Junction::GeneralIndex(ASSET_ID.into()))
.expect("pool assets");
let asset_native = asset_hub_kusama_runtime::xcm_config::KsmLocation::get()
.try_into()
.expect("conversion works");
let asset_one = asset_hub_kusama_runtime::xcm_config::PoolAssetsPalletLocation::get()
.appended_with(GeneralIndex(ASSET_ID.into()))
.expect("valid location")
.try_into()
.expect("conversion works");

AssetHubKusama::execute_with(|| {
let pool_owner_account_id = asset_hub_kusama_runtime::AssetConversionOrigin::get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::*;
use asset_hub_kusama_runtime::xcm_config::XcmConfig as AssetHubKusamaXcmConfig;
use emulated_integration_tests_common::xcm_helpers::non_fee_asset;
use kusama_runtime::xcm_config::XcmConfig as KusamaXcmConfig;
use kusama_system_emulated_network::penpal_emulated_chain::LocalTeleportableToAssetHubV3 as PenpalLocalTeleportableToAssetHubV3;
use kusama_system_emulated_network::penpal_emulated_chain::LocalTeleportableToAssetHub as PenpalLocalTeleportableToAssetHub;

fn relay_origin_assertions(t: RelayToSystemParaTest) {
type RuntimeEvent = <Kusama as Chain>::RuntimeEvent;
Expand Down Expand Up @@ -559,7 +559,8 @@ fn teleport_to_other_system_parachains_works() {
#[test]
fn bidirectional_teleport_foreign_assets_between_para_and_asset_hub() {
let ah_as_seen_by_penpal = PenpalA::sibling_location_of(AssetHubKusama::para_id());
let asset_location_on_penpal = PenpalLocalTeleportableToAssetHubV3::get();
let asset_location_on_penpal =
v3::Location::try_from(PenpalLocalTeleportableToAssetHub::get()).expect("conversion works");
let asset_id_on_penpal = match asset_location_on_penpal.last() {
Some(v3::Junction::GeneralIndex(id)) => *id as u32,
_ => unreachable!(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::*;
use asset_hub_polkadot_runtime::xcm_config::XcmConfig as AssetHubPolkadotXcmConfig;
use emulated_integration_tests_common::xcm_helpers::non_fee_asset;
use polkadot_runtime::xcm_config::XcmConfig as PolkadotXcmConfig;
use polkadot_system_emulated_network::penpal_emulated_chain::LocalTeleportableToAssetHubV3 as PenpalLocalTeleportableToAssetHubV3;
use polkadot_system_emulated_network::penpal_emulated_chain::LocalTeleportableToAssetHub as PenpalLocalTeleportableToAssetHub;

fn relay_origin_assertions(t: RelayToSystemParaTest) {
type RuntimeEvent = <Polkadot as Chain>::RuntimeEvent;
Expand Down Expand Up @@ -559,7 +559,8 @@ fn teleport_to_other_system_parachains_works() {
#[test]
fn bidirectional_teleport_foreign_assets_between_para_and_asset_hub() {
let ah_as_seen_by_penpal = PenpalB::sibling_location_of(AssetHubPolkadot::para_id());
let asset_location_on_penpal = PenpalLocalTeleportableToAssetHubV3::get();
let asset_location_on_penpal =
v3::Location::try_from(PenpalLocalTeleportableToAssetHub::get()).expect("conversion works");
let asset_id_on_penpal = match asset_location_on_penpal.last() {
Some(v3::Junction::GeneralIndex(id)) => *id as u32,
_ => unreachable!(),
Expand Down
2 changes: 0 additions & 2 deletions relay/kusama/src/governance/fellowship.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,15 +352,13 @@ impl pallet_ranked_collective::Config<FellowshipCollectiveInstance> for Runtime
TryMapSuccess<origins::EnsureFellowship, CheckedReduceBy<ConstU16<2>>>,
>,
>;
// TODO:(PR#187)(PR#2587): check ExchangeOrigin
// Exchange is by any of:
// - Root can exchange arbitrarily.
// - the Fellows origin
type ExchangeOrigin =
EitherOf<frame_system::EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>, Fellows>;
type Polls = FellowshipReferenda;
type MinRankOfClass = sp_runtime::traits::Identity;
// TODO:(PR#187)(PR#3156): check MemberSwappedHandler/BenchmarkSetup
type MemberSwappedHandler = ();
type VoteWeight = pallet_ranked_collective::Geometric;
#[cfg(feature = "runtime-benchmarks")]
Expand Down
4 changes: 2 additions & 2 deletions relay/kusama/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,9 @@ fn karura_liquid_staking_xcm_has_sane_weight_upper_limt() {
panic!("can't decode XCM blob")
};
let old_xcm_v3: xcm::v3::Xcm<super::RuntimeCall> =
old_xcm_v2.try_into().expect("conversion from v2 to v3 failed");
old_xcm_v2.try_into().expect("conversion from v2 to v3 works");
let mut xcm: Xcm<super::RuntimeCall> =
old_xcm_v3.try_into().expect("conversion from v3 to latest failed");
old_xcm_v3.try_into().expect("conversion from v3 to latest works");
let weight = <XcmConfig as xcm_executor::Config>::Weigher::weight(&mut xcm)
.expect("weighing XCM failed");

Expand Down
2 changes: 1 addition & 1 deletion relay/polkadot/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub type LocalAssetTransactor = FungibleAdapter<
Balances,
// Use this currency when it is a fungible asset matching the given location or name:
IsConcrete<TokenLocation>,
// We can convert the Locations with our converter above:
// We can convert the `Location`s with our converter above:
SovereignAccountOf,
// Our chain's account ID type (we can't get away without mentioning it explicitly):
AccountId,
Expand Down
10 changes: 4 additions & 6 deletions system-parachains/asset-hubs/asset-hub-kusama/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ parameter_types! {
PalletInstance(<ForeignAssets as PalletInfoAccess>::index() as u8).into();
pub PoolAssetsPalletLocation: Location =
PalletInstance(<PoolAssets as PalletInfoAccess>::index() as u8).into();
pub PoolAssetsPalletLocationV3: xcm::v3::Location =
xcm::v3::Junction::PalletInstance(<PoolAssets as PalletInfoAccess>::index() as u8).into();
pub CheckingAccount: AccountId = PolkadotXcm::check_account();
pub const GovernanceLocation: Location = Location::parent();
pub const FellowshipLocation: Location = Location::parent();
Expand Down Expand Up @@ -105,7 +103,7 @@ pub type FungibleTransactor = FungibleAdapter<
Balances,
// Use this currency when it is a fungible asset matching the given location or name:
IsConcrete<KsmLocation>,
// Convert an XCM Location into a local account id:
// Convert an XCM `Location` into a local account ID:
LocationToAccountId,
// Our chain's account ID type (we can't get away without mentioning it explicitly):
AccountId,
Expand All @@ -123,7 +121,7 @@ pub type FungiblesTransactor = FungiblesAdapter<
Assets,
// Use this currency when it is a fungible asset matching the given location or name:
TrustBackedAssetsConvertedConcreteId,
// Convert an XCM Location into a local account id:
// Convert an XCM `Location` into a local account ID:
LocationToAccountId,
// Our chain's account ID type (we can't get away without mentioning it explicitly):
AccountId,
Expand Down Expand Up @@ -155,7 +153,7 @@ pub type ForeignFungiblesTransactor = FungiblesAdapter<
ForeignAssets,
// Use this currency when it is a fungible asset matching the given location or name:
ForeignAssetsConvertedConcreteId,
// Convert an XCM Location into a local account id:
// Convert an XCM `Location` into a local account ID:
LocationToAccountId,
// Our chain's account ID type (we can't get away without mentioning it explicitly):
AccountId,
Expand All @@ -175,7 +173,7 @@ pub type PoolFungiblesTransactor = FungiblesAdapter<
PoolAssets,
// Use this currency when it is a fungible asset matching the given location or name:
PoolAssetsConvertedConcreteId,
// Convert an XCM Location into a local account id:
// Convert an XCM `Location` into a local account ID:
LocationToAccountId,
// Our chain's account ID type (we can't get away without mentioning it explicitly):
AccountId,
Expand Down
36 changes: 31 additions & 5 deletions system-parachains/asset-hubs/asset-hub-kusama/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,7 @@ fn collator_session_key(account: [u8; 32]) -> CollatorSessionKey<Runtime> {
}

fn collator_session_keys() -> CollatorSessionKeys<Runtime> {
CollatorSessionKeys::new(
AccountId::from(ALICE),
AccountId::from(ALICE),
SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) },
)
CollatorSessionKeys::default().add(collator_session_key(ALICE))
}

fn slot_durations() -> SlotDurations {
Expand Down Expand Up @@ -785,6 +781,36 @@ fn receive_reserve_asset_deposited_dot_from_asset_hub_polkadot_fees_paid_by_suff
)
}

#[test]
fn reserve_transfer_native_asset_to_non_teleport_para_works() {
asset_test_utils::test_cases::reserve_transfer_native_asset_to_non_teleport_para_works::<
Runtime,
AllPalletsWithoutSystem,
XcmConfig,
ParachainSystem,
XcmpQueue,
LocationToAccountId,
>(
collator_session_keys(),
slot_durations(),
ExistentialDeposit::get(),
AccountId::from(ALICE),
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,
}
}),
WeightLimit::Unlimited,
);
}

#[test]
fn report_bridge_status_from_xcm_bridge_router_for_polkadot_works() {
asset_test_utils::test_cases_over_bridge::report_bridge_status_from_xcm_bridge_router_works::<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub type FungibleTransactor = FungibleAdapter<
Balances,
// Use this currency when it is a fungible asset matching the given location or name:
IsConcrete<DotLocation>,
// Convert an XCM Location into a local account id:
// Convert an XCM `Location` into a local account ID:
LocationToAccountId,
// Our chain's account ID type (we can't get away without mentioning it explicitly):
AccountId,
Expand All @@ -114,7 +114,7 @@ pub type FungiblesTransactor = FungiblesAdapter<
Assets,
// Use this currency when it is a fungible asset matching the given location or name:
TrustBackedAssetsConvertedConcreteId,
// Convert an XCM Location into a local account id:
// Convert an XCM `Location` into a local account ID:
LocationToAccountId,
// Our chain's account ID type (we can't get away without mentioning it explicitly):
AccountId,
Expand Down Expand Up @@ -146,7 +146,7 @@ pub type ForeignFungiblesTransactor = FungiblesAdapter<
ForeignAssets,
// Use this currency when it is a fungible asset matching the given location or name:
ForeignAssetsConvertedConcreteId,
// Convert an XCM Location into a local account id:
// Convert an XCM `Location` into a local account ID:
LocationToAccountId,
// Our chain's account ID type (we can't get away without mentioning it explicitly):
AccountId,
Expand Down
39 changes: 31 additions & 8 deletions system-parachains/asset-hubs/asset-hub-polkadot/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ type AssetIdForTrustBackedAssetsConvertLatest =

type RuntimeHelper = asset_test_utils::RuntimeHelper<Runtime, AllPalletsWithoutSystem>;

// TODO:(PR#187) needs patched generic test not requiring pallet_asset_conversion (remove also
// #[allow(dead_code)]
#[allow(dead_code)]
fn collator_session_key(account: [u8; 32]) -> CollatorSessionKey<Runtime> {
CollatorSessionKey::new(
AccountId::from(account),
Expand All @@ -72,11 +69,7 @@ fn collator_session_key(account: [u8; 32]) -> CollatorSessionKey<Runtime> {
}

fn collator_session_keys() -> CollatorSessionKeys<Runtime> {
CollatorSessionKeys::new(
AccountId::from(ALICE),
AccountId::from(ALICE),
SessionKeys { aura: AuraId::from(sp_core::ed25519::Public::from_raw(ALICE)) },
)
CollatorSessionKeys::default().add(collator_session_key(ALICE))
}

fn slot_durations() -> SlotDurations {
Expand Down Expand Up @@ -799,6 +792,36 @@ fn receive_reserve_asset_deposited_ksm_from_asset_hub_kusama_fees_paid_by_suffic
)
}

#[test]
fn reserve_transfer_native_asset_to_non_teleport_para_works() {
asset_test_utils::test_cases::reserve_transfer_native_asset_to_non_teleport_para_works::<
Runtime,
AllPalletsWithoutSystem,
XcmConfig,
ParachainSystem,
XcmpQueue,
LocationToAccountId,
>(
collator_session_keys(),
slot_durations(),
ExistentialDeposit::get(),
AccountId::from(ALICE),
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,
}
}),
WeightLimit::Unlimited,
);
}

#[test]
fn report_bridge_status_from_xcm_bridge_router_for_kusama_works() {
asset_test_utils::test_cases_over_bridge::report_bridge_status_from_xcm_bridge_router_works::<
Expand Down
27 changes: 27 additions & 0 deletions system-parachains/bridge-hubs/bridge-hub-kusama/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,33 @@ fn initialize_bridge_by_governance_works() {
>(collator_session_keys(), bp_bridge_hub_kusama::BRIDGE_HUB_KUSAMA_PARACHAIN_ID)
}

#[test]
fn change_bridge_grandpa_pallet_mode_by_governance_works() {
// for Polkadot finality
bridge_hub_test_utils::test_cases::change_bridge_grandpa_pallet_mode_by_governance_works::<
Runtime,
BridgeGrandpaPolkadotInstance,
>(collator_session_keys(), bp_bridge_hub_kusama::BRIDGE_HUB_KUSAMA_PARACHAIN_ID)
}

#[test]
fn change_bridge_parachains_pallet_mode_by_governance_works() {
// for Polkadot parachains finality
bridge_hub_test_utils::test_cases::change_bridge_parachains_pallet_mode_by_governance_works::<
Runtime,
BridgeParachainPolkadotInstance,
>(collator_session_keys(), bp_bridge_hub_kusama::BRIDGE_HUB_KUSAMA_PARACHAIN_ID)
}

#[test]
fn change_bridge_messages_pallet_mode_by_governance_works() {
// for Polkadot messages
bridge_hub_test_utils::test_cases::change_bridge_messages_pallet_mode_by_governance_works::<
Runtime,
WithBridgeHubPolkadotMessagesInstance,
>(collator_session_keys(), bp_bridge_hub_kusama::BRIDGE_HUB_KUSAMA_PARACHAIN_ID)
}

#[test]
fn change_delivery_reward_by_governance_works() {
bridge_hub_test_utils::test_cases::change_storage_constant_by_governance_works::<
Expand Down
27 changes: 27 additions & 0 deletions system-parachains/bridge-hubs/bridge-hub-polkadot/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,33 @@ fn initialize_bridge_by_governance_works() {
>(collator_session_keys(), bp_bridge_hub_polkadot::BRIDGE_HUB_POLKADOT_PARACHAIN_ID)
}

#[test]
fn change_bridge_grandpa_pallet_mode_by_governance_works() {
// for Kusama finality
bridge_hub_test_utils::test_cases::change_bridge_grandpa_pallet_mode_by_governance_works::<
Runtime,
BridgeGrandpaKusamaInstance,
>(collator_session_keys(), bp_bridge_hub_polkadot::BRIDGE_HUB_POLKADOT_PARACHAIN_ID)
}

#[test]
fn change_bridge_parachains_pallet_mode_by_governance_works() {
// for Kusama parachains finality
bridge_hub_test_utils::test_cases::change_bridge_parachains_pallet_mode_by_governance_works::<
Runtime,
BridgeParachainKusamaInstance,
>(collator_session_keys(), bp_bridge_hub_polkadot::BRIDGE_HUB_POLKADOT_PARACHAIN_ID)
}

#[test]
fn change_bridge_messages_pallet_mode_by_governance_works() {
// for Kusama messages
bridge_hub_test_utils::test_cases::change_bridge_messages_pallet_mode_by_governance_works::<
Runtime,
WithBridgeHubKusamaMessagesInstance,
>(collator_session_keys(), bp_bridge_hub_polkadot::BRIDGE_HUB_POLKADOT_PARACHAIN_ID)
}

#[test]
fn change_delivery_reward_by_governance_works() {
bridge_hub_test_utils::test_cases::change_storage_constant_by_governance_works::<
Expand Down
Loading

0 comments on commit db374a6

Please sign in to comment.