Release parachain host API v4 (#6885)

This commit is contained in:
s0me0ne-unkn0wn
2023-03-15 18:06:18 +01:00
committed by GitHub
parent a715a33ab9
commit 27c9124411
30 changed files with 129 additions and 120 deletions
@@ -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;
@@ -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
<paras::Pallet<T>>::current_code_hash(&para_id)
})
}
/// Implementation for `get_session_disputes` function from the runtime API
pub fn get_session_disputes<T: disputes::Config>(
) -> Vec<(SessionIndex, CandidateHash, DisputeState<T::BlockNumber>)> {
<disputes::Pallet<T>>::disputes()
}
/// Get session executor parameter set
pub fn session_executor_params<T: session_info::Config>(
session_index: SessionIndex,
) -> Option<ExecutorParams> {
// 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_info::Pallet<T>>::session_executor_params(session_index) call.
match <session_info::Pallet<T>>::session_executor_params(session_index) {
Some(ep) => Some(ep),
None => Some(ExecutorParams::default()),
}
}
@@ -15,28 +15,3 @@
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
//! 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<T: disputes::Config>(
) -> Vec<(SessionIndex, CandidateHash, DisputeState<T::BlockNumber>)> {
<disputes::Pallet<T>>::disputes()
}
/// Get session executor parameter set
pub fn session_executor_params<T: session_info::Config>(
session_index: SessionIndex,
) -> Option<ExecutorParams> {
// 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_info::Pallet<T>>::session_executor_params(session_index) call.
match <session_info::Pallet<T>>::session_executor_params(session_index) {
Some(ep) => Some(ep),
None => Some(ExecutorParams::default()),
}
}
@@ -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;