This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Use a more typesafe approach for managing indexed data #5503
Closed
Closed
Changes from 30 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
41a64b8
typed-index crate
tifecool 53ede12
Implementation of TypeIndex for validators (TypeInfo implementation p…
tifecool 927900f
Merge branch 'paritytech:master' into fix2403
tifecool 0531b9d
Temporary Fix
tifecool 4db6034
Temp
tifecool 5b5875a
Merge branch 'paritytech:master' into fix2403
tifecool 1864bfd
Util methods updated
tifecool ea5ff34
Merge remote-tracking branch 'origin/fix2403' into fix2403
tifecool 9cf63d2
Removed Into trait
tifecool e0c332f
Updated Tests
tifecool 3fd4e1c
Fixed split_active_subset function
tifecool 4f8f464
Added TypeVec implementation for validator_groups and updated tests.
tifecool 8d89add
nightly fmt
tifecool 1ca2a12
Merge branch 'master' into fix2403
tifecool 3525a4e
Merge branch 'master' into fix2403
tifecool 731bd7a
TypeVec From Vec consumes vector
tifecool 72087ec
_usize & _u32 implementation over as implementation
tifecool 176800c
minor adjustments
tifecool 8d9a856
Fixes and nightly fmt
tifecool 49ebd7a
Struct and function documentation
tifecool 6e459e1
Merge branch 'master' into fix2403
tifecool d3ebca9
update
tifecool a601db8
fmt
tifecool d51852f
reward_points.rs updated
tifecool d4a584c
Merge branch 'master' into fix2403
tifecool ff5a99e
Cargo.lock fix
tifecool c51ca88
polkadot lib.rs fix
tifecool 6343736
polkadot lib.rs fix
tifecool dcd6e8e
Merge remote-tracking branch 'origin/fix2403' into fix2403
tifecool e441256
fmt
tifecool 5ff6d05
Merge branch 'master' into fix2403
tifecool 6ed1f84
FromVec update
tifecool 42883ec
MallocSizeOf update
tifecool File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
|
@@ -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. | ||
|
|
@@ -631,10 +632,10 @@ mod tests { | |
| Sr25519Keyring::Bob, | ||
| Sr25519Keyring::Charlie, | ||
| ]), | ||
| validator_groups: vec![ | ||
| validator_groups: TypeVec::from(vec![ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should consider adding a custom macro that resembles the ergonomy of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
|
|
@@ -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, | ||
|
|
@@ -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, | ||
|
|
@@ -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, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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"] } | ||
|
|
@@ -54,5 +55,6 @@ std = [ | |
| "polkadot-core-primitives/std", | ||
| "bitvec/std", | ||
| "frame-system/std", | ||
| "typed-index-collections/std" | ||
| ] | ||
| runtime-benchmarks = [] | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated change
There was a problem hiding this comment.
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:
And on debugging saw the as_ref() made no difference to the object.