Introduce ConstUint
to replace ConstU*
for convenient runtime configuration
#6193
Labels
I5-enhancement
An additional feature request.
Is there an existing issue?
Experiencing problems? Have you tried our Stack Exchange first?
Motivation
The current approach in Substrate runtime configuration requires defining separate types (
ConstU8
,ConstU16
,ConstU32
, etc.) for constants that represent basic unsigned integer types. This results in repetitive code and limits flexibility.Request
Consider the proposed introduction of
ConstUint
inSolution
section.Solution
https://github.com/conr2d/polkadot-sdk/blob/const-uint/substrate/primitives/core/src/const_uint.rs
I have introduced a new type,
ConstUint
, which implements theGet
trait for the basic unsigned number types (u8
,u16
,u32
,u64
,u128
, andusize
). This allows for more flexibility in handling constants in configuring runtimes.Registered default config:
Derived config example:
Benefits
Compile-Time Error Handling
If the default constant value is out of range for the newly configured type, it will be caught at compile time, preventing potential runtime errors.
Simplification of Type Definitions:
ConstUint
reduces the need for multipleConstU*
types, making the configuration simpler and less repetitive.Next Steps
If this feature is acceptable, I will proceed with creating a pull request for it. Currently,
ConstUint
is added tosp-core
, but I would appreciate your feedback on whether it would be better to move it toparity-common/bounded-collections
, in line with otherConstU*
types.Are you willing to help with this request?
Yes!
The text was updated successfully, but these errors were encountered: