mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 11:01:01 +00:00
Elastic scaling: use an assumed CoreIndex in candidate-backing (#3229)
First step in implementing https://github.com/paritytech/polkadot-sdk/issues/3144 ### Summary of changes - switch statement `Table` candidate mapping from `ParaId` to `CoreIndex` - introduce experimental `InjectCoreIndex` node feature. - determine and assume a `CoreIndex` for a candidate based on statement validator index. If the signature is valid it means validator controls the validator that index and we can easily map it to a validator group/core. - introduce a temporary provisioner fix until we fully enable elastic scaling in the subystem. The fix ensures we don't fetch the same backable candidate when calling `get_backable_candidate` for each core. TODO: - [x] fix backing tests - [x] fix statement table tests - [x] add new test --------- Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> Signed-off-by: alindima <alin@parity.io> Co-authored-by: alindima <alin@parity.io>
This commit is contained in:
@@ -72,6 +72,7 @@ pub use metrics::{
|
||||
|
||||
/// The key type ID for a collator key.
|
||||
pub const COLLATOR_KEY_TYPE_ID: KeyTypeId = KeyTypeId(*b"coll");
|
||||
const LOG_TARGET: &str = "runtime::primitives";
|
||||
|
||||
mod collator_app {
|
||||
use application_crypto::{app_crypto, sr25519};
|
||||
@@ -746,17 +747,29 @@ impl<H> BackedCandidate<H> {
|
||||
///
|
||||
/// Returns either an error, indicating that one of the signatures was invalid or that the index
|
||||
/// was out-of-bounds, or the number of signatures checked.
|
||||
pub fn check_candidate_backing<H: AsRef<[u8]> + Clone + Encode>(
|
||||
pub fn check_candidate_backing<H: AsRef<[u8]> + Clone + Encode + core::fmt::Debug>(
|
||||
backed: &BackedCandidate<H>,
|
||||
signing_context: &SigningContext<H>,
|
||||
group_len: usize,
|
||||
validator_lookup: impl Fn(usize) -> Option<ValidatorId>,
|
||||
) -> Result<usize, ()> {
|
||||
if backed.validator_indices.len() != group_len {
|
||||
log::debug!(
|
||||
target: LOG_TARGET,
|
||||
"Check candidate backing: indices mismatch: group_len = {} , indices_len = {}",
|
||||
group_len,
|
||||
backed.validator_indices.len(),
|
||||
);
|
||||
return Err(())
|
||||
}
|
||||
|
||||
if backed.validity_votes.len() > group_len {
|
||||
log::debug!(
|
||||
target: LOG_TARGET,
|
||||
"Check candidate backing: Too many votes, expected: {}, found: {}",
|
||||
group_len,
|
||||
backed.validity_votes.len(),
|
||||
);
|
||||
return Err(())
|
||||
}
|
||||
|
||||
@@ -778,11 +791,23 @@ pub fn check_candidate_backing<H: AsRef<[u8]> + Clone + Encode>(
|
||||
if sig.verify(&payload[..], &validator_id) {
|
||||
signed += 1;
|
||||
} else {
|
||||
log::debug!(
|
||||
target: LOG_TARGET,
|
||||
"Check candidate backing: Invalid signature. validator_id = {:?}, validator_index = {} ",
|
||||
validator_id,
|
||||
val_in_group_idx,
|
||||
);
|
||||
return Err(())
|
||||
}
|
||||
}
|
||||
|
||||
if signed != backed.validity_votes.len() {
|
||||
log::error!(
|
||||
target: LOG_TARGET,
|
||||
"Check candidate backing: Too many signatures, expected = {}, found = {}",
|
||||
backed.validity_votes.len() ,
|
||||
signed,
|
||||
);
|
||||
return Err(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user