-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Use Mandatory Indices for FRAME Storage API (and others) #8964
Comments
How would the index look in a To recap, I think it is useful to be able to pin certain calls variants to particular indices in the call enum, so that we can guarantee that they will remain backwards compatible. For example, we could freeze the index of Although, this is more like a patch for the lack of resources on readily parsing of metadata on the tools side. Perhaps it is more worthwhile to spend more effort metadata parsing. If we have great tooling for metadata in different languages, it won't matter at all how frequent we break storage/calls. |
I thought it would just be another tag on top of each of the extrinsic functions?
|
Feedback in chat determined the following:
Then anything which impls |
The FRAME storage APIs use a combination of prefixes to describe the location of storage items. Something like:
We have seen multiple times where this has come to bite us in the butt:
Similarly, we ran into issues with Construct Runtime and the ordering of pallets, and the call enum and ordering of extrinsics.
My suggestion is that we should use indexes, not human strings / variable names, wherever there could be some breaking change caused by reorganization, renaming, refactoring, etc...
Protobuf follows a similar philosophy: https://developers.google.com/protocol-buffers/docs/overview
I believe the following FRAME objects should use explicitly defined indexes:
Items which are not breaking need not have explicit ordering, but should allow optional explicit ordering:
When defining a storage item with the FRAME v2 macros, users should be required(?) to include an explicit index:
We already support and require indices on Pallet ordering in construct runtime. This is needed for transaction versioning.
Combining these two, the new storage pattern should be:
In this case, we can update the name of the storage or move the storage definition to anywhere in the source code, and not break your pallet.
The text was updated successfully, but these errors were encountered: