Skip to content

Commit

Permalink
chore(pop-network): rebase & conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
al3mart committed Mar 23, 2024
2 parents c785630 + 74943ec commit 188f2aa
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 34 deletions.
10 changes: 2 additions & 8 deletions integration-tests/src/chains/pop_network/genesis.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use emulated_integration_tests_common::{accounts, build_genesis_storage, collators};
use emulated_integration_tests_common::{build_genesis_storage, collators};
use pop_runtime_common::Balance;
use sp_core::storage::Storage;

Expand All @@ -9,13 +9,7 @@ const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;
pub(crate) fn genesis() -> Storage {
let genesis_config = pop_runtime_devnet::RuntimeGenesisConfig {
system: pop_runtime_devnet::SystemConfig::default(),
balances: pop_runtime_devnet::BalancesConfig {
balances: accounts::init_balances()
.iter()
.cloned()
.map(|k| (k, ED * 4096 * 4096))
.collect(),
},
balances: pop_runtime_devnet::BalancesConfig { ..Default::default() },
parachain_info: pop_runtime_devnet::ParachainInfoConfig {
parachain_id: PARA_ID.into(),
..Default::default()
Expand Down
55 changes: 42 additions & 13 deletions integration-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ fn para_to_relay_reserve_transfer_assets(t: ParaToRelayTest) -> DispatchResult {
}

// Funds Pop with relay tokens
fn fund_pop_network(
fn fund_pop_from_relay(
sender: sp_runtime::AccountId32,
amount_to_send: Balance,
beneficiary: sp_runtime::AccountId32,
Expand All @@ -257,6 +257,25 @@ fn fund_pop_network(
test.assert();
}

// Funds Pop with relay tokens from system para
fn fund_pop_from_system_para(
sender: sp_runtime::AccountId32,
amount_to_send: Balance,
beneficiary: sp_runtime::AccountId32,
assets: Assets,
) {
let destination = AssetHubRococoPara::sibling_location_of(PopNetworkPara::para_id());
let test_args = TestContext {
sender,
receiver: beneficiary.clone(),
args: TestArgs::new_para(destination, beneficiary, amount_to_send, assets, None, 0),
};

let mut test = SystemParaToParaTest::new(test_args);
test.set_dispatchable::<AssetHubRococoPara>(system_para_to_para_reserve_transfer_assets);
test.assert();
}

/// Reserve Transfers of native asset from Relay to Parachain should work
#[test]
fn reserve_transfer_native_asset_from_relay_to_para() {
Expand Down Expand Up @@ -309,17 +328,18 @@ fn reserve_transfer_native_asset_from_para_to_relay() {

// Setup: reserve transfer from relay to Pop, so that sovereign account accurate for return
// transfer
let amount_to_send: Balance = ROCOCO_ED * 1000;
fund_pop_network(RococoRelaySender::get(), amount_to_send, PopNetworkParaReceiver::get());
let amount_to_send: Balance = ROCOCO_ED * 1_000;
fund_pop_from_relay(RococoRelaySender::get(), amount_to_send, PopNetworkParaReceiver::get()); // alice on relay > bob on pop

// Init values for Pop Network Parachain
let destination = PopNetworkPara::parent_location();
let beneficiary_id = RococoRelayReceiver::get();
let destination = PopNetworkPara::parent_location(); // relay
let beneficiary_id = RococoRelayReceiver::get(); // bob on relay
let amount_to_send = PopNetworkPara::account_data_of(PopNetworkParaReceiver::get()).free; // bob on pop balance
let assets = (Parent, amount_to_send).into();

let test_args = TestContext {
sender: PopNetworkParaSender::get(),
receiver: RococoRelayReceiver::get(),
sender: PopNetworkParaReceiver::get(), // bob on pop
receiver: RococoRelayReceiver::get(), // bob on relay
args: TestArgs::new_para(destination, beneficiary_id, amount_to_send, assets, None, 0),
};

Expand Down Expand Up @@ -403,15 +423,24 @@ fn reserve_transfer_native_asset_from_system_para_to_para() {
fn reserve_transfer_native_asset_from_para_to_system_para() {
init_tracing();

// Setup: reserve transfer from AH to Pop, so that sovereign account accurate for return transfer
let amount_to_send: Balance = ASSET_HUB_ROCOCO_ED * 1000;
fund_pop_from_system_para(
AssetHubRococoParaSender::get(),
amount_to_send,
PopNetworkParaReceiver::get(),
(Parent, amount_to_send).into(),
); // alice on asset hub > bob on pop

// Init values for Pop Network Parachain
let destination = PopNetworkPara::sibling_location_of(AssetHubRococoPara::para_id());
let beneficiary_id = AssetHubRococoParaReceiver::get();
let amount_to_send: Balance = ASSET_HUB_ROCOCO_ED * 1000;
let beneficiary_id = AssetHubRococoParaReceiver::get(); // bob on asset hub
let amount_to_send = PopNetworkPara::account_data_of(PopNetworkParaReceiver::get()).free; // bob on pop balance
let assets = (Parent, amount_to_send).into();

let test_args = TestContext {
sender: PopNetworkParaSender::get(),
receiver: AssetHubRococoParaReceiver::get(),
sender: PopNetworkParaReceiver::get(), // bob on pop
receiver: AssetHubRococoParaReceiver::get(), // bob on asset hub
args: TestArgs::new_para(destination, beneficiary_id, amount_to_send, assets, None, 0),
};

Expand All @@ -425,7 +454,7 @@ fn reserve_transfer_native_asset_from_para_to_system_para() {
let sov_pop_net_on_ahr =
AssetHubRococoPara::sovereign_account_id_of(pop_net_location_as_seen_by_ahr);

// fund the Pop Network's SA on AHR with the native tokens held in reserve
// fund Pop Network's SA on AHR with the native tokens held in reserve
AssetHubRococoPara::fund_accounts(vec![(sov_pop_net_on_ahr.into(), amount_to_send * 2)]);

test.set_assertion::<PopNetworkPara>(para_to_system_para_sender_assertions);
Expand Down Expand Up @@ -460,7 +489,7 @@ fn place_coretime_spot_order_from_para_to_relay() {

// Setup: reserve transfer from relay to Pop, so that sovereign account accurate for return transfer
let amount_to_send: Balance = pop_runtime_devnet::UNIT * 1000;
fund_pop_network(RococoRelaySender::get(), amount_to_send, beneficiary.clone());
fund_pop_from_relay(RococoRelaySender::get(), amount_to_send, beneficiary.clone());

let message = {
let assets: Asset = (Here, 10 * pop_runtime_devnet::UNIT).into();
Expand Down
11 changes: 0 additions & 11 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,6 @@ pub fn testnet_config(relay: Relay) -> TestnetChainSpec {
// POP COLLATOR 1
(collator_1_account_id.clone(), collator_1_aura_id),
],
vec![
// Collator stashes
collator_0_account_id,
collator_1_account_id,
// SUDO account
sudo_account_id.clone(),
],
sudo_account_id,
para_id.into(),
))
Expand All @@ -211,16 +204,12 @@ pub fn testnet_config(relay: Relay) -> TestnetChainSpec {

fn testnet_genesis(
invulnerables: Vec<(AccountId, AuraId)>,
endowed_accounts: Vec<AccountId>,
root: AccountId,
id: ParaId,
) -> serde_json::Value {
use pop_runtime_testnet::EXISTENTIAL_DEPOSIT;

serde_json::json!({
"balances": {
"balances": endowed_accounts.iter().cloned().map(|k| (k, 1u64 << 60)).collect::<Vec<_>>(),
},
"parachainInfo": {
"parachainId": id,
},
Expand Down
23 changes: 21 additions & 2 deletions runtime/testnet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ use frame_support::{
parameter_types,
traits::{
fungible::HoldConsideration, tokens::nonfungibles_v2::Inspect, ConstBool, ConstU32,
ConstU64, ConstU8, EitherOfDiverse, EqualPrivilegeOnly, LinearStoragePrice,
TransformOrigin,
ConstU64, ConstU8, Contains, EitherOfDiverse, EqualPrivilegeOnly, EverythingBut,
LinearStoragePrice, TransformOrigin,
},
weights::{
ConstantMultiplier, Weight, WeightToFeeCoefficient, WeightToFeeCoefficients,
Expand Down Expand Up @@ -255,6 +255,23 @@ parameter_types! {
pub const SS58Prefix: u16 = 42;
}

/// A type to identify filtered calls.
pub struct FilteredCalls;
impl Contains<RuntimeCall> for FilteredCalls {
fn contains(c: &RuntimeCall) -> bool {
use BalancesCall::*;
matches!(
c,
RuntimeCall::Balances(
force_adjust_total_issuance { .. }
| force_set_balance { .. }
| force_transfer { .. }
| force_unreserve { .. }
)
)
}
}

/// The default types are being injected by [`derive_impl`](`frame_support::derive_impl`) from
/// [`ParaChainDefaultConfig`](`struct@frame_system::config_preludes::ParaChainDefaultConfig`),
/// but overridden as needed.
Expand Down Expand Up @@ -282,6 +299,8 @@ impl frame_system::Config for Runtime {
type BlockLength = RuntimeBlockLength;
/// This is used as an identifier of the chain. 42 is the generic substrate prefix.
type SS58Prefix = SS58Prefix;
/// The basic call filter to use in dispatchable. Supports everything as the default.
type BaseCallFilter = EverythingBut<FilteredCalls>;
/// The action to take on a Runtime Upgrade
type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
type MaxConsumers = frame_support::traits::ConstU32<16>;
Expand Down

0 comments on commit 188f2aa

Please sign in to comment.