-
Notifications
You must be signed in to change notification settings - Fork 47
refactor: migrate runtime storage Vec, BTreeSet, BTreeMap to their bounded versions #228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
913d46b
29f8e78
ca92b10
7882dc7
6ad5961
8b1d5b5
1571513
e720d19
b8b7f94
f3f859d
e4b85f5
1c350d5
a555fa8
64d46bc
e7a526a
ac73fb7
a47eac2
84c93d0
3a61f3e
7e83fa5
ebe38e3
00f8d80
0553b90
f1dac50
080c93f
d166529
b90ed76
a807d3f
5120472
038677c
158c0cc
1201ef8
522c885
77b653b
3bb2acc
54d17ce
7ffd5ab
cf09493
c0422cb
9b92141
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,7 @@ use crate::*; | |
| use ctype::mock as ctype_mock; | ||
|
|
||
| use codec::Decode; | ||
| use frame_support::{ensure, parameter_types, weights::constants::RocksDbWeight}; | ||
| use frame_support::{ensure, parameter_types, weights::constants::RocksDbWeight, BoundedVec}; | ||
| use frame_system::EnsureSigned; | ||
| use sp_core::{ed25519, sr25519, Pair}; | ||
| use sp_keystore::{testing::KeyStore, KeystoreExt}; | ||
|
|
@@ -100,6 +100,8 @@ parameter_types! { | |
| pub const MaxSignatureByteLength: u16 = 64; | ||
| pub const MaxParentChecks: u32 = 5; | ||
| pub const MaxRevocations: u32 = 5; | ||
| #[derive(Clone)] | ||
|
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 feel like deriving You will notice a bunch of these more below. I just commented here because this is the first occasion.
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. interesting. The thing here is that this is not a "normal" const but a new type called
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. Yes. But why though? Shouldn't this be implemented by default if the type is a |
||
| pub const MaxChildren: u32 = 1000; | ||
| } | ||
|
|
||
| impl delegation::Config for Test { | ||
|
|
@@ -111,13 +113,20 @@ impl delegation::Config for Test { | |
| type MaxSignatureByteLength = MaxSignatureByteLength; | ||
| type MaxParentChecks = MaxParentChecks; | ||
| type MaxRevocations = MaxRevocations; | ||
| type MaxChildren = MaxChildren; | ||
| type WeightInfo = (); | ||
| } | ||
|
|
||
| parameter_types! { | ||
| // TODO: Find reasonable number | ||
| pub const MaxDelegatedAttestations: u32 = 1000; | ||
| } | ||
|
|
||
| impl Config for Test { | ||
| type EnsureOrigin = EnsureSigned<TestAttester>; | ||
| type Event = (); | ||
| type WeightInfo = (); | ||
| type MaxDelegatedAttestations = MaxDelegatedAttestations; | ||
| } | ||
|
|
||
| impl delegation::VerifyDelegateSignature for Test { | ||
|
|
@@ -227,7 +236,10 @@ pub fn generate_base_attestation(attester: TestAttester) -> AttestationDetails<T | |
| #[derive(Clone)] | ||
| pub struct ExtBuilder { | ||
| attestations_stored: Vec<(TestClaimHash, AttestationDetails<Test>)>, | ||
| delegated_attestations_stored: Vec<(TestDelegationNodeId, Vec<TestClaimHash>)>, | ||
| delegated_attestations_stored: Vec<( | ||
| TestDelegationNodeId, | ||
| BoundedVec<TestClaimHash, <Test as Config>::MaxDelegatedAttestations>, | ||
| )>, | ||
| } | ||
|
|
||
| impl Default for ExtBuilder { | ||
|
|
@@ -247,7 +259,10 @@ impl ExtBuilder { | |
|
|
||
| pub fn with_delegated_attestations( | ||
| mut self, | ||
| delegated_attestations: Vec<(TestDelegationNodeId, Vec<TestClaimHash>)>, | ||
| delegated_attestations: Vec<( | ||
| TestDelegationNodeId, | ||
| BoundedVec<TestClaimHash, <Test as Config>::MaxDelegatedAttestations>, | ||
| )>, | ||
| ) -> Self { | ||
| self.delegated_attestations_stored = delegated_attestations; | ||
| self | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.