diff --git a/polkadot/runtime/common/src/crowdloan.rs b/polkadot/runtime/common/src/crowdloan.rs index 6ead470aef..c09c17736c 100644 --- a/polkadot/runtime/common/src/crowdloan.rs +++ b/polkadot/runtime/common/src/crowdloan.rs @@ -323,6 +323,7 @@ decl_module! { let manager = T::Registrar::manager_of(index).ok_or(Error::::InvalidParaId)?; ensure!(depositor == manager, Error::::InvalidOrigin); + ensure!(T::Registrar::is_registered(index), Error::::InvalidParaId); let trie_index = Self::next_trie_index(); let new_trie_index = trie_index.checked_add(1).ok_or(Error::::Overflow)?; @@ -1644,6 +1645,7 @@ mod benchmarking { CurrencyOf::::make_free_balance_be(&caller, BalanceOf::::max_value()); T::Registrar::register(caller.clone(), para_id, head_data, validation_code)?; + T::Registrar::execute_pending_transitions(); }: _(RawOrigin::Signed(caller), para_id, cap, first_period, last_period, end, Some(verifier)) verify { @@ -1721,6 +1723,7 @@ mod benchmarking { CurrencyOf::::make_free_balance_be(&caller, BalanceOf::::max_value()); T::Registrar::register(caller.clone(), para_id, head_data, validation_code)?; + T::Registrar::execute_pending_transitions(); Crowdloan::::create( RawOrigin::Signed(caller).into(), diff --git a/polkadot/runtime/common/src/integration_tests.rs b/polkadot/runtime/common/src/integration_tests.rs index a4b455bf40..6a6002a164 100644 --- a/polkadot/runtime/common/src/integration_tests.rs +++ b/polkadot/runtime/common/src/integration_tests.rs @@ -570,10 +570,6 @@ fn competing_bids() { // This test will verify that competing bids, from different sources will resolve appropriately. new_test_ext().execute_with(|| { assert!(System::block_number().is_one()); - // Start a new auction in the future - let duration = 99u32; - let lease_period_index_start = 4u32; - assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start)); let start_para = LOWEST_PUBLIC_ID - 1; // Create 3 paras and owners @@ -588,7 +584,18 @@ fn competing_bids() { genesis_head, validation_code, )); + } + // Finish registration of paras. + run_to_session(2); + + // Start a new auction in the future + let starting_block = System::block_number(); + let duration = 99u32; + let lease_period_index_start = 4u32; + assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start)); + + for n in 1 ..= 3 { // Create a crowdloan for each para assert_ok!(Crowdloan::create( Origin::signed(n), @@ -603,7 +610,7 @@ fn competing_bids() { for n in 1 ..= 9 { // Increment block number - run_to_block(n * 10); + run_to_block(starting_block + n * 10); Balances::make_free_balance_be(&(n * 10), n * 1_000); @@ -631,7 +638,7 @@ fn competing_bids() { } // Auction should be done - run_to_block(110); + run_to_block(starting_block + 110); // Appropriate Paras should have won slots let crowdloan_2 = Crowdloan::fund_account_id(ParaId::from(2001));