Exercise 05
Objectives: writing pallets, storage migration, try-runtime
Needs: Exercise 04
Content: We are going to change the logic of the banishment pallet a little. Instead of banishing an account forever, we will banish it only for a fixed number of sessions.
Modify existing pallet so that it supports new semantics. For this, update your existing storage item. Moreover, you will need to listen for session changes. You can check e.g. the
electionspallet for how we interact with thesessionpallet. Ensure that your pallet stores only the accounts that are currently banished. Entities for which the banishment period has ended, shouldn't take up space unnecessarily.Since we will introduce new changes as runtime update (to a running chain), you should also provide a runtime migration. Take a look at the pallets
alephandelectionsfor how to write migrations. For migration test helpers consultpallets-supportcrate.Launch a new chain with the old version of the
banishmentpallet. Test your migration with thetry-runtimetool.Perform a proper runtime update. Verify that the new API works as expected.
Repeat the experiment, but this time ensure that the old storage is not empty:
Restart the old chain.
Banish some account (should be marked as banished forever).
Perform the update.
Check whether the banished account is still considered banished.
References:
pallets/aleph,pallets/elections,pallets/support
Last updated
Was this helpful?