-
Notifications
You must be signed in to change notification settings - Fork 1k
Open
Labels
D1-mediumCan be fixed by a coder with good Rust knowledge but little knowledge of the codebase.Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase.I5-enhancementAn additional feature request.An additional feature request.
Description
Currently we have the WeightInfo
trait which exposes several weight functions in the form of:
pub trait WeightInfo {
fn call_a() -> Weight;
fn call_b() -> Weight;
…
}
Sometimes you want to iterate over all weight functions and do something weight their name or result (eg in paritytech/substrate#12485).
One way to do this would be to have another type; WeightMetaInfo
whose implementation is auto-generated as well:
pub trait WeighMetatInfo<W: WeightInfo> {
/// Executes a callback for each weight function by passing in its name and return value.
fn visit_weight_functions<F: Fn(&'static str, Weight) -> R, R>(f: F) -> Vec<R>;
}
This would allow us to do:
- Mocked
WeigtInfo
implementations such that the weight of a call can be dynamically set in a test (Is already possible, but not in a spell-checked way without ugly macros). - Checking that all weights of a pallet are in a specific bound as part of the runtime-integrity check (eg. no
Zero
or straytodo!()
).
I am not entirely convinced that this is the best design, but having this in some way would be nice.
Metadata
Metadata
Assignees
Labels
D1-mediumCan be fixed by a coder with good Rust knowledge but little knowledge of the codebase.Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase.I5-enhancementAn additional feature request.An additional feature request.
Type
Projects
Status
Backlog