diff --git a/Cargo.lock b/Cargo.lock index 15f3e0ff2..2ca21ef6c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1359,7 +1359,6 @@ dependencies = [ name = "container-chain-template-simple-runtime" version = "0.1.0" dependencies = [ - "cumulus-pallet-aura-ext", "cumulus-pallet-parachain-system", "cumulus-pallet-session-benchmarking", "cumulus-primitives-core", @@ -1374,9 +1373,7 @@ dependencies = [ "hex-literal 0.3.4", "log", "nimbus-primitives", - "pallet-aura", "pallet-author-inherent", - "pallet-authorship", "pallet-balances", "pallet-cc-authorities-noting", "pallet-session", @@ -1917,22 +1914,6 @@ dependencies = [ "sp-transaction-pool", ] -[[package]] -name = "cumulus-pallet-aura-ext" -version = "0.1.0" -source = "git+https://github.com/moondance-labs/cumulus?branch=tanssi-polkadot-v0.9.43#23fbedfbe8887e09eb6f098a8cae72f0615c96a8" -dependencies = [ - "frame-support", - "frame-system", - "pallet-aura", - "parity-scale-codec", - "scale-info", - "sp-application-crypto", - "sp-consensus-aura", - "sp-runtime", - "sp-std", -] - [[package]] name = "cumulus-pallet-parachain-system" version = "0.1.0" @@ -2252,7 +2233,6 @@ dependencies = [ name = "dancebox-runtime" version = "0.1.0" dependencies = [ - "cumulus-pallet-aura-ext", "cumulus-pallet-parachain-system", "cumulus-pallet-session-benchmarking", "cumulus-primitives-core", @@ -2267,12 +2247,10 @@ dependencies = [ "hex-literal 0.3.4", "log", "nimbus-primitives", - "pallet-aura", "pallet-author-inherent", "pallet-author-noting", "pallet-authority-assignment", "pallet-authority-mapping", - "pallet-authorship", "pallet-balances", "pallet-collator-assignment", "pallet-collator-assignment-runtime-api", @@ -6459,22 +6437,6 @@ dependencies = [ "libm 0.1.4", ] -[[package]] -name = "pallet-aura" -version = "4.0.0-dev" -source = "git+https://github.com/moondance-labs/substrate?branch=tanssi-polkadot-v0.9.43#11f2f27ba5af2d4e8eb1f73ae0056106be5bcfb2" -dependencies = [ - "frame-support", - "frame-system", - "pallet-timestamp", - "parity-scale-codec", - "scale-info", - "sp-application-crypto", - "sp-consensus-aura", - "sp-runtime", - "sp-std", -] - [[package]] name = "pallet-author-inherent" version = "0.9.0" diff --git a/Cargo.toml b/Cargo.toml index 1001e1deb..4d99d9cce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,8 +61,6 @@ frame-system = { git = "https://github.com/moondance-labs/substrate.git", branch frame-system-benchmarking = { git = "https://github.com/moondance-labs/substrate", branch = "tanssi-polkadot-v0.9.43", default-features = false } frame-system-rpc-runtime-api = { git = "https://github.com/moondance-labs/substrate", branch = "tanssi-polkadot-v0.9.43", default-features = false } frame-try-runtime = { git = "https://github.com/moondance-labs/substrate", branch = "tanssi-polkadot-v0.9.43", default-features = false } -pallet-aura = { git = "https://github.com/moondance-labs/substrate", branch = "tanssi-polkadot-v0.9.43", default-features = false } -pallet-authorship = { git = "https://github.com/moondance-labs/substrate", branch = "tanssi-polkadot-v0.9.43", default-features = false } pallet-balances = { git = "https://github.com/moondance-labs/substrate", branch = "tanssi-polkadot-v0.9.43", default-features = false } pallet-root-testing = { git = "https://github.com/moondance-labs/substrate", branch = "tanssi-polkadot-v0.9.43", default-features = false } pallet-session = { git = "https://github.com/moondance-labs/substrate", branch = "tanssi-polkadot-v0.9.43", default-features = false } @@ -135,7 +133,6 @@ polkadot-primitives = { git = "https://github.com/moondance-labs/polkadot", bran polkadot-service = { git = "https://github.com/moondance-labs/polkadot", branch = "tanssi-polkadot-v0.9.43" } # Cumulus (wasm) -cumulus-pallet-aura-ext = { git = "https://github.com/moondance-labs/cumulus", branch = "tanssi-polkadot-v0.9.43", default-features = false } cumulus-pallet-parachain-system = { git = "https://github.com/moondance-labs/cumulus", branch = "tanssi-polkadot-v0.9.43", default-features = false } cumulus-pallet-session-benchmarking = { git = "https://github.com/moondance-labs/cumulus", branch = "tanssi-polkadot-v0.9.43", default-features = false } cumulus-primitives-core = { git = "https://github.com/moondance-labs/cumulus", branch = "tanssi-polkadot-v0.9.43", default-features = false } diff --git a/container-chains/templates/simple/runtime/Cargo.toml b/container-chains/templates/simple/runtime/Cargo.toml index 8698316a2..e88126f8a 100644 --- a/container-chains/templates/simple/runtime/Cargo.toml +++ b/container-chains/templates/simple/runtime/Cargo.toml @@ -29,8 +29,6 @@ frame-executive = { workspace = true } frame-support = { workspace = true } frame-system = { workspace = true } frame-system-rpc-runtime-api = { workspace = true } -pallet-aura = { workspace = true } -pallet-authorship = { workspace = true } pallet-balances = { workspace = true } pallet-session = { workspace = true } pallet-sudo = { workspace = true } @@ -55,7 +53,6 @@ polkadot-parachain = { workspace = true } polkadot-runtime-common = { workspace = true } # Cumulus -cumulus-pallet-aura-ext = { workspace = true } cumulus-pallet-parachain-system = { workspace = true } cumulus-pallet-session-benchmarking = { workspace = true } cumulus-primitives-core = { workspace = true } @@ -75,7 +72,6 @@ default = [ "std", ] std = [ - "cumulus-pallet-aura-ext/std", "cumulus-pallet-parachain-system/std", "cumulus-primitives-core/std", "cumulus-primitives-timestamp/std", @@ -86,9 +82,7 @@ std = [ "frame-try-runtime/std", "log/std", "nimbus-primitives/std", - "pallet-aura/std", "pallet-author-inherent/std", - "pallet-authorship/std", "pallet-balances/std", "pallet-cc-authorities-noting/std", "pallet-session/std", @@ -132,8 +126,6 @@ try-runtime = [ "frame-executive/try-runtime", "frame-support/try-runtime", "frame-system/try-runtime", - "pallet-aura/try-runtime", - "pallet-authorship/try-runtime", "pallet-balances/try-runtime", "pallet-session/try-runtime", "pallet-sudo/try-runtime", @@ -141,7 +133,6 @@ try-runtime = [ "pallet-utility/try-runtime", "sp-runtime/try-runtime", "polkadot-runtime-common/try-runtime", - "cumulus-pallet-aura-ext/try-runtime", "cumulus-pallet-parachain-system/try-runtime", "parachain-info/try-runtime", "frame-try-runtime" diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 73a836894..4b0480f4b 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -312,10 +312,6 @@ fn testnet_genesis( }) .collect(), }, - // no need to pass anything to aura, in fact it will panic if we do. Session will take care - // of this. - aura: Default::default(), - aura_ext: Default::default(), parachain_system: Default::default(), configuration, registrar: RegistrarConfig { diff --git a/pallets/registrar/src/benchmarks.rs b/pallets/registrar/src/benchmarks.rs index e407c9977..8a695dba9 100644 --- a/pallets/registrar/src/benchmarks.rs +++ b/pallets/registrar/src/benchmarks.rs @@ -20,8 +20,7 @@ use { crate::{Call, Config, DepositBalanceOf, Pallet}, frame_benchmarking::{account, v2::*}, - frame_support::traits::Currency, - frame_support::BoundedVec, + frame_support::{traits::Currency, BoundedVec}, frame_system::RawOrigin, sp_core::Get, sp_std::vec, diff --git a/runtime/dancebox/Cargo.toml b/runtime/dancebox/Cargo.toml index ebe6e8033..81909149f 100644 --- a/runtime/dancebox/Cargo.toml +++ b/runtime/dancebox/Cargo.toml @@ -37,8 +37,6 @@ frame-executive = { workspace = true } frame-support = { workspace = true } frame-system = { workspace = true } frame-system-rpc-runtime-api = { workspace = true } -pallet-aura = { workspace = true } -pallet-authorship = { workspace = true } pallet-balances = { workspace = true } pallet-root-testing = { workspace = true } pallet-session = { workspace = true } @@ -68,7 +66,6 @@ polkadot-parachain = { workspace = true } polkadot-runtime-common = { workspace = true } # Cumulus -cumulus-pallet-aura-ext = { workspace = true } cumulus-pallet-parachain-system = { workspace = true } cumulus-pallet-session-benchmarking = { workspace = true } cumulus-primitives-core = { workspace = true } @@ -92,7 +89,6 @@ default = [ "std", ] std = [ - "cumulus-pallet-aura-ext/std", "cumulus-pallet-parachain-system/std", "cumulus-primitives-core/std", "cumulus-primitives-timestamp/std", @@ -103,10 +99,8 @@ std = [ "frame-try-runtime/std", "log/std", "nimbus-primitives/std", - "pallet-aura/std", "pallet-author-noting/std", "pallet-authority-assignment/std", - "pallet-authorship/std", "pallet-balances/std", "pallet-collator-assignment-runtime-api/std", "pallet-collator-selection/std", @@ -169,8 +163,6 @@ try-runtime = [ "frame-executive/try-runtime", "frame-support/try-runtime", "frame-system/try-runtime", - "pallet-aura/try-runtime", - "pallet-authorship/try-runtime", "pallet-balances/try-runtime", "pallet-root-testing/try-runtime", "pallet-session/try-runtime", @@ -179,7 +171,6 @@ try-runtime = [ "pallet-utility/try-runtime", "sp-runtime/try-runtime", "polkadot-runtime-common/try-runtime", - "cumulus-pallet-aura-ext/try-runtime", "cumulus-pallet-parachain-system/try-runtime", "pallet-collator-selection/try-runtime", "parachain-info/try-runtime", diff --git a/runtime/dancebox/src/lib.rs b/runtime/dancebox/src/lib.rs index a5d7ed267..80098cce2 100644 --- a/runtime/dancebox/src/lib.rs +++ b/runtime/dancebox/src/lib.rs @@ -35,7 +35,7 @@ use { construct_runtime, dispatch::DispatchClass, parameter_types, - traits::{ConstU32, ConstU64, Everything, OneSessionHandler}, + traits::{ConstU32, ConstU64, Everything}, weights::{ constants::{ BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, @@ -309,11 +309,6 @@ impl pallet_timestamp::Config for Runtime { type WeightInfo = (); } -impl pallet_authorship::Config for Runtime { - type FindAuthor = pallet_session::FindAccountFromAuthorIndex; - type EventHandler = (CollatorSelection,); -} - pub struct CanAuthor; impl nimbus_primitives::CanAuthor for CanAuthor { fn can_author(author: &NimbusId, slot: &u32) -> bool { @@ -325,7 +320,8 @@ impl nimbus_primitives::CanAuthor for CanAuthor { return false; } - let expected_author = &authorities[(*slot as usize) % authorities.len()]; + let author_index = (*slot as usize) % authorities.len(); + let expected_author = &authorities[author_index]; expected_author == author } @@ -381,7 +377,7 @@ impl cumulus_pallet_parachain_system::Config for Runtime { pub struct OwnApplySession; impl pallet_initializer::ApplyNewSession for OwnApplySession { fn apply_new_session( - changed: bool, + _changed: bool, session_index: u32, all_validators: Vec<(AccountId, NimbusId)>, queued: Vec<(AccountId, NimbusId)>, @@ -405,40 +401,6 @@ impl pallet_initializer::ApplyNewSession for OwnApplySession { &queued_id_to_nimbus_map, &assignments.next_assignment, ); - - let orchestrator_current_assignemnt = assignments.active_assignment.orchestrator_chain; - let orchestrator_queued_assignemnt = assignments.next_assignment.orchestrator_chain; - - // We filter the accounts based on the collators assigned to the orchestrator chain (this chain) - // We insert these in Aura - let validators: Vec<_> = all_validators - .iter() - .filter_map(|(k, v)| { - if orchestrator_current_assignemnt.contains(k) { - Some((k, v.clone())) - } else { - None - } - }) - .collect(); - - let queued: Vec<_> = queued - .iter() - .filter_map(|(k, v)| { - if orchestrator_queued_assignemnt.contains(k) { - Some((k, v.clone())) - } else { - None - } - }) - .collect(); - - // Then we apply Aura - if session_index == 0 { - Aura::on_genesis_session(validators.into_iter()); - } else { - Aura::on_new_session(changed, validators.into_iter(), queued.into_iter()); - } } } @@ -453,8 +415,6 @@ impl pallet_initializer::Config for Runtime { impl parachain_info::Config for Runtime {} -impl cumulus_pallet_aura_ext::Config for Runtime {} - parameter_types! { pub const Period: u32 = prod_or_fast!(6 * HOURS, 1 * MINUTES); pub const Offset: u32 = 0; @@ -474,12 +434,6 @@ impl pallet_session::Config for Runtime { type WeightInfo = (); } -impl pallet_aura::Config for Runtime { - type AuthorityId = NimbusId; - type DisabledValidators = (); - type MaxAuthorities = ConstU32<100_000>; -} - impl pallet_collator_assignment::Config for Runtime { type HostConfiguration = Configuration; type ContainerChains = Registrar; @@ -618,14 +572,10 @@ construct_runtime!( AuthorityAssignment: pallet_authority_assignment = 25, // Collator support. The order of these 4 are important and shall not change. - Authorship: pallet_authorship = 30, - CollatorSelection: pallet_collator_selection = 31, - Session: pallet_session = 32, - Aura: pallet_aura = 33, - AuraExt: cumulus_pallet_aura_ext = 34, - AuthorityMapping: pallet_authority_mapping = 35, - - AuthorInherent: pallet_author_inherent = 50, + CollatorSelection: pallet_collator_selection = 30, + Session: pallet_session = 31, + AuthorityMapping: pallet_authority_mapping = 32, + AuthorInherent: pallet_author_inherent = 33, RootTesting: pallet_root_testing = 100, } @@ -634,11 +584,13 @@ construct_runtime!( impl_runtime_apis! { impl sp_consensus_aura::AuraApi for Runtime { fn slot_duration() -> sp_consensus_aura::SlotDuration { - sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration()) + sp_consensus_aura::SlotDuration::from_millis(SLOT_DURATION) } fn authorities() -> Vec { - Aura::authorities().into_inner() + pallet_authority_assignment::CollatorContainerChain::::get(Session::current_index()) + .expect("authorities for current session should exist") + .orchestrator_chain } } diff --git a/runtime/dancebox/tests/common/mod.rs b/runtime/dancebox/tests/common/mod.rs index a8a66bd33..51a179e0a 100644 --- a/runtime/dancebox/tests/common/mod.rs +++ b/runtime/dancebox/tests/common/mod.rs @@ -16,12 +16,13 @@ use { cumulus_primitives_core::PersistedValidationData, + dancebox_runtime::{AuthorInherent, AuthorityAssignment}, frame_support::{ assert_ok, dispatch::Dispatchable, traits::{GenesisBuild, OnFinalize, OnInitialize}, }, - nimbus_primitives::NimbusId, + nimbus_primitives::{NimbusId, NIMBUS_ENGINE_ID}, pallet_collator_assignment_runtime_api::runtime_decl_for_collator_assignment_api::CollatorAssignmentApi, pallet_registrar_runtime_api::ContainerChainGenesisData, parity_scale_codec::Encode, @@ -30,54 +31,55 @@ use { sp_core::{Get, Pair}, sp_runtime::{Digest, DigestItem}, test_relay_sproof_builder::ParaHeaderSproofBuilder, + tp_consensus::runtime_decl_for_tanssi_authority_assignment_api::TanssiAuthorityAssignmentApi, }; pub use dancebox_runtime::{ - AccountId, Aura, Authorship, Balance, Balances, Initializer, ParachainInfo, Registrar, Runtime, - RuntimeCall, RuntimeEvent, Session, System, + AccountId, Balance, Balances, Initializer, ParachainInfo, Registrar, Runtime, RuntimeCall, + RuntimeEvent, Session, System, }; -pub fn run_to_session(n: u32, add_author: bool) { +pub fn run_to_session(n: u32) { let block_number = dancebox_runtime::Period::get() * n; - run_to_block(block_number + 1, add_author); + run_to_block(block_number + 1); } /// Utility function that advances the chain to the desired block number. -/// If add_author is true, the author information is injected to all the blocks in the meantime. -pub fn run_to_block(n: u32, add_author: bool) { - /* - // Finalize the first block - AuthorInherent::on_finalize(System::block_number()); - */ +pub fn run_to_block(n: u32) { while System::block_number() < n { - // Set the new block number and author - if add_author { - let slot = Aura::current_slot(); - let pre_digest = Digest { - logs: vec![DigestItem::PreRuntime(AURA_ENGINE_ID, (slot + 1).encode())], - }; - System::reset_events(); - System::initialize( - &(System::block_number() + 1), - &System::parent_hash(), - &pre_digest, - ); - } else { - System::set_block_number(System::block_number() + 1); - } + let slot = current_slot() + 1; - // Initialize the new block + let authorities = + Runtime::para_id_authorities(ParachainInfo::get()).expect("authorities should be set"); + + let authority: NimbusId = authorities[slot as usize % authorities.len()].clone(); + + let pre_digest = Digest { + logs: vec![ + DigestItem::PreRuntime(AURA_ENGINE_ID, slot.encode()), + DigestItem::PreRuntime(NIMBUS_ENGINE_ID, authority.encode()), + ], + }; + System::reset_events(); + System::initialize( + &(System::block_number() + 1), + &System::parent_hash(), + &pre_digest, + ); + + // Initialize the new block Session::on_initialize(System::block_number()); Initializer::on_initialize(System::block_number()); - Aura::on_initialize(System::block_number()); - Authorship::on_initialize(System::block_number()); + AuthorInherent::on_initialize(System::block_number()); + + pallet_author_inherent::Pallet::::kick_off_authorship_validation(None.into()) + .expect("author inherent to dispatch correctly"); // Finalize the block Session::on_finalize(System::block_number()); Initializer::on_finalize(System::block_number()); - Aura::on_finalize(System::block_number()); - Authorship::on_finalize(System::block_number()); + AuthorInherent::on_finalize(System::block_number()); } } @@ -224,7 +226,7 @@ pub fn get_aura_id_from_seed(seed: &str) -> NimbusId { } pub fn get_orchestrator_current_author() -> Option { - let slot: u64 = Aura::current_slot().into(); + let slot: u64 = current_slot().into(); let orchestrator_collators = Runtime::parachain_collators(ParachainInfo::get())?; let author_index = slot % orchestrator_collators.len() as u64; let account = orchestrator_collators.get(author_index as usize)?; @@ -267,3 +269,30 @@ pub fn empty_genesis_data() -> ContainerChainGenesisData { properties: Default::default(), } } + +pub fn current_slot() -> u64 { + pallet_author_inherent::HighestSlotSeen::::get().into() +} + +pub fn authorities() -> Vec { + let session_index = Session::current_index(); + + AuthorityAssignment::collator_container_chain(session_index) + .expect("authorities should be set") + .orchestrator_chain +} + +pub fn current_author() -> AccountId { + let current_session = Session::current_index(); + let mapping = + pallet_authority_mapping::Pallet::::authority_id_mapping(current_session) + .expect("there is a mapping for the current session"); + + let author = pallet_author_inherent::Author::::get() + .expect("there should be a registered author"); + + mapping + .get(&author) + .expect("there is a mapping for the current author") + .clone() +} diff --git a/runtime/dancebox/tests/integration_test.rs b/runtime/dancebox/tests/integration_test.rs index c4917537a..e48d62520 100644 --- a/runtime/dancebox/tests/integration_test.rs +++ b/runtime/dancebox/tests/integration_test.rs @@ -99,6 +99,16 @@ fn genesis_para_registrar_deregister() { (1001, empty_genesis_data(), vec![]), (1002, empty_genesis_data(), vec![]), ]) + .with_collators(vec![ + (AccountId::from(ALICE), 210 * UNIT), + (AccountId::from(BOB), 100 * UNIT), + ]) + .with_config(pallet_configuration::HostConfiguration { + max_collators: 100, + min_orchestrator_collators: 2, + max_orchestrator_collators: 2, + collators_per_container: 2, + }) .build() .execute_with(|| { assert_eq!( @@ -106,7 +116,7 @@ fn genesis_para_registrar_deregister() { vec![1001.into(), 1002.into()] ); - run_to_block(2, false); + run_to_block(2); assert_ok!(Registrar::deregister(root_origin(), 1002.into()), ()); // Pending @@ -115,7 +125,7 @@ fn genesis_para_registrar_deregister() { vec![(2u32, BoundedVec::try_from(vec![1001u32.into()]).unwrap())] ); - run_to_session(1, false); + run_to_session(1); assert_eq!( Registrar::pending_registered_para_ids(), vec![(2u32, BoundedVec::try_from(vec![1001u32.into()]).unwrap())] @@ -125,7 +135,7 @@ fn genesis_para_registrar_deregister() { vec![1001.into(), 1002.into()] ); - run_to_session(2, false); + run_to_session(2); assert_eq!(Registrar::pending_registered_para_ids(), vec![]); assert_eq!(Registrar::registered_para_ids(), vec![1001.into()]); }); @@ -143,6 +153,16 @@ fn genesis_para_registrar_runtime_api() { (1001, empty_genesis_data(), vec![]), (1002, empty_genesis_data(), vec![]), ]) + .with_collators(vec![ + (AccountId::from(ALICE), 210 * UNIT), + (AccountId::from(BOB), 100 * UNIT), + ]) + .with_config(pallet_configuration::HostConfiguration { + max_collators: 100, + min_orchestrator_collators: 2, + max_orchestrator_collators: 2, + collators_per_container: 2, + }) .build() .execute_with(|| { assert_eq!( @@ -151,18 +171,18 @@ fn genesis_para_registrar_runtime_api() { ); assert_eq!(Runtime::registered_paras(), vec![1001.into(), 1002.into()]); - run_to_block(2, false); + run_to_block(2); assert_ok!(Registrar::deregister(root_origin(), 1002.into()), ()); assert_eq!(Runtime::registered_paras(), vec![1001.into(), 1002.into()]); - run_to_session(1, false); + run_to_session(1); assert_eq!( Registrar::registered_para_ids(), vec![1001.into(), 1002.into()] ); assert_eq!(Runtime::registered_paras(), vec![1001.into(), 1002.into()]); - run_to_session(2, false); + run_to_session(2); assert_eq!(Registrar::registered_para_ids(), vec![1001.into()]); assert_eq!(Runtime::registered_paras(), vec![1001.into()]); }); @@ -189,6 +209,16 @@ fn genesis_para_registrar_container_chain_genesis_data_runtime_api() { (1001, genesis_data_1001.clone(), vec![]), (1002, genesis_data_1002.clone(), vec![]), ]) + .with_collators(vec![ + (AccountId::from(ALICE), 210 * UNIT), + (AccountId::from(BOB), 100 * UNIT), + ]) + .with_config(pallet_configuration::HostConfiguration { + max_collators: 100, + min_orchestrator_collators: 2, + max_orchestrator_collators: 2, + collators_per_container: 2, + }) .build() .execute_with(|| { assert_eq!( @@ -212,7 +242,7 @@ fn genesis_para_registrar_container_chain_genesis_data_runtime_api() { // TODO: where is that 100 defined? assert_eq!(Runtime::genesis_data(100.into()).as_ref(), None); - run_to_block(2, false); + run_to_block(2); assert_ok!(Registrar::deregister(root_origin(), 1002.into()), ()); // Deregistered container chains are deleted immediately @@ -268,17 +298,17 @@ fn test_author_collation_aura() { }) .build() .execute_with(|| { - run_to_block(5, true); + run_to_block(5); // Assert current slot gets updated - assert_eq!(Aura::current_slot(), 4u64); + assert_eq!(current_slot(), 4u64); // slot 4, alice - assert!(Authorship::author().unwrap() == AccountId::from(ALICE)); + assert!(current_author() == AccountId::from(ALICE)); - run_to_block(6, true); + run_to_block(6); - assert_eq!(Aura::current_slot(), 5u64); + assert_eq!(current_slot(), 5u64); // slot 5, bob - assert!(Authorship::author().unwrap() == AccountId::from(BOB)); + assert!(current_author() == AccountId::from(BOB)); }); } @@ -308,10 +338,10 @@ fn test_author_collation_aura_change_of_authorities_on_session() { }) .build() .execute_with(|| { - run_to_block(2, true); + run_to_block(2); // Assert current slot gets updated - assert_eq!(Aura::current_slot(), 1u64); - assert!(Authorship::author().unwrap() == AccountId::from(BOB)); + assert_eq!(current_slot(), 1u64); + assert!(current_author() == AccountId::from(BOB)); // We change invulnerables // We first need to set the keys @@ -344,18 +374,18 @@ fn test_author_collation_aura_change_of_authorities_on_session() { )); // SESSION CHANGE. First session. it takes 2 sessions to see the change - run_to_session(1u32, true); + run_to_session(1u32); let author = get_orchestrator_current_author().unwrap(); - assert_eq!(Authorship::author().unwrap(), author); - assert!(Aura::authorities() == vec![alice_id, bob_id]); + assert_eq!(current_author(), author); + assert!(authorities() == vec![alice_id, bob_id]); // Invulnerables should have triggered on new session authorities change - run_to_session(2u32, true); + run_to_session(2u32); let author_after_changes = get_orchestrator_current_author().unwrap(); - assert_eq!(Authorship::author().unwrap(), author_after_changes); - assert_eq!(Aura::authorities(), vec![charlie_id, dave_id]); + assert_eq!(current_author(), author_after_changes); + assert_eq!(authorities(), vec![charlie_id, dave_id]); }); } @@ -385,10 +415,10 @@ fn test_author_collation_aura_add_assigned_to_paras() { }) .build() .execute_with(|| { - run_to_block(2, true); + run_to_block(2); // Assert current slot gets updated - assert_eq!(Aura::current_slot(), 1u64); - assert!(Authorship::author().unwrap() == AccountId::from(BOB)); + assert_eq!(current_slot(), 1u64); + assert!(current_author() == AccountId::from(BOB)); // We change invulnerables // We first need to set the keys @@ -417,16 +447,16 @@ fn test_author_collation_aura_add_assigned_to_paras() { )); // SESSION CHANGE. First session. it takes 2 sessions to see the change - run_to_session(1u32, true); + run_to_session(1u32); let author = get_orchestrator_current_author().unwrap(); - assert_eq!(Authorship::author().unwrap(), author); - assert_eq!(Aura::authorities(), vec![alice_id.clone(), bob_id.clone()]); + assert_eq!(current_author(), author); + assert_eq!(authorities(), vec![alice_id.clone(), bob_id.clone()]); // Invulnerables should have triggered on new session authorities change // However charlie and dave shoudl have gone to one para (1001) - run_to_session(2u32, true); - assert_eq!(Aura::authorities(), vec![alice_id, bob_id]); + run_to_session(2u32); + assert_eq!(authorities(), vec![alice_id, bob_id]); let assignment = CollatorAssignment::collator_container_chain(); assert_eq!( assignment.container_chains[&1001u32.into()], @@ -459,10 +489,10 @@ fn test_authors_without_paras() { }) .build() .execute_with(|| { - run_to_block(2, true); + run_to_block(2); // Assert current slot gets updated - assert_eq!(Aura::current_slot(), 1u64); - assert!(Authorship::author().unwrap() == AccountId::from(BOB)); + assert_eq!(current_slot(), 1u64); + assert!(current_author() == AccountId::from(BOB)); // Only Alice and Bob collate for our chain let alice_id = get_aura_id_from_seed(&AccountId::from(ALICE).to_string()); @@ -471,7 +501,7 @@ fn test_authors_without_paras() { let dave_id = get_aura_id_from_seed(&AccountId::from(DAVE).to_string()); // It does not matter if we insert more collators, only two will be assigned - assert_eq!(Aura::authorities(), vec![alice_id.clone(), bob_id.clone()]); + assert_eq!(authorities(), vec![alice_id.clone(), bob_id.clone()]); // Set moondance collators to min 2 max 5 assert_ok!( @@ -483,11 +513,8 @@ fn test_authors_without_paras() { () ); - run_to_session(2, true); - assert_eq!( - Aura::authorities(), - vec![alice_id, bob_id, charlie_id, dave_id] - ); + run_to_session(2); + assert_eq!(authorities(), vec![alice_id, bob_id, charlie_id, dave_id]); }); } @@ -515,16 +542,16 @@ fn test_authors_paras_inserted_a_posteriori() { }) .build() .execute_with(|| { - run_to_block(2, true); + run_to_block(2); // Assert current slot gets updated - assert_eq!(Aura::current_slot(), 1u64); - assert!(Authorship::author().unwrap() == AccountId::from(BOB)); + assert_eq!(current_slot(), 1u64); + assert!(current_author() == AccountId::from(BOB)); // Alice and Bob collate in our chain let alice_id = get_aura_id_from_seed(&AccountId::from(ALICE).to_string()); let bob_id = get_aura_id_from_seed(&AccountId::from(BOB).to_string()); - assert_eq!(Aura::authorities(), vec![alice_id, bob_id]); + assert_eq!(authorities(), vec![alice_id, bob_id]); assert_ok!( Registrar::register(origin_of(ALICE.into()), 1001.into(), empty_genesis_data()), @@ -544,10 +571,10 @@ fn test_authors_paras_inserted_a_posteriori() { ); // Assignment should happen after 2 sessions - run_to_session(1u32, true); + run_to_session(1u32); let assignment = CollatorAssignment::collator_container_chain(); assert!(assignment.container_chains.is_empty()); - run_to_session(2u32, true); + run_to_session(2u32); // Charlie and Dave should be assigne dot para 1001 let assignment = CollatorAssignment::collator_container_chain(); @@ -582,10 +609,10 @@ fn test_authors_paras_inserted_a_posteriori_with_collators_already_assigned() { }) .build() .execute_with(|| { - run_to_block(2, true); + run_to_block(2); // Assert current slot gets updated - assert_eq!(Aura::current_slot(), 1u64); - assert!(Authorship::author().unwrap() == AccountId::from(BOB)); + assert_eq!(current_slot(), 1u64); + assert!(current_author() == AccountId::from(BOB)); // Alice and Bob collate in our chain let alice_id = get_aura_id_from_seed(&AccountId::from(ALICE).to_string()); @@ -593,10 +620,7 @@ fn test_authors_paras_inserted_a_posteriori_with_collators_already_assigned() { let charlie_id = get_aura_id_from_seed(&AccountId::from(CHARLIE).to_string()); let dave_id = get_aura_id_from_seed(&AccountId::from(DAVE).to_string()); - assert_eq!( - Aura::authorities(), - vec![alice_id, bob_id, charlie_id, dave_id] - ); + assert_eq!(authorities(), vec![alice_id, bob_id, charlie_id, dave_id]); assert_ok!( Registrar::register(origin_of(ALICE.into()), 1001.into(), empty_genesis_data()), @@ -608,10 +632,10 @@ fn test_authors_paras_inserted_a_posteriori_with_collators_already_assigned() { ); // Assignment should happen after 2 sessions - run_to_session(1u32, true); + run_to_session(1u32); let assignment = CollatorAssignment::collator_container_chain(); assert!(assignment.container_chains.is_empty()); - run_to_session(2u32, true); + run_to_session(2u32); // Charlie and Dave are now assigned to para 1001 let assignment = CollatorAssignment::collator_container_chain(); @@ -654,16 +678,16 @@ fn test_parachains_deregister_collators_re_assigned() { }) .build() .execute_with(|| { - run_to_block(2, true); + run_to_block(2); // Assert current slot gets updated - assert_eq!(Aura::current_slot(), 1u64); - assert!(Authorship::author().unwrap() == AccountId::from(BOB)); + assert_eq!(current_slot(), 1u64); + assert!(current_author() == AccountId::from(BOB)); // Alice and Bob are authorities let alice_id = get_aura_id_from_seed(&AccountId::from(ALICE).to_string()); let bob_id = get_aura_id_from_seed(&AccountId::from(BOB).to_string()); - assert_eq!(Aura::authorities(), vec![alice_id, bob_id]); + assert_eq!(authorities(), vec![alice_id, bob_id]); // Charlie and Dave to 1001 let assignment = CollatorAssignment::collator_container_chain(); @@ -675,7 +699,7 @@ fn test_parachains_deregister_collators_re_assigned() { assert_ok!(Registrar::deregister(root_origin(), 1001.into()), ()); // Assignment should happen after 2 sessions - run_to_session(1u32, true); + run_to_session(1u32); let assignment = CollatorAssignment::collator_container_chain(); assert_eq!( @@ -683,7 +707,7 @@ fn test_parachains_deregister_collators_re_assigned() { vec![CHARLIE.into(), DAVE.into()] ); - run_to_session(2u32, true); + run_to_session(2u32); // Charlie and Dave should be assigne dot para 1002 this time let assignment = CollatorAssignment::collator_container_chain(); @@ -722,16 +746,16 @@ fn test_parachains_deregister_collators_config_change_reassigned() { }) .build() .execute_with(|| { - run_to_block(2, true); + run_to_block(2); // Assert current slot gets updated - assert_eq!(Aura::current_slot(), 1u64); - assert!(Authorship::author().unwrap() == AccountId::from(BOB)); + assert_eq!(current_slot(), 1u64); + assert!(current_author() == AccountId::from(BOB)); // Alice and Bob are authorities let alice_id = get_aura_id_from_seed(&AccountId::from(ALICE).to_string()); let bob_id = get_aura_id_from_seed(&AccountId::from(BOB).to_string()); - assert_eq!(Aura::authorities(), vec![alice_id, bob_id]); + assert_eq!(authorities(), vec![alice_id, bob_id]); // Set orchestrator collators to 1 assert_ok!( @@ -753,7 +777,7 @@ fn test_parachains_deregister_collators_config_change_reassigned() { ); // Assignment should happen after 2 sessions - run_to_session(1u32, true); + run_to_session(1u32); let assignment = CollatorAssignment::collator_container_chain(); assert_eq!( @@ -761,7 +785,7 @@ fn test_parachains_deregister_collators_config_change_reassigned() { vec![CHARLIE.into(), DAVE.into()] ); - run_to_session(2u32, true); + run_to_session(2u32); // Charlie, Dave and BOB should be assigne dot para 1001 this time let assignment = CollatorAssignment::collator_container_chain(); @@ -794,15 +818,15 @@ fn test_orchestrator_collators_with_non_sufficient_collators() { }) .build() .execute_with(|| { - run_to_block(2, true); + run_to_block(2); // Assert current slot gets updated - assert_eq!(Aura::current_slot(), 1u64); - assert!(Authorship::author().unwrap() == AccountId::from(ALICE)); + assert_eq!(current_slot(), 1u64); + assert!(current_author() == AccountId::from(ALICE)); // Alice and Bob are authorities let alice_id = get_aura_id_from_seed(&AccountId::from(ALICE).to_string()); - assert_eq!(Aura::authorities(), vec![alice_id]); + assert_eq!(authorities(), vec![alice_id]); }); } @@ -814,48 +838,50 @@ fn test_configuration_on_session_change() { (AccountId::from(ALICE), 210_000 * UNIT), (AccountId::from(BOB), 100_000 * UNIT), ]) + .with_collators(vec![ + (AccountId::from(ALICE), 210 * UNIT), + (AccountId::from(BOB), 100 * UNIT), + ]) .with_config(pallet_configuration::HostConfiguration { - max_collators: 0, - min_orchestrator_collators: 0, - max_orchestrator_collators: 0, - collators_per_container: 0, + max_collators: 100, + min_orchestrator_collators: 2, + max_orchestrator_collators: 2, + collators_per_container: 2, }) .build() .execute_with(|| { - run_to_block(1, false); - assert_eq!(Configuration::config().max_collators, 0); - assert_eq!(Configuration::config().min_orchestrator_collators, 0); - assert_eq!(Configuration::config().collators_per_container, 0); - assert_ok!(Configuration::set_max_collators(root_origin(), 50), ()); + run_to_block(1); + assert_eq!(Configuration::config().max_collators, 100); + assert_eq!(Configuration::config().min_orchestrator_collators, 2); + assert_eq!(Configuration::config().collators_per_container, 2); - run_to_session(1u32, false); + assert_ok!(Configuration::set_max_collators(root_origin(), 50), ()); + run_to_session(1u32); assert_ok!( Configuration::set_min_orchestrator_collators(root_origin(), 20), () ); + assert_eq!(Configuration::config().max_collators, 100); + assert_eq!(Configuration::config().min_orchestrator_collators, 2); + assert_eq!(Configuration::config().collators_per_container, 2); - assert_eq!(Configuration::config().max_collators, 0); - assert_eq!(Configuration::config().min_orchestrator_collators, 0); - assert_eq!(Configuration::config().collators_per_container, 0); - - run_to_session(2u32, false); - + run_to_session(2u32); assert_ok!( Configuration::set_collators_per_container(root_origin(), 10), () ); assert_eq!(Configuration::config().max_collators, 50); - assert_eq!(Configuration::config().min_orchestrator_collators, 0); - assert_eq!(Configuration::config().collators_per_container, 0); + assert_eq!(Configuration::config().min_orchestrator_collators, 2); + assert_eq!(Configuration::config().collators_per_container, 2); - run_to_session(3u32, false); + run_to_session(3u32); assert_eq!(Configuration::config().max_collators, 50); assert_eq!(Configuration::config().min_orchestrator_collators, 20); - assert_eq!(Configuration::config().collators_per_container, 0); + assert_eq!(Configuration::config().collators_per_container, 2); - run_to_session(4u32, false); + run_to_session(4u32); assert_eq!(Configuration::config().max_collators, 50); assert_eq!(Configuration::config().min_orchestrator_collators, 20); @@ -889,10 +915,10 @@ fn test_author_collation_aura_add_assigned_to_paras_runtime_api() { }) .build() .execute_with(|| { - run_to_block(2, true); + run_to_block(2); // Assert current slot gets updated - assert_eq!(Aura::current_slot(), 1u64); - assert!(Authorship::author().unwrap() == AccountId::from(BOB)); + assert_eq!(current_slot(), 1u64); + assert!(current_author() == AccountId::from(BOB)); assert_eq!( Runtime::parachain_collators(100.into()), Some(vec![ALICE.into(), BOB.into()]) @@ -942,11 +968,11 @@ fn test_author_collation_aura_add_assigned_to_paras_runtime_api() { )); // SESSION CHANGE. First session. it takes 2 sessions to see the change - run_to_session(1u32, true); + run_to_session(1u32); let author = get_orchestrator_current_author().unwrap(); - assert_eq!(Authorship::author().unwrap(), author); - assert_eq!(Aura::authorities(), vec![alice_id.clone(), bob_id.clone()]); + assert_eq!(current_author(), author); + assert_eq!(authorities(), vec![alice_id.clone(), bob_id.clone()]); assert_eq!( Runtime::parachain_collators(100.into()), Some(vec![ALICE.into(), BOB.into()]) @@ -963,8 +989,8 @@ fn test_author_collation_aura_add_assigned_to_paras_runtime_api() { // Invulnerables should have triggered on new session authorities change // However charlie and dave shoudl have gone to one para (1001) - run_to_session(2u32, true); - assert_eq!(Aura::authorities(), vec![alice_id, bob_id]); + run_to_session(2u32); + assert_eq!(authorities(), vec![alice_id, bob_id]); let assignment = CollatorAssignment::collator_container_chain(); assert_eq!( assignment.container_chains[&1001u32.into()], @@ -994,7 +1020,7 @@ fn test_author_collation_aura_add_assigned_to_paras_runtime_api() { vec![ALICE.into(), CHARLIE.into(), DAVE.into()] )); - run_to_session(3u32, true); + run_to_session(3u32); assert_eq!( Runtime::parachain_collators(100.into()), Some(vec![ALICE.into(), BOB.into()]) @@ -1012,7 +1038,7 @@ fn test_author_collation_aura_add_assigned_to_paras_runtime_api() { None ); - run_to_session(4u32, true); + run_to_session(4u32); assert_eq!( Runtime::parachain_collators(100.into()), Some(vec![ALICE.into()]) @@ -1058,7 +1084,7 @@ fn test_consensus_runtime_api() { }) .build() .execute_with(|| { - run_to_block(2, true); + run_to_block(2); let alice_id = get_aura_id_from_seed(&AccountId::from(ALICE).to_string()); let bob_id = get_aura_id_from_seed(&AccountId::from(BOB).to_string()); @@ -1104,7 +1130,7 @@ fn test_consensus_runtime_api() { vec![ALICE.into(), BOB.into(), CHARLIE.into(), DAVE.into()] )); - run_to_session(2u32, true); + run_to_session(2u32); assert_eq!( Runtime::para_id_authorities(100.into()), Some(vec![alice_id.clone(), bob_id.clone()]) @@ -1158,7 +1184,7 @@ fn test_consensus_runtime_api_session_changes() { }) .build() .execute_with(|| { - run_to_block(2, true); + run_to_block(2); let alice_id = get_aura_id_from_seed(&AccountId::from(ALICE).to_string()); let bob_id = get_aura_id_from_seed(&AccountId::from(BOB).to_string()); @@ -1208,7 +1234,7 @@ fn test_consensus_runtime_api_session_changes() { // Let's run just 2 blocks before the session 2 change first // Prediction should still be identical, as we are not in the // edge of a session change - run_to_block(session_two_edge - 2, true); + run_to_block(session_two_edge - 2); assert_eq!( Runtime::para_id_authorities(100.into()), @@ -1228,7 +1254,7 @@ fn test_consensus_runtime_api_session_changes() { // Now we run to session edge -1. Here we should predict already with // authorities of the next block! - run_to_block(session_two_edge - 1, true); + run_to_block(session_two_edge - 1); assert_eq!( Runtime::para_id_authorities(100.into()), Some(vec![alice_id.clone(), bob_id.clone()]) @@ -1378,7 +1404,7 @@ fn test_session_keys_with_authority_mapping() { }) .build() .execute_with(|| { - run_to_block(2, true); + run_to_block(2); let key_mapping_session_0 = AuthorityMapping::authority_id_mapping(0).unwrap(); let alice_id = get_aura_id_from_seed(&AccountId::from(ALICE).to_string()); let bob_id = get_aura_id_from_seed(&AccountId::from(BOB).to_string()); @@ -1390,7 +1416,7 @@ fn test_session_keys_with_authority_mapping() { assert_eq!(key_mapping_session_0.get(&bob_id), Some(&BOB.into())); // Everything should match to aura - assert_eq!(Aura::authorities(), vec![alice_id.clone(), bob_id.clone()]); + assert_eq!(authorities(), vec![alice_id.clone(), bob_id.clone()]); // Change Alice and Bob keys to something different // for now lets change it to alice_2 and bob_2 @@ -1409,7 +1435,7 @@ fn test_session_keys_with_authority_mapping() { vec![] )); - run_to_session(1u32, true); + run_to_session(1u32); let key_mapping_session_0 = AuthorityMapping::authority_id_mapping(0).unwrap(); assert_eq!(key_mapping_session_0.len(), 2); assert_eq!(key_mapping_session_0.get(&alice_id), Some(&ALICE.into())); @@ -1421,10 +1447,10 @@ fn test_session_keys_with_authority_mapping() { assert_eq!(key_mapping_session_1.get(&bob_id), Some(&BOB.into())); // Everything should match to aura - assert_eq!(Aura::authorities(), vec![alice_id.clone(), bob_id.clone()]); + assert_eq!(authorities(), vec![alice_id.clone(), bob_id.clone()]); // - run_to_session(2u32, true); + run_to_session(2u32); assert!(AuthorityMapping::authority_id_mapping(0).is_none()); let key_mapping_session_1 = AuthorityMapping::authority_id_mapping(1).unwrap(); @@ -1438,7 +1464,7 @@ fn test_session_keys_with_authority_mapping() { assert_eq!(key_mapping_session_2.get(&bob_id_2), Some(&BOB.into())); // Everything should match to aura - assert_eq!(Aura::authorities(), vec![alice_id_2, bob_id_2]); + assert_eq!(authorities(), vec![alice_id_2, bob_id_2]); }); } @@ -1468,7 +1494,7 @@ fn test_session_keys_with_authority_assignment() { }) .build() .execute_with(|| { - run_to_block(2, true); + run_to_block(2); let alice_id = get_aura_id_from_seed(&AccountId::from(ALICE).to_string()); let bob_id = get_aura_id_from_seed(&AccountId::from(BOB).to_string()); let alice_id_2 = get_aura_id_from_seed("ALICE2"); @@ -1497,7 +1523,7 @@ fn test_session_keys_with_authority_assignment() { assert!(key_mapping_session_2.is_none()); // Everything should match to aura - assert_eq!(Aura::authorities(), vec![alice_id.clone(), bob_id.clone()]); + assert_eq!(authorities(), vec![alice_id.clone(), bob_id.clone()]); // Change Alice and Bob keys to something different // for now lets change it to alice_2 and bob_2 @@ -1516,7 +1542,7 @@ fn test_session_keys_with_authority_assignment() { vec![] )); - run_to_session(1u32, true); + run_to_session(1u32); let old_key_mapping_session_1 = key_mapping_session_1; // Session 0 got removed @@ -1543,9 +1569,9 @@ fn test_session_keys_with_authority_assignment() { assert!(key_mapping_session_3.is_none()); // Everything should match to aura - assert_eq!(Aura::authorities(), vec![alice_id, bob_id]); + assert_eq!(authorities(), vec![alice_id, bob_id]); - run_to_session(2u32, true); + run_to_session(2u32); // Session 1 got removed let key_mapping_session_1 = AuthorityAssignment::collator_container_chain(1); @@ -1574,6 +1600,6 @@ fn test_session_keys_with_authority_assignment() { assert!(key_mapping_session_4.is_none()); // Everything should match to aura - assert_eq!(Aura::authorities(), vec![alice_id_2, bob_id_2]); + assert_eq!(authorities(), vec![alice_id_2, bob_id_2]); }); } diff --git a/test/suites/dev-tanssi/author-slot-prediction/test_author_slot_prediction.ts b/test/suites/dev-tanssi/author-slot-prediction/test_author_slot_prediction.ts index 9a45b93d5..efbdbede1 100644 --- a/test/suites/dev-tanssi/author-slot-prediction/test_author_slot_prediction.ts +++ b/test/suites/dev-tanssi/author-slot-prediction/test_author_slot_prediction.ts @@ -48,8 +48,9 @@ describeSuite({ expect((await polkadotJs.query.authorityAssignment.collatorContainerChain(2)).isNone).to.be.true; // Check authorities are correct - const authorities = (await polkadotJs.query.aura.authorities()); - expect(u8aToHex(authorities[0])).to.be.eq(u8aToHex(alice.publicKey)); + const sessionIndex = (await polkadotJs.query.session.currentIndex()).toNumber(); + const authorities = await polkadotJs.query.authorityAssignment.collatorContainerChain(sessionIndex); + expect(authorities.toJSON().orchestratorChain[0]).to.be.eq(u8aToHex(alice.publicKey)); }, }); diff --git a/test/suites/dev-tanssi/session-keys/test_session_keys.ts b/test/suites/dev-tanssi/session-keys/test_session_keys.ts index f062a090e..cf2ca1143 100644 --- a/test/suites/dev-tanssi/session-keys/test_session_keys.ts +++ b/test/suites/dev-tanssi/session-keys/test_session_keys.ts @@ -32,9 +32,10 @@ describeSuite({ expect(keys.toJSON()[u8aToHex(bob.publicKey)]).to.be.eq(bob.address); // Check authorities are correct - const authorities = (await polkadotJs.query.aura.authorities()); + const sessionIndex = (await polkadotJs.query.session.currentIndex()).toNumber(); + const authorities = await polkadotJs.query.authorityAssignment.collatorContainerChain(sessionIndex); // TODO: fix once we have types - expect(authorities.toJSON()).to.deep.equal([u8aToHex(alice.publicKey)]); + expect(authorities.toJSON().orchestratorChain).to.deep.equal([u8aToHex(alice.publicKey)]); }, }); @@ -75,9 +76,10 @@ describeSuite({ // TODO: fix once we have types expect(keys.toJSON()[u8aToHex(newKey)]).to.be.eq(alice.address); - const authorities = (await polkadotJs.query.aura.authorities()); + const sessionIndex = (await polkadotJs.query.session.currentIndex()).toNumber(); + const authorities = await polkadotJs.query.authorityAssignment.collatorContainerChain(sessionIndex); // TODO: fix once we have types - expect(authorities.toJSON()).to.deep.equal([ + expect(authorities.toJSON().orchestratorChain).to.deep.equal([ u8aToHex(newKey), ]); diff --git a/test/suites/dev-tanssi/session-keys/test_session_keys_assignment.ts b/test/suites/dev-tanssi/session-keys/test_session_keys_assignment.ts index 31937b84a..edfec3fdf 100644 --- a/test/suites/dev-tanssi/session-keys/test_session_keys_assignment.ts +++ b/test/suites/dev-tanssi/session-keys/test_session_keys_assignment.ts @@ -49,8 +49,9 @@ describeSuite({ expect((await polkadotJs.query.authorityAssignment.collatorContainerChain(2)).isNone).to.be.true; // Check authorities are correct - const authorities = (await polkadotJs.query.aura.authorities()); - expect(authorities.toJSON()).to.deep.equal([ + const sessionIndex = (await polkadotJs.query.session.currentIndex()).toNumber(); + const authorities = await polkadotJs.query.authorityAssignment.collatorContainerChain(sessionIndex); + expect(authorities.toJSON().orchestratorChain).to.deep.equal([ u8aToHex(alice.publicKey), ]); }, @@ -118,9 +119,10 @@ describeSuite({ // TODO: fix once we have types expect(keys.toJSON()[u8aToHex(newKey)]).to.be.eq(alice.address); - const authorities = (await polkadotJs.query.aura.authorities()); + const sessionIndex = (await polkadotJs.query.session.currentIndex()).toNumber(); + const authorities = await polkadotJs.query.authorityAssignment.collatorContainerChain(sessionIndex); // TODO: fix once we have types - expect(authorities.toJSON()).to.deep.equal([ + expect(authorities.toJSON().orchestratorChain).to.deep.equal([ u8aToHex(newKey), ]); // AuthorityMapping should no-longer contain the session 1 diff --git a/test/suites/para/test_tanssi_containers.ts b/test/suites/para/test_tanssi_containers.ts index ea5aa5702..df7d003d9 100644 --- a/test/suites/para/test_tanssi_containers.ts +++ b/test/suites/para/test_tanssi_containers.ts @@ -66,21 +66,6 @@ describeSuite({ }, }); - it({ - id: "T02", - title: "Test Tanssi assignation is correct", - test: async function () { - const currentSession = (await paraApi.query.session.currentIndex()).toNumber(); - // TODO: fix once we have types - const tanssiCollators = ( - await paraApi.query.authorityAssignment.collatorContainerChain(currentSession) - ).toJSON().orchestratorChain; - const authorities = (await paraApi.query.aura.authorities()).toJSON(); - - expect(tanssiCollators).to.deep.equal(authorities); - }, - }); - it({ id: "T03", title: "Test assignation did not change", @@ -184,10 +169,11 @@ describeSuite({ id: "T09", title: "Test author is correct in Orchestrator", test: async function () { - const authorities = await paraApi.query.aura.authorities(); + const sessionIndex = (await paraApi.query.session.currentIndex()).toNumber(); + const authorities = await paraApi.query.authorityAssignment.collatorContainerChain(sessionIndex); const author = await getAuthorFromDigest(paraApi); // TODO: fix once we have types - expect(authorities.toJSON().includes(author.toString())).to.be.true; + expect(authorities.toJSON().orchestratorChain.includes(author.toString())).to.be.true; }, });