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

add _(force_origin) support to benchmarking v2 #13721

Closed
Tracked by #380
sam0x17 opened this issue Mar 27, 2023 · 3 comments · Fixed by #13845
Closed
Tracked by #380

add _(force_origin) support to benchmarking v2 #13721

sam0x17 opened this issue Mar 27, 2023 · 3 comments · Fixed by #13845
Assignees
Labels
T1-runtime This PR/Issue is related to the topic “runtime”. U2-some_time_soon Issue is worth doing soon. Z1-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder Z6-mentor An easy task where a mentor is available. Please indicate in the issue who the mentor could be.

Comments

@sam0x17
Copy link
Contributor

sam0x17 commented Mar 27, 2023

In benchmarking v1 we used to be able to do:

let force_origin =
	T::ForceEnterOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
#[extrinsic_call]
_<T::RuntimeOrigin>(force_origin)

In v2, this doesn't seem to work, and we have to instead do:

let force_origin =
	T::ForceEnterOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
let call = Call::<T>::force_enter {};
#[block]
{
	call.dispatch_bypass_filter(force_origin)?;
}

We should be able to upgrade v2 syntax to do something like this:

let force_origin =
	T::ForceEnterOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
#[extrinsic_call]
_(force_origin);

Should be an easy fix but will have to be careful about what compiler errors get emitted in the event that force_origin or whatever variable we put there isn't a valid origin

@sam0x17 sam0x17 added U2-some_time_soon Issue is worth doing soon. Z1-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder T1-runtime This PR/Issue is related to the topic “runtime”. labels Mar 27, 2023
@sam0x17 sam0x17 self-assigned this Mar 27, 2023
@sam0x17 sam0x17 moved this from Backlog to To do in Benchmarking and Weights Mar 27, 2023
@sam0x17 sam0x17 moved this from Backlog to To Do in Runtime / FRAME Mar 27, 2023
@sam0x17 sam0x17 added the Z6-mentor An easy task where a mentor is available. Please indicate in the issue who the mentor could be. label Mar 27, 2023
@sam0x17
Copy link
Contributor Author

sam0x17 commented Apr 5, 2023

btw if it wasn't clear in my description, the main syntax change here is making this a legal syntax in benchmarking v2:

#[extrinsic_call]
_(some_variable_name);

We may need some additional assertions to ensure that the provided variable is an origin, but won't know that until we see the compiler error when you provide something random like a u32 or a String and see what it does

@gupnik gupnik self-assigned this Apr 5, 2023
@sam0x17
Copy link
Contributor Author

sam0x17 commented Apr 5, 2023

edit: if possible, would be cool to have _(some_special_origin) but otherwise the custom origin type syntax from v1 where it was like _<T::RuntimeOrigin>(force_origin) would be perfectly fine. I think we probably have to do it that way anyway

@ggwpez
Copy link
Member

ggwpez commented Apr 5, 2023

otherwise the custom origin type syntax from v1 where it was like _<T::RuntimeOrigin>(force_origin) would be perfectly fine. I think we probably have to do it that way

Yes IMHO this is the most extensible way, in case that there are other origin types. Maybe we can have a more compact syntax as follow-up.

@gupnik gupnik moved this from To Do to Please Review in Runtime / FRAME Apr 8, 2023
@github-project-automation github-project-automation bot moved this from Please Review to Done in Runtime / FRAME Apr 24, 2023
@github-project-automation github-project-automation bot moved this from To do to Done in Benchmarking and Weights Apr 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
T1-runtime This PR/Issue is related to the topic “runtime”. U2-some_time_soon Issue is worth doing soon. Z1-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder Z6-mentor An easy task where a mentor is available. Please indicate in the issue who the mentor could be.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants