mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 19:01:08 +00:00
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:
@@ -37,10 +37,10 @@ use polkadot_node_subsystem::{
|
||||
ApprovalVotingMessage, BlockDescription, ChainSelectionMessage, DisputeCoordinatorMessage,
|
||||
DisputeDistributionMessage, ImportStatementsResult,
|
||||
},
|
||||
overseer, ActivatedLeaf, ActiveLeavesUpdate, FromOrchestra, OverseerSignal,
|
||||
overseer, ActivatedLeaf, ActiveLeavesUpdate, FromOrchestra, OverseerSignal, RuntimeApiError,
|
||||
};
|
||||
use polkadot_node_subsystem_util::runtime::{
|
||||
key_ownership_proof, submit_report_dispute_lost, RuntimeInfo,
|
||||
self, key_ownership_proof, submit_report_dispute_lost, RuntimeInfo,
|
||||
};
|
||||
use polkadot_primitives::{
|
||||
vstaging, BlockNumber, CandidateHash, CandidateReceipt, CompactStatement, DisputeStatement,
|
||||
@@ -424,8 +424,19 @@ impl Initialized {
|
||||
dispute_proofs.push(dispute_proof);
|
||||
},
|
||||
Ok(None) => {},
|
||||
Err(error) => {
|
||||
Err(runtime::Error::RuntimeRequest(RuntimeApiError::NotSupported {
|
||||
..
|
||||
})) => {
|
||||
gum::debug!(
|
||||
target: LOG_TARGET,
|
||||
?session_index,
|
||||
?candidate_hash,
|
||||
?validator_id,
|
||||
"Key ownership proof not yet supported.",
|
||||
);
|
||||
},
|
||||
Err(error) => {
|
||||
gum::warn!(
|
||||
target: LOG_TARGET,
|
||||
?error,
|
||||
?session_index,
|
||||
@@ -480,6 +491,16 @@ impl Initialized {
|
||||
.await;
|
||||
|
||||
match res {
|
||||
Err(runtime::Error::RuntimeRequest(RuntimeApiError::NotSupported {
|
||||
..
|
||||
})) => {
|
||||
gum::debug!(
|
||||
target: LOG_TARGET,
|
||||
?session_index,
|
||||
?candidate_hash,
|
||||
"Reporting pending slash not yet supported",
|
||||
);
|
||||
},
|
||||
Err(error) => {
|
||||
gum::warn!(
|
||||
target: LOG_TARGET,
|
||||
|
||||
@@ -25,13 +25,13 @@ use lru::LruCache;
|
||||
use polkadot_node_primitives::{DISPUTE_CANDIDATE_LIFETIME_AFTER_FINALIZATION, MAX_FINALITY_LAG};
|
||||
use polkadot_node_subsystem::{
|
||||
messages::ChainApiMessage, overseer, ActivatedLeaf, ActiveLeavesUpdate, ChainApiError,
|
||||
SubsystemSender,
|
||||
RuntimeApiError, SubsystemSender,
|
||||
};
|
||||
use polkadot_node_subsystem_util::runtime::{
|
||||
get_candidate_events, get_on_chain_votes, get_unapplied_slashes,
|
||||
self, get_candidate_events, get_on_chain_votes, get_unapplied_slashes,
|
||||
};
|
||||
use polkadot_primitives::{
|
||||
vstaging, BlockNumber, CandidateEvent, CandidateHash, CandidateReceipt, Hash,
|
||||
slashing::PendingSlashes, BlockNumber, CandidateEvent, CandidateHash, CandidateReceipt, Hash,
|
||||
ScrapedOnChainVotes, SessionIndex,
|
||||
};
|
||||
|
||||
@@ -67,7 +67,7 @@ const LRU_OBSERVED_BLOCKS_CAPACITY: NonZeroUsize = match NonZeroUsize::new(20) {
|
||||
pub struct ScrapedUpdates {
|
||||
pub on_chain_votes: Vec<ScrapedOnChainVotes>,
|
||||
pub included_receipts: Vec<CandidateReceipt>,
|
||||
pub unapplied_slashes: Vec<(SessionIndex, CandidateHash, vstaging::slashing::PendingSlashes)>,
|
||||
pub unapplied_slashes: Vec<(SessionIndex, CandidateHash, PendingSlashes)>,
|
||||
}
|
||||
|
||||
impl ScrapedUpdates {
|
||||
@@ -270,8 +270,15 @@ impl ChainScraper {
|
||||
Ok(unapplied_slashes) => {
|
||||
scraped_updates.unapplied_slashes = unapplied_slashes;
|
||||
},
|
||||
Err(error) => {
|
||||
Err(runtime::Error::RuntimeRequest(RuntimeApiError::NotSupported { .. })) => {
|
||||
gum::debug!(
|
||||
target: LOG_TARGET,
|
||||
block_hash = ?activated.hash,
|
||||
"Fetching unapplied slashes not yet supported.",
|
||||
);
|
||||
},
|
||||
Err(error) => {
|
||||
gum::warn!(
|
||||
target: LOG_TARGET,
|
||||
block_hash = ?activated.hash,
|
||||
?error,
|
||||
|
||||
@@ -39,7 +39,7 @@ use polkadot_node_primitives::{
|
||||
SignedDisputeStatement, SignedFullStatement, ValidationResult,
|
||||
};
|
||||
use polkadot_primitives::{
|
||||
vstaging, AuthorityDiscoveryId, BackedCandidate, BlockNumber, CandidateEvent, CandidateHash,
|
||||
slashing, AuthorityDiscoveryId, BackedCandidate, BlockNumber, CandidateEvent, CandidateHash,
|
||||
CandidateIndex, CandidateReceipt, CollatorId, CommittedCandidateReceipt, CoreState,
|
||||
DisputeState, ExecutorParams, GroupIndex, GroupRotationInfo, Hash, Header as BlockHeader,
|
||||
Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, MultiDisputeStatementSet,
|
||||
@@ -607,21 +607,18 @@ 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`
|
||||
/// `V5`
|
||||
UnappliedSlashes(
|
||||
RuntimeApiSender<Vec<(SessionIndex, CandidateHash, vstaging::slashing::PendingSlashes)>>,
|
||||
RuntimeApiSender<Vec<(SessionIndex, CandidateHash, slashing::PendingSlashes)>>,
|
||||
),
|
||||
/// Returns a merkle proof of a validator session key.
|
||||
/// `VStaging`
|
||||
KeyOwnershipProof(
|
||||
ValidatorId,
|
||||
RuntimeApiSender<Option<vstaging::slashing::OpaqueKeyOwnershipProof>>,
|
||||
),
|
||||
/// `V5`
|
||||
KeyOwnershipProof(ValidatorId, RuntimeApiSender<Option<slashing::OpaqueKeyOwnershipProof>>),
|
||||
/// Submits an unsigned extrinsic to slash validator who lost a past session dispute.
|
||||
/// `VStaging`
|
||||
/// `V5`
|
||||
SubmitReportDisputeLost(
|
||||
vstaging::slashing::DisputeProof,
|
||||
vstaging::slashing::OpaqueKeyOwnershipProof,
|
||||
slashing::DisputeProof,
|
||||
slashing::OpaqueKeyOwnershipProof,
|
||||
RuntimeApiSender<Option<()>>,
|
||||
),
|
||||
}
|
||||
@@ -632,17 +629,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;
|
||||
|
||||
/// `UnappliedSlashes`
|
||||
pub const UNAPPLIED_SLASHES_RUNTIME_REQUIREMENT: u32 = 5;
|
||||
|
||||
/// `KeyOwnershipProof`
|
||||
pub const KEY_OWNERSHIP_PROOF_RUNTIME_REQUIREMENT: u32 = 4;
|
||||
pub const KEY_OWNERSHIP_PROOF_RUNTIME_REQUIREMENT: u32 = 5;
|
||||
|
||||
/// `SubmitReportDisputeLost`
|
||||
pub const SUBMIT_REPORT_DISPUTE_LOST_RUNTIME_REQUIREMENT: u32 = 4;
|
||||
pub const SUBMIT_REPORT_DISPUTE_LOST_RUNTIME_REQUIREMENT: u32 = 5;
|
||||
}
|
||||
|
||||
/// A message to the Runtime API subsystem.
|
||||
|
||||
@@ -29,7 +29,7 @@ use polkadot_node_subsystem::{
|
||||
messages::{RuntimeApiMessage, RuntimeApiRequest, RuntimeApiSender},
|
||||
overseer, SubsystemSender,
|
||||
};
|
||||
use polkadot_primitives::ExecutorParams;
|
||||
use polkadot_primitives::{slashing, ExecutorParams};
|
||||
|
||||
pub use overseer::{
|
||||
gen::{OrchestraError as OverseerError, Timeout},
|
||||
@@ -42,8 +42,8 @@ use futures::channel::{mpsc, oneshot};
|
||||
use parity_scale_codec::Encode;
|
||||
|
||||
use polkadot_primitives::{
|
||||
vstaging, AuthorityDiscoveryId, CandidateEvent, CandidateHash, CommittedCandidateReceipt,
|
||||
CoreState, EncodeAs, GroupIndex, GroupRotationInfo, Hash, Id as ParaId, OccupiedCoreAssumption,
|
||||
AuthorityDiscoveryId, CandidateEvent, CandidateHash, CommittedCandidateReceipt, CoreState,
|
||||
EncodeAs, GroupIndex, GroupRotationInfo, Hash, Id as ParaId, OccupiedCoreAssumption,
|
||||
PersistedValidationData, ScrapedOnChainVotes, SessionIndex, SessionInfo, Signed,
|
||||
SigningContext, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex,
|
||||
ValidatorSignature,
|
||||
@@ -212,9 +212,9 @@ specialize_requests! {
|
||||
-> Option<ValidationCodeHash>; ValidationCodeHash;
|
||||
fn request_on_chain_votes() -> Option<ScrapedOnChainVotes>; FetchOnChainVotes;
|
||||
fn request_session_executor_params(session_index: SessionIndex) -> Option<ExecutorParams>;SessionExecutorParams;
|
||||
fn request_unapplied_slashes() -> Vec<(SessionIndex, CandidateHash, vstaging::slashing::PendingSlashes)>; UnappliedSlashes;
|
||||
fn request_key_ownership_proof(validator_id: ValidatorId) -> Option<vstaging::slashing::OpaqueKeyOwnershipProof>; KeyOwnershipProof;
|
||||
fn request_submit_report_dispute_lost(dp: vstaging::slashing::DisputeProof, okop: vstaging::slashing::OpaqueKeyOwnershipProof) -> Option<()>; SubmitReportDisputeLost;
|
||||
fn request_unapplied_slashes() -> Vec<(SessionIndex, CandidateHash, slashing::PendingSlashes)>; UnappliedSlashes;
|
||||
fn request_key_ownership_proof(validator_id: ValidatorId) -> Option<slashing::OpaqueKeyOwnershipProof>; KeyOwnershipProof;
|
||||
fn request_submit_report_dispute_lost(dp: slashing::DisputeProof, okop: slashing::OpaqueKeyOwnershipProof) -> Option<()>; SubmitReportDisputeLost;
|
||||
}
|
||||
|
||||
/// Requests executor parameters from the runtime effective at given relay-parent. First obtains
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
#![warn(missing_docs)]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
// `v4` is currently the latest stable version of the runtime API.
|
||||
pub mod v4;
|
||||
// `v5` is currently the latest stable version of the runtime API.
|
||||
pub mod v5;
|
||||
|
||||
// The 'staging' version is special - it contains primitives which are
|
||||
// still in development. Once they are considered stable, they will be
|
||||
@@ -33,18 +33,18 @@ 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 v4::{
|
||||
pub use v5::{
|
||||
byzantine_threshold, check_candidate_backing, collator_signature_payload, metric_definitions,
|
||||
supermajority_threshold, well_known_keys, AbridgedHostConfiguration, AbridgedHrmpChannel,
|
||||
AccountId, AccountIndex, AccountPublic, ApprovalVote, AssignmentId, AuthorityDiscoveryId,
|
||||
AvailabilityBitfield, BackedCandidate, Balance, BlakeTwo256, Block, BlockId, BlockNumber,
|
||||
CandidateCommitments, CandidateDescriptor, CandidateEvent, CandidateHash, CandidateIndex,
|
||||
CandidateReceipt, CheckedDisputeStatementSet, CheckedMultiDisputeStatementSet, CollatorId,
|
||||
CollatorSignature, CommittedCandidateReceipt, CompactStatement, ConsensusLog, CoreIndex,
|
||||
CoreOccupied, CoreState, DisputeState, DisputeStatement, DisputeStatementSet, DownwardMessage,
|
||||
EncodeAs, ExecutorParam, ExecutorParams, ExecutorParamsHash, ExplicitDisputeStatement,
|
||||
GroupIndex, GroupRotationInfo, Hash, HashT, HeadData, Header, HrmpChannelId, Id,
|
||||
InboundDownwardMessage, InboundHrmpMessage, IndexedVec, InherentData,
|
||||
slashing, supermajority_threshold, well_known_keys, AbridgedHostConfiguration,
|
||||
AbridgedHrmpChannel, AccountId, AccountIndex, AccountPublic, ApprovalVote, AssignmentId,
|
||||
AuthorityDiscoveryId, AvailabilityBitfield, BackedCandidate, Balance, BlakeTwo256, Block,
|
||||
BlockId, BlockNumber, CandidateCommitments, CandidateDescriptor, CandidateEvent, CandidateHash,
|
||||
CandidateIndex, CandidateReceipt, CheckedDisputeStatementSet, CheckedMultiDisputeStatementSet,
|
||||
CollatorId, CollatorSignature, CommittedCandidateReceipt, CompactStatement, ConsensusLog,
|
||||
CoreIndex, CoreOccupied, CoreState, DisputeState, DisputeStatement, DisputeStatementSet,
|
||||
DownwardMessage, 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,
|
||||
@@ -60,4 +60,4 @@ pub use v4::{
|
||||
};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub use v4::{AssignmentPair, CollatorPair, ValidatorPair};
|
||||
pub use v5::{AssignmentPair, CollatorPair, ValidatorPair};
|
||||
|
||||
@@ -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(4)]
|
||||
#[api_version(5)]
|
||||
pub trait ParachainHost<H: Encode + Decode = pcp::v2::Hash, N: Encode + Decode = pcp::v2::BlockNumber> {
|
||||
/// Get the current validators.
|
||||
fn validators() -> Vec<ValidatorId>;
|
||||
@@ -220,18 +220,18 @@ sp_api::decl_runtime_apis! {
|
||||
fn session_executor_params(session_index: SessionIndex) -> Option<ExecutorParams>;
|
||||
|
||||
/// Returns a list of validators that lost a past session dispute and need to be slashed.
|
||||
#[api_version(5)]
|
||||
/// NOTE: This function is only available since parachain host version 5.
|
||||
fn unapplied_slashes() -> Vec<(SessionIndex, CandidateHash, vstaging::slashing::PendingSlashes)>;
|
||||
|
||||
/// Returns a merkle proof of a validator session key.
|
||||
#[api_version(5)]
|
||||
/// NOTE: This function is only available since parachain host version 5.
|
||||
fn key_ownership_proof(
|
||||
validator_id: ValidatorId,
|
||||
) -> Option<vstaging::slashing::OpaqueKeyOwnershipProof>;
|
||||
|
||||
/// Submit an unsigned extrinsic to slash validators who lost a dispute about
|
||||
/// a candidate of a past session.
|
||||
#[api_version(5)]
|
||||
/// NOTE: This function is only available since parachain host version 5.
|
||||
fn submit_report_dispute_lost(
|
||||
dispute_proof: vstaging::slashing::DisputeProof,
|
||||
key_ownership_proof: vstaging::slashing::OpaqueKeyOwnershipProof,
|
||||
|
||||
@@ -57,6 +57,8 @@ pub use sp_staking::SessionIndex;
|
||||
mod signed;
|
||||
pub use signed::{EncodeAs, Signed, UncheckedSigned};
|
||||
|
||||
pub mod slashing;
|
||||
|
||||
mod metrics;
|
||||
pub use metrics::{
|
||||
metric_definitions, RuntimeMetricLabel, RuntimeMetricLabelValue, RuntimeMetricLabelValues,
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
|
||||
//! Primitives types used for dispute slashing.
|
||||
|
||||
use crate::v4::{CandidateHash, SessionIndex, ValidatorId, ValidatorIndex};
|
||||
use crate::{CandidateHash, SessionIndex, ValidatorId, ValidatorIndex};
|
||||
use parity_scale_codec::{Decode, Encode};
|
||||
use scale_info::TypeInfo;
|
||||
use sp_std::{collections::btree_map::BTreeMap, vec::Vec};
|
||||
@@ -17,8 +17,7 @@
|
||||
//! Staging Primitives.
|
||||
|
||||
// Put any primitives used by staging APIs functions here
|
||||
pub use crate::v4::*;
|
||||
pub mod slashing;
|
||||
pub use crate::v5::*;
|
||||
use sp_std::prelude::*;
|
||||
|
||||
use parity_scale_codec::{Decode, Encode};
|
||||
@@ -37,6 +36,7 @@ use scale_info::TypeInfo;
|
||||
serde::Serialize,
|
||||
serde::Deserialize,
|
||||
)]
|
||||
|
||||
pub struct AsyncBackingParams {
|
||||
/// The maximum number of para blocks between the para head in a relay parent
|
||||
/// and a new candidate. Restricts nodes from building arbitrary long chains
|
||||
|
||||
@@ -23,11 +23,12 @@
|
||||
use pallet_nis::WithMaximumOf;
|
||||
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
|
||||
use primitives::{
|
||||
AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash,
|
||||
slashing, 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,
|
||||
PARACHAIN_KEY_TYPE_ID,
|
||||
};
|
||||
use runtime_common::{
|
||||
auctions, claims, crowdloan, impl_runtime_weights, impls::DealWithFees, paras_registrar,
|
||||
@@ -44,7 +45,7 @@ use runtime_parachains::{
|
||||
inclusion::{AggregateMessageOrigin, UmpQueueId},
|
||||
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::v4 as parachains_runtime_api_impl,
|
||||
runtime_api_impl::v5 as parachains_runtime_api_impl,
|
||||
scheduler as parachains_scheduler, session_info as parachains_session_info,
|
||||
shared as parachains_shared,
|
||||
};
|
||||
@@ -1822,6 +1823,31 @@ sp_api::impl_runtime_apis! {
|
||||
fn disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState<BlockNumber>)> {
|
||||
parachains_runtime_api_impl::get_session_disputes::<Runtime>()
|
||||
}
|
||||
|
||||
fn unapplied_slashes(
|
||||
) -> Vec<(SessionIndex, CandidateHash, slashing::PendingSlashes)> {
|
||||
parachains_runtime_api_impl::unapplied_slashes::<Runtime>()
|
||||
}
|
||||
|
||||
fn key_ownership_proof(
|
||||
validator_id: ValidatorId,
|
||||
) -> Option<slashing::OpaqueKeyOwnershipProof> {
|
||||
use parity_scale_codec::Encode;
|
||||
|
||||
Historical::prove((PARACHAIN_KEY_TYPE_ID, validator_id))
|
||||
.map(|p| p.encode())
|
||||
.map(slashing::OpaqueKeyOwnershipProof::new)
|
||||
}
|
||||
|
||||
fn submit_report_dispute_lost(
|
||||
dispute_proof: slashing::DisputeProof,
|
||||
key_ownership_proof: slashing::OpaqueKeyOwnershipProof,
|
||||
) -> Option<()> {
|
||||
parachains_runtime_api_impl::submit_unsigned_slashing_report::<Runtime>(
|
||||
dispute_proof,
|
||||
key_ownership_proof,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl beefy_primitives::BeefyApi<Block> for Runtime {
|
||||
|
||||
@@ -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;
|
||||
|
||||
+26
-7
@@ -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,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ use frame_support::{
|
||||
traits::{EnqueueMessage, ExecuteOverweightError, ServiceQueues},
|
||||
weights::Weight,
|
||||
};
|
||||
use primitives::v4::{well_known_keys, Id as ParaId, UpwardMessage};
|
||||
use primitives::{well_known_keys, Id as ParaId, UpwardMessage};
|
||||
use sp_core::twox_64;
|
||||
use sp_io::hashing::blake2_256;
|
||||
use sp_runtime::traits::Bounded;
|
||||
|
||||
@@ -33,7 +33,7 @@ use runtime_parachains::{
|
||||
inclusion::{AggregateMessageOrigin, UmpQueueId},
|
||||
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::v4 as parachains_runtime_api_impl,
|
||||
runtime_api_impl::v5 as parachains_runtime_api_impl,
|
||||
scheduler as parachains_scheduler, session_info as parachains_session_info,
|
||||
shared as parachains_shared,
|
||||
};
|
||||
@@ -57,11 +57,12 @@ 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, CandidateHash,
|
||||
slashing, 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,
|
||||
PARACHAIN_KEY_TYPE_ID,
|
||||
};
|
||||
use sp_core::OpaqueMetadata;
|
||||
use sp_mmr_primitives as mmr;
|
||||
@@ -1835,6 +1836,31 @@ sp_api::impl_runtime_apis! {
|
||||
fn disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState<BlockNumber>)> {
|
||||
parachains_runtime_api_impl::get_session_disputes::<Runtime>()
|
||||
}
|
||||
|
||||
fn unapplied_slashes(
|
||||
) -> Vec<(SessionIndex, CandidateHash, slashing::PendingSlashes)> {
|
||||
parachains_runtime_api_impl::unapplied_slashes::<Runtime>()
|
||||
}
|
||||
|
||||
fn key_ownership_proof(
|
||||
validator_id: ValidatorId,
|
||||
) -> Option<slashing::OpaqueKeyOwnershipProof> {
|
||||
use parity_scale_codec::Encode;
|
||||
|
||||
Historical::prove((PARACHAIN_KEY_TYPE_ID, validator_id))
|
||||
.map(|p| p.encode())
|
||||
.map(slashing::OpaqueKeyOwnershipProof::new)
|
||||
}
|
||||
|
||||
fn submit_report_dispute_lost(
|
||||
dispute_proof: slashing::DisputeProof,
|
||||
key_ownership_proof: slashing::OpaqueKeyOwnershipProof,
|
||||
) -> Option<()> {
|
||||
parachains_runtime_api_impl::submit_unsigned_slashing_report::<Runtime>(
|
||||
dispute_proof,
|
||||
key_ownership_proof,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl beefy_primitives::BeefyApi<Block> for Runtime {
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
use pallet_nis::WithMaximumOf;
|
||||
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
|
||||
use primitives::{
|
||||
vstaging, AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash,
|
||||
slashing, AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash,
|
||||
CommittedCandidateReceipt, CoreState, DisputeState, ExecutorParams, GroupRotationInfo, Hash,
|
||||
Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce,
|
||||
OccupiedCoreAssumption, PersistedValidationData, ScrapedOnChainVotes, SessionInfo, Signature,
|
||||
@@ -44,7 +44,7 @@ use runtime_parachains::{
|
||||
inclusion::{AggregateMessageOrigin, UmpQueueId},
|
||||
initializer as parachains_initializer, origin as parachains_origin, paras as parachains_paras,
|
||||
paras_inherent as parachains_paras_inherent,
|
||||
runtime_api_impl::v4 as parachains_runtime_api_impl,
|
||||
runtime_api_impl::v5 as parachains_runtime_api_impl,
|
||||
scheduler as parachains_scheduler, session_info as parachains_session_info,
|
||||
shared as parachains_shared,
|
||||
};
|
||||
@@ -1915,25 +1915,25 @@ sp_api::impl_runtime_apis! {
|
||||
}
|
||||
|
||||
fn unapplied_slashes(
|
||||
) -> Vec<(SessionIndex, CandidateHash, vstaging::slashing::PendingSlashes)> {
|
||||
runtime_parachains::runtime_api_impl::vstaging::unapplied_slashes::<Runtime>()
|
||||
) -> Vec<(SessionIndex, CandidateHash, slashing::PendingSlashes)> {
|
||||
parachains_runtime_api_impl::unapplied_slashes::<Runtime>()
|
||||
}
|
||||
|
||||
fn key_ownership_proof(
|
||||
validator_id: ValidatorId,
|
||||
) -> Option<vstaging::slashing::OpaqueKeyOwnershipProof> {
|
||||
) -> Option<slashing::OpaqueKeyOwnershipProof> {
|
||||
use parity_scale_codec::Encode;
|
||||
|
||||
Historical::prove((PARACHAIN_KEY_TYPE_ID, validator_id))
|
||||
.map(|p| p.encode())
|
||||
.map(vstaging::slashing::OpaqueKeyOwnershipProof::new)
|
||||
.map(slashing::OpaqueKeyOwnershipProof::new)
|
||||
}
|
||||
|
||||
fn submit_report_dispute_lost(
|
||||
dispute_proof: vstaging::slashing::DisputeProof,
|
||||
key_ownership_proof: vstaging::slashing::OpaqueKeyOwnershipProof,
|
||||
dispute_proof: slashing::DisputeProof,
|
||||
key_ownership_proof: slashing::OpaqueKeyOwnershipProof,
|
||||
) -> Option<()> {
|
||||
runtime_parachains::runtime_api_impl::vstaging::submit_unsigned_slashing_report::<Runtime>(
|
||||
parachains_runtime_api_impl::submit_unsigned_slashing_report::<Runtime>(
|
||||
dispute_proof,
|
||||
key_ownership_proof,
|
||||
)
|
||||
|
||||
@@ -26,9 +26,10 @@ use sp_std::{collections::btree_map::BTreeMap, prelude::*};
|
||||
|
||||
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::v4 as runtime_impl,
|
||||
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::v5 as runtime_impl,
|
||||
scheduler as parachains_scheduler, session_info as parachains_session_info,
|
||||
shared as parachains_shared,
|
||||
};
|
||||
@@ -38,19 +39,19 @@ use beefy_primitives::crypto::{AuthorityId as BeefyId, Signature as BeefySignatu
|
||||
use frame_election_provider_support::{onchain, SequentialPhragmen};
|
||||
use frame_support::{
|
||||
construct_runtime, parameter_types,
|
||||
traits::{Everything, WithdrawReasons},
|
||||
traits::{Everything, KeyOwnerProofSystem, WithdrawReasons},
|
||||
};
|
||||
use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId};
|
||||
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, CandidateHash,
|
||||
slashing, 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,
|
||||
ValidatorIndex, PARACHAIN_KEY_TYPE_ID,
|
||||
};
|
||||
use runtime_common::{
|
||||
claims, impl_runtime_weights, paras_sudo_wrapper, BlockHashCount, BlockLength,
|
||||
@@ -67,7 +68,7 @@ use sp_runtime::{
|
||||
SaturatedConversion, StaticLookup, Verify,
|
||||
},
|
||||
transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity},
|
||||
ApplyExtrinsicResult, Perbill,
|
||||
ApplyExtrinsicResult, KeyTypeId, Perbill,
|
||||
};
|
||||
use sp_staking::SessionIndex;
|
||||
#[cfg(any(feature = "std", test))]
|
||||
@@ -170,6 +171,8 @@ where
|
||||
parameter_types! {
|
||||
pub storage EpochDuration: u64 = EPOCH_DURATION_IN_SLOTS as u64;
|
||||
pub storage ExpectedBlockTime: Moment = MILLISECS_PER_BLOCK;
|
||||
pub ReportLongevity: u64 =
|
||||
BondingDuration::get() as u64 * SessionsPerEra::get() as u64 * EpochDuration::get();
|
||||
}
|
||||
|
||||
impl pallet_babe::Config for Runtime {
|
||||
@@ -185,7 +188,8 @@ impl pallet_babe::Config for Runtime {
|
||||
|
||||
type MaxAuthorities = MaxAuthorities;
|
||||
|
||||
type KeyOwnerProof = sp_core::Void;
|
||||
type KeyOwnerProof =
|
||||
<Historical as KeyOwnerProofSystem<(KeyTypeId, pallet_babe::AuthorityId)>>::Proof;
|
||||
|
||||
type EquivocationReportSystem = ();
|
||||
}
|
||||
@@ -484,10 +488,27 @@ impl parachains_inclusion::Config for Runtime {
|
||||
impl parachains_disputes::Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type RewardValidators = ();
|
||||
type SlashingHandler = ();
|
||||
type SlashingHandler = parachains_slashing::SlashValidatorsForDisputes<ParasSlashing>;
|
||||
type WeightInfo = parachains_disputes::TestWeightInfo;
|
||||
}
|
||||
|
||||
impl parachains_slashing::Config for Runtime {
|
||||
type KeyOwnerProofSystem = Historical;
|
||||
type KeyOwnerProof =
|
||||
<Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, ValidatorId)>>::Proof;
|
||||
type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
|
||||
KeyTypeId,
|
||||
ValidatorId,
|
||||
)>>::IdentificationTuple;
|
||||
type HandleReports = parachains_slashing::SlashingReportHandler<
|
||||
Self::KeyOwnerIdentification,
|
||||
Offences,
|
||||
ReportLongevity,
|
||||
>;
|
||||
type WeightInfo = parachains_disputes::slashing::TestWeightInfo;
|
||||
type BenchmarkingConfig = parachains_slashing::BenchConfig<1000>;
|
||||
}
|
||||
|
||||
impl parachains_paras_inherent::Config for Runtime {
|
||||
type WeightInfo = parachains_paras_inherent::TestWeightInfo;
|
||||
}
|
||||
@@ -671,6 +692,7 @@ construct_runtime! {
|
||||
Dmp: parachains_dmp::{Pallet, Storage},
|
||||
Xcm: pallet_xcm::{Pallet, Call, Event<T>, Origin},
|
||||
ParasDisputes: parachains_disputes::{Pallet, Storage, Event<T>},
|
||||
ParasSlashing: parachains_slashing::{Pallet, Call, Storage, ValidateUnsigned},
|
||||
|
||||
Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>},
|
||||
|
||||
@@ -891,6 +913,31 @@ sp_api::impl_runtime_apis! {
|
||||
fn disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState<BlockNumber>)> {
|
||||
runtime_impl::get_session_disputes::<Runtime>()
|
||||
}
|
||||
|
||||
fn unapplied_slashes(
|
||||
) -> Vec<(SessionIndex, CandidateHash, slashing::PendingSlashes)> {
|
||||
runtime_impl::unapplied_slashes::<Runtime>()
|
||||
}
|
||||
|
||||
fn key_ownership_proof(
|
||||
validator_id: ValidatorId,
|
||||
) -> Option<slashing::OpaqueKeyOwnershipProof> {
|
||||
use parity_scale_codec::Encode;
|
||||
|
||||
Historical::prove((PARACHAIN_KEY_TYPE_ID, validator_id))
|
||||
.map(|p| p.encode())
|
||||
.map(slashing::OpaqueKeyOwnershipProof::new)
|
||||
}
|
||||
|
||||
fn submit_report_dispute_lost(
|
||||
dispute_proof: slashing::DisputeProof,
|
||||
key_ownership_proof: slashing::OpaqueKeyOwnershipProof,
|
||||
) -> Option<()> {
|
||||
runtime_impl::submit_unsigned_slashing_report::<Runtime>(
|
||||
dispute_proof,
|
||||
key_ownership_proof,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl beefy_primitives::BeefyApi<Block> for Runtime {
|
||||
|
||||
@@ -39,7 +39,7 @@ use pallet_session::historical as session_historical;
|
||||
use pallet_transaction_payment::{CurrencyAdapter, FeeDetails, RuntimeDispatchInfo};
|
||||
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
|
||||
use primitives::{
|
||||
vstaging, AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash,
|
||||
slashing, AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash,
|
||||
CommittedCandidateReceipt, CoreState, DisputeState, ExecutorParams, GroupRotationInfo, Hash,
|
||||
Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce,
|
||||
OccupiedCoreAssumption, PersistedValidationData, PvfCheckStatement, ScrapedOnChainVotes,
|
||||
@@ -58,9 +58,7 @@ use runtime_parachains::{
|
||||
inclusion::{AggregateMessageOrigin, UmpQueueId},
|
||||
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::{
|
||||
v4 as parachains_runtime_api_impl, vstaging as parachains_runtime_api_impl_staging,
|
||||
},
|
||||
runtime_api_impl::v5 as parachains_runtime_api_impl,
|
||||
scheduler as parachains_scheduler, session_info as parachains_session_info,
|
||||
shared as parachains_shared,
|
||||
};
|
||||
@@ -1582,25 +1580,25 @@ sp_api::impl_runtime_apis! {
|
||||
}
|
||||
|
||||
fn unapplied_slashes(
|
||||
) -> Vec<(SessionIndex, CandidateHash, vstaging::slashing::PendingSlashes)> {
|
||||
parachains_runtime_api_impl_staging::unapplied_slashes::<Runtime>()
|
||||
) -> Vec<(SessionIndex, CandidateHash, slashing::PendingSlashes)> {
|
||||
parachains_runtime_api_impl::unapplied_slashes::<Runtime>()
|
||||
}
|
||||
|
||||
fn key_ownership_proof(
|
||||
validator_id: ValidatorId,
|
||||
) -> Option<vstaging::slashing::OpaqueKeyOwnershipProof> {
|
||||
) -> Option<slashing::OpaqueKeyOwnershipProof> {
|
||||
use parity_scale_codec::Encode;
|
||||
|
||||
Historical::prove((PARACHAIN_KEY_TYPE_ID, validator_id))
|
||||
.map(|p| p.encode())
|
||||
.map(vstaging::slashing::OpaqueKeyOwnershipProof::new)
|
||||
.map(slashing::OpaqueKeyOwnershipProof::new)
|
||||
}
|
||||
|
||||
fn submit_report_dispute_lost(
|
||||
dispute_proof: vstaging::slashing::DisputeProof,
|
||||
key_ownership_proof: vstaging::slashing::OpaqueKeyOwnershipProof,
|
||||
dispute_proof: slashing::DisputeProof,
|
||||
key_ownership_proof: slashing::OpaqueKeyOwnershipProof,
|
||||
) -> Option<()> {
|
||||
parachains_runtime_api_impl_staging::submit_unsigned_slashing_report::<Runtime>(
|
||||
parachains_runtime_api_impl::submit_unsigned_slashing_report::<Runtime>(
|
||||
dispute_proof,
|
||||
key_ownership_proof,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user