Skip to content
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.

12 changes: 9 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ members = [
"frame/ethereum",
"frame/evm",
"frame/evm/precompile/sha3fips",
"frame/evm/precompile/sha3fips/benchmarking",
"frame/evm/precompile/simple",
"frame/evm/precompile/modexp",
"frame/evm/precompile/ed25519",
Expand All @@ -15,6 +16,7 @@ members = [
"frame/evm/precompile/bls12381",
"frame/evm/precompile/dispatch",
"frame/evm/precompile/curve25519",
"frame/evm/precompile/curve25519/benchmarking",
"frame/evm-chain-id",
"frame/evm-polkavm",
"frame/evm-polkavm/proc-macro",
Expand Down Expand Up @@ -80,12 +82,13 @@ rlp = { version = "0.6", default-features = false }
scale-codec = { package = "parity-scale-codec", version = "3.7.5", default-features = false, features = ["derive"] }
scale-info = { version = "2.11.6", default-features = false, features = ["derive"] }
serde = { version = "1.0", default-features = false, features = ["derive", "alloc"] }
serde_json = "1.0"
serde_json = { version = "1.0", default-features = false }
sha2 = { version = "0.10.9", default-features = false }
similar-asserts = "1.7.0"
sqlx = { version = "0.7.4", default-features = false, features = ["macros"] }
syn = "2.0.87"
thiserror = "2.0"
tokio = "1.45.0"
tokio = { version = "1.45.0", default-features = false }

# Substrate Client
sc-basic-authorship = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2506" }
Expand Down Expand Up @@ -156,7 +159,7 @@ pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/parityt
pallet-utility = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2506", default-features = false }
# Substrate Utility
frame-benchmarking-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2506" }
prometheus-endpoint = { package = "substrate-prometheus-endpoint", git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2506" }
prometheus-endpoint = { package = "substrate-prometheus-endpoint", git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2506", default-features = false }
substrate-build-script-utils = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2506" }
substrate-frame-rpc-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2506" }
substrate-test-runtime-client = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2506" }
Expand Down Expand Up @@ -211,8 +214,11 @@ pallet-evm-chain-id = { path = "frame/evm-chain-id", default-features = false }
pallet-evm-polkavm = { path = "frame/evm-polkavm", default-features = false }
pallet-evm-polkavm-proc-macro = { path = "frame/evm-polkavm/proc-macro" }
pallet-evm-polkavm-uapi = { path = "frame/evm-polkavm/uapi", default-features = false }
pallet-evm-precompile-curve25519 = { path = "frame/evm/precompile/curve25519", default-features = false }
pallet-evm-precompile-curve25519-benchmarking = { path = "frame/evm/precompile/curve25519/benchmarking", default-features = false }
pallet-evm-precompile-modexp = { path = "frame/evm/precompile/modexp", default-features = false }
pallet-evm-precompile-sha3fips = { path = "frame/evm/precompile/sha3fips", default-features = false }
pallet-evm-precompile-sha3fips-benchmarking = { path = "frame/evm/precompile/sha3fips/benchmarking", default-features = false }
pallet-evm-precompile-simple = { path = "frame/evm/precompile/simple", default-features = false }
pallet-evm-test-vector-support = { path = "frame/evm/test-vector-support" }
pallet-hotfix-sufficients = { path = "frame/hotfix-sufficients", default-features = false }
Expand Down
6 changes: 4 additions & 2 deletions frame/evm/precompile/curve25519/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ repository = { workspace = true }

[dependencies]
curve25519-dalek = { version = "4.1.0", default-features = false, features = ["alloc"] }
# Frontier
fp-evm = { workspace = true }
frame-support = { workspace = true }
pallet-evm = { workspace = true }

[features]
default = ["std"]
std = [
# Frontier
"fp-evm/std",
"frame-support/std",
"pallet-evm/std",
]
41 changes: 41 additions & 0 deletions frame/evm/precompile/curve25519/benchmarking/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[package]
name = "pallet-evm-precompile-curve25519-benchmarking"
version = "6.0.0-dev"
license = "Apache-2.0"
readme = "README.md"
description = "FRAME EVM precompile benchmarking pallet."
authors = { workspace = true }
edition = { workspace = true }
repository = { workspace = true }

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
curve25519-dalek = { version = "4.1.0", default-features = false, features = ["alloc"] }
sha2 = { workspace = true }

# Substrate
frame-benchmarking = { workspace = true, default-features = false }
frame-system = { workspace = true }
sp-runtime = { workspace = true, default-features = false }

# Precompile dependencies
pallet-evm-precompile-curve25519 = { workspace = true, default-features = false }

[features]
default = ["std"]
std = [
"sha2/std",
# Substrate
"frame-benchmarking/std",
"frame-system/std",
"sp-runtime/std",
# Precompile dependencies
"pallet-evm-precompile-curve25519/std",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
76 changes: 76 additions & 0 deletions frame/evm/precompile/curve25519/benchmarking/src/inner.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// This file is part of Frontier.

// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use alloc::format;
use core::marker::PhantomData;
use curve25519_dalek::{scalar::Scalar, RistrettoPoint};
use frame_benchmarking::v2::*;
use sha2::Sha512;
use sp_runtime::Vec;

// Import existing precompile implementations
use pallet_evm_precompile_curve25519::{Curve25519Add, Curve25519ScalarMul};

pub struct Pallet<T: Config>(PhantomData<T>);
pub trait Config: frame_system::Config {}

#[benchmarks]
mod benchmarks {
use super::*;

#[benchmark]
fn curve25519_add_n_points(n: Linear<1, 10>) -> Result<(), BenchmarkError> {
// Encode N points into a single buffer
let mut points = Vec::new();
for i in 0..n {
points.extend(
RistrettoPoint::hash_from_bytes::<Sha512>(format!("point_{i}").as_bytes())
.compress()
.to_bytes()
.to_vec(),
);
}

#[block]
{
Curve25519Add::<(), ()>::execute_inner(&points, 0)
.expect("Failed to execute curve25519 add");
}

Ok(())
}

#[benchmark]
fn curve25519_scaler_mul() -> Result<(), BenchmarkError> {
// Encode input (scalar - 32 bytes, point - 32 bytes)
let mut input = [0; 64];
input[0..32].copy_from_slice(&Scalar::from(1234567890u64).to_bytes());
input[32..64].copy_from_slice(
&RistrettoPoint::hash_from_bytes::<Sha512>("point_0".as_bytes())
.compress()
.to_bytes(),
);

#[block]
{
Curve25519ScalarMul::<(), ()>::execute_inner(&input, 0)
.expect("Failed to execute curve25519 add");
}

Ok(())
}
}
26 changes: 26 additions & 0 deletions frame/evm/precompile/curve25519/benchmarking/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// This file is part of Frontier.

// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#![cfg_attr(not(feature = "std"), no_std)]

extern crate alloc;

#[cfg(feature = "runtime-benchmarks")]
pub mod inner;

#[cfg(feature = "runtime-benchmarks")]
pub use inner::*;
Loading
Loading