Use a more typesafe approach for managing indexed data (#6150)

* Fix for issue #2403

* Nightly fmt

* Quick documentation fixes

* Default Implementation

* iter() function integrated

* Implemented iter functionalities

* Fmt

* small change

* updates node-network

* updates in dispute-coordinator

* Updates

* benchmarking fix

* minor fix

* test fixes in runtime api

* Update primitives/src/v2/mod.rs

Co-authored-by: Andronik <write@reusable.software>

* Update primitives/src/v2/mod.rs

Co-authored-by: Andronik <write@reusable.software>

* Update primitives/src/v2/mod.rs

Co-authored-by: Andronik <write@reusable.software>

* Update primitives/src/v2/mod.rs

Co-authored-by: Andronik <write@reusable.software>

* Update primitives/src/v2/mod.rs

Co-authored-by: Andronik <write@reusable.software>

* Removal of [index], shorting of FromIterator, Renaming of GroupValidators to ValidatorGroups

* Removal of ops import

* documentation fixes for spell check

* implementation of generic type

* Refactoring

* Test and documentation fixes

* minor test fix

* minor test fix

* minor test fix

* Update node/network/statement-distribution/src/lib.rs

Co-authored-by: Andronik <write@reusable.software>

* Update primitives/src/v2/mod.rs

Co-authored-by: Andronik <write@reusable.software>

* Update primitives/src/v2/mod.rs

Co-authored-by: Andronik <write@reusable.software>

* removed IterMut

* Update node/core/dispute-coordinator/src/import.rs

Co-authored-by: Andronik <write@reusable.software>

* Update node/core/dispute-coordinator/src/initialized.rs

Co-authored-by: Andronik <write@reusable.software>

* Update primitives/src/v2/mod.rs

Co-authored-by: Andronik <write@reusable.software>

* fmt

* IterMut

* documentation update

Co-authored-by: Andronik <write@reusable.software>

* minor adjustments and new TypeIndex trait

* spelling fix

* TypeIndex fix

Co-authored-by: Andronik <write@reusable.software>
This commit is contained in:
Boluwatife Bakre
2022-10-22 09:39:11 +01:00
committed by GitHub
parent f8cc39a761
commit 8eb1f4617f
28 changed files with 261 additions and 138 deletions
+19 -16
View File
@@ -32,7 +32,7 @@ use polkadot_node_subsystem_test_helpers as test_helpers;
use polkadot_node_subsystem_util::TimeoutExt;
use polkadot_overseer::HeadSupportsParachains;
use polkadot_primitives::v2::{
CandidateCommitments, CandidateEvent, CoreIndex, GroupIndex, Header, Id as ParaId,
CandidateCommitments, CandidateEvent, CoreIndex, GroupIndex, Header, Id as ParaId, IndexedVec,
ValidationCode, ValidatorSignature,
};
use std::time::Duration;
@@ -739,7 +739,10 @@ fn session_info(keys: &[Sr25519Keyring]) -> SessionInfo {
validators: keys.iter().map(|v| v.public().into()).collect(),
discovery_keys: keys.iter().map(|v| v.public().into()).collect(),
assignment_keys: keys.iter().map(|v| v.public().into()).collect(),
validator_groups: vec![vec![ValidatorIndex(0)], vec![ValidatorIndex(1)]],
validator_groups: IndexedVec::<GroupIndex, Vec<ValidatorIndex>>::from(vec![
vec![ValidatorIndex(0)],
vec![ValidatorIndex(1)],
]),
n_cores: keys.len() as _,
needed_approvals: 2,
zeroth_delay_tranche_width: 5,
@@ -1552,11 +1555,11 @@ fn subsystem_second_approval_import_only_schedules_wakeups() {
Sr25519Keyring::Eve,
];
let session_info = SessionInfo {
validator_groups: vec![
validator_groups: IndexedVec::<GroupIndex, Vec<ValidatorIndex>>::from(vec![
vec![ValidatorIndex(0), ValidatorIndex(1)],
vec![ValidatorIndex(2)],
vec![ValidatorIndex(3), ValidatorIndex(4)],
],
]),
needed_approvals: 1,
..session_info(&validators)
};
@@ -1889,11 +1892,11 @@ fn import_checked_approval_updates_entries_and_schedules() {
Sr25519Keyring::Eve,
];
let session_info = SessionInfo {
validator_groups: vec![
validator_groups: IndexedVec::<GroupIndex, Vec<ValidatorIndex>>::from(vec![
vec![ValidatorIndex(0), ValidatorIndex(1)],
vec![ValidatorIndex(2)],
vec![ValidatorIndex(3), ValidatorIndex(4)],
],
]),
..session_info(&validators)
};
@@ -2046,11 +2049,11 @@ fn subsystem_import_checked_approval_sets_one_block_bit_at_a_time() {
Sr25519Keyring::Eve,
];
let session_info = SessionInfo {
validator_groups: vec![
validator_groups: IndexedVec::<GroupIndex, Vec<ValidatorIndex>>::from(vec![
vec![ValidatorIndex(0), ValidatorIndex(1)],
vec![ValidatorIndex(2)],
vec![ValidatorIndex(3), ValidatorIndex(4)],
],
]),
..session_info(&validators)
};
@@ -2336,11 +2339,11 @@ fn subsystem_validate_approvals_cache() {
Sr25519Keyring::Eve,
];
let session_info = SessionInfo {
validator_groups: vec![
validator_groups: IndexedVec::<GroupIndex, Vec<ValidatorIndex>>::from(vec![
vec![ValidatorIndex(0), ValidatorIndex(1)],
vec![ValidatorIndex(2)],
vec![ValidatorIndex(3), ValidatorIndex(4)],
],
]),
..session_info(&validators)
};
@@ -2548,11 +2551,11 @@ where
Sr25519Keyring::Ferdie,
];
let session_info = SessionInfo {
validator_groups: vec![
validator_groups: IndexedVec::<GroupIndex, Vec<ValidatorIndex>>::from(vec![
vec![ValidatorIndex(0), ValidatorIndex(1)],
vec![ValidatorIndex(2), ValidatorIndex(3)],
vec![ValidatorIndex(4), ValidatorIndex(5)],
],
]),
relay_vrf_modulo_samples: 2,
no_show_slots,
..session_info(&validators)
@@ -2868,11 +2871,11 @@ fn pre_covers_dont_stall_approval() {
Sr25519Keyring::One,
];
let session_info = SessionInfo {
validator_groups: vec![
validator_groups: IndexedVec::<GroupIndex, Vec<ValidatorIndex>>::from(vec![
vec![ValidatorIndex(0), ValidatorIndex(1)],
vec![ValidatorIndex(2), ValidatorIndex(5)],
vec![ValidatorIndex(3), ValidatorIndex(4)],
],
]),
..session_info(&validators)
};
@@ -3045,11 +3048,11 @@ fn waits_until_approving_assignments_are_old_enough() {
Sr25519Keyring::One,
];
let session_info = SessionInfo {
validator_groups: vec![
validator_groups: IndexedVec::<GroupIndex, Vec<ValidatorIndex>>::from(vec![
vec![ValidatorIndex(0), ValidatorIndex(1)],
vec![ValidatorIndex(2), ValidatorIndex(5)],
vec![ValidatorIndex(3), ValidatorIndex(4)],
],
]),
..session_info(&validators)
};