Skip to content

Commit c779f4c

Browse files
authored
Merge pull request #1896 from taonado/bn128-precompiles
Add bn128 ec precompiles
2 parents 6309d35 + 636ee35 commit c779f4c

File tree

5 files changed

+42
-21
lines changed

5 files changed

+42
-21
lines changed

Cargo.lock

Lines changed: 30 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ pallet-evm-chain-id = { git = "https://github.com/opentensor/frontier", rev = "f
224224
pallet-evm-precompile-modexp = { git = "https://github.com/opentensor/frontier", rev = "fe6976888fda696771cd15f78dbbdd71ee6c1216", default-features = false }
225225
pallet-evm-precompile-sha3fips = { git = "https://github.com/opentensor/frontier", rev = "fe6976888fda696771cd15f78dbbdd71ee6c1216", default-features = false }
226226
pallet-evm-precompile-simple = { git = "https://github.com/opentensor/frontier", rev = "fe6976888fda696771cd15f78dbbdd71ee6c1216", default-features = false }
227+
pallet-evm-precompile-bn128 = { git = "https://github.com/opentensor/frontier", rev = "fe6976888fda696771cd15f78dbbdd71ee6c1216", default-features = false }
227228
pallet-hotfix-sufficients = { git = "https://github.com/opentensor/frontier", rev = "fe6976888fda696771cd15f78dbbdd71ee6c1216", default-features = false }
228229

229230
#DRAND

precompiles/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pallet-evm-precompile-dispatch = { workspace = true }
2323
pallet-evm-precompile-modexp = { workspace = true }
2424
pallet-evm-precompile-sha3fips = { workspace = true }
2525
pallet-evm-precompile-simple = { workspace = true }
26+
pallet-evm-precompile-bn128 = { workspace = true }
2627
pallet-proxy = { workspace = true }
2728
precompile-utils = { workspace = true }
2829
sp-core = { workspace = true }
@@ -55,6 +56,7 @@ std = [
5556
"pallet-evm-precompile-modexp/std",
5657
"pallet-evm-precompile-sha3fips/std",
5758
"pallet-evm-precompile-simple/std",
59+
"pallet-evm-precompile-bn128/std",
5860
"pallet-evm/std",
5961
"pallet-crowdloan/std",
6062
"pallet-proxy/std",

precompiles/src/lib.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use pallet_evm::{
1313
AddressMapping, IsPrecompileResult, Precompile, PrecompileHandle, PrecompileResult,
1414
PrecompileSet,
1515
};
16+
use pallet_evm_precompile_bn128::{Bn128Add, Bn128Mul, Bn128Pairing};
1617
use pallet_evm_precompile_dispatch::Dispatch;
1718
use pallet_evm_precompile_modexp::Modexp;
1819
use pallet_evm_precompile_sha3fips::Sha3FIPS256;
@@ -106,14 +107,17 @@ where
106107
Self(Default::default())
107108
}
108109

109-
pub fn used_addresses() -> [H160; 21] {
110+
pub fn used_addresses() -> [H160; 24] {
110111
[
111112
hash(1),
112113
hash(2),
113114
hash(3),
114115
hash(4),
115116
hash(5),
116117
hash(6),
118+
hash(7),
119+
hash(8),
120+
hash(9),
117121
hash(1024),
118122
hash(1025),
119123
hash(Ed25519Verify::<R::AccountId>::INDEX),
@@ -166,6 +170,9 @@ where
166170
a if a == hash(4) => Some(Identity::execute(handle)),
167171
a if a == hash(5) => Some(Modexp::execute(handle)),
168172
a if a == hash(6) => Some(Dispatch::<R>::execute(handle)),
173+
a if a == hash(7) => Some(Bn128Mul::execute(handle)),
174+
a if a == hash(8) => Some(Bn128Pairing::execute(handle)),
175+
a if a == hash(9) => Some(Bn128Add::execute(handle)),
169176
// Non-Frontier specific nor Ethereum precompiles :
170177
a if a == hash(1024) => Some(Sha3FIPS256::execute(handle)),
171178
a if a == hash(1025) => Some(ECRecoverPublicKey::execute(handle)),

runtime/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
218218
// `spec_version`, and `authoring_version` are the same between Wasm and native.
219219
// This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use
220220
// the compatible custom types.
221-
spec_version: 298,
221+
spec_version: 299,
222222
impl_version: 1,
223223
apis: RUNTIME_API_VERSIONS,
224224
transaction_version: 1,

0 commit comments

Comments
 (0)