mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 00:31:07 +00:00
Move PVF timeouts to executor environment parameters (#6823)
* Move PVF timeouts to executor environment parameters * Typo Co-authored-by: Marcin S. <marcin@realemail.net> * Fix comments * Change handle_import_statements to FatalResult (#6820) * Changing dispute db errors to fatal * fmt * Change node-key for bootnodes (#6772) * Additional tracing in `provisioner`, `vote_selection` and `dispute-coordinator` (#6775) * Additional tracing in `provisioner`, `vote_selection` * Add `fetched_onchain_disputes` metric to provisioner * Some tracelines in dispute-coordinator TODO: cherry pick this in the initial branch!!! * Remove spammy logs * Remove some trace lines * Rename and fix things * Fix comments * Typo * Minor fixes * Add codec indexes; Remove macro --------- Co-authored-by: Marcin S. <marcin@realemail.net> Co-authored-by: Bradley Olson <34992650+BradleyOlson64@users.noreply.github.com> Co-authored-by: Petr Mensik <petr.mensik1@gmail.com> Co-authored-by: Tsvetomir Dimitrov <tsvetomir@parity.io>
This commit is contained in:
@@ -46,16 +46,16 @@ pub use v2::{
|
||||
Header, HrmpChannelId, Id, InboundDownwardMessage, InboundHrmpMessage, IndexedVec,
|
||||
InherentData, InvalidDisputeStatementKind, Moment, MultiDisputeStatementSet, Nonce,
|
||||
OccupiedCore, OccupiedCoreAssumption, OutboundHrmpMessage, ParathreadClaim, ParathreadEntry,
|
||||
PersistedValidationData, PvfCheckStatement, RuntimeMetricLabel, RuntimeMetricLabelValue,
|
||||
RuntimeMetricLabelValues, RuntimeMetricLabels, RuntimeMetricOp, RuntimeMetricUpdate,
|
||||
ScheduledCore, ScrapedOnChainVotes, SessionIndex, SessionInfo, Signature, Signed,
|
||||
SignedAvailabilityBitfield, SignedAvailabilityBitfields, SignedStatement, SigningContext, Slot,
|
||||
UncheckedSigned, UncheckedSignedAvailabilityBitfield, UncheckedSignedAvailabilityBitfields,
|
||||
UncheckedSignedStatement, UpgradeGoAhead, UpgradeRestriction, UpwardMessage,
|
||||
ValidDisputeStatementKind, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex,
|
||||
ValidatorSignature, ValidityAttestation, ValidityError, ASSIGNMENT_KEY_TYPE_ID,
|
||||
LOWEST_PUBLIC_ID, MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE, MAX_POV_SIZE,
|
||||
PARACHAINS_INHERENT_IDENTIFIER, PARACHAIN_KEY_TYPE_ID,
|
||||
PersistedValidationData, PvfCheckStatement, PvfExecTimeoutKind, PvfPrepTimeoutKind,
|
||||
RuntimeMetricLabel, RuntimeMetricLabelValue, RuntimeMetricLabelValues, RuntimeMetricLabels,
|
||||
RuntimeMetricOp, RuntimeMetricUpdate, ScheduledCore, ScrapedOnChainVotes, SessionIndex,
|
||||
SessionInfo, Signature, Signed, SignedAvailabilityBitfield, SignedAvailabilityBitfields,
|
||||
SignedStatement, SigningContext, Slot, UncheckedSigned, UncheckedSignedAvailabilityBitfield,
|
||||
UncheckedSignedAvailabilityBitfields, UncheckedSignedStatement, UpgradeGoAhead,
|
||||
UpgradeRestriction, UpwardMessage, ValidDisputeStatementKind, ValidationCode,
|
||||
ValidationCodeHash, ValidatorId, ValidatorIndex, ValidatorSignature, ValidityAttestation,
|
||||
ValidityError, ASSIGNMENT_KEY_TYPE_ID, LOWEST_PUBLIC_ID, MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE,
|
||||
MAX_POV_SIZE, PARACHAINS_INHERENT_IDENTIFIER, PARACHAIN_KEY_TYPE_ID,
|
||||
};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
|
||||
@@ -1689,6 +1689,33 @@ impl PvfCheckStatement {
|
||||
}
|
||||
}
|
||||
|
||||
/// Type discriminator for PVF preparation timeouts
|
||||
#[derive(Encode, Decode, TypeInfo, Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum PvfPrepTimeoutKind {
|
||||
/// For prechecking requests, the time period after which the preparation worker is considered
|
||||
/// unresponsive and will be killed.
|
||||
Precheck,
|
||||
|
||||
/// For execution and heads-up requests, the time period after which the preparation worker is
|
||||
/// considered unresponsive and will be killed. More lenient than the timeout for prechecking
|
||||
/// to prevent honest validators from timing out on valid PVFs.
|
||||
Lenient,
|
||||
}
|
||||
|
||||
/// Type discriminator for PVF execution timeouts
|
||||
#[derive(Encode, Decode, TypeInfo, Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum PvfExecTimeoutKind {
|
||||
/// The amount of time to spend on execution during backing.
|
||||
Backing,
|
||||
|
||||
/// The amount of time to spend on execution during approval or disputes.
|
||||
///
|
||||
/// This should be much longer than the backing execution timeout to ensure that in the
|
||||
/// absence of extremely large disparities between hardware, blocks that pass backing are
|
||||
/// considered executable by approval checkers or dispute participants.
|
||||
Approval,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
@@ -21,24 +21,34 @@
|
||||
//! by the first element of the vector). Decoding to a usable semantics structure is
|
||||
//! done in `polkadot-node-core-pvf`.
|
||||
|
||||
use crate::{BlakeTwo256, HashT as _};
|
||||
use crate::{BlakeTwo256, HashT as _, PvfExecTimeoutKind, PvfPrepTimeoutKind};
|
||||
use parity_scale_codec::{Decode, Encode};
|
||||
use polkadot_core_primitives::Hash;
|
||||
use scale_info::TypeInfo;
|
||||
use sp_std::{ops::Deref, vec, vec::Vec};
|
||||
use sp_std::{ops::Deref, time::Duration, vec, vec::Vec};
|
||||
|
||||
/// The different executor parameters for changing the execution environment semantics.
|
||||
#[derive(Clone, Debug, Encode, Decode, PartialEq, Eq, TypeInfo)]
|
||||
pub enum ExecutorParam {
|
||||
/// Maximum number of memory pages (64KiB bytes per page) the executor can allocate.
|
||||
#[codec(index = 1)]
|
||||
MaxMemoryPages(u32),
|
||||
/// Wasm logical stack size limit (max. number of Wasm values on stack)
|
||||
#[codec(index = 2)]
|
||||
StackLogicalMax(u32),
|
||||
/// Executor machine stack size limit, in bytes
|
||||
#[codec(index = 3)]
|
||||
StackNativeMax(u32),
|
||||
/// Max. amount of memory the preparation worker is allowed to use during
|
||||
/// pre-checking, in bytes
|
||||
#[codec(index = 4)]
|
||||
PrecheckingMaxMemory(u64),
|
||||
/// PVF preparation timeouts, millisec
|
||||
#[codec(index = 5)]
|
||||
PvfPrepTimeout(PvfPrepTimeoutKind, u64),
|
||||
/// PVF execution timeouts, millisec
|
||||
#[codec(index = 6)]
|
||||
PvfExecTimeout(PvfExecTimeoutKind, u64),
|
||||
}
|
||||
|
||||
/// Unit type wrapper around [`type@Hash`] that represents an execution parameter set hash.
|
||||
@@ -92,6 +102,30 @@ impl ExecutorParams {
|
||||
pub fn hash(&self) -> ExecutorParamsHash {
|
||||
ExecutorParamsHash(BlakeTwo256::hash(&self.encode()))
|
||||
}
|
||||
|
||||
/// Returns a PVF preparation timeout, if any
|
||||
pub fn pvf_prep_timeout(&self, kind: PvfPrepTimeoutKind) -> Option<Duration> {
|
||||
for param in &self.0 {
|
||||
if let ExecutorParam::PvfPrepTimeout(k, timeout) = param {
|
||||
if kind == *k {
|
||||
return Some(Duration::from_millis(*timeout))
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// Returns a PVF execution timeout, if any
|
||||
pub fn pvf_exec_timeout(&self, kind: PvfExecTimeoutKind) -> Option<Duration> {
|
||||
for param in &self.0 {
|
||||
if let ExecutorParam::PvfExecTimeout(k, timeout) = param {
|
||||
if kind == *k {
|
||||
return Some(Duration::from_millis(*timeout))
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for ExecutorParams {
|
||||
|
||||
Reference in New Issue
Block a user