From 9babb099003e85bf7c0f74691a5303f68398a6f8 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Fri, 9 Apr 2021 21:07:49 +0200 Subject: [PATCH] Introduce System Parachains into Registrar (#2858) * initial stuff * adjust deposit * remove unused * weight stuff * Update integration_tests.rs * Update paras_registrar.rs * Update paras_registrar.rs * add test * Update paras_registrar.rs Co-authored-by: parity-processbot <> --- polkadot/parachain/src/primitives.rs | 5 - .../runtime/common/src/integration_tests.rs | 216 +++++++++--------- .../runtime/common/src/paras_registrar.rs | 206 +++++++++++------ polkadot/runtime/common/src/slots.rs | 22 -- 4 files changed, 241 insertions(+), 208 deletions(-) diff --git a/polkadot/parachain/src/primitives.rs b/polkadot/parachain/src/primitives.rs index e4f68a9acc..b022221e7f 100644 --- a/polkadot/parachain/src/primitives.rs +++ b/polkadot/parachain/src/primitives.rs @@ -131,11 +131,6 @@ impl Id { pub const fn new(id: u32) -> Self { Self(id) } - - /// Returns `true` if this parachain runs with system-level privileges. - /// Use IsSystem instead. - #[deprecated] - pub fn is_system(&self) -> bool { self.0 < USER_INDEX_START } } pub trait IsSystem { diff --git a/polkadot/runtime/common/src/integration_tests.rs b/polkadot/runtime/common/src/integration_tests.rs index 437db53480..83bbe3b466 100644 --- a/polkadot/runtime/common/src/integration_tests.rs +++ b/polkadot/runtime/common/src/integration_tests.rs @@ -300,20 +300,20 @@ fn basic_end_to_end_works() { let validation_code = Registrar::worst_validation_code(); assert_ok!(Registrar::register( Origin::signed(1), - ParaId::from(1), + ParaId::from(1001), genesis_head.clone(), validation_code.clone(), )); assert_ok!(Registrar::register( Origin::signed(2), - ParaId::from(2), + ParaId::from(1002), genesis_head, validation_code, )); // Paras should be onboarding - assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::Onboarding)); - assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::Onboarding)); + assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::Onboarding)); + assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::Onboarding)); // Start a new auction in the future let duration = 99u32; @@ -322,21 +322,21 @@ fn basic_end_to_end_works() { // 2 sessions later they are parathreads run_to_session(2); - assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::Parathread)); - assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::Parathread)); + assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::Parathread)); + assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::Parathread)); // Para 1 will bid directly for slot 1, 2 // Open a crowdloan for Para 2 for slot 3, 4 assert_ok!(Crowdloan::create( Origin::signed(2), - ParaId::from(2), + ParaId::from(1002), 1_000, // Cap lease_period_index_start + 2, // First Slot lease_period_index_start + 3, // Last Slot 200, // Block End None, )); - let crowdloan_account = Crowdloan::fund_account_id(ParaId::from(2)); + let crowdloan_account = Crowdloan::fund_account_id(ParaId::from(1002)); // Auction ending begins on block 100, so we make a bid before then. run_to_block(90); @@ -347,7 +347,7 @@ fn basic_end_to_end_works() { // User 10 will bid directly for parachain 1 assert_ok!(Auctions::bid( Origin::signed(10), - ParaId::from(1), + ParaId::from(1001), 1, // Auction Index lease_period_index_start + 0, // First Slot lease_period_index_start + 1, // Last slot @@ -356,13 +356,13 @@ fn basic_end_to_end_works() { // User 2 will be a contribute to crowdloan for parachain 2 Balances::make_free_balance_be(&2, 1_000); - assert_ok!(Crowdloan::contribute(Origin::signed(2), ParaId::from(2), 920, None)); + assert_ok!(Crowdloan::contribute(Origin::signed(2), ParaId::from(1002), 920, None)); // Auction ends at block 110 run_to_block(109); assert_eq!( last_event(), - crowdloan::RawEvent::HandleBidResult(ParaId::from(2), Ok(())).into(), + crowdloan::RawEvent::HandleBidResult(ParaId::from(1002), Ok(())).into(), ); run_to_block(110); assert_eq!( @@ -372,62 +372,62 @@ fn basic_end_to_end_works() { // Paras should have won slots assert_eq!( - slots::Leases::::get(ParaId::from(1)), + slots::Leases::::get(ParaId::from(1001)), // -- 1 --- 2 --- 3 --------- 4 ------------ 5 -------- vec![None, None, None, Some((10, 910)), Some((10, 910))], ); assert_eq!( - slots::Leases::::get(ParaId::from(2)), + slots::Leases::::get(ParaId::from(1002)), // -- 1 --- 2 --- 3 --- 4 --- 5 ---------------- 6 --------------------------- 7 ---------------- vec![None, None, None, None, None, Some((crowdloan_account, 920)), Some((crowdloan_account, 920))], ); // Should not be able to contribute to a winning crowdloan Balances::make_free_balance_be(&3, 1_000); - assert_noop!(Crowdloan::contribute(Origin::signed(3), ParaId::from(2), 10, None), CrowdloanError::::BidOrLeaseActive); + assert_noop!(Crowdloan::contribute(Origin::signed(3), ParaId::from(1002), 10, None), CrowdloanError::::BidOrLeaseActive); // New leases will start on block 400 let lease_start_block = 400; run_to_block(lease_start_block); // First slot, Para 1 should be transitioning to Parachain - assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::UpgradingParathread)); - assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::Parathread)); + assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::UpgradingParathread)); + assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::Parathread)); // Two sessions later, it has upgraded run_to_block(lease_start_block + 20); - assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::Parachain)); - assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::Parathread)); + assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::Parachain)); + assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::Parathread)); // Second slot nothing happens :) run_to_block(lease_start_block + 100); - assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::Parachain)); - assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::Parathread)); + assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::Parachain)); + assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::Parathread)); // Third slot, Para 2 should be upgrading, and Para 1 is downgrading run_to_block(lease_start_block + 200); - assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::DowngradingParachain)); - assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::UpgradingParathread)); + assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::DowngradingParachain)); + assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::UpgradingParathread)); // Two sessions later, they have transitioned run_to_block(lease_start_block + 220); - assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::Parathread)); - assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::Parachain)); + assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::Parathread)); + assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::Parachain)); // Fourth slot nothing happens :) run_to_block(lease_start_block + 300); - assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::Parathread)); - assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::Parachain)); + assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::Parathread)); + assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::Parachain)); // Fifth slot, Para 2 is downgrading run_to_block(lease_start_block + 400); - assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::Parathread)); - assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::DowngradingParachain)); + assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::Parathread)); + assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::DowngradingParachain)); // Two sessions later, Para 2 is downgraded run_to_block(lease_start_block + 420); - assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::Parathread)); - assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::Parathread)); + assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::Parathread)); + assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::Parathread)); }); } @@ -443,13 +443,13 @@ fn basic_errors_fail() { let validation_code = Registrar::worst_validation_code(); assert_ok!(Registrar::register( Origin::signed(1), - ParaId::from(1), + ParaId::from(1001), genesis_head.clone(), validation_code.clone(), )); assert_noop!(Registrar::register( Origin::signed(2), - ParaId::from(1), + ParaId::from(1001), genesis_head, validation_code, ), paras_registrar::Error::::AlreadyRegistered); @@ -462,7 +462,7 @@ fn basic_errors_fail() { // Cannot create a crowdloan if you do not own the para assert_noop!(Crowdloan::create( Origin::signed(2), - ParaId::from(1), + ParaId::from(1001), 1_000, // Cap lease_period_index_start + 2, // First Slot lease_period_index_start + 3, // Last Slot @@ -486,7 +486,7 @@ fn competing_slots() { let validation_code = Registrar::worst_validation_code(); assert_ok!(Registrar::register( Origin::signed(n), - ParaId::from(n), + ParaId::from(1000 + n), genesis_head, validation_code, )); @@ -523,7 +523,7 @@ fn competing_slots() { // Users will bid directly for parachain assert_ok!(Auctions::bid( Origin::signed(n * 10), - ParaId::from(n), + ParaId::from(1000 + n), 1, // Auction Index lease_period_index_start + start, // First Slot lease_period_index_start + end, // Last slot @@ -543,18 +543,18 @@ fn competing_slots() { // 900 + 4500 + 2x 8100 = 21,600 // 900 + 4500 + 7200 + 9000 = 21,600 assert_eq!( - slots::Leases::::get(ParaId::from(1)), + slots::Leases::::get(ParaId::from(1001)), // -- 1 --- 2 --- 3 ---------- 4 ------ vec![None, None, None, Some((10, 900))], ); assert_eq!( - slots::Leases::::get(ParaId::from(5)), + slots::Leases::::get(ParaId::from(1005)), // -- 1 --- 2 --- 3 --- 4 ---------- 5 ------- vec![None, None, None, None, Some((50, 4500))], ); // TODO: Is this right? assert_eq!( - slots::Leases::::get(ParaId::from(9)), + slots::Leases::::get(ParaId::from(1009)), // -- 1 --- 2 --- 3 --- 4 --- 5 ---------- 6 --------------- 7 ------- vec![None, None, None, None, None, Some((90, 8100)), Some((90, 8100))], ); @@ -578,7 +578,7 @@ fn competing_bids() { let validation_code = Registrar::worst_validation_code(); assert_ok!(Registrar::register( Origin::signed(n), - ParaId::from(n), + ParaId::from(1000 + n), genesis_head, validation_code, )); @@ -586,7 +586,7 @@ fn competing_bids() { // Create a crowdloan for each para assert_ok!(Crowdloan::create( Origin::signed(n), - ParaId::from(n), + ParaId::from(1000 + n), 100_000, // Cap lease_period_index_start + 2, // First Slot lease_period_index_start + 3, // Last Slot @@ -601,7 +601,7 @@ fn competing_bids() { Balances::make_free_balance_be(&(n * 10), n * 1_000); - let para = n % 3 + 1; + let para = n % 3 + 1001; if n % 2 == 0 { // User 10 will bid directly for parachain 1 @@ -628,14 +628,14 @@ fn competing_bids() { run_to_block(110); // Appropriate Paras should have won slots - let crowdloan_2 = Crowdloan::fund_account_id(ParaId::from(2)); + let crowdloan_2 = Crowdloan::fund_account_id(ParaId::from(1002)); assert_eq!( - slots::Leases::::get(ParaId::from(1)), + slots::Leases::::get(ParaId::from(1001)), // -- 1 --- 2 --- 3 --- 4 --- 5 ------------- 6 ------------------------ 7 ------------- vec![None, None, None, None, None, Some((crowdloan_2, 1812)), Some((crowdloan_2, 1812))], ); assert_eq!( - slots::Leases::::get(ParaId::from(3)), + slots::Leases::::get(ParaId::from(1003)), // -- 1 --- 2 --- 3 ---------- 4 --------------- 5 ------- vec![None, None, None, Some((80, 7200)), Some((80, 7200))], ); @@ -653,20 +653,20 @@ fn basic_swap_works() { // First register 2 parathreads with different data assert_ok!(Registrar::register( Origin::signed(1), - ParaId::from(1), + ParaId::from(1001), test_genesis_head(10), test_validation_code(10), )); assert_ok!(Registrar::register( Origin::signed(2), - ParaId::from(2), + ParaId::from(1002), test_genesis_head(20), test_validation_code(20), )); // Paras should be onboarding - assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::Onboarding)); - assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::Onboarding)); + assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::Onboarding)); + assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::Onboarding)); // Start a new auction in the future let duration = 99u32; @@ -675,27 +675,26 @@ fn basic_swap_works() { // 2 sessions later they are parathreads run_to_session(2); - assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::Parathread)); - assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::Parathread)); + assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::Parathread)); + assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::Parathread)); // Open a crowdloan for Para 1 for slots 0-3 assert_ok!(Crowdloan::create( Origin::signed(1), - ParaId::from(1), + ParaId::from(1001), 1_000_000, // Cap lease_period_index_start + 0, // First Slot lease_period_index_start + 3, // Last Slot 200, // Block End None, )); - // TODO: Check why this is the same for all paras - let crowdloan_account = Crowdloan::fund_account_id(ParaId::from(1)); + let crowdloan_account = Crowdloan::fund_account_id(ParaId::from(1001)); // Bunch of contributions let mut total = 0; for i in 10 .. 20 { Balances::make_free_balance_be(&i, 1_000); - assert_ok!(Crowdloan::contribute(Origin::signed(i), ParaId::from(1), 900 - i, None)); + assert_ok!(Crowdloan::contribute(Origin::signed(i), ParaId::from(1001), 900 - i, None)); total += 900 - i; } assert!(total > 0); @@ -710,49 +709,49 @@ fn basic_swap_works() { assert_eq!(Balances::reserved_balance(&2), 500 + 20 * 2 * 1); assert_eq!(Balances::reserved_balance(&crowdloan_account), total); // Crowdloan is appropriately set - assert!(Crowdloan::funds(ParaId::from(1)).is_some()); - assert!(Crowdloan::funds(ParaId::from(2)).is_none()); + assert!(Crowdloan::funds(ParaId::from(1001)).is_some()); + assert!(Crowdloan::funds(ParaId::from(1002)).is_none()); // New leases will start on block 400 let lease_start_block = 400; run_to_block(lease_start_block); // Slots are won by Para 1 - assert!(!Slots::lease(ParaId::from(1)).is_empty()); - assert!(Slots::lease(ParaId::from(2)).is_empty()); + assert!(!Slots::lease(ParaId::from(1001)).is_empty()); + assert!(Slots::lease(ParaId::from(1002)).is_empty()); // 2 sessions later it is a parachain run_to_block(lease_start_block + 20); - assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::Parachain)); - assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::Parathread)); + assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::Parachain)); + assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::Parathread)); // Initiate a swap - assert_ok!(Registrar::swap(para_origin(1).into(), ParaId::from(1), ParaId::from(2))); - assert_ok!(Registrar::swap(para_origin(2).into(), ParaId::from(2), ParaId::from(1))); + assert_ok!(Registrar::swap(para_origin(1001).into(), ParaId::from(1001), ParaId::from(1002))); + assert_ok!(Registrar::swap(para_origin(1002).into(), ParaId::from(1002), ParaId::from(1001))); - assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::DowngradingParachain)); - assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::UpgradingParathread)); + assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::DowngradingParachain)); + assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::UpgradingParathread)); // 2 session later they have swapped run_to_block(lease_start_block + 40); - assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::Parathread)); - assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::Parachain)); + assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::Parathread)); + assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::Parachain)); // Deregister parathread - assert_ok!(Registrar::deregister(para_origin(1).into(), ParaId::from(1))); + assert_ok!(Registrar::deregister(para_origin(1001).into(), ParaId::from(1001))); // Correct deposit is unreserved assert_eq!(Balances::reserved_balance(&1), 100); // crowdloan deposit left over assert_eq!(Balances::reserved_balance(&2), 500 + 20 * 2 * 1); // Crowdloan ownership is swapped - assert!(Crowdloan::funds(ParaId::from(1)).is_none()); - assert!(Crowdloan::funds(ParaId::from(2)).is_some()); + assert!(Crowdloan::funds(ParaId::from(1001)).is_none()); + assert!(Crowdloan::funds(ParaId::from(1002)).is_some()); // Slot is swapped - assert!(Slots::lease(ParaId::from(1)).is_empty()); - assert!(!Slots::lease(ParaId::from(2)).is_empty()); + assert!(Slots::lease(ParaId::from(1001)).is_empty()); + assert!(!Slots::lease(ParaId::from(1002)).is_empty()); // Cant dissolve - assert_noop!(Crowdloan::dissolve(Origin::signed(1), ParaId::from(1)), CrowdloanError::::InvalidParaId); - assert_noop!(Crowdloan::dissolve(Origin::signed(2), ParaId::from(2)), CrowdloanError::::NotReadyToDissolve); + assert_noop!(Crowdloan::dissolve(Origin::signed(1), ParaId::from(1001)), CrowdloanError::::InvalidParaId); + assert_noop!(Crowdloan::dissolve(Origin::signed(2), ParaId::from(1002)), CrowdloanError::::NotReadyToDissolve); // Go way in the future when the para is offboarded run_to_block(lease_start_block + 1000); @@ -760,17 +759,17 @@ fn basic_swap_works() { // Withdraw of contributions works assert_eq!(Balances::free_balance(&crowdloan_account), total); for i in 10 .. 20 { - assert_ok!(Crowdloan::withdraw(Origin::signed(i), i, ParaId::from(2))); + assert_ok!(Crowdloan::withdraw(Origin::signed(i), i, ParaId::from(1002))); } assert_eq!(Balances::free_balance(&crowdloan_account), 0); // Dissolve returns the balance of the person who put a deposit for crowdloan - assert_ok!(Crowdloan::dissolve(Origin::signed(1), ParaId::from(2))); + assert_ok!(Crowdloan::dissolve(Origin::signed(1), ParaId::from(1002))); assert_eq!(Balances::reserved_balance(&1), 0); assert_eq!(Balances::reserved_balance(&2), 500 + 20 * 2 * 1); // Final deregister sets everything back to the start - assert_ok!(Registrar::deregister(para_origin(2).into(), ParaId::from(2))); + assert_ok!(Registrar::deregister(para_origin(1002).into(), ParaId::from(1002))); assert_eq!(Balances::reserved_balance(&2), 0); }) } @@ -785,20 +784,20 @@ fn crowdloan_ending_period_bid() { // First register 2 parathreads assert_ok!(Registrar::register( Origin::signed(1), - ParaId::from(1), + ParaId::from(1001), test_genesis_head(10), test_validation_code(10), )); assert_ok!(Registrar::register( Origin::signed(2), - ParaId::from(2), + ParaId::from(1002), test_genesis_head(20), test_validation_code(20), )); // Paras should be onboarding - assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::Onboarding)); - assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::Onboarding)); + assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::Onboarding)); + assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::Onboarding)); // Start a new auction in the future let duration = 99u32; @@ -807,27 +806,26 @@ fn crowdloan_ending_period_bid() { // 2 sessions later they are parathreads run_to_session(2); - assert_eq!(Paras::lifecycle(ParaId::from(1)), Some(ParaLifecycle::Parathread)); - assert_eq!(Paras::lifecycle(ParaId::from(2)), Some(ParaLifecycle::Parathread)); + assert_eq!(Paras::lifecycle(ParaId::from(1001)), Some(ParaLifecycle::Parathread)); + assert_eq!(Paras::lifecycle(ParaId::from(1002)), Some(ParaLifecycle::Parathread)); // Open a crowdloan for Para 1 for slots 0-3 assert_ok!(Crowdloan::create( Origin::signed(1), - ParaId::from(1), + ParaId::from(1001), 1_000_000, // Cap lease_period_index_start + 0, // First Slot lease_period_index_start + 3, // Last Slot 200, // Block End None, )); - // TODO: Check why this is the same for all paras - let crowdloan_account = Crowdloan::fund_account_id(ParaId::from(1)); + let crowdloan_account = Crowdloan::fund_account_id(ParaId::from(1001)); // Bunch of contributions let mut total = 0; for i in 10 .. 20 { Balances::make_free_balance_be(&i, 1_000); - assert_ok!(Crowdloan::contribute(Origin::signed(i), ParaId::from(1), 900 - i, None)); + assert_ok!(Crowdloan::contribute(Origin::signed(i), ParaId::from(1001), 900 - i, None)); total += 900 - i; } assert!(total > 0); @@ -837,7 +835,7 @@ fn crowdloan_ending_period_bid() { Balances::make_free_balance_be(&2, 1_000); assert_ok!(Auctions::bid( Origin::signed(2), - ParaId::from(2), + ParaId::from(1002), 1, // Auction Index lease_period_index_start + 0, // First Slot lease_period_index_start + 1, // Last slot @@ -852,9 +850,9 @@ fn crowdloan_ending_period_bid() { assert_eq!(Auctions::winning(0), Some( [ None, // 0-0 - Some((2, ParaId::from(2), 900)), // 0-1 + Some((2, ParaId::from(1002), 900)), // 0-1 None, // 0-2 - Some((crowdloan_account, ParaId::from(1), total)), // 0-3 + Some((crowdloan_account, ParaId::from(1001), total)), // 0-3 None, // 1-1 None, // 1-2 None, // 1-3 @@ -867,16 +865,16 @@ fn crowdloan_ending_period_bid() { run_to_block(101); Balances::make_free_balance_be(&1234, 1_000); - assert_ok!(Crowdloan::contribute(Origin::signed(1234), ParaId::from(1), 900, None)); + assert_ok!(Crowdloan::contribute(Origin::signed(1234), ParaId::from(1001), 900, None)); // Data propagates correctly run_to_block(102); assert_eq!(Auctions::winning(2), Some( [ None, // 0-0 - Some((2, ParaId::from(2), 900)), // 0-1 + Some((2, ParaId::from(1002), 900)), // 0-1 None, // 0-2 - Some((crowdloan_account, ParaId::from(1), total + 900)), // 0-3 + Some((crowdloan_account, ParaId::from(1001), total + 900)), // 0-3 None, // 1-1 None, // 1-2 None, // 1-3 @@ -902,7 +900,7 @@ fn auction_bid_requires_registered_para() { Balances::make_free_balance_be(&1, 1_000); assert_noop!(Auctions::bid( Origin::signed(1), - ParaId::from(1), + ParaId::from(1001), 1, // Auction Index lease_period_index_start + 0, // First Slot lease_period_index_start + 1, // Last slot @@ -912,7 +910,7 @@ fn auction_bid_requires_registered_para() { // Now we register the para assert_ok!(Registrar::register( Origin::signed(1), - ParaId::from(1), + ParaId::from(1001), test_genesis_head(10), test_validation_code(10), )); @@ -920,7 +918,7 @@ fn auction_bid_requires_registered_para() { // Still can't bid until it is fully onboarded assert_noop!(Auctions::bid( Origin::signed(1), - ParaId::from(1), + ParaId::from(1001), 1, // Auction Index lease_period_index_start + 0, // First Slot lease_period_index_start + 1, // Last slot @@ -934,7 +932,7 @@ fn auction_bid_requires_registered_para() { Balances::make_free_balance_be(&1, 1_000); assert_ok!(Auctions::bid( Origin::signed(1), - ParaId::from(1), + ParaId::from(1001), 1, // Auction Index lease_period_index_start + 0, // First Slot lease_period_index_start + 1, // Last slot @@ -958,13 +956,13 @@ fn gap_bids_work() { // Now register 2 paras assert_ok!(Registrar::register( Origin::signed(1), - ParaId::from(1), + ParaId::from(1001), test_genesis_head(10), test_validation_code(10), )); assert_ok!(Registrar::register( Origin::signed(2), - ParaId::from(2), + ParaId::from(1002), test_genesis_head(10), test_validation_code(10), )); @@ -978,7 +976,7 @@ fn gap_bids_work() { // Slot 1 for 100 from 10 assert_ok!(Auctions::bid( Origin::signed(10), - ParaId::from(1), + ParaId::from(1001), 1, // Auction Index lease_period_index_start + 0, // First Slot lease_period_index_start + 0, // Last slot @@ -987,7 +985,7 @@ fn gap_bids_work() { // Slot 4 for 400 from 10 assert_ok!(Auctions::bid( Origin::signed(10), - ParaId::from(1), + ParaId::from(1001), 1, // Auction Index lease_period_index_start + 3, // First Slot lease_period_index_start + 3, // Last slot @@ -997,7 +995,7 @@ fn gap_bids_work() { // A bid for another para is counted separately. assert_ok!(Auctions::bid( Origin::signed(10), - ParaId::from(2), + ParaId::from(1002), 1, // Auction Index lease_period_index_start + 1, // First Slot lease_period_index_start + 1, // Last slot @@ -1008,7 +1006,7 @@ fn gap_bids_work() { // Slot 2 for 800 from 20, overtaking 10's bid assert_ok!(Auctions::bid( Origin::signed(20), - ParaId::from(1), + ParaId::from(1001), 1, // Auction Index lease_period_index_start + 1, // First Slot lease_period_index_start + 1, // Last slot @@ -1017,7 +1015,7 @@ fn gap_bids_work() { // Slot 3 for 200 from 20 assert_ok!(Auctions::bid( Origin::signed(20), - ParaId::from(1), + ParaId::from(1001), 1, // Auction Index lease_period_index_start + 2, // First Slot lease_period_index_start + 2, // Last slot @@ -1029,7 +1027,7 @@ fn gap_bids_work() { // Should have won the lease periods assert_eq!( - slots::Leases::::get(ParaId::from(1)), + slots::Leases::::get(ParaId::from(1001)), // -- 1 --- 2 --- 3 ---------- 4 -------------- 5 -------------- 6 -------------- 7 ------- vec![None, None, None, Some((10, 100)), Some((20, 800)), Some((20, 200)), Some((10, 400))], ); @@ -1042,7 +1040,7 @@ fn gap_bids_work() { run_to_block(400); assert_eq!( - slots::Leases::::get(ParaId::from(1)), + slots::Leases::::get(ParaId::from(1001)), // --------- 4 -------------- 5 -------------- 6 -------------- 7 ------- vec![Some((10, 100)), Some((20, 800)), Some((20, 200)), Some((10, 400))], ); @@ -1053,7 +1051,7 @@ fn gap_bids_work() { // Lease period 4 is done, but nothing is unreserved since user 1 has a debt on lease 7 run_to_block(500); assert_eq!( - slots::Leases::::get(ParaId::from(1)), + slots::Leases::::get(ParaId::from(1001)), // --------- 5 -------------- 6 -------------- 7 ------- vec![Some((20, 800)), Some((20, 200)), Some((10, 400))], ); @@ -1064,7 +1062,7 @@ fn gap_bids_work() { // Lease period 5 is done, and 20 will unreserve down to 200. run_to_block(600); assert_eq!( - slots::Leases::::get(ParaId::from(1)), + slots::Leases::::get(ParaId::from(1001)), // --------- 6 -------------- 7 ------- vec![Some((20, 200)), Some((10, 400))], ); @@ -1074,7 +1072,7 @@ fn gap_bids_work() { // Lease period 6 is done, and 20 will unreserve everything. run_to_block(700); assert_eq!( - slots::Leases::::get(ParaId::from(1)), + slots::Leases::::get(ParaId::from(1001)), // --------- 7 ------- vec![Some((10, 400))], ); @@ -1083,7 +1081,7 @@ fn gap_bids_work() { // All leases are done. Everything is unreserved. run_to_block(800); - assert_eq!(slots::Leases::::get(ParaId::from(1)), vec![]); + assert_eq!(slots::Leases::::get(ParaId::from(1001)), vec![]); assert_eq!(Balances::reserved_balance(&10), 0); assert_eq!(Balances::reserved_balance(&20), 0); }); diff --git a/polkadot/runtime/common/src/paras_registrar.rs b/polkadot/runtime/common/src/paras_registrar.rs index 80b4ab3991..76d0c8085e 100644 --- a/polkadot/runtime/common/src/paras_registrar.rs +++ b/polkadot/runtime/common/src/paras_registrar.rs @@ -26,7 +26,7 @@ use frame_support::{ }; use frame_system::{self, ensure_root, ensure_signed}; use primitives::v1::{ - Id as ParaId, ValidationCode, HeadData, + Id as ParaId, ValidationCode, HeadData, LOWEST_USER_ID, }; use runtime_parachains::{ paras::{ @@ -56,6 +56,7 @@ type BalanceOf = pub trait WeightInfo { fn register() -> Weight; + fn force_register() -> Weight; fn deregister() -> Weight; fn swap() -> Weight; } @@ -63,6 +64,7 @@ pub trait WeightInfo { pub struct TestWeightInfo; impl WeightInfo for TestWeightInfo { fn register() -> Weight { 0 } + fn force_register() -> Weight { 0 } fn deregister() -> Weight { 0 } fn swap() -> Weight { 0 } } @@ -148,6 +150,8 @@ decl_error! { CannotUpgrade, /// Para is locked from manipulation by the manager. Must use parachain or relay chain governance. ParaLocked, + /// The id you are trying to register is reserved for system parachains. + InvalidParaId, } } @@ -171,7 +175,8 @@ decl_module! { /// This function must be called by a signed origin. /// /// The origin must pay a deposit for the registration information, - /// including the genesis information and validation code. + /// including the genesis information and validation code. ParaId + /// must be greater than or equal to 1000. #[weight = T::WeightInfo::register()] pub fn register( origin, @@ -180,7 +185,27 @@ decl_module! { validation_code: ValidationCode, ) -> DispatchResult { let who = ensure_signed(origin)?; - Self::do_register(who, id, genesis_head, validation_code) + ensure!(id >= LOWEST_USER_ID, Error::::InvalidParaId); + Self::do_register(who, None, id, genesis_head, validation_code) + } + + /// Force the registration of a Para Id on the relay chain. + /// + /// This function must be called by a Root origin. + /// + /// The deposit taken can be specified for this registration. Any ParaId + /// can be registered, including sub-1000 IDs which are System Parachains. + #[weight = T::WeightInfo::force_register()] + pub fn force_register( + origin, + who: T::AccountId, + deposit: BalanceOf, + id: ParaId, + genesis_head: HeadData, + validation_code: ValidationCode, + ) -> DispatchResult { + ensure_root(origin)?; + Self::do_register(who, Some(deposit), id, genesis_head, validation_code) } /// Deregister a Para Id, freeing all data and returning any deposit. @@ -236,6 +261,16 @@ decl_module! { PendingSwap::insert(id, other); } } + + /// Remove a manager lock from a para. This will allow the manager of a + /// previously locked para to deregister or swap a para without using governance. + /// + /// Can only be called by the Root origin. + #[weight = T::DbWeight::get().reads_writes(1, 1)] + fn force_remove_lock(origin, para: ParaId) { + ensure_root(origin)?; + Self::remove_lock(para); + } } } @@ -273,13 +308,16 @@ impl Registrar for Module { } // Register a Para ID under control of `manager`. + // + // Note this is a backend registration api, so verification of ParaId + // is not done here to prevent. fn register( manager: T::AccountId, id: ParaId, genesis_head: HeadData, validation_code: ValidationCode, ) -> DispatchResult { - Self::do_register(manager, id, genesis_head, validation_code) + Self::do_register(manager, None, id, genesis_head, validation_code) } // Deregister a Para ID, free any data, and return any deposits. @@ -357,6 +395,7 @@ impl Module { /// system with the given information. fn do_register( who: T::AccountId, + deposit_override: Option>, id: ParaId, genesis_head: HeadData, validation_code: ValidationCode, @@ -369,6 +408,7 @@ impl Module { false )?; + let deposit = deposit_override.unwrap_or(deposit); ::Currency::reserve(&who, deposit)?; let info = ParaInfo { manager: who.clone(), @@ -610,39 +650,39 @@ mod tests { fn end_to_end_scenario_works() { new_test_ext().execute_with(|| { run_to_block(1); - // 32 is not yet registered - assert!(!Parachains::is_parathread(32.into())); + // 1032 is not yet registered + assert!(!Parachains::is_parathread(1032.into())); // We register the Para ID assert_ok!(Registrar::register( Origin::signed(1), - 32.into(), + 1032.into(), test_genesis_head(32), test_validation_code(32), )); run_to_session(2); // It is now a parathread. - assert!(Parachains::is_parathread(32.into())); - assert!(!Parachains::is_parachain(32.into())); + assert!(Parachains::is_parathread(1032.into())); + assert!(!Parachains::is_parachain(1032.into())); // Some other external process will elevate parathread to parachain - assert_ok!(Registrar::make_parachain(32.into())); + assert_ok!(Registrar::make_parachain(1032.into())); run_to_session(4); // It is now a parachain. - assert!(!Parachains::is_parathread(32.into())); - assert!(Parachains::is_parachain(32.into())); + assert!(!Parachains::is_parathread(1032.into())); + assert!(Parachains::is_parachain(1032.into())); // Turn it back into a parathread - assert_ok!(Registrar::make_parathread(32.into())); + assert_ok!(Registrar::make_parathread(1032.into())); run_to_session(6); - assert!(Parachains::is_parathread(32.into())); - assert!(!Parachains::is_parachain(32.into())); + assert!(Parachains::is_parathread(1032.into())); + assert!(!Parachains::is_parachain(1032.into())); // Deregister it assert_ok!(Registrar::deregister( Origin::root(), - 32.into(), + 1032.into(), )); run_to_session(8); // It is nothing - assert!(!Parachains::is_parathread(32.into())); - assert!(!Parachains::is_parachain(32.into())); + assert!(!Parachains::is_parathread(1032.into())); + assert!(!Parachains::is_parachain(1032.into())); }); } @@ -650,15 +690,15 @@ mod tests { fn register_works() { new_test_ext().execute_with(|| { run_to_block(1); - assert!(!Parachains::is_parathread(32.into())); + assert!(!Parachains::is_parathread(1032.into())); assert_ok!(Registrar::register( Origin::signed(1), - 32.into(), + 1032.into(), test_genesis_head(32), test_validation_code(32), )); run_to_session(2); - assert!(Parachains::is_parathread(32.into())); + assert!(Parachains::is_parathread(1032.into())); assert_eq!( Balances::reserved_balance(&1), ::ParaDeposit::get() + 64 * ::DataDepositPerByte::get() @@ -669,22 +709,30 @@ mod tests { #[test] fn register_handles_basic_errors() { new_test_ext().execute_with(|| { - // Successfully register 32 - assert_ok!(Registrar::register( + // Can't register system parachain + assert_noop!(Registrar::register( Origin::signed(1), 32.into(), test_genesis_head(::MaxHeadSize::get() as usize), test_validation_code(::MaxCodeSize::get() as usize), + ), Error::::InvalidParaId); + + // Successfully register 1032 + assert_ok!(Registrar::register( + Origin::signed(1), + 1032.into(), + test_genesis_head(::MaxHeadSize::get() as usize), + test_validation_code(::MaxCodeSize::get() as usize), )); run_to_session(2); - assert_ok!(Registrar::deregister(Origin::root(), 32u32.into())); + assert_ok!(Registrar::deregister(Origin::root(), 1032.into())); - // Can't do it again + // Can't do it again until offboarded from the paras backend assert_noop!(Registrar::register( Origin::signed(1), - 32.into(), + 1032.into(), test_genesis_head(::MaxHeadSize::get() as usize), test_validation_code(::MaxCodeSize::get() as usize), ), Error::::AlreadyRegistered); @@ -692,7 +740,7 @@ mod tests { // Head Size Check assert_noop!(Registrar::register( Origin::signed(2), - 23.into(), + 1023.into(), test_genesis_head((::MaxHeadSize::get() + 1) as usize), test_validation_code(::MaxCodeSize::get() as usize), ), Error::::HeadDataTooLarge); @@ -700,7 +748,7 @@ mod tests { // Code Size Check assert_noop!(Registrar::register( Origin::signed(2), - 23.into(), + 1023.into(), test_genesis_head(::MaxHeadSize::get() as usize), test_validation_code((::MaxCodeSize::get() + 1) as usize), ), Error::::CodeTooLarge); @@ -708,7 +756,7 @@ mod tests { // Needs enough funds for deposit assert_noop!(Registrar::register( Origin::signed(1337), - 23.into(), + 1023.into(), test_genesis_head(::MaxHeadSize::get() as usize), test_validation_code(::MaxCodeSize::get() as usize), ), BalancesError::::InsufficientBalance); @@ -719,10 +767,10 @@ mod tests { fn deregister_works() { new_test_ext().execute_with(|| { run_to_block(1); - assert!(!Parachains::is_parathread(32.into())); + assert!(!Parachains::is_parathread(1032.into())); assert_ok!(Registrar::register( Origin::signed(1), - 32.into(), + 1032.into(), test_genesis_head(32), test_validation_code(32), )); @@ -731,13 +779,13 @@ mod tests { ::ParaDeposit::get() + 64 * ::DataDepositPerByte::get() ); run_to_session(2); - assert!(Parachains::is_parathread(32.into())); + assert!(Parachains::is_parathread(1032.into())); assert_ok!(Registrar::deregister( Origin::root(), - 32.into(), + 1032.into(), )); run_to_session(4); - assert!(paras::Module::::lifecycle(32.into()).is_none()); + assert!(paras::Module::::lifecycle(1032.into()).is_none()); assert_eq!(Balances::reserved_balance(&1), 0); }); } @@ -746,26 +794,26 @@ mod tests { fn deregister_handles_basic_errors() { new_test_ext().execute_with(|| { run_to_block(1); - assert!(!Parachains::is_parathread(32.into())); + assert!(!Parachains::is_parathread(1032.into())); assert_ok!(Registrar::register( Origin::signed(1), - 32.into(), + 1032.into(), test_genesis_head(32), test_validation_code(32), )); run_to_session(2); - assert!(Parachains::is_parathread(32.into())); + assert!(Parachains::is_parathread(1032.into())); // Owner check assert_noop!(Registrar::deregister( Origin::signed(2), - 32.into(), + 1032.into(), ), BadOrigin); - assert_ok!(Registrar::make_parachain(32.into())); + assert_ok!(Registrar::make_parachain(1032.into())); run_to_session(4); // Cant directly deregister parachain assert_noop!(Registrar::deregister( Origin::root(), - 32.into(), + 1032.into(), ), Error::::NotParathread); }); } @@ -773,57 +821,57 @@ mod tests { #[test] fn swap_works() { new_test_ext().execute_with(|| { - // Successfully register 23 and 32 + // Successfully register 1023 and 1032 assert_ok!(Registrar::register( Origin::signed(1), - 23.into(), + 1023.into(), test_genesis_head(::MaxHeadSize::get() as usize), test_validation_code(::MaxCodeSize::get() as usize), )); assert_ok!(Registrar::register( Origin::signed(2), - 32.into(), + 1032.into(), test_genesis_head(::MaxHeadSize::get() as usize), test_validation_code(::MaxCodeSize::get() as usize), )); run_to_session(2); - // Upgrade 23 into a parachain - assert_ok!(Registrar::make_parachain(23.into())); + // Upgrade 1023 into a parachain + assert_ok!(Registrar::make_parachain(1023.into())); run_to_session(4); // Roles are as we expect - assert!(Parachains::is_parachain(23.into())); - assert!(!Parachains::is_parathread(23.into())); - assert!(!Parachains::is_parachain(32.into())); - assert!(Parachains::is_parathread(32.into())); + assert!(Parachains::is_parachain(1023.into())); + assert!(!Parachains::is_parathread(1023.into())); + assert!(!Parachains::is_parachain(1032.into())); + assert!(Parachains::is_parathread(1032.into())); // Both paras initiate a swap assert_ok!(Registrar::swap( - para_origin(23.into()), - 23.into(), - 32.into(), + para_origin(1023.into()), + 1023.into(), + 1032.into(), )); assert_ok!(Registrar::swap( - para_origin(32.into()), - 32.into(), - 23.into(), + para_origin(1032.into()), + 1032.into(), + 1023.into(), )); run_to_session(6); // Deregister a parathread that was originally a parachain - assert_eq!(Parachains::lifecycle(23u32.into()), Some(ParaLifecycle::Parathread)); - assert_ok!(Registrar::deregister(runtime_parachains::Origin::Parachain(23u32.into()).into(), 23u32.into())); + assert_eq!(Parachains::lifecycle(1023.into()), Some(ParaLifecycle::Parathread)); + assert_ok!(Registrar::deregister(runtime_parachains::Origin::Parachain(1023.into()).into(), 1023.into())); run_to_block(21); // Roles are swapped - assert!(!Parachains::is_parachain(23.into())); - assert!(Parachains::is_parathread(23.into())); - assert!(Parachains::is_parachain(32.into())); - assert!(!Parachains::is_parathread(32.into())); + assert!(!Parachains::is_parachain(1023.into())); + assert!(Parachains::is_parathread(1023.into())); + assert!(Parachains::is_parachain(1032.into())); + assert!(!Parachains::is_parathread(1032.into())); }); } @@ -834,7 +882,7 @@ mod tests { assert_ok!(Registrar::register( Origin::signed(1), - 1u32.into(), + 1001.into(), vec![1; 3].into(), vec![1, 2, 3].into() )); @@ -842,15 +890,15 @@ mod tests { // 2 session changes to fully onboard. run_to_session(2); - assert_eq!(Parachains::lifecycle(1u32.into()), Some(ParaLifecycle::Parathread)); - assert_ok!(Registrar::deregister(Origin::root(), 1u32.into())); + assert_eq!(Parachains::lifecycle(1001.into()), Some(ParaLifecycle::Parathread)); + assert_ok!(Registrar::deregister(Origin::root(), 1001.into())); // Cannot register while it is offboarding. run_to_session(3); assert_noop!(Registrar::register( Origin::signed(1), - 1u32.into(), + 1001.into(), vec![1; 3].into(), vec![1, 2, 3].into() ), Error::::AlreadyRegistered); @@ -860,7 +908,7 @@ mod tests { assert_ok!(Registrar::register( Origin::signed(1), - 1u32.into(), + 1001.into(), vec![1; 3].into(), vec![1, 2, 3].into() )); @@ -874,23 +922,23 @@ mod tests { assert_ok!(Registrar::register( Origin::signed(1), - 1u32.into(), + 1001.into(), vec![1; 3].into(), vec![1, 2, 3].into(), )); // Owner can call swap - assert_ok!(Registrar::swap(Origin::signed(1), 1u32.into(), 2u32.into())); + assert_ok!(Registrar::swap(Origin::signed(1), 1001.into(), 1002.into())); // 2 session changes to fully onboard. run_to_session(2); - assert_eq!(Parachains::lifecycle(1u32.into()), Some(ParaLifecycle::Parathread)); + assert_eq!(Parachains::lifecycle(1001.into()), Some(ParaLifecycle::Parathread)); // Once they begin onboarding, we lock them in. - assert_ok!(Registrar::make_parachain(1u32.into())); + assert_ok!(Registrar::make_parachain(1001.into())); // Owner cannot call swap anymore - assert_noop!(Registrar::swap(Origin::signed(1), 1u32.into(), 3u32.into()), BadOrigin); + assert_noop!(Registrar::swap(Origin::signed(1), 1001.into(), 1003.into()), BadOrigin); }); } } @@ -904,7 +952,7 @@ mod benchmarking { use crate::traits::{Registrar as RegistrarT}; use runtime_parachains::{paras, shared, Origin as ParaOrigin}; - use frame_benchmarking::{benchmarks, whitelisted_caller, impl_benchmark_test_suite}; + use frame_benchmarking::{account, benchmarks, whitelisted_caller, impl_benchmark_test_suite}; fn assert_last_event(generic_event: ::Event) { let events = frame_system::Pallet::::events(); @@ -953,6 +1001,20 @@ mod benchmarking { assert_eq!(paras::Module::::lifecycle(para), Some(ParaLifecycle::Parathread)); } + force_register { + let manager: T::AccountId = account("manager", 0, 0); + let deposit = 0u32.into(); + let para = ParaId::from(69); + let genesis_head = Registrar::::worst_head_data(); + let validation_code = Registrar::::worst_validation_code(); + }: _(RawOrigin::Root, manager.clone(), deposit, para, genesis_head, validation_code) + verify { + assert_last_event::(RawEvent::Registered(para, manager).into()); + assert_eq!(paras::Module::::lifecycle(para), Some(ParaLifecycle::Onboarding)); + next_scheduled_session::(); + assert_eq!(paras::Module::::lifecycle(para), Some(ParaLifecycle::Parathread)); + } + deregister { let para = register_para::(1337); next_scheduled_session::(); diff --git a/polkadot/runtime/common/src/slots.rs b/polkadot/runtime/common/src/slots.rs index 344d214e6d..af16765353 100644 --- a/polkadot/runtime/common/src/slots.rs +++ b/polkadot/runtime/common/src/slots.rs @@ -103,35 +103,13 @@ decl_event!( /// First balance is the extra amount reseved. Second is the total amount reserved. /// \[parachain_id, leaser, period_begin, period_count, extra_reseved, total_amount\] Leased(ParaId, AccountId, LeasePeriod, LeasePeriod, Balance, Balance), - /// A para ID value has been claimed. - Claimed(ParaId), } ); decl_error! { pub enum Error for Module { - /// The lease period is in the past. - LeasePeriodInPast, - /// The origin for this call must be a parachain. - NotParaOrigin, /// The parachain ID is not onboarding. ParaNotOnboarding, - /// The origin for this call must be the origin who registered the parachain. - InvalidOrigin, - /// Parachain is already registered. - AlreadyRegistered, - /// The code must correspond to the hash. - InvalidCode, - /// Deployment data has not been set for this parachain. - UnsetDeployData, - /// The bid must overlap all intersecting ranges. - NonIntersectingRange, - /// Given code size is too large. - CodeTooLarge, - /// Given initial head data is too large. - HeadDataTooLarge, - /// The Id given is already in use. - InUse, /// There was an error with the lease. LeaseError, }