In most runtimes in production, each pallet has a specific index but its not clear what the logic behind ordering them really is. For example, in Polkadot we can see a comment in the construct_runtime
macro that alludes to a decision made around anticipating future pallets that would need to be within a specific index range. We can also observe that XcmPallet
has an index of 99:
// Parachain Onboarding Pallets. Start indices at 70 to leave room.
Registrar: paras_registrar::{Pallet, Call, Storage, Event<T>} = 70,
Slots: slots::{Pallet, Call, Storage, Event<T>} = 71,
Auctions: auctions::{Pallet, Call, Storage, Event<T>} = 72,
Crowdloan: crowdloan::{Pallet, Call, Storage, Event<T>} = 73,
// Pallet for sending XCM.
XcmPallet: pallet_xcm::{Pallet, Call, Storage, Event<T>, Origin, Config} = 99,
What's the logic behind Polkadot's choice in pallet indexing? What is the significance of a pallet's index and what do runtime engineers need to consider when numbering the pallets in their chain's runtime ? It would be great to get an answer that could help other parachain developers make the right pallet indexing decisions for their chain.