mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 18:37:59 +00:00
runtime: past session slashing runtime API (#6667)
* runtime/vstaging: unapplied_slashes runtime API * runtime/vstaging: key_ownership_proof runtime API * runtime/ParachainHost: submit_report_dispute_lost * fix key_ownership_proof API * runtime: submit_report_dispute_lost runtime API * nits * Update node/subsystem-types/src/messages.rs Co-authored-by: Marcin S. <marcin@bytedude.com> * revert unrelated fmt changes * post merge fixes * fix compilation --------- Co-authored-by: Marcin S. <marcin@bytedude.com>
This commit is contained in:
@@ -39,7 +39,7 @@ use polkadot_node_primitives::{
|
||||
SignedDisputeStatement, SignedFullStatement, ValidationResult,
|
||||
};
|
||||
use polkadot_primitives::{
|
||||
AuthorityDiscoveryId, BackedCandidate, BlockNumber, CandidateEvent, CandidateHash,
|
||||
vstaging, AuthorityDiscoveryId, BackedCandidate, BlockNumber, CandidateEvent, CandidateHash,
|
||||
CandidateIndex, CandidateReceipt, CollatorId, CommittedCandidateReceipt, CoreState,
|
||||
DisputeState, ExecutorParams, GroupIndex, GroupRotationInfo, Hash, Header as BlockHeader,
|
||||
Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, MultiDisputeStatementSet,
|
||||
@@ -606,6 +606,24 @@ pub enum RuntimeApiRequest {
|
||||
),
|
||||
/// Returns all on-chain disputes at given block number. Available in `v3`.
|
||||
Disputes(RuntimeApiSender<Vec<(SessionIndex, CandidateHash, DisputeState<BlockNumber>)>>),
|
||||
/// Returns a list of validators that lost a past session dispute and need to be slashed.
|
||||
/// `VStaging`
|
||||
UnappliedSlashes(
|
||||
RuntimeApiSender<Vec<(SessionIndex, CandidateHash, vstaging::slashing::PendingSlashes)>>,
|
||||
),
|
||||
/// Returns a merkle proof of a validator session key.
|
||||
/// `VStaging`
|
||||
KeyOwnershipProof(
|
||||
ValidatorId,
|
||||
RuntimeApiSender<Option<vstaging::slashing::OpaqueKeyOwnershipProof>>,
|
||||
),
|
||||
/// Submits an unsigned extrinsic to slash validator who lost a past session dispute.
|
||||
/// `VStaging`
|
||||
SubmitReportDisputeLost(
|
||||
vstaging::slashing::DisputeProof,
|
||||
vstaging::slashing::OpaqueKeyOwnershipProof,
|
||||
RuntimeApiSender<Option<()>>,
|
||||
),
|
||||
}
|
||||
|
||||
impl RuntimeApiRequest {
|
||||
@@ -614,8 +632,17 @@ impl RuntimeApiRequest {
|
||||
/// `Disputes`
|
||||
pub const DISPUTES_RUNTIME_REQUIREMENT: u32 = 3;
|
||||
|
||||
/// `UnappliedSlashes`
|
||||
pub const UNAPPLIED_SLASHES_RUNTIME_REQUIREMENT: u32 = 4;
|
||||
|
||||
/// `ExecutorParams`
|
||||
pub const EXECUTOR_PARAMS_RUNTIME_REQUIREMENT: u32 = 4;
|
||||
|
||||
/// `KeyOwnershipProof`
|
||||
pub const KEY_OWNERSHIP_PROOF_RUNTIME_REQUIREMENT: u32 = 4;
|
||||
|
||||
/// `SubmitReportDisputeLost`
|
||||
pub const SUBMIT_REPORT_DISPUTE_LOST_RUNTIME_REQUIREMENT: u32 = 4;
|
||||
}
|
||||
|
||||
/// A message to the Runtime API subsystem.
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
use async_trait::async_trait;
|
||||
use polkadot_primitives::{
|
||||
runtime_api::ParachainHost, Block, BlockNumber, CandidateCommitments, CandidateEvent,
|
||||
runtime_api::ParachainHost, vstaging, Block, BlockNumber, CandidateCommitments, CandidateEvent,
|
||||
CandidateHash, CommittedCandidateReceipt, CoreState, DisputeState, ExecutorParams,
|
||||
GroupRotationInfo, Hash, Id, InboundDownwardMessage, InboundHrmpMessage,
|
||||
OccupiedCoreAssumption, PersistedValidationData, PvfCheckStatement, ScrapedOnChainVotes,
|
||||
@@ -182,6 +182,34 @@ pub trait RuntimeApiSubsystemClient {
|
||||
at: Hash,
|
||||
) -> Result<Vec<(SessionIndex, CandidateHash, DisputeState<BlockNumber>)>, ApiError>;
|
||||
|
||||
/// Returns a list of validators that lost a past session dispute and need to be slashed.
|
||||
///
|
||||
/// WARNING: This is a staging method! Do not use on production runtimes!
|
||||
async fn unapplied_slashes(
|
||||
&self,
|
||||
at: Hash,
|
||||
) -> Result<Vec<(SessionIndex, CandidateHash, vstaging::slashing::PendingSlashes)>, ApiError>;
|
||||
|
||||
/// Returns a merkle proof of a validator session key in a past session.
|
||||
///
|
||||
/// WARNING: This is a staging method! Do not use on production runtimes!
|
||||
async fn key_ownership_proof(
|
||||
&self,
|
||||
at: Hash,
|
||||
validator_id: ValidatorId,
|
||||
) -> Result<Option<vstaging::slashing::OpaqueKeyOwnershipProof>, ApiError>;
|
||||
|
||||
/// Submits an unsigned extrinsic to slash validators who lost a dispute about
|
||||
/// a candidate of a past session.
|
||||
///
|
||||
/// WARNING: This is a staging method! Do not use on production runtimes!
|
||||
async fn submit_report_dispute_lost(
|
||||
&self,
|
||||
at: Hash,
|
||||
dispute_proof: vstaging::slashing::DisputeProof,
|
||||
key_ownership_proof: vstaging::slashing::OpaqueKeyOwnershipProof,
|
||||
) -> Result<Option<()>, ApiError>;
|
||||
|
||||
/// Get the execution environment parameter set by parent hash, if stored
|
||||
async fn session_executor_params(
|
||||
&self,
|
||||
@@ -374,4 +402,29 @@ where
|
||||
) -> Result<Vec<(SessionIndex, CandidateHash, DisputeState<BlockNumber>)>, ApiError> {
|
||||
self.runtime_api().disputes(at)
|
||||
}
|
||||
|
||||
async fn unapplied_slashes(
|
||||
&self,
|
||||
at: Hash,
|
||||
) -> Result<Vec<(SessionIndex, CandidateHash, vstaging::slashing::PendingSlashes)>, ApiError> {
|
||||
self.runtime_api().unapplied_slashes(at)
|
||||
}
|
||||
|
||||
async fn key_ownership_proof(
|
||||
&self,
|
||||
at: Hash,
|
||||
validator_id: ValidatorId,
|
||||
) -> Result<Option<vstaging::slashing::OpaqueKeyOwnershipProof>, ApiError> {
|
||||
self.runtime_api().key_ownership_proof(at, validator_id)
|
||||
}
|
||||
|
||||
async fn submit_report_dispute_lost(
|
||||
&self,
|
||||
at: Hash,
|
||||
dispute_proof: vstaging::slashing::DisputeProof,
|
||||
key_ownership_proof: vstaging::slashing::OpaqueKeyOwnershipProof,
|
||||
) -> Result<Option<()>, ApiError> {
|
||||
self.runtime_api()
|
||||
.submit_report_dispute_lost(at, dispute_proof, key_ownership_proof)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user