I'm writing a pallet that implements evm::executor::stack::PrecompileSet
.
The goal is to use this pallet in conjunction with Frontier's pallet-evm
, which has the following types in its Config
trait:
type PrecompilesType: PrecompileSet;
type PrecompilesValue: Get<Self::PrecompilesType>;
While writing a mock environment for unit testing the pallet I'm writing, I'm struggling to make the compiler happy for PrecompilesValue
:
parameter_types! {
...
pub MockPrecompiles: crate::Pallet<Test> = // ?
}
impl pallet_evm::Config for Test {
...
type PrecompilesType = crate::Pallet<Test>;
type PrecompilesValue = MockPrecompiles;
...
}
It seems non-trivial to use the parameter_types!
macro to get an appropriate impl<T: Config> Get<T> for Pallet<T>
. With a blind trial-and-error strategy I ran into this error message:
error[E0423]: cannot initialize a tuple struct which contains private fields
--> frame/evm-precompile/src/mock.rs:136:45
|
136 | pub MockPrecompiles: crate::Pallet<Test> = crate::Pallet(PhantomData::<Test>);
| ^^^^^^^^^^^^^^^^^^^^^
is it possible to set MockPrecompiles
/PrecompilesValue
in this Runtime configuration?
what is the appropriate Rust syntax to set MockPrecompiles/PrecompilesValue in this Runtime configuration?
your question is not completely understandable. Rust aside, what shouldPrecompilesValue
be, just when thinking about it conceptually?pub MockPrecompiles: crate::Pallet<Test> = crate::Pallet(PhantomData::<Test>);
pallet structs are never meant to be instantiated, I find it hardly that you will be able to find a way around this.pallet-evm
:type PrecompilesValue: Get<Self::PrecompilesType>
, and I settype PrecompilesType = crate::Pallet<Test>
pallet-evm
will be able to execute... it is meant to be a custom implementation for each runtime github.com/paritytech/frontier/blob/…