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:
Andrei Sandu
2024-02-23 23:35:48 +07:00
committed by GitHub
parent 6fc1d41d44
commit 2431001ec0
21 changed files with 1642 additions and 350 deletions
@@ -120,7 +120,7 @@ benchmarks! {
// with `v` validity votes.
// let votes = v as usize;
let votes = min(scheduler::Pallet::<T>::group_validators(GroupIndex::from(0)).unwrap().len(), v as usize);
assert_eq!(benchmark.backed_candidates.get(0).unwrap().validity_votes.len(), votes);
assert_eq!(benchmark.backed_candidates.get(0).unwrap().validity_votes().len(), votes);
benchmark.bitfields.clear();
benchmark.disputes.clear();
@@ -177,7 +177,7 @@ benchmarks! {
// There is 1 backed
assert_eq!(benchmark.backed_candidates.len(), 1);
assert_eq!(
benchmark.backed_candidates.get(0).unwrap().validity_votes.len(),
benchmark.backed_candidates.get(0).unwrap().validity_votes().len(),
votes,
);