From 128d99ee8f2e1408b8765a10e699b073bc4c7951 Mon Sep 17 00:00:00 2001 From: tmpolaczyk <44604217+tmpolaczyk@users.noreply.github.com> Date: Tue, 17 Oct 2023 09:10:08 +0200 Subject: [PATCH 1/4] Move monitor tick log to debug (#289) --- node/src/container_chain_monitor.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/src/container_chain_monitor.rs b/node/src/container_chain_monitor.rs index 5579d41ab..e66f8b99a 100644 --- a/node/src/container_chain_monitor.rs +++ b/node/src/container_chain_monitor.rs @@ -209,8 +209,8 @@ pub async fn monitor_task(state: Arc>) { let max_running_container_chains = 4; loop { - log::info!("Monitor tick"); sleep(monitor_period).await; + log::debug!("Monitor tick"); let mut state = state.lock().unwrap(); let monitor_state = &mut state.spawned_containers_monitor; From c0b88e720434408b276372a437cca342b6aeced3 Mon Sep 17 00:00:00 2001 From: tmpolaczyk <44604217+tmpolaczyk@users.noreply.github.com> Date: Tue, 17 Oct 2023 09:10:24 +0200 Subject: [PATCH 2/4] Disable beefy in zombienet (#290) Because it logs many errors like: Got message from unregistered peer BadJustification("Duplicate consensus engine ID") --- test/configs/zombieDanceboxUpgrade.json | 2 +- test/configs/zombieTanssi.json | 2 +- test/configs/zombieTanssiMetrics.json | 2 +- test/configs/zombieTanssiWarpSync.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/configs/zombieDanceboxUpgrade.json b/test/configs/zombieDanceboxUpgrade.json index 76efbb60d..617fc5d03 100644 --- a/test/configs/zombieDanceboxUpgrade.json +++ b/test/configs/zombieDanceboxUpgrade.json @@ -6,7 +6,7 @@ "relaychain": { "chain": "rococo-local", "default_command": "tmp/polkadot", - "default_args": ["--no-hardware-benchmarks", "-lparachain=debug", "--database=paritydb"], + "default_args": ["--no-hardware-benchmarks", "-lparachain=debug", "--database=paritydb", "--no-beefy"], "nodes": [ { "name": "alice", diff --git a/test/configs/zombieTanssi.json b/test/configs/zombieTanssi.json index 444b342ca..32418d3e6 100644 --- a/test/configs/zombieTanssi.json +++ b/test/configs/zombieTanssi.json @@ -6,7 +6,7 @@ "relaychain": { "chain": "rococo-local", "default_command": "tmp/polkadot", - "default_args": ["--no-hardware-benchmarks", "-lparachain=debug", "--database=paritydb"], + "default_args": ["--no-hardware-benchmarks", "-lparachain=debug", "--database=paritydb", "--no-beefy"], "nodes": [ { "name": "alice", diff --git a/test/configs/zombieTanssiMetrics.json b/test/configs/zombieTanssiMetrics.json index ce321fb1c..6ef337714 100644 --- a/test/configs/zombieTanssiMetrics.json +++ b/test/configs/zombieTanssiMetrics.json @@ -6,7 +6,7 @@ "relaychain": { "chain": "rococo-local", "default_command": "tmp/polkadot", - "default_args": ["--no-hardware-benchmarks", "-lparachain=debug", "--database=paritydb"], + "default_args": ["--no-hardware-benchmarks", "-lparachain=debug", "--database=paritydb", "--no-beefy"], "nodes": [ { "name": "alice", diff --git a/test/configs/zombieTanssiWarpSync.json b/test/configs/zombieTanssiWarpSync.json index d6f1b31ff..7c761640f 100644 --- a/test/configs/zombieTanssiWarpSync.json +++ b/test/configs/zombieTanssiWarpSync.json @@ -6,7 +6,7 @@ "relaychain": { "chain": "rococo-local", "default_command": "tmp/polkadot", - "default_args": ["--no-hardware-benchmarks", "-lparachain=debug", "--database=paritydb"], + "default_args": ["--no-hardware-benchmarks", "-lparachain=debug", "--database=paritydb", "--no-beefy"], "nodes": [ { "name": "alice", From 51f6ca6f96c217c1e0b810dc00642ee715a7c8e6 Mon Sep 17 00:00:00 2001 From: Francisco Gamundi <52399794+fgamundi@users.noreply.github.com> Date: Tue, 17 Oct 2023 10:22:17 +0200 Subject: [PATCH 3/4] pallet-initializer new session is applied immediately (#288) * New session is now immediately applied * fmt * Remove BufferedSessionChange struct * Updated ts types * Get registered paras using session_index. Review --- pallets/initializer/src/lib.rs | 73 ++-------------- pallets/initializer/src/tests.rs | 35 +------- runtime/dancebox/src/lib.rs | 14 ++- .../dancebox/interfaces/augment-api-query.ts | 19 ---- .../src/dancebox/interfaces/lookup.ts | 85 +++++++++--------- .../src/dancebox/interfaces/registry.ts | 2 - .../src/dancebox/interfaces/types-lookup.ts | 86 +++++++++---------- 7 files changed, 101 insertions(+), 213 deletions(-) diff --git a/pallets/initializer/src/lib.rs b/pallets/initializer/src/lib.rs index 6857f6283..951a00205 100644 --- a/pallets/initializer/src/lib.rs +++ b/pallets/initializer/src/lib.rs @@ -18,10 +18,8 @@ //! //! This pallet is in charge of organizing what happens on session changes. //! In particular this pallet has implemented the OneSessionHandler trait -//! which will be called upon a session change. This pallet will then store -//! the bufferedSessionChanges (collators, new session index, etc) in the -//! BufferedSessionChanges storage item. This storage item gets read on_finalize -//! and calls the SessionHandler config trait +//! which will be called upon a session change. There it will call the +//! SessionHandler config trait #![cfg_attr(not(feature = "std"), no_std)] @@ -34,13 +32,8 @@ mod tests; pub use pallet::*; use { frame_support::{pallet_prelude::*, traits::OneSessionHandler}, - frame_system::pallet_prelude::*, - parity_scale_codec::{Decode, Encode}, scale_info::TypeInfo, - sp_runtime::{ - traits::{AtLeast32BitUnsigned, Zero}, - RuntimeAppPublic, - }, + sp_runtime::{traits::AtLeast32BitUnsigned, RuntimeAppPublic}, sp_std::prelude::*, }; @@ -48,16 +41,7 @@ use { pub mod pallet { use super::*; - #[derive(Encode, Decode, TypeInfo)] - #[scale_info(skip_type_params(T))] - pub struct BufferedSessionChange { - pub changed: bool, - pub validators: Vec<(T::AccountId, T::AuthorityId)>, - pub queued: Vec<(T::AccountId, T::AuthorityId)>, - pub session_index: T::SessionIndex, - } - - // The apply_new_sseion trait. We need to comply with this + // The apply_new_session trait. We need to comply with this pub trait ApplyNewSession { fn apply_new_session( changed: bool, @@ -84,42 +68,11 @@ pub mod pallet { type SessionHandler: ApplyNewSession; } - - /// Buffered session changes along with the block number at which they should be applied. - /// - /// Typically this will be empty or one element long. Apart from that this item never hits - /// the storage. - /// - /// However this is a `Vec` regardless to handle various edge cases that may occur at runtime - /// upgrade boundaries or if governance intervenes. - #[pallet::storage] - pub(super) type BufferedSessionChanges = - StorageValue<_, BufferedSessionChange, OptionQuery>; - - #[pallet::hooks] - impl Hooks> for Pallet { - fn on_finalize(_now: BlockNumberFor) { - // Apply buffered session changes as the last thing. This way the runtime APIs and the - // next block will observe the next session. - // - // Note that we only apply the last session as all others lasted less than a block (weirdly). - if let Some(BufferedSessionChange { - changed, - session_index, - validators, - queued, - }) = BufferedSessionChanges::::take() - { - // Changes to be applied on new session - T::SessionHandler::apply_new_session(changed, session_index, validators, queued); - } - } - } } impl Pallet { - /// Should be called when a new session occurs. Buffers the session notification to be applied - /// at the end of the block. If `queued` is `None`, the `validators` are considered queued. + /// Should be called when a new session occurs. If `queued` is `None`, + /// the `validators` are considered queued. fn on_new_session<'a, I: 'a>( changed: bool, session_index: T::SessionIndex, @@ -135,19 +88,7 @@ impl Pallet { validators.clone() }; - if session_index == T::SessionIndex::zero() { - // Genesis session should be immediately enacted. - T::SessionHandler::apply_new_session(false, 0u32.into(), validators, queued); - } else { - BufferedSessionChanges::::mutate(|v| { - *v = Some(BufferedSessionChange { - changed, - validators, - queued, - session_index, - }) - }); - } + T::SessionHandler::apply_new_session(changed, session_index, validators, queued); } /// Should be called when a new session occurs. Buffers the session notification to be applied diff --git a/pallets/initializer/src/tests.rs b/pallets/initializer/src/tests.rs index 679180728..9cde050ba 100644 --- a/pallets/initializer/src/tests.rs +++ b/pallets/initializer/src/tests.rs @@ -16,7 +16,7 @@ use { super::*, - crate::mock::{new_test_ext, session_change_validators, Initializer, System, Test}, + crate::mock::{new_test_ext, session_change_validators, Initializer}, }; #[test] @@ -29,15 +29,12 @@ fn session_0_is_instantly_applied() { Some(Vec::new().into_iter()), ); - let v = BufferedSessionChanges::::get(); - assert!(v.is_none()); - assert_eq!(session_change_validators(), Some((0, Vec::new()))); }); } #[test] -fn session_change_before_initialize_is_still_buffered_after() { +fn session_change_applied() { new_test_ext().execute_with(|| { Initializer::test_trigger_on_new_session( false, @@ -46,33 +43,7 @@ fn session_change_before_initialize_is_still_buffered_after() { Some(Vec::new().into_iter()), ); - let now = System::block_number(); - Initializer::on_initialize(now); - - // Session change validators are applied after on_finalize - assert_eq!(session_change_validators(), None); - - let v = BufferedSessionChanges::::get(); - assert!(v.is_some()); - }); -} - -#[test] -fn session_change_applied_on_finalize() { - new_test_ext().execute_with(|| { - Initializer::on_initialize(1); - Initializer::test_trigger_on_new_session( - false, - 1, - Vec::new().into_iter(), - Some(Vec::new().into_iter()), - ); - - Initializer::on_finalize(1); - - // Session change validators are applied after on_finalize + // Session change validators are applied assert_eq!(session_change_validators(), Some((1, Vec::new()))); - - assert!(BufferedSessionChanges::::get().is_none()); }); } diff --git a/runtime/dancebox/src/lib.rs b/runtime/dancebox/src/lib.rs index 2cf9f0374..8c329610a 100644 --- a/runtime/dancebox/src/lib.rs +++ b/runtime/dancebox/src/lib.rs @@ -80,6 +80,7 @@ use { }, sp_std::{marker::PhantomData, prelude::*}, sp_version::RuntimeVersion, + tp_traits::GetSessionContainerChains, }; pub use { sp_runtime::{MultiAddress, Perbill, Permill}, @@ -1332,7 +1333,18 @@ impl_runtime_apis! { impl pallet_registrar_runtime_api::RegistrarApi for Runtime { /// Return the registered para ids fn registered_paras() -> Vec { - Registrar::registered_para_ids().to_vec() + // We should return the container-chains for the session in which we are kicking in + let parent_number = System::block_number(); + let should_end_session = ::ShouldEndSession::should_end_session(parent_number + 1); + + let session_index = if should_end_session { + Session::current_index() +1 + } + else { + Session::current_index() + }; + + Registrar::session_container_chains(session_index).to_vec() } /// Fetch genesis data for this para id diff --git a/typescript-api/src/dancebox/interfaces/augment-api-query.ts b/typescript-api/src/dancebox/interfaces/augment-api-query.ts index 40d96455f..96e3286c5 100644 --- a/typescript-api/src/dancebox/interfaces/augment-api-query.ts +++ b/typescript-api/src/dancebox/interfaces/augment-api-query.ts @@ -33,7 +33,6 @@ import type { PalletBalancesIdAmount, PalletBalancesReserveData, PalletConfigurationHostConfiguration, - PalletInitializerBufferedSessionChange, PalletPooledStakingCandidateEligibleCandidate, PalletPooledStakingPendingOperationKey, PalletPooledStakingPoolsKey, @@ -263,24 +262,6 @@ declare module "@polkadot/api-base/types/storage" { /** Generic query */ [key: string]: QueryableStorageEntry; }; - initializer: { - /** - * Buffered session changes along with the block number at which they should be applied. - * - * Typically this will be empty or one element long. Apart from that this item never hits the storage. - * - * However this is a `Vec` regardless to handle various edge cases that may occur at runtime upgrade boundaries or - * if governance intervenes. - */ - bufferedSessionChanges: AugmentedQuery< - ApiType, - () => Observable>, - [] - > & - QueryableStorageEntry; - /** Generic query */ - [key: string]: QueryableStorageEntry; - }; invulnerables: { /** The invulnerable, permissioned collators. This list must be sorted. */ invulnerables: AugmentedQuery Observable>, []> & diff --git a/typescript-api/src/dancebox/interfaces/lookup.ts b/typescript-api/src/dancebox/interfaces/lookup.ts index bbf9fbc79..b3e33b151 100644 --- a/typescript-api/src/dancebox/interfaces/lookup.ts +++ b/typescript-api/src/dancebox/interfaces/lookup.ts @@ -2419,19 +2419,12 @@ export default { orchestratorChain: "Vec", containerChains: "BTreeMap>", }, - /** Lookup294: pallet_initializer::pallet::BufferedSessionChange */ - PalletInitializerBufferedSessionChange: { - changed: "bool", - validators: "Vec<(AccountId32,NimbusPrimitivesNimbusCryptoPublic)>", - queued: "Vec<(AccountId32,NimbusPrimitivesNimbusCryptoPublic)>", - sessionIndex: "u32", - }, - /** Lookup297: pallet_author_noting::pallet::ContainerChainBlockInfo */ + /** Lookup294: pallet_author_noting::pallet::ContainerChainBlockInfo */ PalletAuthorNotingContainerChainBlockInfo: { blockNumber: "u32", author: "AccountId32", }, - /** Lookup298: pallet_author_noting::pallet::Error */ + /** Lookup295: pallet_author_noting::pallet::Error */ PalletAuthorNotingError: { _enum: [ "FailedReading", @@ -2443,31 +2436,31 @@ export default { "NonAuraDigest", ], }, - /** Lookup299: tp_collator_assignment::AssignedCollators */ + /** Lookup296: tp_collator_assignment::AssignedCollators */ TpCollatorAssignmentAssignedCollatorsPublic: { orchestratorChain: "Vec", containerChains: "BTreeMap>", }, - /** Lookup305: pallet_invulnerables::pallet::Error */ + /** Lookup302: pallet_invulnerables::pallet::Error */ PalletInvulnerablesError: { _enum: ["TooManyInvulnerables", "AlreadyInvulnerable", "NotInvulnerable"], }, - /** Lookup310: sp_core::crypto::KeyTypeId */ + /** Lookup307: sp_core::crypto::KeyTypeId */ SpCoreCryptoKeyTypeId: "[u8;4]", - /** Lookup311: pallet_session::pallet::Error */ + /** Lookup308: pallet_session::pallet::Error */ PalletSessionError: { _enum: ["InvalidProof", "NoAssociatedValidatorId", "DuplicatedKey", "NoKeys", "NoAccount"], }, - /** Lookup315: pallet_author_inherent::pallet::Error */ + /** Lookup312: pallet_author_inherent::pallet::Error */ PalletAuthorInherentError: { _enum: ["AuthorAlreadySet", "NoAccountId", "CannotBeAuthor"], }, - /** Lookup317: pallet_pooled_staking::candidate::EligibleCandidate */ + /** Lookup314: pallet_pooled_staking::candidate::EligibleCandidate */ PalletPooledStakingCandidateEligibleCandidate: { candidate: "AccountId32", stake: "u128", }, - /** Lookup320: pallet_pooled_staking::pallet::PoolsKey */ + /** Lookup317: pallet_pooled_staking::pallet::PoolsKey */ PalletPooledStakingPoolsKey: { _enum: { CandidateTotalStake: "Null", @@ -2509,7 +2502,7 @@ export default { }, }, }, - /** Lookup322: pallet_pooled_staking::pallet::Error */ + /** Lookup319: pallet_pooled_staking::pallet::Error */ PalletPooledStakingError: { _enum: { InvalidPalletSetting: "Null", @@ -2528,21 +2521,21 @@ export default { SwapResultsInZeroShares: "Null", }, }, - /** Lookup324: cumulus_pallet_xcmp_queue::InboundChannelDetails */ + /** Lookup321: cumulus_pallet_xcmp_queue::InboundChannelDetails */ CumulusPalletXcmpQueueInboundChannelDetails: { sender: "u32", state: "CumulusPalletXcmpQueueInboundState", messageMetadata: "Vec<(u32,PolkadotParachainPrimitivesPrimitivesXcmpMessageFormat)>", }, - /** Lookup325: cumulus_pallet_xcmp_queue::InboundState */ + /** Lookup322: cumulus_pallet_xcmp_queue::InboundState */ CumulusPalletXcmpQueueInboundState: { _enum: ["Ok", "Suspended"], }, - /** Lookup328: polkadot_parachain_primitives::primitives::XcmpMessageFormat */ + /** Lookup325: polkadot_parachain_primitives::primitives::XcmpMessageFormat */ PolkadotParachainPrimitivesPrimitivesXcmpMessageFormat: { _enum: ["ConcatenatedVersionedXcm", "ConcatenatedEncodedBlob", "Signals"], }, - /** Lookup331: cumulus_pallet_xcmp_queue::OutboundChannelDetails */ + /** Lookup328: cumulus_pallet_xcmp_queue::OutboundChannelDetails */ CumulusPalletXcmpQueueOutboundChannelDetails: { recipient: "u32", state: "CumulusPalletXcmpQueueOutboundState", @@ -2550,11 +2543,11 @@ export default { firstIndex: "u16", lastIndex: "u16", }, - /** Lookup332: cumulus_pallet_xcmp_queue::OutboundState */ + /** Lookup329: cumulus_pallet_xcmp_queue::OutboundState */ CumulusPalletXcmpQueueOutboundState: { _enum: ["Ok", "Suspended"], }, - /** Lookup334: cumulus_pallet_xcmp_queue::QueueConfigData */ + /** Lookup331: cumulus_pallet_xcmp_queue::QueueConfigData */ CumulusPalletXcmpQueueQueueConfigData: { suspendThreshold: "u32", dropThreshold: "u32", @@ -2563,27 +2556,27 @@ export default { weightRestrictDecay: "SpWeightsWeightV2Weight", xcmpMaxIndividualWeight: "SpWeightsWeightV2Weight", }, - /** Lookup336: cumulus_pallet_xcmp_queue::pallet::Error */ + /** Lookup333: cumulus_pallet_xcmp_queue::pallet::Error */ CumulusPalletXcmpQueueError: { _enum: ["FailedToSend", "BadXcmOrigin", "BadXcm", "BadOverweightIndex", "WeightOverLimit"], }, - /** Lookup337: cumulus_pallet_xcm::pallet::Error */ + /** Lookup334: cumulus_pallet_xcm::pallet::Error */ CumulusPalletXcmError: "Null", - /** Lookup338: cumulus_pallet_dmp_queue::ConfigData */ + /** Lookup335: cumulus_pallet_dmp_queue::ConfigData */ CumulusPalletDmpQueueConfigData: { maxIndividual: "SpWeightsWeightV2Weight", }, - /** Lookup339: cumulus_pallet_dmp_queue::PageIndexData */ + /** Lookup336: cumulus_pallet_dmp_queue::PageIndexData */ CumulusPalletDmpQueuePageIndexData: { beginUsed: "u32", endUsed: "u32", overweightCount: "u64", }, - /** Lookup342: cumulus_pallet_dmp_queue::pallet::Error */ + /** Lookup339: cumulus_pallet_dmp_queue::pallet::Error */ CumulusPalletDmpQueueError: { _enum: ["Unknown", "OverLimit"], }, - /** Lookup343: pallet_xcm::pallet::QueryStatus */ + /** Lookup340: pallet_xcm::pallet::QueryStatus */ PalletXcmQueryStatus: { _enum: { Pending: { @@ -2602,7 +2595,7 @@ export default { }, }, }, - /** Lookup347: staging_xcm::VersionedResponse */ + /** Lookup344: staging_xcm::VersionedResponse */ StagingXcmVersionedResponse: { _enum: { __Unused0: "Null", @@ -2611,7 +2604,7 @@ export default { V3: "StagingXcmV3Response", }, }, - /** Lookup353: pallet_xcm::pallet::VersionMigrationStage */ + /** Lookup350: pallet_xcm::pallet::VersionMigrationStage */ PalletXcmVersionMigrationStage: { _enum: { MigrateSupportedVersion: "Null", @@ -2620,7 +2613,7 @@ export default { MigrateAndNotifyOldTargets: "Null", }, }, - /** Lookup355: staging_xcm::VersionedAssetId */ + /** Lookup352: staging_xcm::VersionedAssetId */ StagingXcmVersionedAssetId: { _enum: { __Unused0: "Null", @@ -2629,14 +2622,14 @@ export default { V3: "StagingXcmV3MultiassetAssetId", }, }, - /** Lookup356: pallet_xcm::pallet::RemoteLockedFungibleRecord */ + /** Lookup353: pallet_xcm::pallet::RemoteLockedFungibleRecord */ PalletXcmRemoteLockedFungibleRecord: { amount: "u128", owner: "StagingXcmVersionedMultiLocation", locker: "StagingXcmVersionedMultiLocation", consumers: "Vec<(Null,u128)>", }, - /** Lookup363: pallet_xcm::pallet::Error */ + /** Lookup360: pallet_xcm::pallet::Error */ PalletXcmError: { _enum: [ "Unreachable", @@ -2661,7 +2654,7 @@ export default { "InUse", ], }, - /** Lookup365: sp_runtime::MultiSignature */ + /** Lookup362: sp_runtime::MultiSignature */ SpRuntimeMultiSignature: { _enum: { Ed25519: "SpCoreEd25519Signature", @@ -2669,26 +2662,26 @@ export default { Ecdsa: "SpCoreEcdsaSignature", }, }, - /** Lookup366: sp_core::ed25519::Signature */ + /** Lookup363: sp_core::ed25519::Signature */ SpCoreEd25519Signature: "[u8;64]", - /** Lookup368: sp_core::sr25519::Signature */ + /** Lookup365: sp_core::sr25519::Signature */ SpCoreSr25519Signature: "[u8;64]", - /** Lookup369: sp_core::ecdsa::Signature */ + /** Lookup366: sp_core::ecdsa::Signature */ SpCoreEcdsaSignature: "[u8;65]", - /** Lookup372: frame_system::extensions::check_non_zero_sender::CheckNonZeroSender */ + /** Lookup369: frame_system::extensions::check_non_zero_sender::CheckNonZeroSender */ FrameSystemExtensionsCheckNonZeroSender: "Null", - /** Lookup373: frame_system::extensions::check_spec_version::CheckSpecVersion */ + /** Lookup370: frame_system::extensions::check_spec_version::CheckSpecVersion */ FrameSystemExtensionsCheckSpecVersion: "Null", - /** Lookup374: frame_system::extensions::check_tx_version::CheckTxVersion */ + /** Lookup371: frame_system::extensions::check_tx_version::CheckTxVersion */ FrameSystemExtensionsCheckTxVersion: "Null", - /** Lookup375: frame_system::extensions::check_genesis::CheckGenesis */ + /** Lookup372: frame_system::extensions::check_genesis::CheckGenesis */ FrameSystemExtensionsCheckGenesis: "Null", - /** Lookup378: frame_system::extensions::check_nonce::CheckNonce */ + /** Lookup375: frame_system::extensions::check_nonce::CheckNonce */ FrameSystemExtensionsCheckNonce: "Compact", - /** Lookup379: frame_system::extensions::check_weight::CheckWeight */ + /** Lookup376: frame_system::extensions::check_weight::CheckWeight */ FrameSystemExtensionsCheckWeight: "Null", - /** Lookup380: pallet_transaction_payment::ChargeTransactionPayment */ + /** Lookup377: pallet_transaction_payment::ChargeTransactionPayment */ PalletTransactionPaymentChargeTransactionPayment: "Compact", - /** Lookup381: dancebox_runtime::Runtime */ + /** Lookup378: dancebox_runtime::Runtime */ DanceboxRuntimeRuntime: "Null", }; diff --git a/typescript-api/src/dancebox/interfaces/registry.ts b/typescript-api/src/dancebox/interfaces/registry.ts index 616c0b431..4faca09eb 100644 --- a/typescript-api/src/dancebox/interfaces/registry.ts +++ b/typescript-api/src/dancebox/interfaces/registry.ts @@ -82,7 +82,6 @@ import type { PalletConfigurationCall, PalletConfigurationError, PalletConfigurationHostConfiguration, - PalletInitializerBufferedSessionChange, PalletInvulnerablesCall, PalletInvulnerablesError, PalletInvulnerablesEvent, @@ -296,7 +295,6 @@ declare module "@polkadot/types/types/registry" { PalletConfigurationCall: PalletConfigurationCall; PalletConfigurationError: PalletConfigurationError; PalletConfigurationHostConfiguration: PalletConfigurationHostConfiguration; - PalletInitializerBufferedSessionChange: PalletInitializerBufferedSessionChange; PalletInvulnerablesCall: PalletInvulnerablesCall; PalletInvulnerablesError: PalletInvulnerablesError; PalletInvulnerablesEvent: PalletInvulnerablesEvent; diff --git a/typescript-api/src/dancebox/interfaces/types-lookup.ts b/typescript-api/src/dancebox/interfaces/types-lookup.ts index 449fc5d9b..5a0037301 100644 --- a/typescript-api/src/dancebox/interfaces/types-lookup.ts +++ b/typescript-api/src/dancebox/interfaces/types-lookup.ts @@ -3316,21 +3316,13 @@ declare module "@polkadot/types/lookup" { readonly containerChains: BTreeMap>; } - /** @name PalletInitializerBufferedSessionChange (294) */ - interface PalletInitializerBufferedSessionChange extends Struct { - readonly changed: bool; - readonly validators: Vec>; - readonly queued: Vec>; - readonly sessionIndex: u32; - } - - /** @name PalletAuthorNotingContainerChainBlockInfo (297) */ + /** @name PalletAuthorNotingContainerChainBlockInfo (294) */ interface PalletAuthorNotingContainerChainBlockInfo extends Struct { readonly blockNumber: u32; readonly author: AccountId32; } - /** @name PalletAuthorNotingError (298) */ + /** @name PalletAuthorNotingError (295) */ interface PalletAuthorNotingError extends Enum { readonly isFailedReading: boolean; readonly isFailedDecodingHeader: boolean; @@ -3349,13 +3341,13 @@ declare module "@polkadot/types/lookup" { | "NonAuraDigest"; } - /** @name TpCollatorAssignmentAssignedCollatorsPublic (299) */ + /** @name TpCollatorAssignmentAssignedCollatorsPublic (296) */ interface TpCollatorAssignmentAssignedCollatorsPublic extends Struct { readonly orchestratorChain: Vec; readonly containerChains: BTreeMap>; } - /** @name PalletInvulnerablesError (305) */ + /** @name PalletInvulnerablesError (302) */ interface PalletInvulnerablesError extends Enum { readonly isTooManyInvulnerables: boolean; readonly isAlreadyInvulnerable: boolean; @@ -3363,10 +3355,10 @@ declare module "@polkadot/types/lookup" { readonly type: "TooManyInvulnerables" | "AlreadyInvulnerable" | "NotInvulnerable"; } - /** @name SpCoreCryptoKeyTypeId (310) */ + /** @name SpCoreCryptoKeyTypeId (307) */ interface SpCoreCryptoKeyTypeId extends U8aFixed {} - /** @name PalletSessionError (311) */ + /** @name PalletSessionError (308) */ interface PalletSessionError extends Enum { readonly isInvalidProof: boolean; readonly isNoAssociatedValidatorId: boolean; @@ -3376,7 +3368,7 @@ declare module "@polkadot/types/lookup" { readonly type: "InvalidProof" | "NoAssociatedValidatorId" | "DuplicatedKey" | "NoKeys" | "NoAccount"; } - /** @name PalletAuthorInherentError (315) */ + /** @name PalletAuthorInherentError (312) */ interface PalletAuthorInherentError extends Enum { readonly isAuthorAlreadySet: boolean; readonly isNoAccountId: boolean; @@ -3384,13 +3376,13 @@ declare module "@polkadot/types/lookup" { readonly type: "AuthorAlreadySet" | "NoAccountId" | "CannotBeAuthor"; } - /** @name PalletPooledStakingCandidateEligibleCandidate (317) */ + /** @name PalletPooledStakingCandidateEligibleCandidate (314) */ interface PalletPooledStakingCandidateEligibleCandidate extends Struct { readonly candidate: AccountId32; readonly stake: u128; } - /** @name PalletPooledStakingPoolsKey (320) */ + /** @name PalletPooledStakingPoolsKey (317) */ interface PalletPooledStakingPoolsKey extends Enum { readonly isCandidateTotalStake: boolean; readonly isJoiningShares: boolean; @@ -3460,7 +3452,7 @@ declare module "@polkadot/types/lookup" { | "LeavingSharesHeldStake"; } - /** @name PalletPooledStakingError (322) */ + /** @name PalletPooledStakingError (319) */ interface PalletPooledStakingError extends Enum { readonly isInvalidPalletSetting: boolean; readonly isDisabledFeature: boolean; @@ -3494,21 +3486,21 @@ declare module "@polkadot/types/lookup" { | "SwapResultsInZeroShares"; } - /** @name CumulusPalletXcmpQueueInboundChannelDetails (324) */ + /** @name CumulusPalletXcmpQueueInboundChannelDetails (321) */ interface CumulusPalletXcmpQueueInboundChannelDetails extends Struct { readonly sender: u32; readonly state: CumulusPalletXcmpQueueInboundState; readonly messageMetadata: Vec>; } - /** @name CumulusPalletXcmpQueueInboundState (325) */ + /** @name CumulusPalletXcmpQueueInboundState (322) */ interface CumulusPalletXcmpQueueInboundState extends Enum { readonly isOk: boolean; readonly isSuspended: boolean; readonly type: "Ok" | "Suspended"; } - /** @name PolkadotParachainPrimitivesPrimitivesXcmpMessageFormat (328) */ + /** @name PolkadotParachainPrimitivesPrimitivesXcmpMessageFormat (325) */ interface PolkadotParachainPrimitivesPrimitivesXcmpMessageFormat extends Enum { readonly isConcatenatedVersionedXcm: boolean; readonly isConcatenatedEncodedBlob: boolean; @@ -3516,7 +3508,7 @@ declare module "@polkadot/types/lookup" { readonly type: "ConcatenatedVersionedXcm" | "ConcatenatedEncodedBlob" | "Signals"; } - /** @name CumulusPalletXcmpQueueOutboundChannelDetails (331) */ + /** @name CumulusPalletXcmpQueueOutboundChannelDetails (328) */ interface CumulusPalletXcmpQueueOutboundChannelDetails extends Struct { readonly recipient: u32; readonly state: CumulusPalletXcmpQueueOutboundState; @@ -3525,14 +3517,14 @@ declare module "@polkadot/types/lookup" { readonly lastIndex: u16; } - /** @name CumulusPalletXcmpQueueOutboundState (332) */ + /** @name CumulusPalletXcmpQueueOutboundState (329) */ interface CumulusPalletXcmpQueueOutboundState extends Enum { readonly isOk: boolean; readonly isSuspended: boolean; readonly type: "Ok" | "Suspended"; } - /** @name CumulusPalletXcmpQueueQueueConfigData (334) */ + /** @name CumulusPalletXcmpQueueQueueConfigData (331) */ interface CumulusPalletXcmpQueueQueueConfigData extends Struct { readonly suspendThreshold: u32; readonly dropThreshold: u32; @@ -3542,7 +3534,7 @@ declare module "@polkadot/types/lookup" { readonly xcmpMaxIndividualWeight: SpWeightsWeightV2Weight; } - /** @name CumulusPalletXcmpQueueError (336) */ + /** @name CumulusPalletXcmpQueueError (333) */ interface CumulusPalletXcmpQueueError extends Enum { readonly isFailedToSend: boolean; readonly isBadXcmOrigin: boolean; @@ -3552,29 +3544,29 @@ declare module "@polkadot/types/lookup" { readonly type: "FailedToSend" | "BadXcmOrigin" | "BadXcm" | "BadOverweightIndex" | "WeightOverLimit"; } - /** @name CumulusPalletXcmError (337) */ + /** @name CumulusPalletXcmError (334) */ type CumulusPalletXcmError = Null; - /** @name CumulusPalletDmpQueueConfigData (338) */ + /** @name CumulusPalletDmpQueueConfigData (335) */ interface CumulusPalletDmpQueueConfigData extends Struct { readonly maxIndividual: SpWeightsWeightV2Weight; } - /** @name CumulusPalletDmpQueuePageIndexData (339) */ + /** @name CumulusPalletDmpQueuePageIndexData (336) */ interface CumulusPalletDmpQueuePageIndexData extends Struct { readonly beginUsed: u32; readonly endUsed: u32; readonly overweightCount: u64; } - /** @name CumulusPalletDmpQueueError (342) */ + /** @name CumulusPalletDmpQueueError (339) */ interface CumulusPalletDmpQueueError extends Enum { readonly isUnknown: boolean; readonly isOverLimit: boolean; readonly type: "Unknown" | "OverLimit"; } - /** @name PalletXcmQueryStatus (343) */ + /** @name PalletXcmQueryStatus (340) */ interface PalletXcmQueryStatus extends Enum { readonly isPending: boolean; readonly asPending: { @@ -3596,7 +3588,7 @@ declare module "@polkadot/types/lookup" { readonly type: "Pending" | "VersionNotifier" | "Ready"; } - /** @name StagingXcmVersionedResponse (347) */ + /** @name StagingXcmVersionedResponse (344) */ interface StagingXcmVersionedResponse extends Enum { readonly isV2: boolean; readonly asV2: StagingXcmV2Response; @@ -3605,7 +3597,7 @@ declare module "@polkadot/types/lookup" { readonly type: "V2" | "V3"; } - /** @name PalletXcmVersionMigrationStage (353) */ + /** @name PalletXcmVersionMigrationStage (350) */ interface PalletXcmVersionMigrationStage extends Enum { readonly isMigrateSupportedVersion: boolean; readonly isMigrateVersionNotifiers: boolean; @@ -3619,14 +3611,14 @@ declare module "@polkadot/types/lookup" { | "MigrateAndNotifyOldTargets"; } - /** @name StagingXcmVersionedAssetId (355) */ + /** @name StagingXcmVersionedAssetId (352) */ interface StagingXcmVersionedAssetId extends Enum { readonly isV3: boolean; readonly asV3: StagingXcmV3MultiassetAssetId; readonly type: "V3"; } - /** @name PalletXcmRemoteLockedFungibleRecord (356) */ + /** @name PalletXcmRemoteLockedFungibleRecord (353) */ interface PalletXcmRemoteLockedFungibleRecord extends Struct { readonly amount: u128; readonly owner: StagingXcmVersionedMultiLocation; @@ -3634,7 +3626,7 @@ declare module "@polkadot/types/lookup" { readonly consumers: Vec>; } - /** @name PalletXcmError (363) */ + /** @name PalletXcmError (360) */ interface PalletXcmError extends Enum { readonly isUnreachable: boolean; readonly isSendFailure: boolean; @@ -3679,7 +3671,7 @@ declare module "@polkadot/types/lookup" { | "InUse"; } - /** @name SpRuntimeMultiSignature (365) */ + /** @name SpRuntimeMultiSignature (362) */ interface SpRuntimeMultiSignature extends Enum { readonly isEd25519: boolean; readonly asEd25519: SpCoreEd25519Signature; @@ -3690,36 +3682,36 @@ declare module "@polkadot/types/lookup" { readonly type: "Ed25519" | "Sr25519" | "Ecdsa"; } - /** @name SpCoreEd25519Signature (366) */ + /** @name SpCoreEd25519Signature (363) */ interface SpCoreEd25519Signature extends U8aFixed {} - /** @name SpCoreSr25519Signature (368) */ + /** @name SpCoreSr25519Signature (365) */ interface SpCoreSr25519Signature extends U8aFixed {} - /** @name SpCoreEcdsaSignature (369) */ + /** @name SpCoreEcdsaSignature (366) */ interface SpCoreEcdsaSignature extends U8aFixed {} - /** @name FrameSystemExtensionsCheckNonZeroSender (372) */ + /** @name FrameSystemExtensionsCheckNonZeroSender (369) */ type FrameSystemExtensionsCheckNonZeroSender = Null; - /** @name FrameSystemExtensionsCheckSpecVersion (373) */ + /** @name FrameSystemExtensionsCheckSpecVersion (370) */ type FrameSystemExtensionsCheckSpecVersion = Null; - /** @name FrameSystemExtensionsCheckTxVersion (374) */ + /** @name FrameSystemExtensionsCheckTxVersion (371) */ type FrameSystemExtensionsCheckTxVersion = Null; - /** @name FrameSystemExtensionsCheckGenesis (375) */ + /** @name FrameSystemExtensionsCheckGenesis (372) */ type FrameSystemExtensionsCheckGenesis = Null; - /** @name FrameSystemExtensionsCheckNonce (378) */ + /** @name FrameSystemExtensionsCheckNonce (375) */ interface FrameSystemExtensionsCheckNonce extends Compact {} - /** @name FrameSystemExtensionsCheckWeight (379) */ + /** @name FrameSystemExtensionsCheckWeight (376) */ type FrameSystemExtensionsCheckWeight = Null; - /** @name PalletTransactionPaymentChargeTransactionPayment (380) */ + /** @name PalletTransactionPaymentChargeTransactionPayment (377) */ interface PalletTransactionPaymentChargeTransactionPayment extends Compact {} - /** @name DanceboxRuntimeRuntime (381) */ + /** @name DanceboxRuntimeRuntime (378) */ type DanceboxRuntimeRuntime = Null; } // declare module From 93cfc2f90b86fadbe4d5938c13675ec99faaa56b Mon Sep 17 00:00:00 2001 From: girazoki Date: Tue, 17 Oct 2023 15:08:08 +0200 Subject: [PATCH 4/4] rework prediction with the paraId in which you are assigned (#292) * rework prediction with the paraId in which you are assigned * remove unneeded var * remove more unneeded * fix tests * remove unused --- client/consensus/src/lib.rs | 4 +--- client/consensus/src/tests.rs | 36 +++-------------------------------- node/src/service.rs | 8 ++------ 3 files changed, 6 insertions(+), 42 deletions(-) diff --git a/client/consensus/src/lib.rs b/client/consensus/src/lib.rs index 1b57615da..95af05e22 100644 --- a/client/consensus/src/lib.rs +++ b/client/consensus/src/lib.rs @@ -81,7 +81,7 @@ pub(crate) fn slot_author( pub fn authorities( client: &C, parent_hash: &B::Hash, - keystore: KeystorePtr, + para_id: ParaId, ) -> Option>> where P: Pair + Send + Sync, @@ -94,8 +94,6 @@ where { let runtime_api = client.runtime_api(); - let (_first_eligibile_key, para_id) = - first_eligible_key::(client, parent_hash, keystore.clone())?; let authorities = runtime_api .para_id_authorities(*parent_hash, para_id) .ok()?; diff --git a/client/consensus/src/tests.rs b/client/consensus/src/tests.rs index dfa88aceb..0cdaf3b39 100644 --- a/client/consensus/src/tests.rs +++ b/client/consensus/src/tests.rs @@ -705,48 +705,18 @@ async fn authorities_runtime_api_tests() { let net = AuraTestNet::new(4); let net = Arc::new(Mutex::new(net)); - let keystore_path = tempfile::tempdir().expect("Creates keystore path"); - let keystore = LocalKeystore::open(keystore_path.path(), None).expect("Creates keystore."); - - let keystoreptr: sp_keystore::KeystorePtr = keystore.into(); let mut net = net.lock(); let peer = net.peer(3); let client = peer.client().as_client(); let environ = DummyFactory(client.clone()); let default_hash = Default::default(); - let authorities = crate::authorities::<_, _, nimbus_primitives::NimbusPair>( - &environ, - &default_hash, - keystoreptr.clone(), - ); - assert!(authorities.is_none()); - - keystoreptr - .sr25519_generate_new(NIMBUS_KEY_ID, Some(&Keyring::Bob.to_seed())) - .expect("Key should be created"); - // Bob according top the runtime-api is not eligible - let authorities_after_bob = crate::authorities::<_, _, nimbus_primitives::NimbusPair>( - &environ, - &default_hash, - keystoreptr.clone(), - ); - assert!(authorities_after_bob.is_none()); - - // Alice according top the runtime-api is eligible - keystoreptr - .sr25519_generate_new(NIMBUS_KEY_ID, Some(&Keyring::Alice.to_seed())) - .expect("Key should be created"); - - let authorities_after_alice = crate::authorities::<_, _, nimbus_primitives::NimbusPair>( + let authorities = crate::authorities::<_, _, nimbus_primitives::NimbusPair>( &environ, &default_hash, - keystoreptr.clone(), + 1000u32.into(), ); - assert_eq!( - authorities_after_alice, - Some(vec![Keyring::Alice.public().into()]) - ); + assert_eq!(authorities, Some(vec![Keyring::Alice.public().into()])); } diff --git a/node/src/service.rs b/node/src/service.rs index f56c03c62..387e5f67f 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -1071,7 +1071,6 @@ fn build_consensus_container( let relay_chain_interace_for_orch = relay_chain_interface.clone(); let orchestrator_client_for_cidp = orchestrator_client; - let keystore_for_cidp = keystore.clone(); let params = tc_consensus::BuildOrchestratorAuraConsensusParams { proposer_factory, @@ -1129,7 +1128,6 @@ fn build_consensus_container( get_authorities_from_orchestrator: move |_block_hash, (relay_parent, _validation_data)| { let relay_chain_interace_for_orch = relay_chain_interace_for_orch.clone(); let orchestrator_client_for_cidp = orchestrator_client_for_cidp.clone(); - let keystore_for_cidp = keystore_for_cidp.clone(); async move { let latest_header = @@ -1149,7 +1147,7 @@ fn build_consensus_container( let authorities = tc_consensus::authorities::( orchestrator_client_for_cidp.as_ref(), &latest_header.hash(), - keystore_for_cidp, + para_id, ); let aux_data = authorities.ok_or_else(|| { @@ -1216,7 +1214,6 @@ fn build_consensus_orchestrator( ); let client_set_aside_for_cidp = client.clone(); - let keystore_for_cidp = keystore.clone(); let client_set_aside_for_orch = client.clone(); let params = BuildOrchestratorAuraConsensusParams { @@ -1272,13 +1269,12 @@ fn build_consensus_orchestrator( get_authorities_from_orchestrator: move |block_hash: H256, (_relay_parent, _validation_data)| { let client_set_aside_for_orch = client_set_aside_for_orch.clone(); - let keystore_for_cidp = keystore_for_cidp.clone(); async move { let authorities = tc_consensus::authorities::( client_set_aside_for_orch.as_ref(), &block_hash, - keystore_for_cidp, + para_id, ); let aux_data = authorities.ok_or_else(|| {