Move vstaging to production (#7341)

* Move vstaging to production (and thus past session slashing).

WIP: test-runtime still needs to be fixed.

* Fix test-runtime.

---------

Co-authored-by: eskimor <eskimor@no-such-url.com>
This commit is contained in:
eskimor
2023-06-12 13:15:37 +02:00
committed by GitHub
parent d90173e438
commit 4527f24735
21 changed files with 236 additions and 122 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 v4;
pub mod v5;
pub mod vstaging;
@@ -11,7 +11,7 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//! A module exporting runtime API implementation functions for all runtime APIs using v2
//! A module exporting runtime API implementation functions for all runtime APIs using v5
//! primitives.
//!
//! Runtimes implementing the v2 runtime API are recommended to forward directly to these
@@ -22,12 +22,12 @@ use crate::{
session_info, shared,
};
use primitives::{
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,
slashing, 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::*};
@@ -425,3 +425,22 @@ pub fn session_executor_params<T: session_info::Config>(
None => Some(ExecutorParams::default()),
}
}
/// Implementation of `unapplied_slashes` runtime API
pub fn unapplied_slashes<T: disputes::slashing::Config>(
) -> Vec<(SessionIndex, CandidateHash, slashing::PendingSlashes)> {
<disputes::slashing::Pallet<T>>::unapplied_slashes()
}
/// Implementation of `submit_report_dispute_lost` runtime API
pub fn submit_unsigned_slashing_report<T: disputes::slashing::Config>(
dispute_proof: slashing::DisputeProof,
key_ownership_proof: slashing::OpaqueKeyOwnershipProof,
) -> Option<()> {
let key_ownership_proof = key_ownership_proof.decode()?;
<disputes::slashing::Pallet<T>>::submit_unsigned_slashing_report(
dispute_proof,
key_ownership_proof,
)
}
@@ -15,32 +15,3 @@
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
//! Put implementations of functions from staging APIs here.
use crate::disputes;
use primitives::{vstaging, 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()
}
/// Implementation of `unapplied_slashes` runtime API
pub fn unapplied_slashes<T: disputes::slashing::Config>(
) -> Vec<(SessionIndex, CandidateHash, vstaging::slashing::PendingSlashes)> {
<disputes::slashing::Pallet<T>>::unapplied_slashes()
}
/// Implementation of `submit_report_dispute_lost` runtime API
pub fn submit_unsigned_slashing_report<T: disputes::slashing::Config>(
dispute_proof: vstaging::slashing::DisputeProof,
key_ownership_proof: vstaging::slashing::OpaqueKeyOwnershipProof,
) -> Option<()> {
let key_ownership_proof = key_ownership_proof.decode()?;
<disputes::slashing::Pallet<T>>::submit_unsigned_slashing_report(
dispute_proof,
key_ownership_proof,
)
}