Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 04f8014

Browse files
eskimoreskimor
andauthored
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>
1 parent ee8aa32 commit 04f8014

File tree

21 files changed

+236
-122
lines changed

21 files changed

+236
-122
lines changed

node/core/dispute-coordinator/src/initialized.rs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ use polkadot_node_subsystem::{
3737
ApprovalVotingMessage, BlockDescription, ChainSelectionMessage, DisputeCoordinatorMessage,
3838
DisputeDistributionMessage, ImportStatementsResult,
3939
},
40-
overseer, ActivatedLeaf, ActiveLeavesUpdate, FromOrchestra, OverseerSignal,
40+
overseer, ActivatedLeaf, ActiveLeavesUpdate, FromOrchestra, OverseerSignal, RuntimeApiError,
4141
};
4242
use polkadot_node_subsystem_util::runtime::{
43-
key_ownership_proof, submit_report_dispute_lost, RuntimeInfo,
43+
self, key_ownership_proof, submit_report_dispute_lost, RuntimeInfo,
4444
};
4545
use polkadot_primitives::{
4646
vstaging, BlockNumber, CandidateHash, CandidateReceipt, CompactStatement, DisputeStatement,
@@ -424,8 +424,19 @@ impl Initialized {
424424
dispute_proofs.push(dispute_proof);
425425
},
426426
Ok(None) => {},
427-
Err(error) => {
427+
Err(runtime::Error::RuntimeRequest(RuntimeApiError::NotSupported {
428+
..
429+
})) => {
428430
gum::debug!(
431+
target: LOG_TARGET,
432+
?session_index,
433+
?candidate_hash,
434+
?validator_id,
435+
"Key ownership proof not yet supported.",
436+
);
437+
},
438+
Err(error) => {
439+
gum::warn!(
429440
target: LOG_TARGET,
430441
?error,
431442
?session_index,
@@ -480,6 +491,16 @@ impl Initialized {
480491
.await;
481492

482493
match res {
494+
Err(runtime::Error::RuntimeRequest(RuntimeApiError::NotSupported {
495+
..
496+
})) => {
497+
gum::debug!(
498+
target: LOG_TARGET,
499+
?session_index,
500+
?candidate_hash,
501+
"Reporting pending slash not yet supported",
502+
);
503+
},
483504
Err(error) => {
484505
gum::warn!(
485506
target: LOG_TARGET,

node/core/dispute-coordinator/src/scraping/mod.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ use lru::LruCache;
2525
use polkadot_node_primitives::{DISPUTE_CANDIDATE_LIFETIME_AFTER_FINALIZATION, MAX_FINALITY_LAG};
2626
use polkadot_node_subsystem::{
2727
messages::ChainApiMessage, overseer, ActivatedLeaf, ActiveLeavesUpdate, ChainApiError,
28-
SubsystemSender,
28+
RuntimeApiError, SubsystemSender,
2929
};
3030
use polkadot_node_subsystem_util::runtime::{
31-
get_candidate_events, get_on_chain_votes, get_unapplied_slashes,
31+
self, get_candidate_events, get_on_chain_votes, get_unapplied_slashes,
3232
};
3333
use polkadot_primitives::{
34-
vstaging, BlockNumber, CandidateEvent, CandidateHash, CandidateReceipt, Hash,
34+
slashing::PendingSlashes, BlockNumber, CandidateEvent, CandidateHash, CandidateReceipt, Hash,
3535
ScrapedOnChainVotes, SessionIndex,
3636
};
3737

@@ -67,7 +67,7 @@ const LRU_OBSERVED_BLOCKS_CAPACITY: NonZeroUsize = match NonZeroUsize::new(20) {
6767
pub struct ScrapedUpdates {
6868
pub on_chain_votes: Vec<ScrapedOnChainVotes>,
6969
pub included_receipts: Vec<CandidateReceipt>,
70-
pub unapplied_slashes: Vec<(SessionIndex, CandidateHash, vstaging::slashing::PendingSlashes)>,
70+
pub unapplied_slashes: Vec<(SessionIndex, CandidateHash, PendingSlashes)>,
7171
}
7272

7373
impl ScrapedUpdates {
@@ -270,8 +270,15 @@ impl ChainScraper {
270270
Ok(unapplied_slashes) => {
271271
scraped_updates.unapplied_slashes = unapplied_slashes;
272272
},
273-
Err(error) => {
273+
Err(runtime::Error::RuntimeRequest(RuntimeApiError::NotSupported { .. })) => {
274274
gum::debug!(
275+
target: LOG_TARGET,
276+
block_hash = ?activated.hash,
277+
"Fetching unapplied slashes not yet supported.",
278+
);
279+
},
280+
Err(error) => {
281+
gum::warn!(
275282
target: LOG_TARGET,
276283
block_hash = ?activated.hash,
277284
?error,

node/subsystem-types/src/messages.rs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use polkadot_node_primitives::{
3939
SignedDisputeStatement, SignedFullStatement, ValidationResult,
4040
};
4141
use polkadot_primitives::{
42-
vstaging, AuthorityDiscoveryId, BackedCandidate, BlockNumber, CandidateEvent, CandidateHash,
42+
slashing, AuthorityDiscoveryId, BackedCandidate, BlockNumber, CandidateEvent, CandidateHash,
4343
CandidateIndex, CandidateReceipt, CollatorId, CommittedCandidateReceipt, CoreState,
4444
DisputeState, ExecutorParams, GroupIndex, GroupRotationInfo, Hash, Header as BlockHeader,
4545
Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, MultiDisputeStatementSet,
@@ -607,21 +607,18 @@ pub enum RuntimeApiRequest {
607607
/// Returns all on-chain disputes at given block number. Available in `v3`.
608608
Disputes(RuntimeApiSender<Vec<(SessionIndex, CandidateHash, DisputeState<BlockNumber>)>>),
609609
/// Returns a list of validators that lost a past session dispute and need to be slashed.
610-
/// `VStaging`
610+
/// `V5`
611611
UnappliedSlashes(
612-
RuntimeApiSender<Vec<(SessionIndex, CandidateHash, vstaging::slashing::PendingSlashes)>>,
612+
RuntimeApiSender<Vec<(SessionIndex, CandidateHash, slashing::PendingSlashes)>>,
613613
),
614614
/// Returns a merkle proof of a validator session key.
615-
/// `VStaging`
616-
KeyOwnershipProof(
617-
ValidatorId,
618-
RuntimeApiSender<Option<vstaging::slashing::OpaqueKeyOwnershipProof>>,
619-
),
615+
/// `V5`
616+
KeyOwnershipProof(ValidatorId, RuntimeApiSender<Option<slashing::OpaqueKeyOwnershipProof>>),
620617
/// Submits an unsigned extrinsic to slash validator who lost a past session dispute.
621-
/// `VStaging`
618+
/// `V5`
622619
SubmitReportDisputeLost(
623-
vstaging::slashing::DisputeProof,
624-
vstaging::slashing::OpaqueKeyOwnershipProof,
620+
slashing::DisputeProof,
621+
slashing::OpaqueKeyOwnershipProof,
625622
RuntimeApiSender<Option<()>>,
626623
),
627624
}
@@ -632,17 +629,17 @@ impl RuntimeApiRequest {
632629
/// `Disputes`
633630
pub const DISPUTES_RUNTIME_REQUIREMENT: u32 = 3;
634631

635-
/// `UnappliedSlashes`
636-
pub const UNAPPLIED_SLASHES_RUNTIME_REQUIREMENT: u32 = 4;
637-
638632
/// `ExecutorParams`
639633
pub const EXECUTOR_PARAMS_RUNTIME_REQUIREMENT: u32 = 4;
640634

635+
/// `UnappliedSlashes`
636+
pub const UNAPPLIED_SLASHES_RUNTIME_REQUIREMENT: u32 = 5;
637+
641638
/// `KeyOwnershipProof`
642-
pub const KEY_OWNERSHIP_PROOF_RUNTIME_REQUIREMENT: u32 = 4;
639+
pub const KEY_OWNERSHIP_PROOF_RUNTIME_REQUIREMENT: u32 = 5;
643640

644641
/// `SubmitReportDisputeLost`
645-
pub const SUBMIT_REPORT_DISPUTE_LOST_RUNTIME_REQUIREMENT: u32 = 4;
642+
pub const SUBMIT_REPORT_DISPUTE_LOST_RUNTIME_REQUIREMENT: u32 = 5;
646643
}
647644

648645
/// A message to the Runtime API subsystem.

node/subsystem-util/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use polkadot_node_subsystem::{
2929
messages::{RuntimeApiMessage, RuntimeApiRequest, RuntimeApiSender},
3030
overseer, SubsystemSender,
3131
};
32-
use polkadot_primitives::ExecutorParams;
32+
use polkadot_primitives::{slashing, ExecutorParams};
3333

3434
pub use overseer::{
3535
gen::{OrchestraError as OverseerError, Timeout},
@@ -42,8 +42,8 @@ use futures::channel::{mpsc, oneshot};
4242
use parity_scale_codec::Encode;
4343

4444
use polkadot_primitives::{
45-
vstaging, AuthorityDiscoveryId, CandidateEvent, CandidateHash, CommittedCandidateReceipt,
46-
CoreState, EncodeAs, GroupIndex, GroupRotationInfo, Hash, Id as ParaId, OccupiedCoreAssumption,
45+
AuthorityDiscoveryId, CandidateEvent, CandidateHash, CommittedCandidateReceipt, CoreState,
46+
EncodeAs, GroupIndex, GroupRotationInfo, Hash, Id as ParaId, OccupiedCoreAssumption,
4747
PersistedValidationData, ScrapedOnChainVotes, SessionIndex, SessionInfo, Signed,
4848
SigningContext, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex,
4949
ValidatorSignature,
@@ -212,9 +212,9 @@ specialize_requests! {
212212
-> Option<ValidationCodeHash>; ValidationCodeHash;
213213
fn request_on_chain_votes() -> Option<ScrapedOnChainVotes>; FetchOnChainVotes;
214214
fn request_session_executor_params(session_index: SessionIndex) -> Option<ExecutorParams>;SessionExecutorParams;
215-
fn request_unapplied_slashes() -> Vec<(SessionIndex, CandidateHash, vstaging::slashing::PendingSlashes)>; UnappliedSlashes;
216-
fn request_key_ownership_proof(validator_id: ValidatorId) -> Option<vstaging::slashing::OpaqueKeyOwnershipProof>; KeyOwnershipProof;
217-
fn request_submit_report_dispute_lost(dp: vstaging::slashing::DisputeProof, okop: vstaging::slashing::OpaqueKeyOwnershipProof) -> Option<()>; SubmitReportDisputeLost;
215+
fn request_unapplied_slashes() -> Vec<(SessionIndex, CandidateHash, slashing::PendingSlashes)>; UnappliedSlashes;
216+
fn request_key_ownership_proof(validator_id: ValidatorId) -> Option<slashing::OpaqueKeyOwnershipProof>; KeyOwnershipProof;
217+
fn request_submit_report_dispute_lost(dp: slashing::DisputeProof, okop: slashing::OpaqueKeyOwnershipProof) -> Option<()>; SubmitReportDisputeLost;
218218
}
219219

220220
/// Requests executor parameters from the runtime effective at given relay-parent. First obtains

primitives/src/lib.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#![warn(missing_docs)]
2020
#![cfg_attr(not(feature = "std"), no_std)]
2121

22-
// `v4` is currently the latest stable version of the runtime API.
23-
pub mod v4;
22+
// `v5` is currently the latest stable version of the runtime API.
23+
pub mod v5;
2424

2525
// The 'staging' version is special - it contains primitives which are
2626
// still in development. Once they are considered stable, they will be
@@ -33,18 +33,18 @@ pub mod runtime_api;
3333

3434
// Current primitives not requiring versioning are exported here.
3535
// Primitives requiring versioning must not be exported and must be referred by an exact version.
36-
pub use v4::{
36+
pub use v5::{
3737
byzantine_threshold, check_candidate_backing, collator_signature_payload, metric_definitions,
38-
supermajority_threshold, well_known_keys, AbridgedHostConfiguration, AbridgedHrmpChannel,
39-
AccountId, AccountIndex, AccountPublic, ApprovalVote, AssignmentId, AuthorityDiscoveryId,
40-
AvailabilityBitfield, BackedCandidate, Balance, BlakeTwo256, Block, BlockId, BlockNumber,
41-
CandidateCommitments, CandidateDescriptor, CandidateEvent, CandidateHash, CandidateIndex,
42-
CandidateReceipt, CheckedDisputeStatementSet, CheckedMultiDisputeStatementSet, CollatorId,
43-
CollatorSignature, CommittedCandidateReceipt, CompactStatement, ConsensusLog, CoreIndex,
44-
CoreOccupied, CoreState, DisputeState, DisputeStatement, DisputeStatementSet, DownwardMessage,
45-
EncodeAs, ExecutorParam, ExecutorParams, ExecutorParamsHash, ExplicitDisputeStatement,
46-
GroupIndex, GroupRotationInfo, Hash, HashT, HeadData, Header, HrmpChannelId, Id,
47-
InboundDownwardMessage, InboundHrmpMessage, IndexedVec, InherentData,
38+
slashing, supermajority_threshold, well_known_keys, AbridgedHostConfiguration,
39+
AbridgedHrmpChannel, AccountId, AccountIndex, AccountPublic, ApprovalVote, AssignmentId,
40+
AuthorityDiscoveryId, AvailabilityBitfield, BackedCandidate, Balance, BlakeTwo256, Block,
41+
BlockId, BlockNumber, CandidateCommitments, CandidateDescriptor, CandidateEvent, CandidateHash,
42+
CandidateIndex, CandidateReceipt, CheckedDisputeStatementSet, CheckedMultiDisputeStatementSet,
43+
CollatorId, CollatorSignature, CommittedCandidateReceipt, CompactStatement, ConsensusLog,
44+
CoreIndex, CoreOccupied, CoreState, DisputeState, DisputeStatement, DisputeStatementSet,
45+
DownwardMessage, EncodeAs, ExecutorParam, ExecutorParams, ExecutorParamsHash,
46+
ExplicitDisputeStatement, GroupIndex, GroupRotationInfo, Hash, HashT, HeadData, Header,
47+
HrmpChannelId, Id, InboundDownwardMessage, InboundHrmpMessage, IndexedVec, InherentData,
4848
InvalidDisputeStatementKind, Moment, MultiDisputeStatementSet, Nonce, OccupiedCore,
4949
OccupiedCoreAssumption, OutboundHrmpMessage, ParathreadClaim, ParathreadEntry,
5050
PersistedValidationData, PvfCheckStatement, PvfExecTimeoutKind, PvfPrepTimeoutKind,
@@ -60,4 +60,4 @@ pub use v4::{
6060
};
6161

6262
#[cfg(feature = "std")]
63-
pub use v4::{AssignmentPair, CollatorPair, ValidatorPair};
63+
pub use v5::{AssignmentPair, CollatorPair, ValidatorPair};

primitives/src/runtime_api.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ use sp_std::{collections::btree_map::BTreeMap, prelude::*};
123123

124124
sp_api::decl_runtime_apis! {
125125
/// The API for querying the state of parachains on-chain.
126-
#[api_version(4)]
126+
#[api_version(5)]
127127
pub trait ParachainHost<H: Encode + Decode = pcp::v2::Hash, N: Encode + Decode = pcp::v2::BlockNumber> {
128128
/// Get the current validators.
129129
fn validators() -> Vec<ValidatorId>;
@@ -220,18 +220,18 @@ sp_api::decl_runtime_apis! {
220220
fn session_executor_params(session_index: SessionIndex) -> Option<ExecutorParams>;
221221

222222
/// Returns a list of validators that lost a past session dispute and need to be slashed.
223-
#[api_version(5)]
223+
/// NOTE: This function is only available since parachain host version 5.
224224
fn unapplied_slashes() -> Vec<(SessionIndex, CandidateHash, vstaging::slashing::PendingSlashes)>;
225225

226226
/// Returns a merkle proof of a validator session key.
227-
#[api_version(5)]
227+
/// NOTE: This function is only available since parachain host version 5.
228228
fn key_ownership_proof(
229229
validator_id: ValidatorId,
230230
) -> Option<vstaging::slashing::OpaqueKeyOwnershipProof>;
231231

232232
/// Submit an unsigned extrinsic to slash validators who lost a dispute about
233233
/// a candidate of a past session.
234-
#[api_version(5)]
234+
/// NOTE: This function is only available since parachain host version 5.
235235
fn submit_report_dispute_lost(
236236
dispute_proof: vstaging::slashing::DisputeProof,
237237
key_ownership_proof: vstaging::slashing::OpaqueKeyOwnershipProof,
File renamed without changes.

primitives/src/v4/mod.rs renamed to primitives/src/v5/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ pub use sp_staking::SessionIndex;
5757
mod signed;
5858
pub use signed::{EncodeAs, Signed, UncheckedSigned};
5959

60+
pub mod slashing;
61+
6062
mod metrics;
6163
pub use metrics::{
6264
metric_definitions, RuntimeMetricLabel, RuntimeMetricLabelValue, RuntimeMetricLabelValues,
File renamed without changes.

0 commit comments

Comments
 (0)