Disabled validators runtime API (#1257)

Exposes disabled validators list via a runtime API.

---------

Co-authored-by: ordian <noreply@reusable.software>
Co-authored-by: ordian <write@reusable.software>
This commit is contained in:
Tsvetomir Dimitrov
2023-10-12 16:01:07 +03:00
committed by GitHub
parent f0e6d2ad52
commit 7aace06b3d
13 changed files with 115 additions and 8 deletions
@@ -695,6 +695,8 @@ pub enum RuntimeApiRequest {
),
/// Get the minimum required backing votes.
MinimumBackingVotes(SessionIndex, RuntimeApiSender<u32>),
/// Returns all disabled validators at a given block height.
DisabledValidators(RuntimeApiSender<Vec<ValidatorIndex>>),
/// Get the backing state of the given para.
ParaBackingState(ParaId, RuntimeApiSender<Option<async_backing::BackingState>>),
/// Get candidate's acceptance limitations for asynchronous backing for a relay parent.
@@ -726,6 +728,9 @@ impl RuntimeApiRequest {
/// Minimum version to enable asynchronous backing: `AsyncBackingParams` and `ParaBackingState`.
pub const ASYNC_BACKING_STATE_RUNTIME_REQUIREMENT: u32 = 7;
/// `DisabledValidators`
pub const DISABLED_VALIDATORS_RUNTIME_REQUIREMENT: u32 = 8;
}
/// A message to the Runtime API subsystem.
@@ -255,6 +255,10 @@ pub trait RuntimeApiSubsystemClient {
at: Hash,
para_id: Id,
) -> Result<Option<async_backing::BackingState>, ApiError>;
// === v8 ===
/// Gets the disabled validators at a specific block height
async fn disabled_validators(&self, at: Hash) -> Result<Vec<ValidatorIndex>, ApiError>;
}
/// Default implementation of [`RuntimeApiSubsystemClient`] using the client.
@@ -497,11 +501,14 @@ where
self.client.runtime_api().para_backing_state(at, para_id)
}
/// Returns candidate's acceptance limitations for asynchronous backing for a relay parent.
async fn async_backing_params(
&self,
at: Hash,
) -> Result<async_backing::AsyncBackingParams, ApiError> {
self.client.runtime_api().async_backing_params(at)
}
async fn disabled_validators(&self, at: Hash) -> Result<Vec<ValidatorIndex>, ApiError> {
self.client.runtime_api().disabled_validators(at)
}
}