diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2745abb320..ab224ca7f9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -339,6 +339,7 @@ jobs: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y fi rustup show + rustup target add wasm32-unknown-unknown # Checks are run after uploading artifacts since they are modified by the tests - name: Unit tests run: | @@ -613,7 +614,18 @@ jobs: docker create --name moonbeam_container $DOCKER_TAG bash docker cp moonbeam_container:moonbeam/moonbeam test/tmp/moonbeam_rt docker rm -f moonbeam_container - - name: Setup chainspecs + - name: "TEMPORARY: Download forked polkadot-bins" + run: | + # When we remove this step, re-add "runScripts": ["download-polkadot.sh"]," to moonwall config + cd test/tmp + wget https://opslayer-dev-artifacts.s3.us-east-2.amazonaws.com/bins/moonbeam/polkadot/1.3.0/polkadot + wget https://opslayer-dev-artifacts.s3.us-east-2.amazonaws.com/bins/moonbeam/polkadot/1.3.0/polkadot-execute-worker + wget https://opslayer-dev-artifacts.s3.us-east-2.amazonaws.com/bins/moonbeam/polkadot/1.3.0/polkadot-prepare-worker + + chmod +x polkadot + chmod +x polkadot-execute-worker + chmod +x polkadot-prepare-worker + - name: Prepare Chainspecs run: | cd test pnpm install diff --git a/.github/workflows/subxt-diff.yml b/.github/workflows/subxt-diff.yml index 34137645c4..c0d953410c 100644 --- a/.github/workflows/subxt-diff.yml +++ b/.github/workflows/subxt-diff.yml @@ -16,11 +16,6 @@ jobs: uses: pnpm/action-setup@v2 with: version: 8.6.12 - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: 1.74.0 - override: true - name: Install Subxt-cli run: | cargo install subxt-cli diff --git a/Cargo.lock b/Cargo.lock index e5d317150e..5524bdbe63 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -641,7 +641,7 @@ checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" [[package]] name = "async-backing-primitives" version = "0.9.0" -source = "git+https://github.com/Moonsong-Labs/moonkit?branch=moonbeam-polkadot-v1.3.0#4ef527e1e708bb635637c343194277e24aa4c477" +source = "git+https://github.com/Moonsong-Labs/moonkit?branch=moonbeam-polkadot-v1.3.0#048545f682f896659cd4ece32bc702f63ec21799" dependencies = [ "sp-api", "sp-consensus-slots", @@ -7659,7 +7659,7 @@ dependencies = [ [[package]] name = "nimbus-consensus" version = "0.9.0" -source = "git+https://github.com/Moonsong-Labs/moonkit?branch=moonbeam-polkadot-v1.3.0#4ef527e1e708bb635637c343194277e24aa4c477" +source = "git+https://github.com/Moonsong-Labs/moonkit?branch=moonbeam-polkadot-v1.3.0#048545f682f896659cd4ece32bc702f63ec21799" dependencies = [ "async-backing-primitives", "async-trait", @@ -7697,7 +7697,7 @@ dependencies = [ [[package]] name = "nimbus-primitives" version = "0.9.0" -source = "git+https://github.com/Moonsong-Labs/moonkit?branch=moonbeam-polkadot-v1.3.0#4ef527e1e708bb635637c343194277e24aa4c477" +source = "git+https://github.com/Moonsong-Labs/moonkit?branch=moonbeam-polkadot-v1.3.0#048545f682f896659cd4ece32bc702f63ec21799" dependencies = [ "async-trait", "frame-benchmarking", @@ -8211,7 +8211,7 @@ dependencies = [ [[package]] name = "pallet-async-backing" version = "0.9.0" -source = "git+https://github.com/Moonsong-Labs/moonkit?branch=moonbeam-polkadot-v1.3.0#4ef527e1e708bb635637c343194277e24aa4c477" +source = "git+https://github.com/Moonsong-Labs/moonkit?branch=moonbeam-polkadot-v1.3.0#048545f682f896659cd4ece32bc702f63ec21799" dependencies = [ "cumulus-pallet-parachain-system", "cumulus-primitives-core", @@ -8231,7 +8231,7 @@ dependencies = [ [[package]] name = "pallet-author-inherent" version = "0.9.0" -source = "git+https://github.com/Moonsong-Labs/moonkit?branch=moonbeam-polkadot-v1.3.0#4ef527e1e708bb635637c343194277e24aa4c477" +source = "git+https://github.com/Moonsong-Labs/moonkit?branch=moonbeam-polkadot-v1.3.0#048545f682f896659cd4ece32bc702f63ec21799" dependencies = [ "frame-benchmarking", "frame-support", @@ -8250,7 +8250,7 @@ dependencies = [ [[package]] name = "pallet-author-mapping" version = "2.0.5" -source = "git+https://github.com/Moonsong-Labs/moonkit?branch=moonbeam-polkadot-v1.3.0#4ef527e1e708bb635637c343194277e24aa4c477" +source = "git+https://github.com/Moonsong-Labs/moonkit?branch=moonbeam-polkadot-v1.3.0#048545f682f896659cd4ece32bc702f63ec21799" dependencies = [ "frame-benchmarking", "frame-support", @@ -8268,7 +8268,7 @@ dependencies = [ [[package]] name = "pallet-author-slot-filter" version = "0.9.0" -source = "git+https://github.com/Moonsong-Labs/moonkit?branch=moonbeam-polkadot-v1.3.0#4ef527e1e708bb635637c343194277e24aa4c477" +source = "git+https://github.com/Moonsong-Labs/moonkit?branch=moonbeam-polkadot-v1.3.0#048545f682f896659cd4ece32bc702f63ec21799" dependencies = [ "frame-benchmarking", "frame-support", @@ -9478,7 +9478,7 @@ dependencies = [ [[package]] name = "pallet-maintenance-mode" version = "0.1.0" -source = "git+https://github.com/Moonsong-Labs/moonkit?branch=moonbeam-polkadot-v1.3.0#4ef527e1e708bb635637c343194277e24aa4c477" +source = "git+https://github.com/Moonsong-Labs/moonkit?branch=moonbeam-polkadot-v1.3.0#048545f682f896659cd4ece32bc702f63ec21799" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -9530,7 +9530,7 @@ dependencies = [ [[package]] name = "pallet-migrations" version = "0.1.0" -source = "git+https://github.com/Moonsong-Labs/moonkit?branch=moonbeam-polkadot-v1.3.0#4ef527e1e708bb635637c343194277e24aa4c477" +source = "git+https://github.com/Moonsong-Labs/moonkit?branch=moonbeam-polkadot-v1.3.0#048545f682f896659cd4ece32bc702f63ec21799" dependencies = [ "frame-benchmarking", "frame-support", @@ -9780,7 +9780,7 @@ dependencies = [ [[package]] name = "pallet-randomness" version = "0.1.0" -source = "git+https://github.com/Moonsong-Labs/moonkit?branch=moonbeam-polkadot-v1.3.0#4ef527e1e708bb635637c343194277e24aa4c477" +source = "git+https://github.com/Moonsong-Labs/moonkit?branch=moonbeam-polkadot-v1.3.0#048545f682f896659cd4ece32bc702f63ec21799" dependencies = [ "environmental", "frame-benchmarking", @@ -14292,7 +14292,7 @@ dependencies = [ [[package]] name = "session-keys-primitives" version = "0.1.0" -source = "git+https://github.com/Moonsong-Labs/moonkit?branch=moonbeam-polkadot-v1.3.0#4ef527e1e708bb635637c343194277e24aa4c477" +source = "git+https://github.com/Moonsong-Labs/moonkit?branch=moonbeam-polkadot-v1.3.0#048545f682f896659cd4ece32bc702f63ec21799" dependencies = [ "async-trait", "frame-support", @@ -18069,7 +18069,7 @@ dependencies = [ [[package]] name = "xcm-primitives" version = "0.1.0" -source = "git+https://github.com/Moonsong-Labs/moonkit?branch=moonbeam-polkadot-v1.3.0#4ef527e1e708bb635637c343194277e24aa4c477" +source = "git+https://github.com/Moonsong-Labs/moonkit?branch=moonbeam-polkadot-v1.3.0#048545f682f896659cd4ece32bc702f63ec21799" dependencies = [ "sp-runtime", ] diff --git a/node/cli/src/cli.rs b/node/cli/src/cli.rs index 85f40ec7a9..33f2a1d0be 100644 --- a/node/cli/src/cli.rs +++ b/node/cli/src/cli.rs @@ -232,11 +232,6 @@ pub struct RunCmd { /// Removes moonbeam prefix from Prometheus metrics #[clap(long)] pub no_prometheus_prefix: bool, - - /// Enable asynchronous backing (for collators only) - /// This feature is still experimental, please don't use it in production. - #[clap(hide = true, long = "experimental-async-backing")] - pub async_backing: bool, } impl RunCmd { diff --git a/node/cli/src/command.rs b/node/cli/src/command.rs index 421f0151d1..90f514b211 100644 --- a/node/cli/src/command.rs +++ b/node/cli/src/command.rs @@ -791,7 +791,7 @@ pub fn run() -> Result<()> { collator_options, id, rpc_config, - cli.run.async_backing, + false, hwbench, ) .await @@ -807,7 +807,7 @@ pub fn run() -> Result<()> { collator_options, id, rpc_config, - cli.run.async_backing, + false, hwbench, ) .await @@ -823,7 +823,7 @@ pub fn run() -> Result<()> { collator_options, id, rpc_config, - cli.run.async_backing, + true, hwbench, ) .await diff --git a/node/service/src/chain_spec/moonbase.rs b/node/service/src/chain_spec/moonbase.rs index 20fdcba859..e19794f3d0 100644 --- a/node/service/src/chain_spec/moonbase.rs +++ b/node/service/src/chain_spec/moonbase.rs @@ -205,12 +205,11 @@ pub fn get_chain_spec(para_id: ParaId) -> ChainSpec { const COLLATOR_COMMISSION: Perbill = Perbill::from_percent(20); const PARACHAIN_BOND_RESERVE_PERCENT: Percent = Percent::from_percent(30); const BLOCKS_PER_ROUND: u32 = 2 * HOURS; +const BLOCKS_PER_YEAR: u32 = 31_557_600 / 6; const NUM_SELECTED_CANDIDATES: u32 = 8; pub fn moonbase_inflation_config() -> InflationInfo { fn to_round_inflation(annual: Range) -> Range { - use pallet_parachain_staking::inflation::{ - perbill_annual_to_perbill_round, BLOCKS_PER_YEAR, - }; + use pallet_parachain_staking::inflation::perbill_annual_to_perbill_round; perbill_annual_to_perbill_round( annual, // rounds per year diff --git a/node/service/src/chain_spec/moonbeam.rs b/node/service/src/chain_spec/moonbeam.rs index 7280793a58..b84b2eafa1 100644 --- a/node/service/src/chain_spec/moonbeam.rs +++ b/node/service/src/chain_spec/moonbeam.rs @@ -195,12 +195,11 @@ pub fn get_chain_spec(para_id: ParaId) -> ChainSpec { const COLLATOR_COMMISSION: Perbill = Perbill::from_percent(20); const PARACHAIN_BOND_RESERVE_PERCENT: Percent = Percent::from_percent(30); const BLOCKS_PER_ROUND: u32 = 6 * HOURS; +const BLOCKS_PER_YEAR: u32 = 31_557_600 / 12; const NUM_SELECTED_CANDIDATES: u32 = 8; pub fn moonbeam_inflation_config() -> InflationInfo { fn to_round_inflation(annual: Range) -> Range { - use pallet_parachain_staking::inflation::{ - perbill_annual_to_perbill_round, BLOCKS_PER_YEAR, - }; + use pallet_parachain_staking::inflation::perbill_annual_to_perbill_round; perbill_annual_to_perbill_round( annual, // rounds per year diff --git a/node/service/src/chain_spec/moonriver.rs b/node/service/src/chain_spec/moonriver.rs index 1b19dbed85..0f59c13e47 100644 --- a/node/service/src/chain_spec/moonriver.rs +++ b/node/service/src/chain_spec/moonriver.rs @@ -195,12 +195,11 @@ pub fn get_chain_spec(para_id: ParaId) -> ChainSpec { const COLLATOR_COMMISSION: Perbill = Perbill::from_percent(20); const PARACHAIN_BOND_RESERVE_PERCENT: Percent = Percent::from_percent(30); const BLOCKS_PER_ROUND: u32 = 2 * HOURS; +const BLOCKS_PER_YEAR: u32 = 31_557_600 / 12; const NUM_SELECTED_CANDIDATES: u32 = 8; pub fn moonriver_inflation_config() -> InflationInfo { fn to_round_inflation(annual: Range) -> Range { - use pallet_parachain_staking::inflation::{ - perbill_annual_to_perbill_round, BLOCKS_PER_YEAR, - }; + use pallet_parachain_staking::inflation::perbill_annual_to_perbill_round; perbill_annual_to_perbill_round( annual, // rounds per year diff --git a/node/service/src/lib.rs b/node/service/src/lib.rs index e4f89a8b4f..2d2eabc427 100644 --- a/node/service/src/lib.rs +++ b/node/service/src/lib.rs @@ -1045,6 +1045,7 @@ where }; if async_backing { + log::info!("Collator started with asynchronous backing."); let client_clone = client.clone(); let code_hash_provider = move |block_hash| { client_clone @@ -1093,6 +1094,7 @@ where }), ); } else { + log::info!("Collator started without asynchronous backing."); task_manager.spawn_essential_handle().spawn( "nimbus", None, diff --git a/pallets/parachain-staking/src/inflation.rs b/pallets/parachain-staking/src/inflation.rs index 6469686d05..64f346aab5 100644 --- a/pallets/parachain-staking/src/inflation.rs +++ b/pallets/parachain-staking/src/inflation.rs @@ -16,7 +16,7 @@ //! Helper methods for computing issuance based on inflation use crate::pallet::{BalanceOf, Config, Pallet}; -use frame_support::traits::Currency; +use frame_support::traits::{Currency, Get}; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; use serde::{Deserialize, Serialize}; @@ -25,13 +25,9 @@ use sp_runtime::{Perbill, RuntimeDebug}; use substrate_fixed::transcendental::pow as floatpow; use substrate_fixed::types::I64F64; -const SECONDS_PER_YEAR: u32 = 31557600; -const SECONDS_PER_BLOCK: u32 = 12; -pub const BLOCKS_PER_YEAR: u32 = SECONDS_PER_YEAR / SECONDS_PER_BLOCK; - fn rounds_per_year() -> u32 { let blocks_per_round = >::round().length; - BLOCKS_PER_YEAR / blocks_per_round + T::SlotsPerYear::get() / blocks_per_round } #[derive( @@ -136,8 +132,8 @@ impl InflationInfo { self.round = annual_to_round::(new); } /// Reset round inflation rate based on changes to round length - pub fn reset_round(&mut self, new_length: u32) { - let periods = BLOCKS_PER_YEAR / new_length; + pub fn reset_round(&mut self, new_length: u32) { + let periods = T::SlotsPerYear::get() / new_length; self.round = perbill_annual_to_perbill_round(self.annual, periods); } /// Set staking expectations diff --git a/pallets/parachain-staking/src/lib.rs b/pallets/parachain-staking/src/lib.rs index cc0b992357..5511a359b7 100644 --- a/pallets/parachain-staking/src/lib.rs +++ b/pallets/parachain-staking/src/lib.rs @@ -189,6 +189,9 @@ pub mod pallet { /// Maximum candidates #[pallet::constant] type MaxCandidates: Get; + /// Average number of slots per year + /// A slot here is the unit of time for staking rounds (provided by SlotProvider) + type SlotsPerYear: Get; } #[pallet::error] @@ -973,7 +976,7 @@ pub mod pallet { round.length = new; // update per-round inflation given new rounds per year let mut inflation_config = >::get(); - inflation_config.reset_round(new); + inflation_config.reset_round::(new); >::put(round); Self::deposit_event(Event::BlocksPerRoundSet { current_round: now, diff --git a/pallets/parachain-staking/src/mock.rs b/pallets/parachain-staking/src/mock.rs index 712ea252cc..03f83c421e 100644 --- a/pallets/parachain-staking/src/mock.rs +++ b/pallets/parachain-staking/src/mock.rs @@ -161,6 +161,7 @@ impl Config for Test { type SlotProvider = StakingRoundSlotProvider; type WeightInfo = (); type MaxCandidates = MaxCandidates; + type SlotsPerYear = frame_support::traits::ConstU32<{ 31_557_600 / 6 }>; } pub(crate) struct ExtBuilder { diff --git a/pallets/parachain-staking/src/tests.rs b/pallets/parachain-staking/src/tests.rs index 4142cbc878..36843b3bd5 100644 --- a/pallets/parachain-staking/src/tests.rs +++ b/pallets/parachain-staking/src/tests.rs @@ -277,9 +277,9 @@ fn set_blocks_per_round_event_emits_correctly() { first_block: 0, old: 5, new: 6, - new_per_round_inflation_min: Perbill::from_parts(926), - new_per_round_inflation_ideal: Perbill::from_parts(926), - new_per_round_inflation_max: Perbill::from_parts(926), + new_per_round_inflation_min: Perbill::from_parts(463), + new_per_round_inflation_ideal: Perbill::from_parts(463), + new_per_round_inflation_max: Perbill::from_parts(463), }); }); } @@ -518,9 +518,9 @@ fn set_inflation_event_emits_correctly() { annual_min: min, annual_ideal: ideal, annual_max: max, - round_min: Perbill::from_parts(57), - round_ideal: Perbill::from_parts(75), - round_max: Perbill::from_parts(93), + round_min: Perbill::from_parts(29), + round_ideal: Perbill::from_parts(38), + round_max: Perbill::from_parts(47), }); }); } @@ -560,9 +560,9 @@ fn set_inflation_storage_updates_correctly() { assert_eq!( ParachainStaking::inflation_config().round, Range { - min: Perbill::from_parts(57), - ideal: Perbill::from_parts(75), - max: Perbill::from_parts(93) + min: Perbill::from_parts(29), + ideal: Perbill::from_parts(38), + max: Perbill::from_parts(47) } ); }); diff --git a/precompiles/parachain-staking/src/mock.rs b/precompiles/parachain-staking/src/mock.rs index ea6c7ca4b3..4e543e2736 100644 --- a/precompiles/parachain-staking/src/mock.rs +++ b/precompiles/parachain-staking/src/mock.rs @@ -221,6 +221,7 @@ impl pallet_parachain_staking::Config for Runtime { type SlotProvider = StakingRoundSlotProvider; type WeightInfo = (); type MaxCandidates = MaxCandidates; + type SlotsPerYear = frame_support::traits::ConstU32<{ 31_557_600 / 6 }>; } pub(crate) struct ExtBuilder { diff --git a/runtime/moonbase/src/lib.rs b/runtime/moonbase/src/lib.rs index 1f68920f15..bfeadc0359 100644 --- a/runtime/moonbase/src/lib.rs +++ b/runtime/moonbase/src/lib.rs @@ -158,8 +158,7 @@ pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(WEIGHT_REF_TIME_PER_ .saturating_div(2) .set_proof_size(cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64); -// TODO: Set MILLISECS_PER_BLOCK to 6000 when async backing will be definitly enabled -pub const MILLISECS_PER_BLOCK: u64 = 12000; +pub const MILLISECS_PER_BLOCK: u64 = 6_000; pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber); pub const HOURS: BlockNumber = MINUTES * 60; pub const DAYS: BlockNumber = HOURS * 24; @@ -709,8 +708,12 @@ parameter_types! { pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4); } -pub const UNINCLUDED_SEGMENT_CAPACITY: u32 = 1; -pub const BLOCK_PROCESSING_VELOCITY: u32 = 1; +/// Maximum number of blocks simultaneously accepted by the Runtime, not yet included +/// into the relay chain. +const UNINCLUDED_SEGMENT_CAPACITY: u32 = 3; +/// How many parachain blocks are processed by the relay chain per parent. Limits the +/// number of blocks authored per slot. +const BLOCK_PROCESSING_VELOCITY: u32 = 2; type ConsensusHook = pallet_async_backing::consensus_hook::FixedVelocityConsensusHook< Runtime, @@ -830,6 +833,7 @@ impl pallet_parachain_staking::Config for Runtime { type SlotProvider = RelayChainSlotProvider; type WeightInfo = moonbeam_weights::pallet_parachain_staking::WeightInfo; type MaxCandidates = ConstU32<200>; + type SlotsPerYear = ConstU32<{ 31_557_600 / 6 }>; } impl pallet_author_inherent::Config for Runtime { diff --git a/runtime/moonbase/tests/common/mod.rs b/runtime/moonbase/tests/common/mod.rs index c6d1206b42..2b615ae40d 100644 --- a/runtime/moonbase/tests/common/mod.rs +++ b/runtime/moonbase/tests/common/mod.rs @@ -66,7 +66,6 @@ pub fn rpc_run_to_block(n: u32) { pub fn run_to_block(n: u32, author: Option) { // Finalize the first block Ethereum::on_finalize(System::block_number()); - AuthorInherent::on_finalize(System::block_number()); while System::block_number() < n { // Set the new block number and author match author { @@ -95,7 +94,6 @@ pub fn run_to_block(n: u32, author: Option) { // Finalize the block Ethereum::on_finalize(System::block_number()); - AuthorInherent::on_finalize(System::block_number()); ParachainStaking::on_finalize(System::block_number()); } } diff --git a/runtime/moonbase/tests/integration_test.rs b/runtime/moonbase/tests/integration_test.rs index 9c672374a3..e836b7a6c1 100644 --- a/runtime/moonbase/tests/integration_test.rs +++ b/runtime/moonbase/tests/integration_test.rs @@ -667,7 +667,7 @@ fn reward_block_authors() { .build() .execute_with(|| { increase_last_relay_slot_number(2); - for x in 2..599 { + for x in 2..1199 { run_to_block(x, Some(NimbusId::from_slice(&ALICE_NIMBUS).unwrap())); } // no rewards doled out yet @@ -676,7 +676,7 @@ fn reward_block_authors() { 1_100 * UNIT, ); assert_eq!(Balances::usable_balance(AccountId::from(BOB)), 500 * UNIT,); - run_to_block(601, Some(NimbusId::from_slice(&ALICE_NIMBUS).unwrap())); + run_to_block(1201, Some(NimbusId::from_slice(&ALICE_NIMBUS).unwrap())); // rewards minted and distributed assert_eq!( Balances::usable_balance(AccountId::from(ALICE)), @@ -716,7 +716,7 @@ fn reward_block_authors_with_parachain_bond_reserved() { AccountId::from(CHARLIE), ),); - for x in 2..599 { + for x in 2..1199 { run_to_block(x, Some(NimbusId::from_slice(&ALICE_NIMBUS).unwrap())); } @@ -727,7 +727,7 @@ fn reward_block_authors_with_parachain_bond_reserved() { ); assert_eq!(Balances::usable_balance(AccountId::from(BOB)), 500 * UNIT,); assert_eq!(Balances::usable_balance(AccountId::from(CHARLIE)), UNIT,); - run_to_block(601, Some(NimbusId::from_slice(&ALICE_NIMBUS).unwrap())); + run_to_block(1201, Some(NimbusId::from_slice(&ALICE_NIMBUS).unwrap())); // rewards minted and distributed assert_eq!( Balances::usable_balance(AccountId::from(ALICE)), diff --git a/runtime/moonbeam/src/lib.rs b/runtime/moonbeam/src/lib.rs index f1197161a4..0d57d20fd3 100644 --- a/runtime/moonbeam/src/lib.rs +++ b/runtime/moonbeam/src/lib.rs @@ -808,6 +808,7 @@ impl pallet_parachain_staking::Config for Runtime { type SlotProvider = StakingRoundSlotProvider; type WeightInfo = moonbeam_weights::pallet_parachain_staking::WeightInfo; type MaxCandidates = ConstU32<200>; + type SlotsPerYear = ConstU32<{ 31_557_600 / 12 }>; } impl pallet_author_inherent::Config for Runtime { diff --git a/runtime/moonbeam/tests/common/mod.rs b/runtime/moonbeam/tests/common/mod.rs index 068695603e..c4d86cd848 100644 --- a/runtime/moonbeam/tests/common/mod.rs +++ b/runtime/moonbeam/tests/common/mod.rs @@ -64,7 +64,6 @@ pub fn rpc_run_to_block(n: u32) { pub fn run_to_block(n: u32, author: Option) { // Finalize the first block Ethereum::on_finalize(System::block_number()); - AuthorInherent::on_finalize(System::block_number()); while System::block_number() < n { // Set the new block number and author match author { @@ -91,7 +90,6 @@ pub fn run_to_block(n: u32, author: Option) { // Finalize the block Ethereum::on_finalize(System::block_number()); - AuthorInherent::on_finalize(System::block_number()); ParachainStaking::on_finalize(System::block_number()); } } diff --git a/runtime/moonriver/src/lib.rs b/runtime/moonriver/src/lib.rs index 27e83c8fdc..01e0ebaaef 100644 --- a/runtime/moonriver/src/lib.rs +++ b/runtime/moonriver/src/lib.rs @@ -809,6 +809,7 @@ impl pallet_parachain_staking::Config for Runtime { type SlotProvider = StakingRoundSlotProvider; type WeightInfo = moonbeam_weights::pallet_parachain_staking::WeightInfo; type MaxCandidates = ConstU32<200>; + type SlotsPerYear = ConstU32<{ 31_557_600 / 12 }>; } impl pallet_author_inherent::Config for Runtime { diff --git a/runtime/moonriver/tests/common/mod.rs b/runtime/moonriver/tests/common/mod.rs index 8c20a49b11..21614b44a6 100644 --- a/runtime/moonriver/tests/common/mod.rs +++ b/runtime/moonriver/tests/common/mod.rs @@ -65,7 +65,6 @@ pub fn rpc_run_to_block(n: u32) { pub fn run_to_block(n: u32, author: Option) { // Finalize the first block Ethereum::on_finalize(System::block_number()); - AuthorInherent::on_finalize(System::block_number()); while System::block_number() < n { // Set the new block number and author match author { @@ -92,7 +91,6 @@ pub fn run_to_block(n: u32, author: Option) { // Finalize the block Ethereum::on_finalize(System::block_number()); - AuthorInherent::on_finalize(System::block_number()); ParachainStaking::on_finalize(System::block_number()); } } diff --git a/test/configs/zombieAlphanet.json b/test/configs/zombieAlphanet.json index aeb96d98c8..0d4c7c1389 100644 --- a/test/configs/zombieAlphanet.json +++ b/test/configs/zombieAlphanet.json @@ -14,10 +14,12 @@ "nodes": [ { "name": "alice", + "ws_port": 33346, "validator": true }, { "name": "bob", + "ws_port": 33347, "validator": true } ] diff --git a/test/moonwall.config.json b/test/moonwall.config.json index e923c5910e..b33fdfa26c 100644 --- a/test/moonwall.config.json +++ b/test/moonwall.config.json @@ -75,7 +75,6 @@ { "name": "zombie_moonbase", "testFileDir": ["suites/zombie"], - "runScripts": ["download-polkadot.sh"], "foundation": { "rtUpgradePath": "../target/release/wbuild/moonbase-runtime/moonbase_runtime.compact.compressed.wasm", "type": "zombie", @@ -87,7 +86,6 @@ { "name": "zombie_moonbase_rpc", "testFileDir": ["suites/zombie"], - "runScripts": ["download-polkadot.sh"], "foundation": { "rtUpgradePath": "../target/release/wbuild/moonbase-runtime/moonbase_runtime.compact.compressed.wasm", "type": "zombie", diff --git a/test/suites/dev/test-democracy/test-democracy-fastrack.ts b/test/suites/dev/test-democracy/test-democracy-fastrack.ts deleted file mode 100644 index 431a7d99ab..0000000000 --- a/test/suites/dev/test-democracy/test-democracy-fastrack.ts +++ /dev/null @@ -1,133 +0,0 @@ -import "@moonbeam-network/api-augment"; -import { - ExtrinsicCreation, - beforeEach, - describeSuite, - execCouncilProposal, - execTechnicalCommitteeProposal, - expect, - notePreimage, -} from "@moonwall/cli"; -import { HOURS, alith, baltathar } from "@moonwall/util"; -import { SubmittableExtrinsic } from "@polkadot/api/types"; -import { Result } from "@polkadot/types"; -import { SpRuntimeDispatchError } from "@polkadot/types/lookup"; -import { ISubmittableResult } from "@polkadot/types/types"; -import { generatePrivateKey, privateKeyToAccount } from "viem/accounts"; - -describeSuite({ - id: "D0801", - title: "Democracy - FastTracking", - foundationMethods: "dev", - testCases: ({ it, log, context }) => { - let proposalHash: string; - let proposal: SubmittableExtrinsic<"promise", ISubmittableResult>; - - beforeEach(async () => { - proposal = context - .polkadotJs() - .tx.parachainStaking.setParachainBondAccount( - privateKeyToAccount(generatePrivateKey()).address - ); - proposalHash = await notePreimage(context, proposal, alith); - await execCouncilProposal( - context, - context.polkadotJs().tx.democracy.externalProposeMajority({ - Lookup: { - hash: proposalHash, - len: proposal.method.encodedLength, - }, - }) - ); - }); - - it({ - id: "T01", - title: "should succeed with less than 1/2 of the council", - test: async function () { - const referendumCount = ( - await context.polkadotJs().query.democracy.referendumCount() - ).toNumber(); - const { events }: ExtrinsicCreation = await execTechnicalCommitteeProposal( - context, - context.polkadotJs().tx.democracy.fastTrack(proposalHash, 4 * HOURS, 1), - [alith], - 1 - ); - - expect( - events.findIndex( - ({ event: { section, method } }) => - section == "techCommitteeCollective" && method == "Executed" - ), - "Technical Committee Wrong event" - ).to.equal(2); - expect((events[2].event.data[1] as Result).isOk).to.be.true; - expect( - (await context.polkadotJs().query.democracy.referendumCount()).toNumber(), - "Unexpected count, should not be sent to referendum" - ).toBe(referendumCount + 1); - }, - }); - - it({ - id: "T02", - title: "should succeed with the full council", - test: async function () { - const referendumCount = ( - await context.polkadotJs().query.democracy.referendumCount() - ).toNumber(); - const { events }: ExtrinsicCreation = await execTechnicalCommitteeProposal( - context, - context.polkadotJs().tx.democracy.fastTrack(proposalHash, 1, 1), - [alith, baltathar], - 2 - ); - - expect( - events.findIndex( - ({ event: { section, method } }) => - section == "techCommitteeCollective" && method == "Executed" - ), - "Technical Committee Wrong event" - ).to.equal(4); - expect((events[4].event.data[1] as Result).isOk).to.be.true; - expect( - (await context.polkadotJs().query.democracy.referendumCount()).toNumber(), - "Unexpected count, should not be sent to referendum" - ).toBe(referendumCount + 1); - }, - }); - - it({ - id: "T03", - title: "should fail with less than 1/2 of the council", - test: async function () { - const referendumCount = ( - await context.polkadotJs().query.democracy.referendumCount() - ).toNumber(); - const { events }: ExtrinsicCreation = await execTechnicalCommitteeProposal( - context, - context.polkadotJs().tx.democracy.fastTrack(proposalHash, 1, 1), - [alith], - 1 - ); - - expect( - events.findIndex( - ({ event: { section, method } }) => - section == "techCommitteeCollective" && method == "Executed" - ), - "Technical Committee Wrong event" - ).to.equal(1); - expect((events[1].event.data[1] as Result).asErr.isBadOrigin) - .to.be.true; - - expect( - (await context.polkadotJs().query.democracy.referendumCount()).toNumber(), - "Unexpected count, should not be sent to referendum" - ).toBe(referendumCount); - }, - }); - }, -}); diff --git a/test/suites/dev/test-democracy/test-democracy-genesis.ts b/test/suites/dev/test-democracy/test-democracy-genesis.ts deleted file mode 100644 index ddd7e8a511..0000000000 --- a/test/suites/dev/test-democracy/test-democracy-genesis.ts +++ /dev/null @@ -1,70 +0,0 @@ -import "@moonbeam-network/api-augment"; -import { describeSuite, expect } from "@moonwall/cli"; - -describeSuite({ - id: "D0802", - title: "Democracy - genesis", - foundationMethods: "dev", - testCases: ({ context, it }) => { - it({ - id: "T01", - title: "should have no referendum", - test: async function () { - expect((await context.polkadotJs().query.democracy.referendumCount()).toNumber()).to.equal( - 0 - ); - }, - }); - it({ - id: "T02", - title: "should have no preimages", - test: async function () { - expect((await context.polkadotJs().query.preimage.preimageFor.entries()).length).to.equal( - 0 - ); - }, - }); - it({ - id: "T03", - title: "should have an enactment of 7500", - test: async function () { - expect(context.polkadotJs().consts.democracy.enactmentPeriod.toNumber()).to.equal(7500); - }, - }); - it({ - id: "T04", - title: "should have a voting period of 36000", - test: async function () { - expect(context.polkadotJs().consts.democracy.votingPeriod.toNumber()).to.equal(36000); - }, - }); - it({ - id: "T05", - title: "should have a launch period of 7200", - test: async function () { - expect(context.polkadotJs().consts.democracy.launchPeriod.toNumber()).to.equal(7200); - }, - }); - it({ - id: "T06", - title: "should have a locking period of 7200", - test: async function () { - expect(context.polkadotJs().consts.democracy.voteLockingPeriod.toNumber()).to.equal(7200); - }, - }); - it({ - id: "T07", - title: "should have a cooloff period of 50400", - test: async function () { - expect(context.polkadotJs().consts.democracy.cooloffPeriod.toNumber()).to.equal(50400); - }, - }); - it({ - id: "T08", - title: "should have instant fast track allowed", - test: async function () { - expect(context.polkadotJs().consts.democracy.instantAllowed.isTrue).to.be.true; - }, - }); - }, -}); diff --git a/test/suites/dev/test-precompile/test-precompile-conviction-voting5.ts b/test/suites/dev/test-precompile/test-precompile-conviction-voting5.ts index 40de319997..946761e656 100644 --- a/test/suites/dev/test-precompile/test-precompile-conviction-voting5.ts +++ b/test/suites/dev/test-precompile/test-precompile-conviction-voting5.ts @@ -31,7 +31,7 @@ describeSuite({ .voteYes(proposalIndex, alithAccount.data.free.toBigInt() - 20n * 10n ** 18n, 1n) .block(); // 20 minutes jump - await jumpBlocks(context, (20 * 60) / 12); + await jumpBlocks(context, (20 * 60) / 6); // Verifies the setup is correct const referendum = await context diff --git a/test/suites/dev/test-staking/test-staking-consts.ts b/test/suites/dev/test-staking/test-staking-consts.ts index 9d73ce015d..23b693f554 100644 --- a/test/suites/dev/test-staking/test-staking-consts.ts +++ b/test/suites/dev/test-staking/test-staking-consts.ts @@ -70,6 +70,7 @@ describeSuite({ let nonce = await context .viem() .getTransactionCount({ address: randomAccount.address as `0x${string}` }); + for (const randomCandidatesChunk of chunk(randomCandidates, 20)) { await context.createBlock( randomCandidatesChunk.map((randomCandidate) => diff --git a/test/suites/dev/test-staking/test-staking-locks9.ts b/test/suites/dev/test-staking/test-staking-locks9.ts index ddb9d3a5fc..3300a9d62a 100644 --- a/test/suites/dev/test-staking/test-staking-locks9.ts +++ b/test/suites/dev/test-staking/test-staking-locks9.ts @@ -72,6 +72,7 @@ describeSuite({ let nonce = await context .viem() .getTransactionCount({ address: randomAccount.address as `0x${string}` }); + for (const randomCandidatesChunk of chunk(randomCandidates, 20)) { await context.createBlock( randomCandidatesChunk.map( diff --git a/test/suites/zombie/test_para.ts b/test/suites/zombie/test_para.ts index 16bb007449..37005e0f2a 100644 --- a/test/suites/zombie/test_para.ts +++ b/test/suites/zombie/test_para.ts @@ -75,7 +75,7 @@ describeSuite({ it({ id: "T03", title: "Can connect to parachain and execute a transaction", - timeout: 60000, + timeout: 240000, test: async () => { const balBefore = (await paraApi.query.system.account(BALTATHAR_ADDRESS)).data.free; @@ -83,19 +83,39 @@ describeSuite({ context.waitBlock(5); - await new Promise((resolve) => { - paraApi.tx.balances - .transferAllowDeath(BALTATHAR_ADDRESS, ethers.parseEther("2")) - .signAndSend(charleth, ({ status, events }) => { - if (status.isInBlock) { - log("Transaction is in block"); - } - if (status.isFinalized) { - log("Transaction is finalized!"); - resolve(events); - } - }); - }); + // TODO: Renable the below when we are using polkadot 1.7.0 + // There is a discrepancy with polkadotJs and 1.3.0 + // + // await new Promise((resolve, reject) => { + // paraApi.tx.balances + // .transferAllowDeath(BALTATHAR_ADDRESS, ethers.parseEther("2")) + // .signAndSend(charleth, ({ status, events }) => { + // if (status.isInBlock) { + // log("Transaction is in block"); + // } + // if (status.isFinalized) { + // log("Transaction is finalized!"); + // resolve(events); + // } + + // if ( + // status.isDropped || + // status.isInvalid || + // status.isUsurped || + // status.isFinalityTimeout + // ) { + // reject("transaction failed!"); + // throw new Error("Transaction failed"); + // } + // }); + // }) + + await paraApi.tx.balances + .transferAllowDeath(BALTATHAR_ADDRESS, ethers.parseEther("2")) + .signAndSend(charleth); + + // TODO: Remove waitBlock below when we are using polkadot 1.7.0 + await context.waitBlock(2); const balAfter = (await paraApi.query.system.account(BALTATHAR_ADDRESS)).data.free; expect(balBefore.lt(balAfter)).to.be.true;