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

Default PalletInfo impl for () can cause storage collisions #7949

Closed
@ascjones

Description

@ascjones

Discovered while working on #7936.

Usually construct_runtime! generates a PalletInfo impl which returns the unique pallet name to use as the storage prefix. However, manually configured test runtimes use type PalletInfo = () in their system::Config implementation. The PalletInfo impl for () returns "test" from name(), which can cause storage collisions where two pallets have a storage item with the same name.

In my case it was because both System and Balances have an Account storage item - the temporary fix was applied here: c147734.

Chatted with @thiolliere, and we have agreed that we need to remove the footgun of the PalletInfo impl for (). Potential solutions:

  • Make construct_runtime! macro work for test ruuntimes (@thiolliere already has some code in this direction)
  • Create impl_pallet_info! for test runtimes to generate code similar to construct_runtime
  • Make the default impl for () return some guaranteed unique and consistent pallet prefix, maybe using something in std::any.
  • Allow standalone pallets to somehow provide an implementation of PalletInfo that is only used if the System does not provide one, though this might be tricky because of instantiable pallets (@thiolliere to elaborate)

Update:

We are in the process of updating all test runtimes to use construct_runtime! directly. Here is a list, please put your name against any that you are working on to avoid duplicating work. It's just a raw list of all frame modules, so feel free to amend where necessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions