mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-20 14:01:02 +00:00
Runtime: allow backing multiple candidates of same parachain on different cores (#3231)
Fixes https://github.com/paritytech/polkadot-sdk/issues/3144 Builds on top of https://github.com/paritytech/polkadot-sdk/pull/3229 ### Summary Some preparations for Runtime to support elastic scaling, guarded by config node features bit `FeatureIndex::ElasticScalingMVP`. This PR introduces a per-candidate `CoreIndex` but does it in a hacky way to avoid changing `CandidateCommitments`, `CandidateReceipts` primitives and networking protocols. #### Including `CoreIndex` in `BackedCandidate` If the `ElasticScalingMVP` feature bit is enabled then `BackedCandidate::validator_indices` is extended by 8 bits. The value stored in these bits represents the assumed core index for the candidate. It is temporary solution which works by creating a mapping from `BackedCandidate` to `CoreIndex` by assuming the `CoreIndex` can be discovered by checking in which validator group the validator that signed the statement is. TODO: - [x] fix tests - [x] add new tests - [x] Bump runtime API for Kusama, so we have that node features thing! -> https://github.com/polkadot-fellows/runtimes/pull/194 --------- 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:
@@ -766,7 +766,7 @@ async fn select_candidates(
|
||||
// keep only one candidate with validation code.
|
||||
let mut with_validation_code = false;
|
||||
candidates.retain(|c| {
|
||||
if c.candidate.commitments.new_validation_code.is_some() {
|
||||
if c.candidate().commitments.new_validation_code.is_some() {
|
||||
if with_validation_code {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -460,13 +460,16 @@ mod select_candidates {
|
||||
|
||||
let expected_backed = expected_candidates
|
||||
.iter()
|
||||
.map(|c| BackedCandidate {
|
||||
candidate: CommittedCandidateReceipt {
|
||||
descriptor: c.descriptor.clone(),
|
||||
commitments: Default::default(),
|
||||
},
|
||||
validity_votes: Vec::new(),
|
||||
validator_indices: default_bitvec(MOCK_GROUP_SIZE),
|
||||
.map(|c| {
|
||||
BackedCandidate::new(
|
||||
CommittedCandidateReceipt {
|
||||
descriptor: c.descriptor().clone(),
|
||||
commitments: Default::default(),
|
||||
},
|
||||
Vec::new(),
|
||||
default_bitvec(MOCK_GROUP_SIZE),
|
||||
None,
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
|
||||
@@ -486,7 +489,7 @@ mod select_candidates {
|
||||
|
||||
result.into_iter().for_each(|c| {
|
||||
assert!(
|
||||
expected_candidates.iter().any(|c2| c.candidate.corresponds_to(c2)),
|
||||
expected_candidates.iter().any(|c2| c.candidate().corresponds_to(c2)),
|
||||
"Failed to find candidate: {:?}",
|
||||
c,
|
||||
)
|
||||
@@ -532,10 +535,13 @@ mod select_candidates {
|
||||
// Build possible outputs from select_candidates
|
||||
let backed_candidates: Vec<_> = committed_receipts
|
||||
.iter()
|
||||
.map(|committed_receipt| BackedCandidate {
|
||||
candidate: committed_receipt.clone(),
|
||||
validity_votes: Vec::new(),
|
||||
validator_indices: default_bitvec(MOCK_GROUP_SIZE),
|
||||
.map(|committed_receipt| {
|
||||
BackedCandidate::new(
|
||||
committed_receipt.clone(),
|
||||
Vec::new(),
|
||||
default_bitvec(MOCK_GROUP_SIZE),
|
||||
None,
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
|
||||
@@ -566,7 +572,7 @@ mod select_candidates {
|
||||
|
||||
result.into_iter().for_each(|c| {
|
||||
assert!(
|
||||
expected_backed_filtered.iter().any(|c2| c.candidate.corresponds_to(c2)),
|
||||
expected_backed_filtered.iter().any(|c2| c.candidate().corresponds_to(c2)),
|
||||
"Failed to find candidate: {:?}",
|
||||
c,
|
||||
)
|
||||
@@ -605,13 +611,16 @@ mod select_candidates {
|
||||
|
||||
let expected_backed = expected_candidates
|
||||
.iter()
|
||||
.map(|c| BackedCandidate {
|
||||
candidate: CommittedCandidateReceipt {
|
||||
descriptor: c.descriptor.clone(),
|
||||
commitments: Default::default(),
|
||||
},
|
||||
validity_votes: Vec::new(),
|
||||
validator_indices: default_bitvec(MOCK_GROUP_SIZE),
|
||||
.map(|c| {
|
||||
BackedCandidate::new(
|
||||
CommittedCandidateReceipt {
|
||||
descriptor: c.descriptor.clone(),
|
||||
commitments: Default::default(),
|
||||
},
|
||||
Vec::new(),
|
||||
default_bitvec(MOCK_GROUP_SIZE),
|
||||
None,
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
|
||||
@@ -631,7 +640,7 @@ mod select_candidates {
|
||||
|
||||
result.into_iter().for_each(|c| {
|
||||
assert!(
|
||||
expected_candidates.iter().any(|c2| c.candidate.corresponds_to(c2)),
|
||||
expected_candidates.iter().any(|c2| c.candidate().corresponds_to(c2)),
|
||||
"Failed to find candidate: {:?}",
|
||||
c,
|
||||
)
|
||||
@@ -671,13 +680,16 @@ mod select_candidates {
|
||||
|
||||
let expected_backed = expected_candidates
|
||||
.iter()
|
||||
.map(|c| BackedCandidate {
|
||||
candidate: CommittedCandidateReceipt {
|
||||
descriptor: c.descriptor.clone(),
|
||||
commitments: Default::default(),
|
||||
},
|
||||
validity_votes: Vec::new(),
|
||||
validator_indices: default_bitvec(MOCK_GROUP_SIZE),
|
||||
.map(|c| {
|
||||
BackedCandidate::new(
|
||||
CommittedCandidateReceipt {
|
||||
descriptor: c.descriptor().clone(),
|
||||
commitments: Default::default(),
|
||||
},
|
||||
Vec::new(),
|
||||
default_bitvec(MOCK_GROUP_SIZE),
|
||||
None,
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
|
||||
@@ -697,7 +709,7 @@ mod select_candidates {
|
||||
|
||||
result.into_iter().for_each(|c| {
|
||||
assert!(
|
||||
expected_candidates.iter().any(|c2| c.candidate.corresponds_to(c2)),
|
||||
expected_candidates.iter().any(|c2| c.candidate().corresponds_to(c2)),
|
||||
"Failed to find candidate: {:?}",
|
||||
c,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user