-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Production / Non-Production Feature Flags for FRAME Pallets and Runtime #8965
Comments
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. |
I understand the interest but actually I don't see that much possible improvments in practice:
For the mock configuration when testing pallet, I know people complains about setting it, but it is always the same configuration of frame-system, providing a good example to copy and paste could be enough to be able to set easily. |
For implementing this on the pallet, I suggest a syntax like:
Which will automatically remove the need for |
As a test, this minimal frame pallet should compile:
|
Would it instead be desirable to make the existing |
Note that after a while I realized that the suggested syntax: #[frame_support::pallet]
#[frame_support::pallet::dev_mode]
pub mod pallet { will not work because the Instead, I recommend this much easier to parse syntax: #[frame_support::pallet(dev_mode)]
pub mod pallet { In other words add |
In FRAME we should try to satisfy these two, sometime conflicting requirements as best as possible:
The original SRML macros was really good at satisfying (1), where you could just start writing code and try it out right away.
However, over time, and as we transitioned to FRAME, we had to add more and more requirements to pallets in order to make it all production ready for Polkadot and Parachains.
Some example of "production features" that make the tinkerer experience worse:
On the flip side, we also have introduced things within FRAME which should only be used in non-production environments:
()
or test impl for many traitsUsing Rust's feature system, we should easily be able to enable / disable production and non-production features using feature flags.
For example, when building a pallet or working with substrate for fun, you can design a pallet without needing to define any weights, or maxencodedlen stuff.
However, when you are going to production, you can compile with
--features=production
, and these compiler errors will appear saying that you need to implement this stuff.Then, at in the runtime definition, you can ensure that your runtime is always compiled with the production flag by using something like:
This will only compile with the
--features=production
flag, ensuring that all pallets included in your runtime are ready to be used in production.The text was updated successfully, but these errors were encountered: