1

Aside from the obvious, configuring the pallet and adding it to the construct_runtime! invocation, what else needs to be done that isn't mentioned in the substrate tutorials?

For example, it's also necessary to manually set the storage of the pallet (storage version, anything otherwise belonging to the genesis config). Is there anything else missing?

1 Answer 1

1

Thats a good question!
There is indeed a difference between adding a pallet at genesis and adding it into a live runtime.

When a pallet is added into the genesis state, its build function is called as part of the setting up the initial chain sate. This does not happen when the pallet is freshly added to a live runtime.

However, the genesis state of a pallet is normally only used to seed it with some initial data. Pallets do in general not rely on that hook to ever execute. There are some exceptions, like pallets that are tightly coupled with other pallets and similar. If you want to be really sure, check the build function of the pallets that you want to add.

And since you specifically mentioned the storage version: it does not need to be set manually for recent Substrate versions. In older versions, it is necessary.

Otherwise you definitely should benchmark the pallet with your runtime. For that, you can add it to the define_benchmarks! macro and generate the weights from running the benchmarks. Then configure the weight of that file in your runtime.

5
  • "And since you specifically mentioned the storage version: it does not need to be set manually." I've tested this and the storage version of pallet added to a live chain defaults to zero.
    – mkl
    May 14 at 13:30
  • Nevermind, the polkadot version I'm using is too old.
    – mkl
    May 14 at 14:15
  • So the answer is that this depends on the substrate version. Storage version must be set manually if you're using a substrate version from before the PR linked above was merged.
    – mkl
    May 14 at 14:20
  • Yea true, updated the answer. May 14 at 14:59
  • Thanks, much appreciated!
    – mkl
    May 14 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.