Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Production / Non-Production Feature Flags for FRAME Pallets and Runtime #8965

@shawntabrizi

Description

@shawntabrizi

In FRAME we should try to satisfy these two, sometime conflicting requirements as best as possible:

  1. Make it dead simple easy to build new pallets with FRAME
  2. Allow developers to make completely safe, production ready pallets

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:

  • Transactional Extrinsics (is it production ready?)
  • () or test impl for many traits
  • Many pallets which are not fully audited or use real weights and stff

Using 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:

// instead of `construct_runtime!(...)

construct_production_runtime!(...)

This will only compile with the --features=production flag, ensuring that all pallets included in your runtime are ready to be used in production.

Metadata

Metadata

Assignees

Labels

U2-some_time_soonIssue is worth doing soon.Z2-mediumCan be fixed by a coder with good Rust knowledge but little knowledge of the codebase.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions