Update to frame-metadata 22#8327
Conversation
There was a problem hiding this comment.
LGTM! Indeed, it sounds highly unlikely that an entire enum would be deprecated and since it also simplifies the code on the client side everything looks good, thanks🙏
I think our testing also needs a bit of adjusting to pass the CI (https://github.com/paritytech/polkadot-sdk/actions/runs/14663412489/job/41152740930?pr=8327)
|
All GitHub workflows were cancelled due to failure one of the required jobs. |
kianenigma
left a comment
There was a problem hiding this comment.
After this PR, a pallet author can still deprecate individual variants, but not the entire enum.
I agree that this is very rare to want to deprecate the whole thing. Even if needed, developers can still deprecate individual items.
Assuming this simplifies the internals of managing deprecation, it is a reasonable choice ✅
The prdoc from #8327 did not reference all crates that were touched. I added them here.
The main change in [the proposed `frame-metadata@22`](paritytech/frame-metadata#101) is that the deprecation information was tidied to remove some possible but confusing states, which simplifies making use of it in client code. One change made in the process is that **the ability to deprecate the entire of the Call/Error/Event enum was removed**. In other words, prior to this change a pallet author could do either of these: ```rust /// Deprecate the entire enum (but this is ignored if any variants are deprecated): #[deprecated(note = "This is deprecated")] #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event<T: Config<I>, I: 'static = ()> { /// An account was created with some free balance. Endowed { account: T::AccountId, free_balance: T::Balance }, /// An account was removed whose balance was non-zero but below ExistentialDeposit, /// resulting in an outright loss. DustLost { account: T::AccountId, amount: T::Balance }, } /// Deprecate individual variants: #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event<T: Config<I>, I: 'static = ()> { /// An account was created with some free balance. #[deprecated(note = "This is deprecated")] Endowed { account: T::AccountId, free_balance: T::Balance }, /// An account was removed whose balance was non-zero but below ExistentialDeposit, /// resulting in an outright loss. #[deprecated(note = "This is deprecated too")] DustLost { account: T::AccountId, amount: T::Balance }, } ``` After this PR, **a pallet author can still deprecate individual variants, but not the entire enum**. Some reasoning behind this change: 1. It's unlikely that the entire of these enums would ever be entirely deprecated. 2. In the case of calls, there is no obvious place to put such a warning anyway. 3. Sticking to just deprecating variants makes it a little simpler for client code; fewer cases to handle during codegen or whatever. 4. Avoid a confusing state where `#[deprecation]` can be put on the entire enum _and_ some variants, which leads to the enum-wide deprecation warning being ignored. See paritytech/frame-metadata#100 for some more context on the changes. # Notes This PR currently pulls `frame-metadata` via a github branch, for testing purposes. If we are happy here, I'll merge that PR, release `frame-metadata` and remove the github dependency before we merge this.
The prdoc from #8327 did not reference all crates that were touched. I added them here.
The prdoc from #8327 did not reference all crates that were touched. I added them here.
The main change in the proposed
frame-metadata@22is that the deprecation information was tidied to remove some possible but confusing states, which simplifies making use of it in client code.One change made in the process is that the ability to deprecate the entire of the Call/Error/Event enum was removed.
In other words, prior to this change a pallet author could do either of these:
After this PR, a pallet author can still deprecate individual variants, but not the entire enum.
Some reasoning behind this change:
#[deprecation]can be put on the entire enum and some variants, which leads to the enum-wide deprecation warning being ignored.See paritytech/frame-metadata#100 for some more context on the changes.
Notes
This PR currently pulls
frame-metadatavia a github branch, for testing purposes. If we are happy here, I'll merge that PR, releaseframe-metadataand remove the github dependency before we merge this.