I was looking at removing some extrinsics from my pallet and wanted to know the safe way of going about it.
- Can/should I reuse the
call_index
? - How will
historic transaction
data be impacted?
Anything else I need to watch out for?
Thanks
Substrate and Polkadot Stack Exchange is a question and answer site for developers building blockchains with the Substrate SDK. It only takes a minute to sign up.
Sign up to join this communityI was looking at removing some extrinsics from my pallet and wanted to know the safe way of going about it.
call_index
?historic transaction
data be impacted?Anything else I need to watch out for?
Thanks
Each call receives an index depending on its position in the Call Enum of a pallet. One could as well explicitly assign a concrete index to a call, for instance:
#[pallet::call_index(0)]
#[pallet::weight(<T as Config>::WeightInfo::register_fast_unstake())]
pub fn register_fast_unstake(origin: OriginFor<T>) -> DispatchResult {
This index will be, among other things, used to properly encode the call.
By explicitly assigning indices to each call you are shielding your calls against getting another index after a runtime upgrade where one other call has been removed, reorganising the indices for all the following calls in this pallet's Call Enum.
Similarly this happens as well with pallets in construct_runtime!
, where we can also assign explicit indices for them.
My advise would be that in this runtime upgrade you are about to make, assign explicit indices to your calls too in case you are not doing that already so that when removing a certain call it doesn't mess with the rest of indices.
After the upgrade clients encoding non existing calls will just get an error back, but if the rest of them kept the same index and its pallet did too, those call encodings should work fine.
call_index
3 today and 6 months later I add a new extrinsic to the pallet.
#[pallet::call_index(7)]
should never be used again for anything right? I.e. After this extrinsic is removed, if someone adds a totally different extrinsic with the same index it will break things?
3
thinking that it is fn hello_world()
, but instead this index is now fn foo()
. Nothing breaks on the runtime side, but as long as they are not aware of this change, they'll be making the wrong call, most probably.
Jun 19 at 11:50