sp_evm_precompiles/
lib.rs

1//! EVM precompile primitives
2#![cfg_attr(not(feature = "std"), no_std)]
3#![forbid(unsafe_code)]
4#![warn(rust_2018_idioms)]
5
6use pallet_evm_precompile_modexp::Modexp;
7use pallet_evm_precompile_sha3fips::Sha3FIPS256;
8use pallet_evm_precompile_simple::{ECRecover, ECRecoverPublicKey, Identity, Ripemd160, Sha256};
9use precompile_utils::precompile_set::*;
10use transporter_precompile::TransporterPrecompile;
11
12type EthereumPrecompilesChecks = (AcceptDelegateCall, CallableByContract, CallableByPrecompile);
13
14#[precompile_utils::precompile_name_from_address]
15type PrecompilesAt<R> = (
16    // Ethereum precompiles:
17    // We allow DELEGATECALL to stay compliant with Ethereum behavior.
18    PrecompileAt<AddressU64<1>, ECRecover, EthereumPrecompilesChecks>,
19    PrecompileAt<AddressU64<2>, Sha256, EthereumPrecompilesChecks>,
20    PrecompileAt<AddressU64<3>, Ripemd160, EthereumPrecompilesChecks>,
21    PrecompileAt<AddressU64<4>, Identity, EthereumPrecompilesChecks>,
22    PrecompileAt<AddressU64<5>, Modexp, EthereumPrecompilesChecks>,
23    // Non-Frontier specific nor Ethereum precompiles :
24    PrecompileAt<AddressU64<1024>, Sha3FIPS256, (CallableByContract, CallableByPrecompile)>,
25    PrecompileAt<AddressU64<1025>, ECRecoverPublicKey, (CallableByContract, CallableByPrecompile)>,
26    // Subspace specific precompiles
27    PrecompileAt<
28        AddressU64<2048>,
29        TransporterPrecompile<R>,
30        (CallableByContract, CallableByPrecompile),
31    >,
32);
33
34/// The PrecompileSet installed in the EVM Domain runtime.
35/// The following distribution has been decided for the precompiles
36/// 0-1023: Ethereum Mainnet Precompiles
37/// 1024-2047 Precompiles that are not in Ethereum Mainnet, and are not Subspace specific
38/// 2048-4095 Subspace specific precompiles
39pub type Precompiles<R> = PrecompileSetBuilder<
40    R,
41    (
42        // Skip precompiles if out of range.
43        PrecompilesInRangeInclusive<(AddressU64<1>, AddressU64<4095>), PrecompilesAt<R>>,
44    ),
45>;