Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Add an INDEX to the Instance trait #8555

Merged
2 commits merged into from
Apr 7, 2021
Merged

Add an INDEX to the Instance trait #8555

2 commits merged into from
Apr 7, 2021

Conversation

shawntabrizi
Copy link
Member

This PR introduces a simple const INDEX: u8; to the Instance trait used for Pallets.

This is useful for getting a minimal unique identifier for different instances, for example using it as a seed to some unique account generation.

The DefaultInstance uses index == 0, so we deprecate Instance0 (which wasn't used anywhere) and instead use instances 1 ..= 16.

@github-actions github-actions bot added the A0-please_review Pull request needs code review. label Apr 7, 2021
@shawntabrizi shawntabrizi added B7-runtimenoteworthy C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit labels Apr 7, 2021
@shawntabrizi
Copy link
Member Author

bot merge

@ghost
Copy link

ghost commented Apr 7, 2021

Waiting for commit status.

@ghost ghost merged commit 7eb671f into master Apr 7, 2021
@ghost ghost deleted the shawntabrizi-instance-index branch April 7, 2021 12:58
@gui1117
Copy link
Contributor

gui1117 commented Apr 7, 2021

note that pallet macro doesn't make use of instance trait anymore, instance trait was created in order to give different prefix to each instances, now that prefix is given by PalletInfo, the instance trait had no purpose so it was removed.

In order to have a INDEX identifier in pallet defines with pallet macro I think ppl should add it to the Config trait or we can add one in PalletInfo. (actually adding one in PalletInfo seems the best strategy to me).

@shawntabrizi
Copy link
Member Author

🤦

hirschenberger pushed a commit to hirschenberger/substrate that referenced this pull request Apr 14, 2021
* Add an index to the Instance trait

* Update frame/support/procedural/src/storage/instance_trait.rs
@kianenigma
Copy link
Contributor

kianenigma commented Apr 27, 2021

FYI this is moving to the next polkadot release very soon, didn't we decide to revert this?

@kianenigma
Copy link
Contributor

(It doesn't have a big impact and we can remove it any point anyhow, but I just saw it in the release notes and thought better do it soon than later.)

@gui1117
Copy link
Contributor

gui1117 commented Apr 27, 2021

The Instance trait will be deprecated alongside decl_storage macro.
It is not used in the pallet macro.

So for me it doesn't matter, we are not creating code debt here.
But if a revert PR opens I'll also approve.

@kianenigma
Copy link
Contributor

will be deprecated alongside decl_storage macro

Then I am also neutral, whatever @shawntabrizi prefers.

@shawntabrizi
Copy link
Member Author

i dont think it matters if we keep it.

This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants