substrate icon indicating copy to clipboard operation
substrate copied to clipboard

remove storage getters in FRAME

Open muraca opened this issue 2 years ago • 23 comments

resolves paritytech/polkadot-sdk#223

I added the deprecation message, removed every usage of #[pallet::getter] and refactored everything accordingly. Since a few getters for non-public maps were used in runtime or other situations, I manually wrote those functions and removed the getter. I generally used the pallet_name::StorageItem::<T>::get() syntax, I don't like the use pallet_name::StorageItem; because it's less explicit. I removed the getters from the examples, because since we don't want users to use them anymore, I think it's a better UX if we just don't mention them.

Companions: Cumulus paritytech/substrate#2216 Polkadot TBD

muraca avatar Feb 11 '23 17:02 muraca

I'm sure I missed something, I'll let the tests run to see if there's any errors in pallets. I also think I need to add some info about the deprecation in the docs of the procedural macro. Any hints?

@shawntabrizi @kianenigma

muraca avatar Feb 11 '23 17:02 muraca

Do we really want to do this like this? This is a big breaking change and will add significantly amount of work to downstream projects for no benefits.

It makes some sense to deprecate the getter syntax, but please don't remove the getters from pallets immediately.

xlc avatar Feb 11 '23 22:02 xlc

Do we really want to do this like this? This is a big breaking change and will add significantly amount of work to downstream projects for no benefits.

It makes some sense to deprecate the getter syntax, but please don't remove the getters from pallets immediately.

Indeed, as per the original issue:

... for now mark them as deprecated, and just remove all usage in substrate.

kianenigma avatar Feb 11 '23 22:02 kianenigma

No problem then, I'll revert those changes!

muraca avatar Feb 12 '23 10:02 muraca

Polkadot and Cumulus tests fail because of a missing SetMembersOrigin in pallet collective. It was added yesterday in PR paritytech/substrate#13159. I rebased and will let the checks tell me if something has broken.

muraca avatar Feb 13 '23 21:02 muraca

... for now mark them as deprecated, and just remove all usage in substrate.

I think this is how @muraca already approached this problem, but better to just manually implement all the getters on existing pallets, and no need to really mark anything as deprecated. Basically, this is just some legacy debt that probably will stick around, but has little impact.

shawntabrizi avatar Feb 20 '23 21:02 shawntabrizi

Please don't close the linked issue with this PR, as we still need to revisit this and make sure we remove the code after some time has passed.

kianenigma avatar Mar 10 '23 15:03 kianenigma

This pull request has been mentioned on Polkadot Forum. There might be relevant details there:

https://forum.polkadot.network/t/less-magic-in-frame-good-or-bad/2287/1

Polkadot-Forum avatar Mar 10 '23 15:03 Polkadot-Forum

@muraca rebase please?

kianenigma avatar Mar 19 '23 02:03 kianenigma

this needs to be rebased on current master, there have been breaking changes to the check-crate-publishing job.

altaua avatar Mar 29 '23 18:03 altaua

@liamaharon / @gupnik if @muraca does not show up, can either of you push this to the finish line? Seems like it is mostly done.

We can mark PR as "made with ❤️ by PBA students" :))

kianenigma avatar Apr 11 '23 09:04 kianenigma

@liamaharon / @gupnik if @muraca does not show up, can either of you push this to the finish line? Seems like it is mostly done.

We can mark PR as "made with ❤️ by PBA students" :))

I just spoke with @gupnik, I can take it on if we don't hear from @muraca before next week

liamaharon avatar Apr 11 '23 09:04 liamaharon

why is this removing getters instead of deprecate them?

xlc avatar Apr 12 '23 15:04 xlc

@xlc as per request, I added a deprecation message and removed every usage of the auto-generated functions

muraca avatar Apr 12 '23 15:04 muraca

But the getter is still removed? There shouldn't be any companions PR required for this PR.

xlc avatar Apr 12 '23 15:04 xlc

But the getter is still removed? There shouldn't be any companions PR required for this PR.

Ahh yeah good point, we should first deprecate the usage before removing the actual calls.

bkchr avatar Apr 12 '23 15:04 bkchr

But the getter is still removed?

@xlc I'm not sure I understood what you're asking. I'm not actually removing any of the getter functions, it just shows a warning message if you try to use one.

I was told I should not leave any warning behind, so I removed all the calls to said auto-generated functions in the FRAME pallets, and I did the same for the Cumulus repository. For the same reason, I had to replace some of the auto-generated getters, for example Aura's fn authorities, because it is used somewhere you can't call pallet_aura::Authorities::<T>::get().

muraca avatar Apr 12 '23 20:04 muraca

Ahh yeah, thank you @muraca!

bkchr avatar Apr 12 '23 21:04 bkchr

The CI pipeline was cancelled due to failure one of the required jobs. Job name: test-linux-stable Logs: https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/2702142

paritytech-cicd-pr avatar Apr 19 '23 11:04 paritytech-cicd-pr

Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jul 12 '23 11:07 stale[bot]

@muraca unfortunately this got behind master massively, would you take this over?

juangirini avatar Jul 12 '23 12:07 juangirini

Hey @juangirini as far as I remember it was decided not to proceed with this deprecation at the moment. If you're sure that this should be done right now, please let me know, and I'll go through the code again in the next few days.

muraca avatar Jul 12 '23 12:07 muraca

Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Aug 11 '23 13:08 stale[bot]