diff --git a/src/macros.rs b/src/macros.rs index 1003af907..7f542b273 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -53,10 +53,8 @@ macro_rules! for_legacy_runtime { use $crate::static_types::legacy::westend::MinerConfig; $($code)* }, - $crate::opt::Chain::AssetHubNext => { - #[allow(unused)] - use $crate::static_types::legacy::westend::MinerConfig; - $($code)* + $crate::opt::Chain::StakingAsync => { + panic!("StakingAsync is not supported in legacy monitor"); } $crate::opt::Chain::SubstrateNode => { #[allow(unused)] @@ -87,9 +85,9 @@ macro_rules! for_multi_block_runtime { use $crate::static_types::multi_block::westend::MinerConfig; $($code)* }, - $crate::opt::Chain::AssetHubNext => { + $crate::opt::Chain::StakingAsync => { #[allow(unused)] - use $crate::static_types::multi_block::westend::MinerConfig; + use $crate::static_types::multi_block::staking_async::MinerConfig; $($code)* } $crate::opt::Chain::SubstrateNode => { diff --git a/src/main.rs b/src/main.rs index fce675642..64f74e47d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -459,4 +459,15 @@ mod tests { ) ); } + + #[test] + #[should_panic(expected = "StakingAsync is not supported in legacy monitor")] + fn for_legacy_runtime_panics_on_staking_async() { + use crate::opt::Chain; + let chain = Chain::StakingAsync; + macros::for_legacy_runtime!(chain, { + // This block should never be executed + let _ = (); + }); + } } diff --git a/src/opt.rs b/src/opt.rs index 3bca51d14..ef891e609 100644 --- a/src/opt.rs +++ b/src/opt.rs @@ -51,7 +51,7 @@ pub enum Chain { Kusama, Polkadot, SubstrateNode, - AssetHubNext, + StakingAsync, } impl fmt::Display for Chain { @@ -61,7 +61,7 @@ impl fmt::Display for Chain { Self::Kusama => "kusama", Self::Westend => "westend", Self::SubstrateNode => "node", - Self::AssetHubNext => "asset-hub-next", + Self::StakingAsync => "staking-async", }; write!(f, "{}", chain) } @@ -73,9 +73,15 @@ impl std::str::FromStr for Chain { fn from_str(s: &str) -> Result { match s { "polkadot" => Ok(Self::Polkadot), + "statemint" => Ok(Self::Polkadot), // Polkadot AH "kusama" => Ok(Self::Kusama), + "statemine" => Ok(Self::Kusama), // Kusama AH "westend" => Ok(Self::Westend), - "asset-hub-next" => Ok(Self::AssetHubNext), + "westmint" => Ok(Self::Westend), // Westend AH + "staking-async-parachain" => Ok(Self::StakingAsync), + "staking-async-rc" => { + unimplemented!("multi-block mining is not supported on relay chains") + } "node" => Ok(Self::SubstrateNode), chain => Err(Error::InvalidChain(chain.to_string())), } diff --git a/src/static_types/multi_block.rs b/src/static_types/multi_block.rs index 634a45c65..aec2a33d3 100644 --- a/src/static_types/multi_block.rs +++ b/src/static_types/multi_block.rs @@ -157,3 +157,40 @@ pub mod westend { type Hash = Hash; } } + +/// This is used to test against staking-async runtimes from the SDK. +pub mod staking_async { + use super::*; + use frame_election_provider_support::SequentialPhragmen; + + // TODO: validate config https://github.com/paritytech/polkadot-staking-miner/issues/994 + frame_election_provider_support::generate_solution_type!( + #[compact] + pub struct NposSolution16::< + VoterIndex = u32, + TargetIndex = u16, + Accuracy = PerU16, + MaxVoters = ConstU32::<22500> + >(16) + ); + + #[derive(Debug)] + pub struct MinerConfig; + + // TODO: validate config https://github.com/paritytech/polkadot-staking-miner/issues/994 + impl multi_block::unsigned::miner::MinerConfig for MinerConfig { + type AccountId = AccountId; + type Solution = NposSolution16; + // TODO: make it configurable via CLI https://github.com/paritytech/polkadot-staking-miner/issues/989 + type Solver = SequentialPhragmen; + type Pages = Pages; + type MaxVotesPerVoter = ConstU32<16>; + type MaxWinnersPerPage = MaxWinnersPerPage; + type MaxBackersPerWinner = MaxBackersPerWinner; + type MaxBackersPerWinnerFinal = ConstU32<{ u32::MAX }>; + type VoterSnapshotPerBlock = VoterSnapshotPerBlock; + type TargetSnapshotPerBlock = TargetSnapshotPerBlock; + type MaxLength = MaxLength; + type Hash = Hash; + } +} diff --git a/tests/common.rs b/tests/common.rs index e2d328218..3d58c3287 100644 --- a/tests/common.rs +++ b/tests/common.rs @@ -84,7 +84,7 @@ pub fn run_polkadot_node(chain: Chain) -> (KillChildOnDrop, String) { Chain::Kusama => "chainspecs/kusama-dev.json", Chain::Westend => "westend-dev", Chain::SubstrateNode => "dev", - Chain::AssetHubNext => panic!("AssetHubNext is not supported"), + Chain::StakingAsync => panic!("StakingAsync is not supported"), }; let mut node_cmd = KillChildOnDrop(