-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Conversation
frame/benchmarking/src/utils.rs
Outdated
#[derive(Encode, Decode, Clone, PartialEq, Debug)] | ||
|
||
pub enum BenchmarkError { | ||
Stop(#[codec(skip)] &'static str), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you skip this here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the proper fix for?
error[E0277]: the trait bound `&'static str: WrapperTypeDecode` is not satisfied
--> frame/benchmarking/src/utils.rs:128:7
|
128 | Stop(&'static str),
| ^ the trait `WrapperTypeDecode` is not implemented for `&'static str`
|
::: /Users/shawntabrizi/.cargo/registry/src/github.com-1ecc6299db9ec823/parity-scale-codec-2.2.0/src/codec.rs:284:18
|
284 | fn decode<I: Input>(input: &mut I) -> Result<Self, Error>;
| ----- required by this bound in `utils::_::_parity_scale_codec::Decode::decode`
|
= note: required because of the requirements on the impl of `Decode` for `&'static str`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use sp_runtime::RuntimeString
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Runtime string came with a whole host of other issues, again related to Arbitrary Error -> Static String, then Static String -> Runtime String, since it rust can't figure out to do two jumps.
Instead I removed Encode, Decode
cause it just wasnt needed
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
what is the usecase for this ? |
For XCM, we want to be able to specify a benchmark for all commands and orders, but based on runtime configurations, return custom values (example: return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Just a little unsure the override should be an error.
(but probably too bikesheddy to be worth delaying the PR for)
@@ -108,6 +112,50 @@ pub struct BenchmarkResults { | |||
pub keys: Vec<(Vec<u8>, u32, u32, bool)>, | |||
} | |||
|
|||
impl BenchmarkResult { | |||
pub fn from_weight(w: Weight) -> Self { | |||
Self { extrinsic_time: (w as u128) / 1_000, ..Default::default() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not implement From<Weight> for BenchmarkResult
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks okay overall; doesn't quite matter if the comment is addressed or not.
bot merge |
Waiting for commit status. |
This PR allows the benchmarking pipeline to return a custom
BenchmarkError
error type.With this new error type, we can allow a user to define a "default" weight to output if a benchmark would fail, or is otherwise unimplemented:
Any data set here will then be swallowed by the benchmarking pipeline, and be used in the final output.
polkadot companion: paritytech/polkadot#3600