pallet_revive/precompiles/builtin/
benchmarking.rs1use crate::{
19 precompiles::{BuiltinAddressMatcher, BuiltinPrecompile, Error, Ext, ExtWithInfo},
20 Config,
21};
22use alloc::vec::Vec;
23use alloy_core::sol;
24use core::{marker::PhantomData, num::NonZero};
25
26sol! {
27 interface IBenchmarking {
28 function bench(bytes calldata input) external;
29 }
30}
31
32pub struct WithInfo<T>(PhantomData<T>);
33
34impl<T: Config> BuiltinPrecompile for WithInfo<T> {
35 type T = T;
36 type Interface = IBenchmarking::IBenchmarkingCalls;
37 const MATCHER: BuiltinAddressMatcher =
38 BuiltinAddressMatcher::Fixed(NonZero::new(0xFF_FF).unwrap());
39 const HAS_CONTRACT_INFO: bool = true;
40
41 fn call_with_info(
42 _address: &[u8; 20],
43 _input: &Self::Interface,
44 _env: &mut impl ExtWithInfo<T = Self::T>,
45 ) -> Result<Vec<u8>, Error> {
46 Ok(Vec::new())
47 }
48}
49
50pub struct NoInfo<T>(PhantomData<T>);
51
52impl<T: Config> BuiltinPrecompile for NoInfo<T> {
53 type T = T;
54 type Interface = IBenchmarking::IBenchmarkingCalls;
55 const MATCHER: BuiltinAddressMatcher =
56 BuiltinAddressMatcher::Fixed(NonZero::new(0xEF_FF).unwrap());
57 const HAS_CONTRACT_INFO: bool = false;
58
59 fn call(
60 _address: &[u8; 20],
61 _input: &Self::Interface,
62 _env: &mut impl Ext<T = Self::T>,
63 ) -> Result<Vec<u8>, Error> {
64 Ok(Vec::new())
65 }
66}