-
Notifications
You must be signed in to change notification settings - Fork 707
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
feat: compute pallet/storage prefix hash at compile time #1539
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 |
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.
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 |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assumption is already used there multiple times.
|
||
/// Storage prefix. Used for generating final key. | ||
fn storage_prefix() -> &'static [u8]; | ||
|
||
/// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_prefix
are always fixed, we can put the runtime calculation into compile time.polkadot address: 15ouFh2SHpGbHtDPsJ6cXQfes9Cx1gEFnJJsJVqPGzBSTudr