-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Implement StorageNMap #8635
Implement StorageNMap #8635
Changes from 23 commits
8456583
a52724a
42513d2
a89bf41
6b17d09
09b34ab
976e337
09be192
54b38e7
a3b48a7
69fbed3
d5598e5
bbf8459
9fbf1ad
275f5a5
7686c7b
b83dbf2
994e170
c3e4b9f
55c8544
c0b1516
fdc3e13
c041a6c
ce13f5e
1aeda76
3671857
707cf45
6e264ef
e8f9740
2ff4de0
f75bc5a
02b7ce3
e142267
dbcb1f6
d207d77
f259f46
b081885
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 |
|---|---|---|
|
|
@@ -300,6 +300,11 @@ pub enum StorageEntryType { | |
| value: DecodeDifferentStr, | ||
| key2_hasher: StorageHasher, | ||
| }, | ||
| NMap { | ||
| keys: DecodeDifferentArray<&'static str, StringBuf>, | ||
| hashers: DecodeDifferentArray<StorageHasher>, | ||
| value: DecodeDifferentStr, | ||
| }, | ||
|
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. I think we should bump the metadata version. Because third-parties won't be able to make sense of this new variant. Thus releasing RuntimeMetadataV13: diff --git a/frame/metadata/src/lib.rs b/frame/metadata/src/lib.rs
index a502af0798..ba232a88f1 100644
--- a/frame/metadata/src/lib.rs
+++ b/frame/metadata/src/lib.rs
@@ -369,8 +369,10 @@ pub enum RuntimeMetadata {
V10(RuntimeMetadataDeprecated),
/// Version 11 for runtime metadata. No longer used.
V11(RuntimeMetadataDeprecated),
- /// Version 12 for runtime metadata.
- V12(RuntimeMetadataV12),
+ /// Version 12 for runtime metadata. No longer used.
+ V12(RuntimeMetadataDeprecated),
+ /// Version 13 for runtime metadata.
+ V13(RuntimeMetadataV13),
}
/// Enum that should fail.
@@ -394,7 +396,7 @@ impl Decode for RuntimeMetadataDeprecated {
/// The metadata of a runtime.
#[derive(Eq, Encode, PartialEq, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
-pub struct RuntimeMetadataV12 {
+pub struct RuntimeMetadataV13 {
/// Metadata of all the modules.
pub modules: DecodeDifferentArray<ModuleMetadata>,
/// Metadata of the extrinsic.
@@ -402,7 +404,7 @@ pub struct RuntimeMetadataV12 {
}
/// The latest version of the metadata.
-pub type RuntimeMetadataLastVersion = RuntimeMetadataV12;
+pub type RuntimeMetadataLastVersion = RuntimeMetadataV13;
/// All metadata about an runtime module.
#[derive(Clone, PartialEq, Eq, Encode, RuntimeDebug)]
@@ -430,6 +432,6 @@ impl Into<sp_core::OpaqueMetadata> for RuntimeMetadataPrefixed {
impl Into<RuntimeMetadataPrefixed> for RuntimeMetadataLastVersion {
fn into(self) -> RuntimeMetadataPrefixed {
- RuntimeMetadataPrefixed(META_RESERVED, RuntimeMetadata::V12(self))
+ RuntimeMetadataPrefixed(META_RESERVED, RuntimeMetadata::V13(self))
}
}Also we could remove other variant as they can all be expressed as a NMap but I think it is better for compatibility to keep them (basically (Also it would make more sense to have something like
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. Ok. This is the first I have seen this. This is a major revamp on my side for everything storage related.
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. But yes, this is correct bumping - with metadata you can just change at will - it needs a bump to avoid issue like we have in the v9-late iteration metadata.
Member
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. @jacogr we wont spring anything on you here. This should be unused in the runtime for now, and might only get used in assets in the near future for a triple map.
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. That is fine, appreciate it. Do bear in mind that once merged, it does immediately make Substrate master non-supported (if any enum changes are made to the storage descriptors or the metadata version is bumped), even if unused in practice. |
||
| } | ||
|
|
||
| /// A storage entry modifier. | ||
|
|
@@ -364,8 +369,10 @@ pub enum RuntimeMetadata { | |
| V10(RuntimeMetadataDeprecated), | ||
| /// Version 11 for runtime metadata. No longer used. | ||
| V11(RuntimeMetadataDeprecated), | ||
| /// Version 12 for runtime metadata. | ||
| V12(RuntimeMetadataV12), | ||
| /// Version 12 for runtime metadata. No longer used. | ||
| V12(RuntimeMetadataDeprecated), | ||
| /// Version 13 for runtime metadata. | ||
| V13(RuntimeMetadataV13), | ||
| } | ||
|
|
||
| /// Enum that should fail. | ||
|
|
@@ -389,15 +396,15 @@ impl Decode for RuntimeMetadataDeprecated { | |
| /// The metadata of a runtime. | ||
| #[derive(Eq, Encode, PartialEq, RuntimeDebug)] | ||
| #[cfg_attr(feature = "std", derive(Decode, Serialize))] | ||
| pub struct RuntimeMetadataV12 { | ||
| pub struct RuntimeMetadataV13 { | ||
| /// Metadata of all the modules. | ||
| pub modules: DecodeDifferentArray<ModuleMetadata>, | ||
| /// Metadata of the extrinsic. | ||
| pub extrinsic: ExtrinsicMetadata, | ||
| } | ||
|
|
||
| /// The latest version of the metadata. | ||
| pub type RuntimeMetadataLastVersion = RuntimeMetadataV12; | ||
| pub type RuntimeMetadataLastVersion = RuntimeMetadataV13; | ||
|
|
||
| /// All metadata about an runtime module. | ||
| #[derive(Clone, PartialEq, Eq, Encode, RuntimeDebug)] | ||
|
|
@@ -425,6 +432,6 @@ impl Into<sp_core::OpaqueMetadata> for RuntimeMetadataPrefixed { | |
|
|
||
| impl Into<RuntimeMetadataPrefixed> for RuntimeMetadataLastVersion { | ||
| fn into(self) -> RuntimeMetadataPrefixed { | ||
| RuntimeMetadataPrefixed(META_RESERVED, RuntimeMetadata::V12(self)) | ||
| RuntimeMetadataPrefixed(META_RESERVED, RuntimeMetadata::V13(self)) | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.