Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
41a64b8
typed-index crate
tifecool Apr 23, 2022
53ede12
Implementation of TypeIndex for validators (TypeInfo implementation p…
tifecool Apr 27, 2022
927900f
Merge branch 'paritytech:master' into fix2403
tifecool Apr 27, 2022
0531b9d
Temporary Fix
tifecool Apr 27, 2022
4db6034
Temp
tifecool Apr 29, 2022
5b5875a
Merge branch 'paritytech:master' into fix2403
tifecool Apr 29, 2022
1864bfd
Util methods updated
tifecool May 4, 2022
ea5ff34
Merge remote-tracking branch 'origin/fix2403' into fix2403
tifecool May 4, 2022
9cf63d2
Removed Into trait
tifecool May 8, 2022
e0c332f
Updated Tests
tifecool May 8, 2022
3fd4e1c
Fixed split_active_subset function
tifecool May 9, 2022
4f8f464
Added TypeVec implementation for validator_groups and updated tests.
tifecool May 11, 2022
8d89add
nightly fmt
tifecool May 11, 2022
1ca2a12
Merge branch 'master' into fix2403
tifecool May 11, 2022
3525a4e
Merge branch 'master' into fix2403
tifecool May 14, 2022
731bd7a
TypeVec From Vec consumes vector
tifecool May 14, 2022
72087ec
_usize & _u32 implementation over as implementation
tifecool May 15, 2022
176800c
minor adjustments
tifecool May 15, 2022
8d9a856
Fixes and nightly fmt
tifecool May 15, 2022
49ebd7a
Struct and function documentation
tifecool May 15, 2022
6e459e1
Merge branch 'master' into fix2403
tifecool May 17, 2022
d3ebca9
update
tifecool May 17, 2022
a601db8
fmt
tifecool May 17, 2022
d51852f
reward_points.rs updated
tifecool May 17, 2022
d4a584c
Merge branch 'master' into fix2403
tifecool May 19, 2022
ff5a99e
Cargo.lock fix
tifecool May 19, 2022
c51ca88
polkadot lib.rs fix
tifecool May 19, 2022
6343736
polkadot lib.rs fix
tifecool May 19, 2022
dcd6e8e
Merge remote-tracking branch 'origin/fix2403' into fix2403
tifecool May 19, 2022
e441256
fmt
tifecool May 19, 2022
5ff6d05
Merge branch 'master' into fix2403
tifecool May 20, 2022
6ed1f84
FromVec update
tifecool May 20, 2022
42883ec
MallocSizeOf update
tifecool May 25, 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
354 changes: 182 additions & 172 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion erasure-coding/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ where
// construct trie mapping each chunk's index to its hash.
{
let mut trie = TrieDBMut::new(&mut trie_storage, &mut root);
for (i, chunk) in chunks.as_ref().iter().enumerate() {
for (i, chunk) in chunks.iter().enumerate() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated change

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was getting this error:

error[E0282]: type annotations needed
   --> erasure-coding/src/lib.rs:261:28
    |
261 |         for (i, chunk) in chunks.as_ref().iter().enumerate() {
    |                           -------^^^^^^--
    |                           |      |
    |                           |      cannot infer type for type parameter `T` declared on the trait `AsRef`
    |                           this method call resolves to `&T`
    |
    = note: type must be known at this point

And on debugging saw the as_ref() made no difference to the object.

(i as u32).using_encoded(|encoded_index| {
let chunk_hash = BlakeTwo256::hash(chunk.as_ref());
trie.insert(encoded_index, chunk_hash.as_ref())
Expand Down
17 changes: 9 additions & 8 deletions node/core/approval-voting/src/criteria.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ use polkadot_node_primitives::approval::{
self as approval_types, AssignmentCert, AssignmentCertKind, DelayTranche, RelayVRFStory,
};
use polkadot_primitives::v2::{
AssignmentId, AssignmentPair, CandidateHash, CoreIndex, GroupIndex, SessionInfo, ValidatorIndex,
AssignmentId, AssignmentPair, CandidateHash, CoreIndex, GroupIndex, SessionInfo, TypeVec,
ValidatorIndex,
};
use sc_keystore::LocalKeystore;
use sp_application_crypto::ByteArray;
Expand Down Expand Up @@ -138,7 +139,7 @@ pub(crate) struct Config {
/// The assignment public keys for validators.
assignment_keys: Vec<AssignmentId>,
/// The groups of validators assigned to each core.
validator_groups: Vec<Vec<ValidatorIndex>>,
validator_groups: TypeVec<GroupIndex, Vec<ValidatorIndex>>,
/// The number of availability cores used by the protocol during this session.
n_cores: u32,
/// The zeroth delay tranche width.
Expand Down Expand Up @@ -631,10 +632,10 @@ mod tests {
Sr25519Keyring::Bob,
Sr25519Keyring::Charlie,
]),
validator_groups: vec![
validator_groups: TypeVec::from(vec![
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should consider adding a custom macro that resembles the ergonomy of vec![..]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't write macros.

vec![ValidatorIndex(0)],
vec![ValidatorIndex(1), ValidatorIndex(2)],
],
]),
n_cores: 2,
zeroth_delay_tranche_width: 10,
relay_vrf_modulo_samples: 3,
Expand Down Expand Up @@ -666,10 +667,10 @@ mod tests {
Sr25519Keyring::Bob,
Sr25519Keyring::Charlie,
]),
validator_groups: vec![
validator_groups: TypeVec::from(vec![
vec![ValidatorIndex(0)],
vec![ValidatorIndex(1), ValidatorIndex(2)],
],
]),
n_cores: 2,
zeroth_delay_tranche_width: 10,
relay_vrf_modulo_samples: 3,
Expand All @@ -696,7 +697,7 @@ mod tests {
Sr25519Keyring::Bob,
Sr25519Keyring::Charlie,
]),
validator_groups: vec![],
validator_groups: TypeVec::from(vec![]),
n_cores: 0,
zeroth_delay_tranche_width: 10,
relay_vrf_modulo_samples: 3,
Expand Down Expand Up @@ -733,7 +734,7 @@ mod tests {
&[Sr25519Keyring::Alice],
n_validators - 1,
),
validator_groups: basic_groups(n_validators, n_cores),
validator_groups: TypeVec::from(basic_groups(n_validators, n_cores)),
n_cores: n_cores as u32,
zeroth_delay_tranche_width: 10,
relay_vrf_modulo_samples: 3,
Expand Down
13 changes: 8 additions & 5 deletions node/core/approval-voting/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ pub(crate) mod tests {
use polkadot_node_subsystem::messages::{AllMessages, ApprovalVotingMessage};
use polkadot_node_subsystem_test_helpers::make_subsystem_context;
use polkadot_node_subsystem_util::database::Database;
use polkadot_primitives::v2::{Id as ParaId, SessionInfo, ValidatorIndex};
use polkadot_primitives::v2::{Id as ParaId, SessionInfo, TypeVec, ValidatorIndex};
pub(crate) use sp_consensus_babe::{
digests::{CompatibleDigestItem, PreDigest, SecondaryVRFPreDigest},
AllowedSlots, BabeEpochConfiguration, Epoch as BabeEpoch,
Expand Down Expand Up @@ -707,10 +707,10 @@ pub(crate) mod tests {

fn dummy_session_info(index: SessionIndex) -> SessionInfo {
SessionInfo {
validators: Vec::new(),
validators: TypeVec::new(),
discovery_keys: Vec::new(),
assignment_keys: Vec::new(),
validator_groups: Vec::new(),
validator_groups: TypeVec::new(),
n_cores: index as _,
zeroth_delay_tranche_width: index as _,
relay_vrf_modulo_samples: index as _,
Expand Down Expand Up @@ -1169,10 +1169,13 @@ pub(crate) mod tests {
let session = 5;
let irrelevant = 666;
let session_info = SessionInfo {
validators: vec![Sr25519Keyring::Alice.public().into(); 6],
validators: TypeVec::from(vec![Sr25519Keyring::Alice.public().into(); 6]),
discovery_keys: Vec::new(),
assignment_keys: Vec::new(),
validator_groups: vec![vec![ValidatorIndex(0); 5], vec![ValidatorIndex(0); 2]],
validator_groups: TypeVec::from(vec![
vec![ValidatorIndex(0); 5],
vec![ValidatorIndex(0); 2],
]),
n_cores: 6,
needed_approvals: 2,
zeroth_delay_tranche_width: irrelevant,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ impl SessionCache {
}
// Look up `AuthorityDiscoveryId`s right away:
let validator_groups: Vec<Vec<_>> = validator_groups
.to_vec()
.into_iter()
.map(|group| {
group
Expand Down
2 changes: 1 addition & 1 deletion node/network/availability-recovery/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ async fn launch_recovery_task<Context>(

let params = RecoveryParams {
validator_authority_keys: session_info.discovery_keys.clone(),
validators: session_info.validators.clone(),
validators: session_info.validators.clone().to_vec(),
threshold: recovery_threshold(session_info.validators.len())?,
candidate_hash,
erasure_root: receipt.descriptor.erasure_root,
Expand Down
15 changes: 8 additions & 7 deletions node/network/statement-distribution/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ use polkadot_node_network_protocol::{
use polkadot_node_primitives::{SignedFullStatement, Statement, UncheckedSignedFullStatement};
use polkadot_node_subsystem_util::{self as util, rand, MIN_GOSSIP_PEERS};

use polkadot_primitives::v2::{
AuthorityDiscoveryId, CandidateHash, CommittedCandidateReceipt, CompactStatement, Hash,
SignedStatement, SigningContext, TypeVec, UncheckedSignedStatement, ValidatorId,
ValidatorIndex, ValidatorSignature,
};

use polkadot_node_subsystem::{
jaeger,
messages::{
Expand All @@ -45,11 +51,6 @@ 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 futures::{
channel::{mpsc, oneshot},
Expand Down Expand Up @@ -665,7 +666,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: TypeVec<ValidatorIndex, ValidatorId>,
/// 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 +677,7 @@ struct ActiveHeadData {

impl ActiveHeadData {
fn new(
validators: Vec<ValidatorId>,
validators: TypeVec<ValidatorIndex, ValidatorId>,
session_index: sp_staking::SessionIndex,
span: PerLeafSpan,
) -> Self {
Expand Down
6 changes: 3 additions & 3 deletions node/subsystem-util/src/rolling_session_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,17 +284,17 @@ mod tests {
SubsystemContext,
};
use polkadot_node_subsystem_test_helpers::make_subsystem_context;
use polkadot_primitives::v2::Header;
use polkadot_primitives::v2::{Header, TypeVec};
use sp_core::testing::TaskExecutor;

pub const TEST_WINDOW_SIZE: SessionWindowSize = new_session_window_size!(6);

fn dummy_session_info(index: SessionIndex) -> SessionInfo {
SessionInfo {
validators: Vec::new(),
validators: TypeVec::new(),
discovery_keys: Vec::new(),
assignment_keys: Vec::new(),
validator_groups: Vec::new(),
validator_groups: TypeVec::new(),
n_cores: index as _,
zeroth_delay_tranche_width: index as _,
relay_vrf_modulo_samples: index as _,
Expand Down
2 changes: 2 additions & 0 deletions primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ authors = ["Parity Technologies <[email protected]>"]
edition = "2021"

[dependencies]
typed-index-collections = { version = "3.0.3", default-features = false, features = ["alloc","serde","serde-alloc"] }
serde = { version = "1.0.137", optional = true, features = ["derive"] }
scale-info = { version = "2.1.2", default-features = false, features = ["bit-vec", "derive"] }
parity-scale-codec = { version = "3.1.2", default-features = false, features = ["bit-vec", "derive"] }
Expand Down Expand Up @@ -54,5 +55,6 @@ std = [
"polkadot-core-primitives/std",
"bitvec/std",
"frame-system/std",
"typed-index-collections/std"
]
runtime-benchmarks = []
Loading