Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate all eips related available frontier precompiles #1024

Merged
merged 6 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ fp-storage = { git = "https://github.com/humanode-network/frontier", branch = "l
pallet-ethereum = { git = "https://github.com/humanode-network/frontier", branch = "locked/polkadot-v0.9.40", default-features = false }
pallet-evm = { git = "https://github.com/humanode-network/frontier", branch = "locked/polkadot-v0.9.40", default-features = false }
pallet-evm-balances = { git = "https://github.com/humanode-network/frontier", branch = "locked/polkadot-v0.9.40", default-features = false }
pallet-evm-precompile-blake2 = { git = "https://github.com/humanode-network/frontier", branch = "locked/polkadot-v0.9.40", default-features = false }
pallet-evm-precompile-bn128 = { git = "https://github.com/humanode-network/frontier", branch = "locked/polkadot-v0.9.40", default-features = false }
pallet-evm-precompile-modexp = { git = "https://github.com/humanode-network/frontier", branch = "locked/polkadot-v0.9.40", default-features = false }
pallet-evm-precompile-sha3fips = { git = "https://github.com/humanode-network/frontier", branch = "locked/polkadot-v0.9.40", default-features = false }
pallet-evm-precompile-simple = { git = "https://github.com/humanode-network/frontier", branch = "locked/polkadot-v0.9.40", default-features = false }
Expand Down
4 changes: 4 additions & 0 deletions crates/humanode-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ pallet-balances = { workspace = true }
pallet-ethereum = { workspace = true }
pallet-evm = { workspace = true }
pallet-evm-balances = { workspace = true }
pallet-evm-precompile-blake2 = { workspace = true }
pallet-evm-precompile-bn128 = { workspace = true }
pallet-evm-precompile-modexp = { workspace = true }
pallet-evm-precompile-sha3fips = { workspace = true }
pallet-evm-precompile-simple = { workspace = true }
Expand Down Expand Up @@ -173,6 +175,8 @@ std = [
"pallet-ethereum-chain-id/std",
"pallet-ethereum/std",
"pallet-evm-accounts-mapping/std",
"pallet-evm-precompile-blake2/std",
"pallet-evm-precompile-bn128/std",
"pallet-evm-precompile-modexp/std",
"pallet-evm-precompile-sha3fips/std",
"pallet-evm-precompile-simple/std",
Expand Down
22 changes: 22 additions & 0 deletions crates/humanode-runtime/src/frontier_precompiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use frame_support::traits::Currency;
use pallet_evm::{
IsPrecompileResult, Precompile, PrecompileHandle, PrecompileResult, PrecompileSet,
};
use pallet_evm_precompile_blake2::Blake2F;
use pallet_evm_precompile_bn128::{Bn128Add, Bn128Mul, Bn128Pairing};
use pallet_evm_precompile_modexp::Modexp;
use pallet_evm_precompile_sha3fips::Sha3FIPS256;
use pallet_evm_precompile_simple::{ECRecover, ECRecoverPublicKey, Identity, Ripemd160, Sha256};
Expand Down Expand Up @@ -32,6 +34,16 @@ pub mod precompiles_constants {
/// `Modexp` precompile constant.
pub const MODEXP: u64 = 5;

/// `Bn128Add` precompile constant.
pub const BN128_ADD: u64 = 6;
/// `Bn128Mul` precompile constant.
pub const BN128_MUL: u64 = 7;
/// `Bn128Pairing` precompile constant.
pub const BN128_PAIRING: u64 = 8;

/// `Blake2F` precompile constant.
pub const BLAKE2F: u64 = 9;

/// `Bls12381G1Add` precompile constant.
pub const BLS12381_G1_ADD: u64 = 11;
/// `Bls12381G1Mul` precompile constant.
Expand Down Expand Up @@ -87,6 +99,10 @@ where
RIPEMD_160,
IDENTITY,
MODEXP,
BN128_ADD,
BN128_MUL,
BN128_PAIRING,
BLAKE2F,
BLS12381_G1_ADD,
BLS12381_G1_MUL,
BLS12381_G1_MULTI_EXP,
Expand Down Expand Up @@ -131,6 +147,12 @@ where
a if a == hash(RIPEMD_160) => Some(Ripemd160::execute(handle)),
a if a == hash(IDENTITY) => Some(Identity::execute(handle)),
a if a == hash(MODEXP) => Some(Modexp::execute(handle)),
// Bn128 precompiles:
a if a == hash(BN128_ADD) => Some(Bn128Add::execute(handle)),
a if a == hash(BN128_MUL) => Some(Bn128Mul::execute(handle)),
a if a == hash(BN128_PAIRING) => Some(Bn128Pairing::execute(handle)),
// Blake-2 precompiles:
a if a == hash(BLAKE2F) => Some(Blake2F::execute(handle)),
// BLS12-381 precompiles:
a if a == hash(BLS12381_G1_ADD) => Some(Bls12381G1Add::execute(handle)),
a if a == hash(BLS12381_G1_MUL) => Some(Bls12381G1Mul::execute(handle)),
Expand Down
8 changes: 8 additions & 0 deletions utils/checks/snapshots/features.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2196,6 +2196,12 @@
features:
- default
- std
- name: pallet-evm-precompile-blake2 2.0.0-dev
features:
- std
- name: pallet-evm-precompile-bn128 2.0.0-dev
features:
- std
- name: pallet-evm-precompile-modexp 2.0.0-dev
features:
- std
Expand Down Expand Up @@ -3542,6 +3548,8 @@
- default
- name: substrate-bip39 0.4.5
features: []
- name: substrate-bn 0.6.0
features: []
- name: substrate-frame-rpc-system 4.0.0-dev
features: []
- name: substrate-prometheus-endpoint 0.10.0-dev
Expand Down