pallet_revive/precompiles/
builtin.rs1mod blake2f;
19mod bn128;
20mod ecrecover;
21mod identity;
22mod modexp;
23mod point_eval;
24mod ripemd160;
25mod sha256;
26mod system;
27
28#[cfg(feature = "runtime-benchmarks")]
29mod benchmarking;
30
31#[cfg(feature = "runtime-benchmarks")]
32use crate::{
33 precompiles::{ExtWithInfo, Instance, Precompiles},
34 Config,
35};
36
37#[cfg(feature = "runtime-benchmarks")]
38pub use self::{
39 benchmarking::{IBenchmarking, NoInfo, WithInfo},
40 system::{ISystem, System},
41};
42
43#[cfg(not(feature = "runtime-benchmarks"))]
44pub type Builtin<T> = Production<T>;
45
46#[cfg(feature = "runtime-benchmarks")]
47pub type Builtin<T> = (Production<T>, Benchmarking<T>);
48
49type Production<T> = (
50 ecrecover::EcRecover<T>,
51 sha256::Sha256<T>,
52 ripemd160::Ripemd160<T>,
53 identity::Identity<T>,
54 modexp::Modexp<T>,
55 bn128::Bn128Add<T>,
56 bn128::Bn128Mul<T>,
57 bn128::Bn128Pairing<T>,
58 blake2f::Blake2F<T>,
59 point_eval::PointEval<T>,
60 system::System<T>,
61);
62
63#[cfg(feature = "runtime-benchmarks")]
64type Benchmarking<T> = (benchmarking::WithInfo<T>, benchmarking::NoInfo<T>);
65
66#[cfg(feature = "runtime-benchmarks")]
67impl<T: Config> Precompiles<T> for (Production<T>, Benchmarking<T>) {
68 const CHECK_COLLISION: () = ();
69 const USES_EXTERNAL_RANGE: bool =
70 Production::<T>::USES_EXTERNAL_RANGE || Benchmarking::<T>::USES_EXTERNAL_RANGE;
71
72 fn code(address: &[u8; 20]) -> Option<&'static [u8]> {
73 <Production<T>>::code(address).or_else(|| Benchmarking::<T>::code(address))
74 }
75
76 fn get<E: ExtWithInfo<T = T>>(address: &[u8; 20]) -> Option<Instance<E>> {
77 let _ = <Self as Precompiles<T>>::CHECK_COLLISION;
78 <Production<T>>::get(address).or_else(|| Benchmarking::<T>::get(address))
79 }
80}