Implement a proper generic resolution in decl_storage!#2913
Conversation
* remove default hash, introduce twox_128 and blake2 * use blake2_128 & create ext_blake2_128 * refactor code * add benchmark * factorize generator * fix * parameterizable hasher * some fix * fix * fix * fix * metadata * fix * remove debug print * map -> blake2_256 * fix test * fix test * Apply suggestions from code review Co-Authored-By: thiolliere <gui.thiolliere@gmail.com> * impl twox 128 concat (#2353) * impl twox_128_concat * comment addressed * fix * impl twox_128->64_concat * fix test
|
as a note the API change in the following way:
|
|
Thx for the extended summary :D
Yeah, I wanted to have it the same way, as it would be in a manual implementation.
This does not break homogeneity, we already could have
You could also have |
gui1117
left a comment
There was a problem hiding this comment.
great PR :-) there is just assimilate_require_generic I have to review again but otherwise everything looks good
| ($module::Origin < $( $generic, )? $( $module::$generic_instance )? > ), | ||
| )* | ||
| #[allow(dead_code)] | ||
| Void($crate::Void) |
There was a problem hiding this comment.
do you remember what this was for ?
There was a problem hiding this comment.
I mean I removed it and all test compiles
There was a problem hiding this comment.
Good question, but I don't really know it and would rather like to keep it for the moment.^^
| @@ -634,14 +689,31 @@ impl<'a, I: Iterator<Item=syn::Meta>> Impls<'a, I> { | |||
| quote!{ #prefix.as_bytes() } | |||
| }; | |||
There was a problem hiding this comment.
now that you generate a inherent instance you could make use of it to factorize this if condition like, maybe even renaming changing prefix and having such condition in transformation.rs but whatever I might take look after and all in all it is fine at the moment.
|
@thiolliere addressed your feedback :) |
|
Yes changes looks good I can approve or do a final review on tuesday. Also we might want to update decl_storage doc, as the stucture is no longer always generic. And I was thinking does it make sense to talk about assimilate storage stuff ? I mean it is for used when writing test for your modules, but I think it is something that ppl want to know, though I'm not sure and could added in a second time as it doesn't exist yet. |
Tuesday is okay.
Good point.
You mean the function |
|
did the final review happen? |
|
Not yet. |
Yes I know construct_runtime handle that you, but someone that create a modules will make use of it for its testing so he wants to be aware of subtelties (though everything is in the generated doc) |
…s error: missing field `_genesis_phantom_data` in initializer of `groups::GenesisConfig<groups::tests::GroupsTest>` Probably related to this: paritytech/substrate#2913 and Issue #2219
…2913) * Add failing test case * move storage maps to blake2_128 (paritytech#2268) * remove default hash, introduce twox_128 and blake2 * use blake2_128 & create ext_blake2_128 * refactor code * add benchmark * factorize generator * fix * parameterizable hasher * some fix * fix * fix * fix * metadata * fix * remove debug print * map -> blake2_256 * fix test * fix test * Apply suggestions from code review Co-Authored-By: thiolliere <gui.thiolliere@gmail.com> * impl twox 128 concat (paritytech#2353) * impl twox_128_concat * comment addressed * fix * impl twox_128->64_concat * fix test * Fix compilation and cleanup some docs * Lol * Remove traits from storage types that are not generic * Get instance test almost working as wanted * Make `srml-support-test` compile again :) * Fixes test of srml-support * Fix compilation * Break some lines * Remove incorrect macro match arm * Integrates review feedback * Update documentation * Fix compilation
Until now, we are required to add the generic type to types generated by
decl_storage!that do not require it.The worst outcome of this is the requirement of
_genesis_phantom_datainGenesisConfig.All of this is now fixed by this pr. We do not require anymore a phantom field in a
GenesisConfig, as we do a proper lookup if a generic type is required.Fixes: #2219