Allow two Parachains to swap (#4772)

* add support for parachain to parachain swap

* enable swaps on kusama

* sanity test in paras_registrar

* express more errors

* finish up tests

* fmt

* make fields pub

* refactor integration tests to use real accounts

* Update Crowdloan Account to FundIndex (#4824)

* update fund account to use index

* fix integration tests

* Update runtime/common/src/crowdloan.rs

* finish parachain swap test

* format

* fix warning

* fix spacing

* fix formatting

* write migrations

* add migration

* fixes

* more fixes to migration

* Update runtime/common/src/crowdloan/mod.rs

Co-authored-by: Zeke Mostov <z.mostov@gmail.com>

* Update runtime/common/src/paras_registrar.rs

* Update migration.rs

* extract swap function

Co-authored-by: Zeke Mostov <z.mostov@gmail.com>
This commit is contained in:
Shawn Tabrizi
2022-02-12 18:16:22 +01:00
committed by GitHub
parent 85f4740591
commit d5f5127354
8 changed files with 811 additions and 247 deletions
+22 -4
View File
@@ -138,11 +138,11 @@ pub fn native_version() -> NativeVersion {
NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
}
/// Don't allow swaps until parathread story is more mature.
/// We currently allow all calls.
pub struct BaseFilter;
impl Contains<Call> for BaseFilter {
fn contains(c: &Call) -> bool {
!matches!(c, Call::Registrar(paras_registrar::Call::swap { .. }))
fn contains(_c: &Call) -> bool {
true
}
}
@@ -1497,7 +1497,7 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
(SchedulerMigrationV3, RefundNickPalletDeposit),
(SchedulerMigrationV3, RefundNickPalletDeposit, CrowdloanIndexMigration),
>;
/// The payload being signed in the transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
@@ -2929,6 +2929,24 @@ impl OnRuntimeUpgrade for SchedulerMigrationV3 {
}
}
// Migration for crowdloan pallet to use fund index for account generation.
pub struct CrowdloanIndexMigration;
impl OnRuntimeUpgrade for CrowdloanIndexMigration {
fn on_runtime_upgrade() -> frame_support::weights::Weight {
crowdloan::migration::crowdloan_index_migration::migrate::<Runtime>()
}
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<(), &'static str> {
crowdloan::migration::crowdloan_index_migration::pre_migrate::<Runtime>()
}
#[cfg(feature = "try-runtime")]
fn post_upgrade() -> Result<(), &'static str> {
crowdloan::migration::crowdloan_index_migration::post_migrate::<Runtime>()
}
}
/// Migrate session-historical from `Session` to the new pallet prefix `Historical`
pub struct SessionHistoricalPalletPrefixMigration;