Skip to content

Commit

Permalink
Integrate blake2 precompile
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrylavrenov committed May 6, 2024
1 parent 4d7176c commit 8062d3c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ 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-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
2 changes: 2 additions & 0 deletions crates/humanode-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ 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-modexp = { workspace = true }
pallet-evm-precompile-sha3fips = { workspace = true }
pallet-evm-precompile-simple = { workspace = true }
Expand Down Expand Up @@ -173,6 +174,7 @@ std = [
"pallet-ethereum-chain-id/std",
"pallet-ethereum/std",
"pallet-evm-accounts-mapping/std",
"pallet-evm-precompile-blake2/std",
"pallet-evm-precompile-modexp/std",
"pallet-evm-precompile-sha3fips/std",
"pallet-evm-precompile-simple/std",
Expand Down
5 changes: 5 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,7 @@ use frame_support::traits::Currency;
use pallet_evm::{
IsPrecompileResult, Precompile, PrecompileHandle, PrecompileResult, PrecompileSet,
};
use pallet_evm_precompile_blake2::Blake2F;
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 @@ -31,6 +32,8 @@ pub mod precompiles_constants {
pub const IDENTITY: u64 = 4;
/// `Modexp` precompile constant.
pub const MODEXP: u64 = 5;
/// `Blake2F` precompile constant.
pub const BLAKE2F: u64 = 9;

/// `Bls12381G1Add` precompile constant.
pub const BLS12381_G1_ADD: u64 = 11;
Expand Down Expand Up @@ -87,6 +90,7 @@ where
RIPEMD_160,
IDENTITY,
MODEXP,
BLAKE2F,
BLS12381_G1_ADD,
BLS12381_G1_MUL,
BLS12381_G1_MULTI_EXP,
Expand Down Expand Up @@ -131,6 +135,7 @@ 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)),
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

0 comments on commit 8062d3c

Please sign in to comment.