Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Use a more typesafe approach for managing indexed data #6150

Merged
merged 46 commits into from
Oct 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
b5c02e8
Fix for issue #2403
tifecool Oct 13, 2022
954d392
Merge branch 'paritytech:master' into fix2403
tifecool Oct 13, 2022
ce8aba9
Nightly fmt
tifecool Oct 13, 2022
b5a7bfc
Quick documentation fixes
tifecool Oct 14, 2022
5da6693
Default Implementation
tifecool Oct 14, 2022
b90fc1e
iter() function integrated
tifecool Oct 14, 2022
557eebb
Implemented iter functionalities
tifecool Oct 15, 2022
09cc765
Fmt
tifecool Oct 15, 2022
3a6e327
small change
tifecool Oct 15, 2022
aba5837
updates node-network
tifecool Oct 15, 2022
dbac388
updates in dispute-coordinator
tifecool Oct 16, 2022
f1b8b4f
Updates
tifecool Oct 18, 2022
8696f93
benchmarking fix
tifecool Oct 18, 2022
4d10ca1
minor fix
tifecool Oct 18, 2022
95a3881
test fixes in runtime api
tifecool Oct 18, 2022
71fc436
Merge branch 'paritytech:master' into fix2403
tifecool Oct 18, 2022
4951b54
Update primitives/src/v2/mod.rs
tifecool Oct 19, 2022
35c1304
Update primitives/src/v2/mod.rs
tifecool Oct 19, 2022
a0edab4
Update primitives/src/v2/mod.rs
tifecool Oct 19, 2022
3823be1
Update primitives/src/v2/mod.rs
tifecool Oct 19, 2022
5714ad4
Update primitives/src/v2/mod.rs
tifecool Oct 19, 2022
7a8be34
Removal of [index], shorting of FromIterator, Renaming of GroupValida…
tifecool Oct 19, 2022
c3a1e72
Merge remote-tracking branch 'origin/fix2403' into fix2403
tifecool Oct 19, 2022
56b3904
Removal of ops import
tifecool Oct 19, 2022
a0bb41b
documentation fixes for spell check
tifecool Oct 19, 2022
ef5438c
implementation of generic type
tifecool Oct 20, 2022
4e825d0
Refactoring
tifecool Oct 21, 2022
f127cb4
Test and documentation fixes
tifecool Oct 21, 2022
06ecd6a
minor test fix
tifecool Oct 21, 2022
efa2278
minor test fix
tifecool Oct 21, 2022
cfca9b4
minor test fix
tifecool Oct 21, 2022
e6f685f
Update node/network/statement-distribution/src/lib.rs
tifecool Oct 21, 2022
33e3102
Update primitives/src/v2/mod.rs
tifecool Oct 21, 2022
e4d548b
Update primitives/src/v2/mod.rs
tifecool Oct 21, 2022
dee6396
removed IterMut
tifecool Oct 21, 2022
956a62e
Update node/core/dispute-coordinator/src/import.rs
tifecool Oct 21, 2022
1aba477
Update node/core/dispute-coordinator/src/initialized.rs
tifecool Oct 21, 2022
9025b12
Merge remote-tracking branch 'origin/fix2403' into fix2403
tifecool Oct 21, 2022
37cccf6
Update primitives/src/v2/mod.rs
tifecool Oct 21, 2022
f03adc0
fmt
tifecool Oct 21, 2022
bdc316c
IterMut
tifecool Oct 21, 2022
5ca768f
documentation update
tifecool Oct 21, 2022
2ee57d4
minor adjustments and new TypeIndex trait
tifecool Oct 21, 2022
be785f9
Merge remote-tracking branch 'origin/fix2403' into fix2403
tifecool Oct 21, 2022
6d87954
spelling fix
tifecool Oct 21, 2022
a2ae881
TypeIndex fix
tifecool Oct 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
updates node-network
  • Loading branch information
tifecool committed Oct 15, 2022
commit aba583708764cde2f037914c961bb0267a51e2f1
4 changes: 2 additions & 2 deletions node/network/dispute-distribution/src/sender/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ impl DisputeSender {
let valid_public = info
.session_info
.validators
.get(valid_index.0 as usize)
.get(*valid_index)
.ok_or(JfyiError::InvalidStatementFromCoordinator)?;
let valid_signed = SignedDisputeStatement::new_checked(
DisputeStatement::Valid(kind.clone()),
Expand All @@ -314,7 +314,7 @@ impl DisputeSender {
let invalid_public = info
.session_info
.validators
.get(invalid_index.0 as usize)
.get(*invalid_index)
.ok_or(JfyiError::InvalidValidatorIndexFromCoordinator)?;
let invalid_signed = SignedDisputeStatement::new_checked(
DisputeStatement::Invalid(kind.clone()),
Expand Down
6 changes: 3 additions & 3 deletions node/network/dispute-distribution/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub static ref MOCK_SESSION_INFO: SessionInfo =
.map(|k| MOCK_VALIDATORS_DISCOVERY_KEYS.get(&k).unwrap().clone())
.collect(),
assignment_keys: vec![],
validator_groups: vec![],
validator_groups: Default::default(),
n_cores: 0,
zeroth_delay_tranche_width: 0,
relay_vrf_modulo_samples: 0,
Expand All @@ -104,9 +104,9 @@ pub static ref MOCK_NEXT_SESSION_INFO: SessionInfo =
.iter()
.map(|k| MOCK_VALIDATORS_DISCOVERY_KEYS.get(&k).unwrap().clone())
.collect(),
validators: vec![],
validators: Default::default(),
assignment_keys: vec![],
validator_groups: vec![],
validator_groups: Default::default(),
n_cores: 0,
zeroth_delay_tranche_width: 0,
relay_vrf_modulo_samples: 0,
Expand Down
14 changes: 5 additions & 9 deletions node/network/statement-distribution/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ use polkadot_node_subsystem::{
overseer, ActiveLeavesUpdate, FromOrchestra, OverseerSignal, PerLeafSpan, SpawnedSubsystem,
SubsystemError,
};
use polkadot_primitives::v2::{
AuthorityDiscoveryId, CandidateHash, CommittedCandidateReceipt, CompactStatement, Hash,
SignedStatement, SigningContext, UncheckedSignedStatement, ValidatorId, ValidatorIndex,
ValidatorSignature,
};
use polkadot_primitives::v2::{AuthorityDiscoveryId, CandidateHash, CommittedCandidateReceipt, CompactStatement, Hash, SignedStatement, SigningContext, UncheckedSignedStatement, ValidatorIndex, Validators, ValidatorSignature};

use futures::{
channel::{mpsc, oneshot},
Expand Down Expand Up @@ -665,7 +661,7 @@ struct ActiveHeadData {
/// Large statements we are waiting for with associated meta data.
waiting_large_statements: HashMap<CandidateHash, LargeStatementStatus>,
/// The parachain validators at the head's child session index.
validators: Vec<ValidatorId>,
validators: Validators,
/// The current session index of this fork.
session_index: sp_staking::SessionIndex,
/// How many `Seconded` statements we've seen per validator.
Expand All @@ -676,7 +672,7 @@ struct ActiveHeadData {

impl ActiveHeadData {
fn new(
validators: Vec<ValidatorId>,
validators: Validators,
session_index: sp_staking::SessionIndex,
span: PerLeafSpan,
) -> Self {
Expand Down Expand Up @@ -878,7 +874,7 @@ fn check_statement_signature(
SigningContext { session_index: head.session_index, parent_hash: relay_parent };

head.validators
.get(statement.unchecked_validator_index().0 as usize)
.get(statement.unchecked_validator_index())
.ok_or_else(|| statement.clone())
.and_then(|v| statement.try_into_checked(&signing_context, v))
}
Expand Down Expand Up @@ -2072,7 +2068,7 @@ impl<R: rand::Rng> StatementDistributionSubsystem<R> {
// directly:
let group_peers = {
if let Some(our_group) = validator_info.our_group {
let our_group = &session_info.validator_groups[our_group.0 as usize];
let our_group = &session_info.validator_groups[our_group];

our_group
.into_iter()
Expand Down
8 changes: 4 additions & 4 deletions node/network/statement-distribution/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use polkadot_node_subsystem::{
ActivatedLeaf, LeafStatus,
};
use polkadot_node_subsystem_test_helpers::mock::make_ferdie_keystore;
use polkadot_primitives::v2::{Hash, Id as ParaId, SessionInfo, ValidationCode};
use polkadot_primitives::v2::{GroupValidators, Hash, Id as ParaId, SessionInfo, ValidationCode, ValidatorId};
use polkadot_primitives_test_helpers::{
dummy_committed_candidate_receipt, dummy_hash, AlwaysZeroRng,
};
Expand Down Expand Up @@ -83,7 +83,7 @@ fn active_head_accepts_only_2_seconded_per_validator() {
};

let mut head_data = ActiveHeadData::new(
validators,
Validators::from(validators),
session_index,
PerLeafSpan::new(Arc::new(jaeger::Span::Disabled), "test"),
);
Expand Down Expand Up @@ -429,7 +429,7 @@ fn peer_view_update_sends_messages() {

let new_head_data = {
let mut data = ActiveHeadData::new(
validators,
Validators::from(validators),
session_index,
PerLeafSpan::new(Arc::new(jaeger::Span::Disabled), "test"),
);
Expand Down Expand Up @@ -2319,7 +2319,7 @@ fn handle_multiple_seconded_statements() {
}

fn make_session_info(validators: Vec<Pair>, groups: Vec<Vec<u32>>) -> SessionInfo {
let validator_groups: Vec<Vec<ValidatorIndex>> = groups
let validator_groups: GroupValidators = groups
.iter()
.map(|g| g.into_iter().map(|v| ValidatorIndex(*v)).collect())
.collect();
Expand Down