In Config
of my pallet I have:
type FilteredOrigin: EnsureOriginWithArg<
Self::RuntimeOrigin,
SomeEnum,
Success = Self::AccountId
>;
And there is an extrinsic in my pallet extrinsic_name
where i do a check T::FilteredOrigin::ensure_origin(origin)
Firstly I wrote the bench like this using v1:
extrinsic_name{
let origin = T::FilteredOrigin::try_successful_origin(&SomeEnum::SomeOption).unwrap();
// omitted
let data = Data {...};
}: _(origin, data)
And got the following error: expected associated type <T as frame_system::Config>::RuntimeOrigin
found enum Result<RawOrigin<<T as frame_system::Config>::AccountId>, <T as frame_system::Config>::RuntimeOrigin>
Then I found a solution in one of the frame's pallets (<T::RuntimeOrigin> added):
extrinsic_name{
let origin = T::FilteredOrigin::try_successful_origin(&SomeEnum::SomeOption).unwrap();
// omitted
let data = Data {...};
}: _<T::RuntimeOrigin>(origin, data)
Now I'm trying to use frame_benchmarking::v2
, I have written the following code and got the same error:
#[benchmarks]
mod benchmarks {
use super::*;
#[benchmark]
fn extrinsic_name() {
let origin = T::FilteredOrigin::try_successful_origin(&SomeEnum::SomeOption).unwrap();
// omitted
let data = Data {...};
#[extrinsic_call]
_(origin, data);
}
}
I guess the solution is described in the doc, also there is an example of doing similar thing in the pallet-lottery and I should do this way:
#[benchmarks]
mod benchmarks {
use super::*;
#[benchmark]
fn extrinsic_name() {
let origin = T::FilteredOrigin::try_successful_origin(&SomeEnum::SomeOption).unwrap();
// omitted
let data = Data {...};
#[extrinsic_call]
_(origin as T::RuntimeOrigin, data);
}
}
But compiler complains to this casting. On the other hand this is working in pallet-lottery. Could someone please clarify the problem occured here and point out what am I doing wrong?