From c717dbbd9ad0770879c881b38af53f8acb0695d4 Mon Sep 17 00:00:00 2001 From: s0me0ne-unkn0wn <48632512+s0me0ne-unkn0wn@users.noreply.github.com> Date: Wed, 15 Mar 2023 18:06:18 +0100 Subject: [PATCH] Release parachain host API v4 (#6885) --- node/core/candidate-validation/src/lib.rs | 2 +- node/core/pvf/src/artifacts.rs | 4 +-- node/core/pvf/src/execute/queue.rs | 2 +- node/core/pvf/src/execute/worker.rs | 2 +- node/core/pvf/src/executor_intf.rs | 2 +- node/core/pvf/src/host.rs | 2 +- node/core/pvf/src/pvf.rs | 2 +- node/core/pvf/src/testing.rs | 2 +- node/core/pvf/tests/it/main.rs | 2 +- node/core/runtime-api/src/cache.rs | 11 +++--- node/subsystem-types/src/messages.rs | 6 ++-- node/subsystem-types/src/runtime_client.rs | 4 +-- node/subsystem-util/src/lib.rs | 2 +- node/test/performance-test/src/lib.rs | 2 +- primitives/src/lib.rs | 17 +++++----- primitives/src/runtime_api.rs | 12 +++---- .../src/{vstaging => v4}/executor_params.rs | 0 primitives/src/{v2 => v4}/metrics.rs | 0 primitives/src/{v2 => v4}/mod.rs | 3 ++ primitives/src/{v2 => v4}/signed.rs | 0 primitives/src/vstaging/mod.rs | 3 -- runtime/kusama/src/lib.rs | 20 +++++++---- .../parachains/src/runtime_api_impl/mod.rs | 2 +- .../src/runtime_api_impl/{v2.rs => v4.rs} | 34 +++++++++++++++---- .../src/runtime_api_impl/vstaging.rs | 25 -------------- runtime/parachains/src/session_info.rs | 3 +- runtime/polkadot/src/lib.rs | 20 +++++++---- runtime/rococo/src/lib.rs | 22 +++++------- runtime/test-runtime/src/lib.rs | 21 ++++++++---- runtime/westend/src/lib.rs | 22 +++++------- 30 files changed, 129 insertions(+), 120 deletions(-) rename primitives/src/{vstaging => v4}/executor_params.rs (100%) rename primitives/src/{v2 => v4}/metrics.rs (100%) rename primitives/src/{v2 => v4}/mod.rs (99%) rename primitives/src/{v2 => v4}/signed.rs (100%) rename runtime/parachains/src/runtime_api_impl/{v2.rs => v4.rs} (91%) diff --git a/node/core/candidate-validation/src/lib.rs b/node/core/candidate-validation/src/lib.rs index a1c939b236ac..7d3fa964eeff 100644 --- a/node/core/candidate-validation/src/lib.rs +++ b/node/core/candidate-validation/src/lib.rs @@ -42,7 +42,7 @@ use polkadot_node_subsystem::{ use polkadot_node_subsystem_util::executor_params_at_relay_parent; use polkadot_parachain::primitives::{ValidationParams, ValidationResult as WasmValidationResult}; use polkadot_primitives::{ - vstaging::ExecutorParams, CandidateCommitments, CandidateDescriptor, CandidateReceipt, Hash, + CandidateCommitments, CandidateDescriptor, CandidateReceipt, ExecutorParams, Hash, OccupiedCoreAssumption, PersistedValidationData, PvfExecTimeoutKind, PvfPrepTimeoutKind, ValidationCode, ValidationCodeHash, }; diff --git a/node/core/pvf/src/artifacts.rs b/node/core/pvf/src/artifacts.rs index 7ddbaef38c5a..760e7ed46a1c 100644 --- a/node/core/pvf/src/artifacts.rs +++ b/node/core/pvf/src/artifacts.rs @@ -17,7 +17,7 @@ use crate::{error::PrepareError, host::PrepareResultSender, prepare::PrepareStats}; use always_assert::always; use polkadot_parachain::primitives::ValidationCodeHash; -use polkadot_primitives::vstaging::ExecutorParamsHash; +use polkadot_primitives::ExecutorParamsHash; use std::{ collections::HashMap, path::{Path, PathBuf}, @@ -219,7 +219,7 @@ impl Artifacts { #[cfg(test)] mod tests { use super::{ArtifactId, Artifacts}; - use polkadot_primitives::vstaging::ExecutorParamsHash; + use polkadot_primitives::ExecutorParamsHash; use sp_core::H256; use std::{path::Path, str::FromStr}; diff --git a/node/core/pvf/src/execute/queue.rs b/node/core/pvf/src/execute/queue.rs index 9a89c46e7a14..af9c0d8672ef 100644 --- a/node/core/pvf/src/execute/queue.rs +++ b/node/core/pvf/src/execute/queue.rs @@ -30,7 +30,7 @@ use futures::{ stream::{FuturesUnordered, StreamExt as _}, Future, FutureExt, }; -use polkadot_primitives::vstaging::{ExecutorParams, ExecutorParamsHash}; +use polkadot_primitives::{ExecutorParams, ExecutorParamsHash}; use slotmap::HopSlotMap; use std::{ collections::VecDeque, diff --git a/node/core/pvf/src/execute/worker.rs b/node/core/pvf/src/execute/worker.rs index 5db6a6261cc9..523be67da268 100644 --- a/node/core/pvf/src/execute/worker.rs +++ b/node/core/pvf/src/execute/worker.rs @@ -30,7 +30,7 @@ use futures_timer::Delay; use parity_scale_codec::{Decode, Encode}; use polkadot_parachain::primitives::ValidationResult; -use polkadot_primitives::vstaging::ExecutorParams; +use polkadot_primitives::ExecutorParams; use std::{ path::{Path, PathBuf}, sync::{mpsc::channel, Arc}, diff --git a/node/core/pvf/src/executor_intf.rs b/node/core/pvf/src/executor_intf.rs index a1b5f9a4886c..af552077bc43 100644 --- a/node/core/pvf/src/executor_intf.rs +++ b/node/core/pvf/src/executor_intf.rs @@ -16,7 +16,7 @@ //! Interface to the Substrate Executor -use polkadot_primitives::vstaging::executor_params::{ExecutorParam, ExecutorParams}; +use polkadot_primitives::{ExecutorParam, ExecutorParams}; use sc_executor_common::{ runtime_blob::RuntimeBlob, wasm_runtime::{HeapAllocStrategy, InvokeMethod, WasmModule as _}, diff --git a/node/core/pvf/src/host.rs b/node/core/pvf/src/host.rs index d4071064d41a..eeb0936e898f 100644 --- a/node/core/pvf/src/host.rs +++ b/node/core/pvf/src/host.rs @@ -33,7 +33,7 @@ use futures::{ Future, FutureExt, SinkExt, StreamExt, }; use polkadot_parachain::primitives::ValidationResult; -use polkadot_primitives::vstaging::ExecutorParams; +use polkadot_primitives::ExecutorParams; use std::{ collections::HashMap, path::{Path, PathBuf}, diff --git a/node/core/pvf/src/pvf.rs b/node/core/pvf/src/pvf.rs index 3a40b972f09a..7e7aa6be5245 100644 --- a/node/core/pvf/src/pvf.rs +++ b/node/core/pvf/src/pvf.rs @@ -17,7 +17,7 @@ use crate::artifacts::ArtifactId; use parity_scale_codec::{Decode, Encode}; use polkadot_parachain::primitives::ValidationCodeHash; -use polkadot_primitives::vstaging::ExecutorParams; +use polkadot_primitives::ExecutorParams; use sp_core::blake2_256; use std::{ cmp::{Eq, PartialEq}, diff --git a/node/core/pvf/src/testing.rs b/node/core/pvf/src/testing.rs index e41b769440df..f0b6a0a60f7c 100644 --- a/node/core/pvf/src/testing.rs +++ b/node/core/pvf/src/testing.rs @@ -19,7 +19,7 @@ //! N.B. This is not guarded with some feature flag. Overexposing items here may affect the final //! artifact even for production builds. -use polkadot_primitives::vstaging::ExecutorParams; +use polkadot_primitives::ExecutorParams; pub mod worker_common { pub use crate::worker_common::{spawn_with_program_path, SpawnErr}; diff --git a/node/core/pvf/tests/it/main.rs b/node/core/pvf/tests/it/main.rs index c35a638ba43b..6833a7de9fb0 100644 --- a/node/core/pvf/tests/it/main.rs +++ b/node/core/pvf/tests/it/main.rs @@ -21,7 +21,7 @@ use polkadot_node_core_pvf::{ JOB_TIMEOUT_WALL_CLOCK_FACTOR, }; use polkadot_parachain::primitives::{BlockData, ValidationParams, ValidationResult}; -use polkadot_primitives::vstaging::{ExecutorParam, ExecutorParams}; +use polkadot_primitives::{ExecutorParam, ExecutorParams}; use std::time::Duration; use tokio::sync::Mutex; diff --git a/node/core/runtime-api/src/cache.rs b/node/core/runtime-api/src/cache.rs index 82d2e0dbc8b3..63274f10c4bf 100644 --- a/node/core/runtime-api/src/cache.rs +++ b/node/core/runtime-api/src/cache.rs @@ -20,12 +20,11 @@ use lru::LruCache; use sp_consensus_babe::Epoch; use polkadot_primitives::{ - vstaging::ExecutorParams, AuthorityDiscoveryId, BlockNumber, CandidateCommitments, - CandidateEvent, CandidateHash, CommittedCandidateReceipt, CoreState, DisputeState, - GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, - OccupiedCoreAssumption, PersistedValidationData, PvfCheckStatement, ScrapedOnChainVotes, - SessionIndex, SessionInfo, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, - ValidatorSignature, + AuthorityDiscoveryId, BlockNumber, CandidateCommitments, CandidateEvent, CandidateHash, + CommittedCandidateReceipt, CoreState, DisputeState, ExecutorParams, GroupRotationInfo, Hash, + Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, OccupiedCoreAssumption, + PersistedValidationData, PvfCheckStatement, ScrapedOnChainVotes, SessionIndex, SessionInfo, + ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, ValidatorSignature, }; /// For consistency we have the same capacity for all caches. We use 128 as we'll only need that diff --git a/node/subsystem-types/src/messages.rs b/node/subsystem-types/src/messages.rs index e5b9db9e5e97..95895a5b0aec 100644 --- a/node/subsystem-types/src/messages.rs +++ b/node/subsystem-types/src/messages.rs @@ -39,9 +39,9 @@ use polkadot_node_primitives::{ SignedDisputeStatement, SignedFullStatement, ValidationResult, }; use polkadot_primitives::{ - vstaging::ExecutorParams, AuthorityDiscoveryId, BackedCandidate, BlockNumber, CandidateEvent, - CandidateHash, CandidateIndex, CandidateReceipt, CollatorId, CommittedCandidateReceipt, - CoreState, DisputeState, GroupIndex, GroupRotationInfo, Hash, Header as BlockHeader, + AuthorityDiscoveryId, BackedCandidate, BlockNumber, CandidateEvent, CandidateHash, + CandidateIndex, CandidateReceipt, CollatorId, CommittedCandidateReceipt, CoreState, + DisputeState, ExecutorParams, GroupIndex, GroupRotationInfo, Hash, Header as BlockHeader, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, MultiDisputeStatementSet, OccupiedCoreAssumption, PersistedValidationData, PvfCheckStatement, PvfExecTimeoutKind, SessionIndex, SessionInfo, SignedAvailabilityBitfield, SignedAvailabilityBitfields, diff --git a/node/subsystem-types/src/runtime_client.rs b/node/subsystem-types/src/runtime_client.rs index 81b33c62cc0a..7af3cb33696b 100644 --- a/node/subsystem-types/src/runtime_client.rs +++ b/node/subsystem-types/src/runtime_client.rs @@ -16,8 +16,8 @@ use async_trait::async_trait; use polkadot_primitives::{ - runtime_api::ParachainHost, vstaging::ExecutorParams, Block, BlockNumber, CandidateCommitments, - CandidateEvent, CandidateHash, CommittedCandidateReceipt, CoreState, DisputeState, + runtime_api::ParachainHost, Block, BlockNumber, CandidateCommitments, CandidateEvent, + CandidateHash, CommittedCandidateReceipt, CoreState, DisputeState, ExecutorParams, GroupRotationInfo, Hash, Id, InboundDownwardMessage, InboundHrmpMessage, OccupiedCoreAssumption, PersistedValidationData, PvfCheckStatement, ScrapedOnChainVotes, SessionIndex, SessionInfo, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, diff --git a/node/subsystem-util/src/lib.rs b/node/subsystem-util/src/lib.rs index 3aafc14a7878..1fec56ef15a6 100644 --- a/node/subsystem-util/src/lib.rs +++ b/node/subsystem-util/src/lib.rs @@ -29,7 +29,7 @@ use polkadot_node_subsystem::{ messages::{RuntimeApiMessage, RuntimeApiRequest, RuntimeApiSender}, overseer, SubsystemSender, }; -use polkadot_primitives::vstaging::ExecutorParams; +use polkadot_primitives::ExecutorParams; pub use overseer::{ gen::{OrchestraError as OverseerError, Timeout}, diff --git a/node/test/performance-test/src/lib.rs b/node/test/performance-test/src/lib.rs index 4ba86014e1e4..636bb7a00ea9 100644 --- a/node/test/performance-test/src/lib.rs +++ b/node/test/performance-test/src/lib.rs @@ -18,7 +18,7 @@ use polkadot_erasure_coding::{obtain_chunks, reconstruct}; use polkadot_node_core_pvf::{sc_executor_common, sp_maybe_compressed_blob}; -use polkadot_primitives::vstaging::ExecutorParams; +use polkadot_primitives::ExecutorParams; use std::time::{Duration, Instant}; mod constants; diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index e242c7c0800c..c7c4b502d3f3 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -19,8 +19,8 @@ #![warn(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] -// `v2` is currently the latest stable version of the runtime API. -pub mod v2; +// `v4` is currently the latest stable version of the runtime API. +pub mod v4; // The 'staging' version is special - it contains primitives which are // still in development. Once they are considered stable, they will be @@ -33,7 +33,7 @@ pub mod runtime_api; // Current primitives not requiring versioning are exported here. // Primitives requiring versioning must not be exported and must be referred by an exact version. -pub use v2::{ +pub use v4::{ byzantine_threshold, check_candidate_backing, collator_signature_payload, metric_definitions, supermajority_threshold, well_known_keys, AbridgedHostConfiguration, AbridgedHrmpChannel, AccountId, AccountIndex, AccountPublic, ApprovalVote, AssignmentId, AuthorityDiscoveryId, @@ -42,10 +42,11 @@ pub use v2::{ CandidateReceipt, CheckedDisputeStatementSet, CheckedMultiDisputeStatementSet, CollatorId, CollatorSignature, CommittedCandidateReceipt, CompactStatement, ConsensusLog, CoreIndex, CoreOccupied, CoreState, DisputeState, DisputeStatement, DisputeStatementSet, DownwardMessage, - EncodeAs, ExplicitDisputeStatement, GroupIndex, GroupRotationInfo, Hash, HashT, HeadData, - Header, HrmpChannelId, Id, InboundDownwardMessage, InboundHrmpMessage, IndexedVec, - InherentData, InvalidDisputeStatementKind, Moment, MultiDisputeStatementSet, Nonce, - OccupiedCore, OccupiedCoreAssumption, OutboundHrmpMessage, ParathreadClaim, ParathreadEntry, + EncodeAs, ExecutorParam, ExecutorParams, ExecutorParamsHash, ExplicitDisputeStatement, + GroupIndex, GroupRotationInfo, Hash, HashT, HeadData, Header, HrmpChannelId, Id, + InboundDownwardMessage, InboundHrmpMessage, IndexedVec, InherentData, + InvalidDisputeStatementKind, Moment, MultiDisputeStatementSet, Nonce, OccupiedCore, + OccupiedCoreAssumption, OutboundHrmpMessage, ParathreadClaim, ParathreadEntry, PersistedValidationData, PvfCheckStatement, PvfExecTimeoutKind, PvfPrepTimeoutKind, RuntimeMetricLabel, RuntimeMetricLabelValue, RuntimeMetricLabelValues, RuntimeMetricLabels, RuntimeMetricOp, RuntimeMetricUpdate, ScheduledCore, ScrapedOnChainVotes, SessionIndex, @@ -59,4 +60,4 @@ pub use v2::{ }; #[cfg(feature = "std")] -pub use v2::{AssignmentPair, CollatorPair, ValidatorPair}; +pub use v4::{AssignmentPair, CollatorPair, ValidatorPair}; diff --git a/primitives/src/runtime_api.rs b/primitives/src/runtime_api.rs index 8275d595d61b..222eb9580ce0 100644 --- a/primitives/src/runtime_api.rs +++ b/primitives/src/runtime_api.rs @@ -111,8 +111,8 @@ //! from the stable primitives. use crate::{ - vstaging, BlockNumber, CandidateCommitments, CandidateEvent, CandidateHash, - CommittedCandidateReceipt, CoreState, DisputeState, GroupRotationInfo, OccupiedCoreAssumption, + BlockNumber, CandidateCommitments, CandidateEvent, CandidateHash, CommittedCandidateReceipt, + CoreState, DisputeState, ExecutorParams, GroupRotationInfo, OccupiedCoreAssumption, PersistedValidationData, PvfCheckStatement, ScrapedOnChainVotes, SessionIndex, SessionInfo, ValidatorId, ValidatorIndex, ValidatorSignature, }; @@ -123,7 +123,7 @@ use sp_std::{collections::btree_map::BTreeMap, prelude::*}; sp_api::decl_runtime_apis! { /// The API for querying the state of parachains on-chain. - #[api_version(2)] + #[api_version(4)] pub trait ParachainHost { /// Get the current validators. fn validators() -> Vec; @@ -213,14 +213,10 @@ sp_api::decl_runtime_apis! { fn validation_code_hash(para_id: ppp::Id, assumption: OccupiedCoreAssumption) -> Option; - /***** STAGING *****/ - /// Returns all onchain disputes. - #[api_version(3)] fn disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState)>; /// Returns execution parameters for the session. - #[api_version(4)] - fn session_executor_params(session_index: SessionIndex) -> Option; + fn session_executor_params(session_index: SessionIndex) -> Option; } } diff --git a/primitives/src/vstaging/executor_params.rs b/primitives/src/v4/executor_params.rs similarity index 100% rename from primitives/src/vstaging/executor_params.rs rename to primitives/src/v4/executor_params.rs diff --git a/primitives/src/v2/metrics.rs b/primitives/src/v4/metrics.rs similarity index 100% rename from primitives/src/v2/metrics.rs rename to primitives/src/v4/metrics.rs diff --git a/primitives/src/v2/mod.rs b/primitives/src/v4/mod.rs similarity index 99% rename from primitives/src/v2/mod.rs rename to primitives/src/v4/mod.rs index d39c322e37be..82d7954b8090 100644 --- a/primitives/src/v2/mod.rs +++ b/primitives/src/v4/mod.rs @@ -1716,6 +1716,9 @@ pub enum PvfExecTimeoutKind { Approval, } +pub mod executor_params; +pub use executor_params::{ExecutorParam, ExecutorParams, ExecutorParamsHash}; + #[cfg(test)] mod tests { use super::*; diff --git a/primitives/src/v2/signed.rs b/primitives/src/v4/signed.rs similarity index 100% rename from primitives/src/v2/signed.rs rename to primitives/src/v4/signed.rs diff --git a/primitives/src/vstaging/mod.rs b/primitives/src/vstaging/mod.rs index d6428d252149..64671bd48a60 100644 --- a/primitives/src/vstaging/mod.rs +++ b/primitives/src/vstaging/mod.rs @@ -17,6 +17,3 @@ //! Staging Primitives. // Put any primitives used by staging APIs functions here - -pub mod executor_params; -pub use executor_params::{ExecutorParam, ExecutorParams, ExecutorParamsHash}; diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 8ff6ba21c993..daa5b7d5f1a7 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -23,11 +23,11 @@ use pallet_nis::WithMaximumOf; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use primitives::{ - AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CommittedCandidateReceipt, - CoreState, GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, - Moment, Nonce, OccupiedCoreAssumption, PersistedValidationData, ScrapedOnChainVotes, - SessionInfo, Signature, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, - LOWEST_PUBLIC_ID, + AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash, + CommittedCandidateReceipt, CoreState, DisputeState, ExecutorParams, GroupRotationInfo, Hash, + Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce, + OccupiedCoreAssumption, PersistedValidationData, ScrapedOnChainVotes, SessionInfo, Signature, + ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, LOWEST_PUBLIC_ID, }; use runtime_common::{ auctions, claims, crowdloan, impl_runtime_weights, impls::DealWithFees, paras_registrar, @@ -41,7 +41,7 @@ use runtime_parachains::{ dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion, initializer as parachains_initializer, origin as parachains_origin, paras as parachains_paras, paras_inherent as parachains_paras_inherent, reward_points as parachains_reward_points, - runtime_api_impl::v2 as parachains_runtime_api_impl, scheduler as parachains_scheduler, + runtime_api_impl::v4 as parachains_runtime_api_impl, scheduler as parachains_scheduler, session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump, }; @@ -1678,6 +1678,10 @@ sp_api::impl_runtime_apis! { parachains_runtime_api_impl::session_info::(index) } + fn session_executor_params(session_index: SessionIndex) -> Option { + parachains_runtime_api_impl::session_executor_params::(session_index) + } + fn dmq_contents(recipient: ParaId) -> Vec> { parachains_runtime_api_impl::dmq_contents::(recipient) } @@ -1712,6 +1716,10 @@ sp_api::impl_runtime_apis! { { parachains_runtime_api_impl::validation_code_hash::(para_id, assumption) } + + fn disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState)> { + parachains_runtime_api_impl::get_session_disputes::() + } } impl beefy_primitives::BeefyApi for Runtime { diff --git a/runtime/parachains/src/runtime_api_impl/mod.rs b/runtime/parachains/src/runtime_api_impl/mod.rs index da1cd6d09337..e5a17f33f3ad 100644 --- a/runtime/parachains/src/runtime_api_impl/mod.rs +++ b/runtime/parachains/src/runtime_api_impl/mod.rs @@ -26,5 +26,5 @@ //! 2. Move methods from `vstaging` to `v3`. The new stable version should include //! all methods from `vstaging` tagged with the new version number (e.g. all //! `v3` methods). -pub mod v2; +pub mod v4; pub mod vstaging; diff --git a/runtime/parachains/src/runtime_api_impl/v2.rs b/runtime/parachains/src/runtime_api_impl/v4.rs similarity index 91% rename from runtime/parachains/src/runtime_api_impl/v2.rs rename to runtime/parachains/src/runtime_api_impl/v4.rs index 15b91d57d923..da34a0723a06 100644 --- a/runtime/parachains/src/runtime_api_impl/v2.rs +++ b/runtime/parachains/src/runtime_api_impl/v4.rs @@ -18,15 +18,16 @@ //! functions. use crate::{ - configuration, dmp, hrmp, inclusion, initializer, paras, paras_inherent, scheduler, + configuration, disputes, dmp, hrmp, inclusion, initializer, paras, paras_inherent, scheduler, session_info, shared, }; use primitives::{ - AuthorityDiscoveryId, CandidateEvent, CommittedCandidateReceipt, CoreIndex, CoreOccupied, - CoreState, GroupIndex, GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage, - InboundHrmpMessage, OccupiedCore, OccupiedCoreAssumption, PersistedValidationData, - PvfCheckStatement, ScheduledCore, ScrapedOnChainVotes, SessionIndex, SessionInfo, - ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, ValidatorSignature, + AuthorityDiscoveryId, CandidateEvent, CandidateHash, CommittedCandidateReceipt, CoreIndex, + CoreOccupied, CoreState, DisputeState, ExecutorParams, GroupIndex, GroupRotationInfo, Hash, + Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, OccupiedCore, OccupiedCoreAssumption, + PersistedValidationData, PvfCheckStatement, ScheduledCore, ScrapedOnChainVotes, SessionIndex, + SessionInfo, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, + ValidatorSignature, }; use sp_runtime::traits::One; use sp_std::{collections::btree_map::BTreeMap, prelude::*}; @@ -399,3 +400,24 @@ where >::current_code_hash(¶_id) }) } + +/// Implementation for `get_session_disputes` function from the runtime API +pub fn get_session_disputes( +) -> Vec<(SessionIndex, CandidateHash, DisputeState)> { + >::disputes() +} + +/// Get session executor parameter set +pub fn session_executor_params( + session_index: SessionIndex, +) -> Option { + // This is to bootstrap the storage working around the runtime migration issue: + // https://github.com/paritytech/substrate/issues/9997 + // After the bootstrap is complete (no less than 7 session passed with the runtime) + // this code should be replaced with a pure + // >::session_executor_params(session_index) call. + match >::session_executor_params(session_index) { + Some(ep) => Some(ep), + None => Some(ExecutorParams::default()), + } +} diff --git a/runtime/parachains/src/runtime_api_impl/vstaging.rs b/runtime/parachains/src/runtime_api_impl/vstaging.rs index f96323ce5043..c6ab554030a7 100644 --- a/runtime/parachains/src/runtime_api_impl/vstaging.rs +++ b/runtime/parachains/src/runtime_api_impl/vstaging.rs @@ -15,28 +15,3 @@ // along with Polkadot. If not, see . //! Put implementations of functions from staging APIs here. - -use crate::{disputes, session_info}; -use primitives::{vstaging::ExecutorParams, CandidateHash, DisputeState, SessionIndex}; -use sp_std::prelude::*; - -/// Implementation for `get_session_disputes` function from the runtime API -pub fn get_session_disputes( -) -> Vec<(SessionIndex, CandidateHash, DisputeState)> { - >::disputes() -} - -/// Get session executor parameter set -pub fn session_executor_params( - session_index: SessionIndex, -) -> Option { - // This is to bootstrap the storage working around the runtime migration issue: - // https://github.com/paritytech/substrate/issues/9997 - // After the bootstrap is complete (no less than 7 session passed with the runtime) - // this code should be replaced with a pure - // >::session_executor_params(session_index) call. - match >::session_executor_params(session_index) { - Some(ep) => Some(ep), - None => Some(ExecutorParams::default()), - } -} diff --git a/runtime/parachains/src/session_info.rs b/runtime/parachains/src/session_info.rs index 11d430d1ef72..df0dd5cc7874 100644 --- a/runtime/parachains/src/session_info.rs +++ b/runtime/parachains/src/session_info.rs @@ -28,8 +28,7 @@ use frame_support::{ traits::{OneSessionHandler, ValidatorSet, ValidatorSetWithIdentification}, }; use primitives::{ - vstaging::{ExecutorParam, ExecutorParams}, - AssignmentId, AuthorityDiscoveryId, SessionIndex, SessionInfo, + AssignmentId, AuthorityDiscoveryId, ExecutorParam, ExecutorParams, SessionIndex, SessionInfo, }; use sp_std::vec::Vec; diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index 1d8133f2ba9c..f33990348aa4 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -31,7 +31,7 @@ use runtime_parachains::{ dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion, initializer as parachains_initializer, origin as parachains_origin, paras as parachains_paras, paras_inherent as parachains_paras_inherent, reward_points as parachains_reward_points, - runtime_api_impl::v2 as parachains_runtime_api_impl, scheduler as parachains_scheduler, + runtime_api_impl::v4 as parachains_runtime_api_impl, scheduler as parachains_scheduler, session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump, }; @@ -54,11 +54,11 @@ use pallet_session::historical as session_historical; use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo}; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use primitives::{ - AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CommittedCandidateReceipt, - CoreState, GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, - Moment, Nonce, OccupiedCoreAssumption, PersistedValidationData, ScrapedOnChainVotes, - SessionInfo, Signature, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, - LOWEST_PUBLIC_ID, + AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash, + CommittedCandidateReceipt, CoreState, DisputeState, ExecutorParams, GroupRotationInfo, Hash, + Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce, + OccupiedCoreAssumption, PersistedValidationData, ScrapedOnChainVotes, SessionInfo, Signature, + ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, LOWEST_PUBLIC_ID, }; use sp_core::OpaqueMetadata; use sp_mmr_primitives as mmr; @@ -1822,6 +1822,10 @@ sp_api::impl_runtime_apis! { parachains_runtime_api_impl::session_info::(index) } + fn session_executor_params(session_index: SessionIndex) -> Option { + parachains_runtime_api_impl::session_executor_params::(session_index) + } + fn dmq_contents(recipient: ParaId) -> Vec> { parachains_runtime_api_impl::dmq_contents::(recipient) } @@ -1856,6 +1860,10 @@ sp_api::impl_runtime_apis! { { parachains_runtime_api_impl::validation_code_hash::(para_id, assumption) } + + fn disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState)> { + parachains_runtime_api_impl::get_session_disputes::() + } } impl beefy_primitives::BeefyApi for Runtime { diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 2ef53c585ecc..b6ed0a0660f0 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -23,8 +23,8 @@ use pallet_nis::WithMaximumOf; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use primitives::{ - vstaging::ExecutorParams, AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, - CandidateHash, CommittedCandidateReceipt, CoreState, DisputeState, GroupRotationInfo, Hash, + AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash, + CommittedCandidateReceipt, CoreState, DisputeState, ExecutorParams, GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce, OccupiedCoreAssumption, PersistedValidationData, ScrapedOnChainVotes, SessionInfo, Signature, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, @@ -38,15 +38,12 @@ use sp_std::{cmp::Ordering, collections::btree_map::BTreeMap, prelude::*}; use runtime_parachains::{ configuration as parachains_configuration, disputes as parachains_disputes, - disputes::slashing as parachains_slashing, - dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion, - initializer as parachains_initializer, origin as parachains_origin, paras as parachains_paras, + disputes::slashing as parachains_slashing, dmp as parachains_dmp, hrmp as parachains_hrmp, + inclusion as parachains_inclusion, initializer as parachains_initializer, + origin as parachains_origin, paras as parachains_paras, paras_inherent as parachains_paras_inherent, - runtime_api_impl::{ - v2 as parachains_runtime_api_impl, vstaging as parachains_runtime_api_impl_staging, - }, - scheduler as parachains_scheduler, session_info as parachains_session_info, - shared as parachains_shared, ump as parachains_ump, + runtime_api_impl::v4 as parachains_runtime_api_impl, scheduler as parachains_scheduler, + session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump, }; use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId; @@ -1625,7 +1622,6 @@ sp_api::impl_runtime_apis! { } } - #[api_version(4)] impl primitives::runtime_api::ParachainHost for Runtime { fn validators() -> Vec { parachains_runtime_api_impl::validators::() @@ -1690,7 +1686,7 @@ sp_api::impl_runtime_apis! { } fn session_executor_params(session_index: SessionIndex) -> Option { - parachains_runtime_api_impl_staging::session_executor_params::(session_index) + parachains_runtime_api_impl::session_executor_params::(session_index) } fn dmq_contents(recipient: ParaId) -> Vec> { @@ -1729,7 +1725,7 @@ sp_api::impl_runtime_apis! { } fn disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState)> { - runtime_parachains::runtime_api_impl::vstaging::get_session_disputes::() + parachains_runtime_api_impl::get_session_disputes::() } } diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index 2fdaa60513d3..4cdbbed04433 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -28,7 +28,7 @@ use polkadot_runtime_parachains::{ configuration as parachains_configuration, disputes as parachains_disputes, dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion, initializer as parachains_initializer, origin as parachains_origin, paras as parachains_paras, - paras_inherent as parachains_paras_inherent, runtime_api_impl::v2 as runtime_impl, + paras_inherent as parachains_paras_inherent, runtime_api_impl::v4 as runtime_impl, scheduler as parachains_scheduler, session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump, }; @@ -45,11 +45,12 @@ use pallet_session::historical as session_historical; use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo}; use polkadot_runtime_parachains::reward_points::RewardValidatorsWithEraPoints; use primitives::{ - AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CommittedCandidateReceipt, - CoreState, GroupRotationInfo, Hash as HashT, Id as ParaId, InboundDownwardMessage, - InboundHrmpMessage, Moment, Nonce, OccupiedCoreAssumption, PersistedValidationData, - ScrapedOnChainVotes, SessionInfo as SessionInfoData, Signature, ValidationCode, - ValidationCodeHash, ValidatorId, ValidatorIndex, + AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash, + CommittedCandidateReceipt, CoreState, DisputeState, ExecutorParams, GroupRotationInfo, + Hash as HashT, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce, + OccupiedCoreAssumption, PersistedValidationData, ScrapedOnChainVotes, + SessionInfo as SessionInfoData, Signature, ValidationCode, ValidationCodeHash, ValidatorId, + ValidatorIndex, }; use runtime_common::{ claims, impl_runtime_weights, paras_sudo_wrapper, BlockHashCount, BlockLength, @@ -837,6 +838,10 @@ sp_api::impl_runtime_apis! { runtime_impl::session_info::(index) } + fn session_executor_params(session_index: SessionIndex) -> Option { + runtime_impl::session_executor_params::(session_index) + } + fn dmq_contents( recipient: ParaId, ) -> Vec> { @@ -873,6 +878,10 @@ sp_api::impl_runtime_apis! { { runtime_impl::validation_code_hash::(para_id, assumption) } + + fn disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState)> { + runtime_impl::get_session_disputes::() + } } impl beefy_primitives::BeefyApi for Runtime { diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 6005bc6893e6..2c06753f7c30 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -36,8 +36,8 @@ use pallet_session::historical as session_historical; use pallet_transaction_payment::{CurrencyAdapter, FeeDetails, RuntimeDispatchInfo}; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use primitives::{ - vstaging::ExecutorParams, AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, - CandidateHash, CommittedCandidateReceipt, CoreState, DisputeState, GroupRotationInfo, Hash, + AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash, + CommittedCandidateReceipt, CoreState, DisputeState, ExecutorParams, GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce, OccupiedCoreAssumption, PersistedValidationData, PvfCheckStatement, ScrapedOnChainVotes, SessionInfo, Signature, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, @@ -50,15 +50,12 @@ use runtime_common::{ }; use runtime_parachains::{ configuration as parachains_configuration, disputes as parachains_disputes, - disputes::slashing as parachains_slashing, - dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion, - initializer as parachains_initializer, origin as parachains_origin, paras as parachains_paras, + disputes::slashing as parachains_slashing, dmp as parachains_dmp, hrmp as parachains_hrmp, + inclusion as parachains_inclusion, initializer as parachains_initializer, + origin as parachains_origin, paras as parachains_paras, paras_inherent as parachains_paras_inherent, reward_points as parachains_reward_points, - runtime_api_impl::{ - v2 as parachains_runtime_api_impl, vstaging as parachains_runtime_api_impl_staging, - }, - scheduler as parachains_scheduler, session_info as parachains_session_info, - shared as parachains_shared, ump as parachains_ump, + runtime_api_impl::v4 as parachains_runtime_api_impl, scheduler as parachains_scheduler, + session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump, }; use scale_info::TypeInfo; use sp_core::{OpaqueMetadata, RuntimeDebug}; @@ -1341,7 +1338,6 @@ sp_api::impl_runtime_apis! { } } - #[api_version(4)] impl primitives::runtime_api::ParachainHost for Runtime { fn validators() -> Vec { parachains_runtime_api_impl::validators::() @@ -1406,7 +1402,7 @@ sp_api::impl_runtime_apis! { } fn session_executor_params(session_index: SessionIndex) -> Option { - parachains_runtime_api_impl_staging::session_executor_params::(session_index) + parachains_runtime_api_impl::session_executor_params::(session_index) } fn dmq_contents(recipient: ParaId) -> Vec> { @@ -1445,7 +1441,7 @@ sp_api::impl_runtime_apis! { } fn disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState)> { - runtime_parachains::runtime_api_impl::vstaging::get_session_disputes::() + parachains_runtime_api_impl::get_session_disputes::() } }