backing: move the min votes threshold to the runtime (#1200)

* move min backing votes const to runtime

also cache it per-session in the backing subsystem

Signed-off-by: alindima <alin@parity.io>

* add runtime migration

* introduce api versioning for min_backing votes

also enable it for rococo/versi for testing

* also add min_backing_votes runtime calls to statement-distribution

this dependency has been recently introduced by async backing

* remove explicit version runtime API call

this is not needed, as the RuntimeAPISubsystem already takes care
of versioning and will return NotSupported if the version is not
right.

* address review comments

- parametrise backing votes runtime API with session index
- remove RuntimeInfo usage in backing subsystem, as runtime API
caches the min backing votes by session index anyway.
- move the logic for adjusting the configured needed backing votes with the size of the backing group
to a primitives helper.
- move the legacy min backing votes value to a primitives helper.
- mark JoinMultiple error as fatal, since the Canceled (non-multiple) counterpart is also fatal.
- make backing subsystem handle fatal errors for new leaves update.
- add HostConfiguration consistency check for zeroed backing votes threshold
- add cumulus accompanying change

* fix cumulus test compilation

* fix tests

* more small fixes

* fix merge

* bump runtime api version for westend and rollback version for rococo

---------

Signed-off-by: alindima <alin@parity.io>
Co-authored-by: Javier Viola <javier@parity.io>
This commit is contained in:
Alin Dima
2023-08-31 14:01:36 +03:00
committed by GitHub
parent f1845f725d
commit d6af073aa5
37 changed files with 920 additions and 255 deletions
@@ -691,6 +691,8 @@ pub enum RuntimeApiRequest {
slashing::OpaqueKeyOwnershipProof,
RuntimeApiSender<Option<()>>,
),
/// Get the minimum required backing votes.
MinimumBackingVotes(SessionIndex, RuntimeApiSender<u32>),
/// Get the backing state of the given para.
/// This is a staging API that will not be available on production runtimes.
@@ -719,6 +721,9 @@ impl RuntimeApiRequest {
/// `SubmitReportDisputeLost`
pub const SUBMIT_REPORT_DISPUTE_LOST_RUNTIME_REQUIREMENT: u32 = 5;
/// `MinimumBackingVotes`
pub const MINIMUM_BACKING_VOTES_RUNTIME_REQUIREMENT: u32 = 6;
/// Minimum version for backing state, required for async backing.
///
/// 99 for now, should be adjusted to VSTAGING/actual runtime version once released.
@@ -232,6 +232,14 @@ pub trait RuntimeApiSubsystemClient {
session_index: SessionIndex,
) -> Result<Option<ExecutorParams>, ApiError>;
// === STAGING v6 ===
/// Get the minimum number of backing votes.
async fn minimum_backing_votes(
&self,
at: Hash,
session_index: SessionIndex,
) -> Result<u32, ApiError>;
// === Asynchronous backing API ===
/// Returns candidate's acceptance limitations for asynchronous backing for a relay parent.
@@ -473,6 +481,14 @@ where
runtime_api.submit_report_dispute_lost(at, dispute_proof, key_ownership_proof)
}
async fn minimum_backing_votes(
&self,
at: Hash,
_session_index: SessionIndex,
) -> Result<u32, ApiError> {
self.client.runtime_api().minimum_backing_votes(at)
}
async fn staging_para_backing_state(
&self,
at: Hash,