Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#[disable_frame_system_supertrait_check] doesn't seem to work as expected #3535

Closed
liamaharon opened this issue Mar 1, 2024 · 5 comments
Closed
Labels
I10-unconfirmed Issue might be valid, but it's not yet known.

Comments

@liamaharon
Copy link
Contributor

I expect to be able to write a simple pallet where the config doesn't depend on frame_system::Config like this:

#[frame_support::pallet]
pub mod pallet {
	use super::*;

	#[pallet::pallet]
	pub struct Pallet<T>(_);

	#[pallet::config]
	#[pallet::disable_frame_system_supertrait_check]
	pub trait Config: 'static {}
}

Instead, it fails to compile

Screenshot 2024-03-01 at 11 28 28

See my branch to reproduce https://github.com/liamaharon/substrate-node-template/blob/liam-disable-supertrait-issue/pallets/template/src/lib.rs

Is there something wrong with my pallet, or is this a bug with the macro?

@liamaharon liamaharon added the I10-unconfirmed Issue might be valid, but it's not yet known. label Mar 1, 2024
@kianenigma
Copy link
Contributor

kianenigma commented Mar 1, 2024

I was initially tripped by this too, but I think it is all correct.

My mistake was also to naively think that frame actually allows you to avoid frame_system. It does not. Having T: frame_system::Config is 100% mandatory. All the code generated for things like Hooks, PalletInfo and more is unavoidably reliant on the existence of frame_system.

What disable_frame_system_supertrait_check is to just syntactically hide this.

For example, you can have things like:

trait MyOpinionatedSystem: frame_system::Config {}

You can then write pub trait Config: MyOpinionatedSystem { .. } and it would be valid with this attribute.

Or, if you tightly couple to another a pallet, and the other pallet is already bounded by frame_system::Config, you don't need to name : frame_system::Config again.

Can you post this in SE as well please, if no similar previous question exists? And I will asap write paritytech/polkadot-sdk-docs#76

@liamaharon
Copy link
Contributor Author

OK this makes a tonne of sense, thanks!

I've updated the documentation to address this in #2638. Not sure if a SE post is required if it's explained in the docs, but happy to create one if you think it would still be valuable :)

@gupnik
Copy link
Contributor

gupnik commented Mar 3, 2024

We already do have a pallet in tests without frame_system::Config using that macro:

#[pallet::disable_frame_system_supertrait_check]

It exposes a prelude and adds a few items in the config. I imagine the similar changes would help here. If so, agreed that it would be good to get the docs updated.

@liamaharon
Copy link
Contributor Author

If this is possible, could #[pallet::disable_frame_system_supertrait_check] add the necessary items from config for the dev so they don't need to do it themselves? Then it should function like we initially thought?

github-merge-queue bot pushed a commit that referenced this issue Mar 7, 2024
substrate.io deprecation companion:
polkadot-developers/substrate-docs#2139
pba-content companion:
Polkadot-Blockchain-Academy/pba-content#978

partially inspired by:
#3535

---------

Co-authored-by: Ankan <[email protected]>
bgallois pushed a commit to duniter/duniter-polkadot-sdk that referenced this issue Mar 25, 2024
substrate.io deprecation companion:
polkadot-developers/substrate-docs#2139
pba-content companion:
Polkadot-Blockchain-Academy/pba-content#978

partially inspired by:
paritytech#3535

---------

Co-authored-by: Ankan <[email protected]>
@bkchr
Copy link
Member

bkchr commented May 2, 2024

Then it should function like we initially thought?

As you already found out, this is not the purpose of this macro. The linked "pallet" is also a test and nothing that should be repeated in the real world. FRAME expects that every runtime has the system pallet and that the config is a super trait. This is backed deeply into the entire FRAME macro machinery etc and nothing we want/can change.

@bkchr bkchr closed this as completed May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I10-unconfirmed Issue might be valid, but it's not yet known.
Projects
None yet
Development

No branches or pull requests

4 participants