feat: compute pallet/storage prefix hash at compile time#1539
feat: compute pallet/storage prefix hash at compile time#1539bkchr merged 26 commits intoparitytech:masterfrom
Conversation
|
Nice! This will close: #372 |
Co-authored-by: Juan <[email protected]>
Co-authored-by: Juan <[email protected]>
|
bot fmt |
|
@juangirini https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/3677452 was started for your command Comment |
|
@juangirini Command |
|
@bkchr hi ,it is done |
|
Any other problem? |
|
@yjhmelody I'm fine issuing a medium tip for this pr when it is merged |
bkchr
left a comment
There was a problem hiding this comment.
Looks good! Just some nitpicks!
Ty!
|
/tip medium |
|
@kianenigma A medium (80 DOT) tip was successfully submitted for @yjhmelody (15ouFh2SHpGbHtDPsJ6cXQfes9Cx1gEFnJJsJVqPGzBSTudr on polkadot). https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frpc.polkadot.io#/referenda |
ggwpez
left a comment
There was a problem hiding this comment.
Pretty cool, thanks!
Are there some tests to check that the computed storage hashes are identical to the old ones?
| <T as #frame_system::Config>::PalletInfo as #frame_support::traits::PalletInfo | ||
| >::name_hash::<Self>() | ||
| .expect("Pallet is part of the runtime because pallet `Config` trait is \ | ||
| implemented by the runtime") |
There was a problem hiding this comment.
So, this might not be true under a misconfiguration, i.e. someone implements the pallet Config trait for a runtime, but forgets to include the actual pallet in construct_runtime.
Hopefully we do now have lints or warnings to catch this, but on the off-chance that we don't, I'd want to make sure that this expect doesn't trigger and cause a panic in runtime.
There was a problem hiding this comment.
This assumption is already used there multiple times.
|
|
||
| /// The full prefix; just the hash of `module_prefix` concatenated to the hash of | ||
| /// The full prefix; just the hash of `pallet_prefix` concatenated to the hash of | ||
| /// `storage_prefix`. |
There was a problem hiding this comment.
By removing the default implementation, we can no longer guarantee that the full prefix is "just the hash of pallet_prefix concatenated to the hash of storage_prefix".
There was a problem hiding this comment.
Why was it removed in the first place? I see no explanation and commit message is unhelpful "minor improve" 😕
|
are there any benchmarks for this and the improvements? |
…1539) Since the hash rules of this part of the `pallet_prefix/storage_prefix` are always fixed, we can put the runtime calculation into compile time. --- polkadot address: 15ouFh2SHpGbHtDPsJ6cXQfes9Cx1gEFnJJsJVqPGzBSTudr --------- Co-authored-by: Juan <[email protected]> Co-authored-by: command-bot <> Co-authored-by: Oliver Tale-Yazdi <[email protected]>

Since the hash rules of this part of the
pallet_prefix/storage_prefixare always fixed, we can put the runtime calculation into compile time.polkadot address: 15ouFh2SHpGbHtDPsJ6cXQfes9Cx1gEFnJJsJVqPGzBSTudr