mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 22:51:13 +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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user