From bad4afca36ae931624a4ed7efec63ffa4a863cd0 Mon Sep 17 00:00:00 2001 From: s0me0ne-unkn0wn <48632512+s0me0ne-unkn0wn@users.noreply.github.com> Date: Mon, 20 Feb 2023 11:30:45 +0100 Subject: [PATCH] Retire `OldV1SessionInfo` (#6744) --- polkadot/node/core/runtime-api/src/lib.rs | 35 +-------- .../subsystem-types/src/runtime_client.rs | 25 +------ polkadot/primitives/src/lib.rs | 22 +++--- polkadot/primitives/src/runtime_api.rs | 8 +-- polkadot/primitives/src/v2/mod.rs | 72 ------------------- 5 files changed, 17 insertions(+), 145 deletions(-) diff --git a/polkadot/node/core/runtime-api/src/lib.rs b/polkadot/node/core/runtime-api/src/lib.rs index 0c5641d1201..8ea9d1509bf 100644 --- a/polkadot/node/core/runtime-api/src/lib.rs +++ b/polkadot/node/core/runtime-api/src/lib.rs @@ -460,39 +460,8 @@ where ), Request::CandidateEvents(sender) => query!(CandidateEvents, candidate_events(), ver = 1, sender), - Request::SessionInfo(index, sender) => { - let api_version = client - .api_version_parachain_host(relay_parent) - .await - .unwrap_or_default() - .unwrap_or_default(); - - let res = if api_version >= 2 { - let res = client.session_info(relay_parent, index).await.map_err(|e| { - RuntimeApiError::Execution { - runtime_api_name: "SessionInfo", - source: std::sync::Arc::new(e), - } - }); - metrics.on_request(res.is_ok()); - res - } else { - #[allow(deprecated)] - let res = client.session_info_before_version_2(relay_parent, index).await.map_err(|e| { - RuntimeApiError::Execution { - runtime_api_name: "SessionInfo", - source: std::sync::Arc::new(e), - } - }); - metrics.on_request(res.is_ok()); - - res.map(|r| r.map(|old| old.into())) - }; - - let _ = sender.send(res.clone()); - - res.ok().map(|res| RequestResult::SessionInfo(relay_parent, index, res)) - }, + Request::SessionInfo(index, sender) => + query!(SessionInfo, session_info(index), ver = 2, sender), Request::SessionExecutorParams(session_index, sender) => query!( SessionExecutorParams, session_executor_params(session_index), diff --git a/polkadot/node/subsystem-types/src/runtime_client.rs b/polkadot/node/subsystem-types/src/runtime_client.rs index 03283942b74..fc878c6fc7e 100644 --- a/polkadot/node/subsystem-types/src/runtime_client.rs +++ b/polkadot/node/subsystem-types/src/runtime_client.rs @@ -19,9 +19,9 @@ use polkadot_primitives::{ runtime_api::ParachainHost, vstaging::ExecutorParams, Block, BlockId, BlockNumber, CandidateCommitments, CandidateEvent, CandidateHash, CommittedCandidateReceipt, CoreState, DisputeState, GroupRotationInfo, Hash, Id, InboundDownwardMessage, InboundHrmpMessage, - OccupiedCoreAssumption, OldV1SessionInfo, PersistedValidationData, PvfCheckStatement, - ScrapedOnChainVotes, SessionIndex, SessionInfo, ValidationCode, ValidationCodeHash, - ValidatorId, ValidatorIndex, ValidatorSignature, + OccupiedCoreAssumption, PersistedValidationData, PvfCheckStatement, ScrapedOnChainVotes, + SessionIndex, SessionInfo, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, + ValidatorSignature, }; use sp_api::{ApiError, ApiExt, ProvideRuntimeApi}; use sp_authority_discovery::AuthorityDiscoveryApi; @@ -148,15 +148,6 @@ pub trait RuntimeApiSubsystemClient { index: SessionIndex, ) -> Result<Option<SessionInfo>, ApiError>; - /// Get the session info for the given session, if stored. - /// - /// NOTE: This function is only available since parachain host version 2. - async fn session_info_before_version_2( - &self, - at: Hash, - index: SessionIndex, - ) -> Result<Option<OldV1SessionInfo>, ApiError>; - /// Submits a PVF pre-checking statement into the transaction pool. /// /// NOTE: This function is only available since parachain host version 2. @@ -380,16 +371,6 @@ where self.runtime_api().api_version::<dyn ParachainHost<Block>>(&BlockId::Hash(at)) } - #[warn(deprecated)] - async fn session_info_before_version_2( - &self, - at: Hash, - index: SessionIndex, - ) -> Result<Option<OldV1SessionInfo>, ApiError> { - #[allow(deprecated)] - self.runtime_api().session_info_before_version_2(&BlockId::Hash(at), index) - } - async fn disputes( &self, at: Hash, diff --git a/polkadot/primitives/src/lib.rs b/polkadot/primitives/src/lib.rs index 0cd7d6d3ff5..c166b91b8bd 100644 --- a/polkadot/primitives/src/lib.rs +++ b/polkadot/primitives/src/lib.rs @@ -45,17 +45,17 @@ pub use v2::{ EncodeAs, ExplicitDisputeStatement, GroupIndex, GroupRotationInfo, Hash, HashT, HeadData, Header, HrmpChannelId, Id, InboundDownwardMessage, InboundHrmpMessage, IndexedVec, InherentData, InvalidDisputeStatementKind, Moment, MultiDisputeStatementSet, Nonce, - OccupiedCore, OccupiedCoreAssumption, OldV1SessionInfo, OutboundHrmpMessage, ParathreadClaim, - ParathreadEntry, PersistedValidationData, PvfCheckStatement, RuntimeMetricLabel, - RuntimeMetricLabelValue, RuntimeMetricLabelValues, RuntimeMetricLabels, RuntimeMetricOp, - RuntimeMetricUpdate, ScheduledCore, ScrapedOnChainVotes, SessionIndex, SessionInfo, Signature, - Signed, SignedAvailabilityBitfield, SignedAvailabilityBitfields, SignedStatement, - SigningContext, Slot, UncheckedSigned, UncheckedSignedAvailabilityBitfield, - UncheckedSignedAvailabilityBitfields, UncheckedSignedStatement, UpgradeGoAhead, - UpgradeRestriction, UpwardMessage, ValidDisputeStatementKind, ValidationCode, - ValidationCodeHash, ValidatorId, ValidatorIndex, ValidatorSignature, ValidityAttestation, - ValidityError, ASSIGNMENT_KEY_TYPE_ID, LOWEST_PUBLIC_ID, MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE, - MAX_POV_SIZE, PARACHAINS_INHERENT_IDENTIFIER, PARACHAIN_KEY_TYPE_ID, + OccupiedCore, OccupiedCoreAssumption, OutboundHrmpMessage, ParathreadClaim, ParathreadEntry, + PersistedValidationData, PvfCheckStatement, RuntimeMetricLabel, RuntimeMetricLabelValue, + RuntimeMetricLabelValues, RuntimeMetricLabels, RuntimeMetricOp, RuntimeMetricUpdate, + ScheduledCore, ScrapedOnChainVotes, SessionIndex, SessionInfo, Signature, Signed, + SignedAvailabilityBitfield, SignedAvailabilityBitfields, SignedStatement, SigningContext, Slot, + UncheckedSigned, UncheckedSignedAvailabilityBitfield, UncheckedSignedAvailabilityBitfields, + UncheckedSignedStatement, UpgradeGoAhead, UpgradeRestriction, UpwardMessage, + ValidDisputeStatementKind, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, + ValidatorSignature, ValidityAttestation, ValidityError, ASSIGNMENT_KEY_TYPE_ID, + LOWEST_PUBLIC_ID, MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE, MAX_POV_SIZE, + PARACHAINS_INHERENT_IDENTIFIER, PARACHAIN_KEY_TYPE_ID, }; #[cfg(feature = "std")] diff --git a/polkadot/primitives/src/runtime_api.rs b/polkadot/primitives/src/runtime_api.rs index a618d18e22d..8275d595d61 100644 --- a/polkadot/primitives/src/runtime_api.rs +++ b/polkadot/primitives/src/runtime_api.rs @@ -111,7 +111,7 @@ //! from the stable primitives. use crate::{ - v2, vstaging, BlockNumber, CandidateCommitments, CandidateEvent, CandidateHash, + vstaging, BlockNumber, CandidateCommitments, CandidateEvent, CandidateHash, CommittedCandidateReceipt, CoreState, DisputeState, GroupRotationInfo, OccupiedCoreAssumption, PersistedValidationData, PvfCheckStatement, ScrapedOnChainVotes, SessionIndex, SessionInfo, ValidatorId, ValidatorIndex, ValidatorSignature, @@ -213,12 +213,6 @@ sp_api::decl_runtime_apis! { fn validation_code_hash(para_id: ppp::Id, assumption: OccupiedCoreAssumption) -> Option<ppp::ValidationCodeHash>; - /***** Replaced in v2 *****/ - - /// Old method to fetch v1 session info. - #[changed_in(2)] - fn session_info(index: SessionIndex) -> Option<v2::OldV1SessionInfo>; - /***** STAGING *****/ /// Returns all onchain disputes. diff --git a/polkadot/primitives/src/v2/mod.rs b/polkadot/primitives/src/v2/mod.rs index c8e03a7ad5f..06326676c9d 100644 --- a/polkadot/primitives/src/v2/mod.rs +++ b/polkadot/primitives/src/v2/mod.rs @@ -1686,78 +1686,6 @@ impl PvfCheckStatement { } } -/// Old, v1-style info about session info. Only needed for limited -/// backwards-compatibility. -#[derive(Clone, Encode, Decode, RuntimeDebug, TypeInfo)] -#[cfg_attr(feature = "std", derive(PartialEq))] -pub struct OldV1SessionInfo { - /// Validators in canonical ordering. - /// - /// NOTE: There might be more authorities in the current session, than `validators` participating - /// in parachain consensus. See - /// [`max_validators`](https://github.com/paritytech/polkadot/blob/a52dca2be7840b23c19c153cf7e110b1e3e475f8/runtime/parachains/src/configuration.rs#L148). - /// - /// `SessionInfo::validators` will be limited to to `max_validators` when set. - pub validators: IndexedVec<ValidatorIndex, ValidatorId>, - /// Validators' authority discovery keys for the session in canonical ordering. - /// - /// NOTE: The first `validators.len()` entries will match the corresponding validators in - /// `validators`, afterwards any remaining authorities can be found. This is any authorities not - /// participating in parachain consensus - see - /// [`max_validators`](https://github.com/paritytech/polkadot/blob/a52dca2be7840b23c19c153cf7e110b1e3e475f8/runtime/parachains/src/configuration.rs#L148) - pub discovery_keys: Vec<AuthorityDiscoveryId>, - /// The assignment keys for validators. - /// - /// NOTE: There might be more authorities in the current session, than validators participating - /// in parachain consensus. See - /// [`max_validators`](https://github.com/paritytech/polkadot/blob/a52dca2be7840b23c19c153cf7e110b1e3e475f8/runtime/parachains/src/configuration.rs#L148). - /// - /// Therefore: - /// ```ignore - /// assignment_keys.len() == validators.len() && validators.len() <= discovery_keys.len() - /// ``` - pub assignment_keys: Vec<AssignmentId>, - /// Validators in shuffled ordering - these are the validator groups as produced - /// by the `Scheduler` module for the session and are typically referred to by - /// `GroupIndex`. - pub validator_groups: IndexedVec<GroupIndex, Vec<ValidatorIndex>>, - /// The number of availability cores used by the protocol during this session. - pub n_cores: u32, - /// The zeroth delay tranche width. - pub zeroth_delay_tranche_width: u32, - /// The number of samples we do of `relay_vrf_modulo`. - pub relay_vrf_modulo_samples: u32, - /// The number of delay tranches in total. - pub n_delay_tranches: u32, - /// How many slots (BABE / SASSAFRAS) must pass before an assignment is considered a - /// no-show. - pub no_show_slots: u32, - /// The number of validators needed to approve a block. - pub needed_approvals: u32, -} - -impl From<OldV1SessionInfo> for SessionInfo { - fn from(old: OldV1SessionInfo) -> SessionInfo { - SessionInfo { - // new fields - active_validator_indices: Vec::new(), - random_seed: [0u8; 32], - dispute_period: 6, - // old fields - validators: old.validators, - discovery_keys: old.discovery_keys, - assignment_keys: old.assignment_keys, - validator_groups: old.validator_groups, - n_cores: old.n_cores, - zeroth_delay_tranche_width: old.zeroth_delay_tranche_width, - relay_vrf_modulo_samples: old.relay_vrf_modulo_samples, - n_delay_tranches: old.n_delay_tranches, - no_show_slots: old.no_show_slots, - needed_approvals: old.needed_approvals, - } - } -} - #[cfg(test)] mod tests { use super::*; -- GitLab