diff --git a/Cargo.lock b/Cargo.lock index b9d1119a4..ac0495888 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4128,6 +4128,8 @@ dependencies = [ "pallet-evm", "pallet-evm-accounts-mapping", "pallet-evm-balances", + "pallet-evm-precompile-blake2", + "pallet-evm-precompile-bn128", "pallet-evm-precompile-modexp", "pallet-evm-precompile-sha3fips", "pallet-evm-precompile-simple", @@ -6508,6 +6510,24 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-evm-precompile-blake2" +version = "2.0.0-dev" +source = "git+https://github.com/humanode-network/frontier?branch=locked/polkadot-v0.9.40#ac5c3415f47adf126419579924052daff07301e1" +dependencies = [ + "fp-evm", +] + +[[package]] +name = "pallet-evm-precompile-bn128" +version = "2.0.0-dev" +source = "git+https://github.com/humanode-network/frontier?branch=locked/polkadot-v0.9.40#ac5c3415f47adf126419579924052daff07301e1" +dependencies = [ + "fp-evm", + "sp-core", + "substrate-bn", +] + [[package]] name = "pallet-evm-precompile-modexp" version = "2.0.0-dev" @@ -11031,6 +11051,19 @@ dependencies = [ "zeroize", ] +[[package]] +name = "substrate-bn" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b5bbfa79abbae15dd642ea8176a21a635ff3c00059961d1ea27ad04e5b441c" +dependencies = [ + "byteorder", + "crunchy", + "lazy_static", + "rand 0.8.5", + "rustc-hex", +] + [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" diff --git a/Cargo.toml b/Cargo.toml index 4512a39dc..7a6acd766 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 } diff --git a/crates/humanode-runtime/Cargo.toml b/crates/humanode-runtime/Cargo.toml index 0e937312e..7c0e3b7fd 100644 --- a/crates/humanode-runtime/Cargo.toml +++ b/crates/humanode-runtime/Cargo.toml @@ -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 } @@ -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", diff --git a/crates/humanode-runtime/src/frontier_precompiles.rs b/crates/humanode-runtime/src/frontier_precompiles.rs index fb6da6c68..8a733eb77 100644 --- a/crates/humanode-runtime/src/frontier_precompiles.rs +++ b/crates/humanode-runtime/src/frontier_precompiles.rs @@ -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}; @@ -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. @@ -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, @@ -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)), diff --git a/utils/checks/snapshots/features.yaml b/utils/checks/snapshots/features.yaml index 951a7b971..4d90c7975 100644 --- a/utils/checks/snapshots/features.yaml +++ b/utils/checks/snapshots/features.yaml @@ -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 @@ -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