From 3719adcb09f5026616053a3aef1d0e9e8160910a Mon Sep 17 00:00:00 2001 From: AurelienFT Date: Thu, 14 Nov 2024 13:46:15 +0100 Subject: [PATCH 1/2] Add boilerplate for new op codes --- Cargo.lock | 18 +++++++++--------- Cargo.toml | 2 +- benches/src/default_gas_costs.rs | 4 ++++ crates/client/assets/schema.sdl | 3 +++ crates/client/src/client/schema/chain.rs | 6 ++++++ 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c76eae062ab..f927a082eae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3166,7 +3166,7 @@ dependencies = [ [[package]] name = "fuel-asm" version = "0.58.2" -source = "git+https://github.com/fuelLabs/fuel-vm#486d06f83de6ea3411543f3034700b0157a65eb5" +source = "git+https://github.com/fuelLabs/fuel-vm?branch=add_zk_opcodes#d53e0605fab3725e925cdeddad2b4610ac95ac60" dependencies = [ "bitflags 2.6.0", "fuel-types 0.58.2", @@ -3177,7 +3177,7 @@ dependencies = [ [[package]] name = "fuel-compression" version = "0.58.2" -source = "git+https://github.com/fuelLabs/fuel-vm#486d06f83de6ea3411543f3034700b0157a65eb5" +source = "git+https://github.com/fuelLabs/fuel-vm?branch=add_zk_opcodes#d53e0605fab3725e925cdeddad2b4610ac95ac60" dependencies = [ "fuel-derive 0.58.2", "fuel-types 0.58.2", @@ -3891,7 +3891,7 @@ dependencies = [ [[package]] name = "fuel-crypto" version = "0.58.2" -source = "git+https://github.com/fuelLabs/fuel-vm#486d06f83de6ea3411543f3034700b0157a65eb5" +source = "git+https://github.com/fuelLabs/fuel-vm?branch=add_zk_opcodes#d53e0605fab3725e925cdeddad2b4610ac95ac60" dependencies = [ "coins-bip32", "coins-bip39", @@ -3923,7 +3923,7 @@ dependencies = [ [[package]] name = "fuel-derive" version = "0.58.2" -source = "git+https://github.com/fuelLabs/fuel-vm#486d06f83de6ea3411543f3034700b0157a65eb5" +source = "git+https://github.com/fuelLabs/fuel-vm?branch=add_zk_opcodes#d53e0605fab3725e925cdeddad2b4610ac95ac60" dependencies = [ "proc-macro2", "quote", @@ -3959,7 +3959,7 @@ dependencies = [ [[package]] name = "fuel-merkle" version = "0.58.2" -source = "git+https://github.com/fuelLabs/fuel-vm#486d06f83de6ea3411543f3034700b0157a65eb5" +source = "git+https://github.com/fuelLabs/fuel-vm?branch=add_zk_opcodes#d53e0605fab3725e925cdeddad2b4610ac95ac60" dependencies = [ "derive_more 0.99.18", "digest 0.10.7", @@ -3979,7 +3979,7 @@ checksum = "4c1b711f28553ddc5f3546711bd220e144ce4c1af7d9e9a1f70b2f20d9f5b791" [[package]] name = "fuel-storage" version = "0.58.2" -source = "git+https://github.com/fuelLabs/fuel-vm#486d06f83de6ea3411543f3034700b0157a65eb5" +source = "git+https://github.com/fuelLabs/fuel-vm?branch=add_zk_opcodes#d53e0605fab3725e925cdeddad2b4610ac95ac60" [[package]] name = "fuel-tx" @@ -4006,7 +4006,7 @@ dependencies = [ [[package]] name = "fuel-tx" version = "0.58.2" -source = "git+https://github.com/fuelLabs/fuel-vm#486d06f83de6ea3411543f3034700b0157a65eb5" +source = "git+https://github.com/fuelLabs/fuel-vm?branch=add_zk_opcodes#d53e0605fab3725e925cdeddad2b4610ac95ac60" dependencies = [ "bitflags 2.6.0", "derivative", @@ -4039,7 +4039,7 @@ dependencies = [ [[package]] name = "fuel-types" version = "0.58.2" -source = "git+https://github.com/fuelLabs/fuel-vm#486d06f83de6ea3411543f3034700b0157a65eb5" +source = "git+https://github.com/fuelLabs/fuel-vm?branch=add_zk_opcodes#d53e0605fab3725e925cdeddad2b4610ac95ac60" dependencies = [ "fuel-derive 0.58.2", "hex", @@ -4081,7 +4081,7 @@ dependencies = [ [[package]] name = "fuel-vm" version = "0.58.2" -source = "git+https://github.com/fuelLabs/fuel-vm#486d06f83de6ea3411543f3034700b0157a65eb5" +source = "git+https://github.com/fuelLabs/fuel-vm?branch=add_zk_opcodes#d53e0605fab3725e925cdeddad2b4610ac95ac60" dependencies = [ "anyhow", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index 27dc602e521..e6bc470e501 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -145,4 +145,4 @@ tempfile = "3.4" tikv-jemallocator = "0.5" [patch.crates-io] -fuel-vm = { git = "https://github.com/fuelLabs/fuel-vm" } +fuel-vm = { git = "https://github.com/fuelLabs/fuel-vm", branch = "add_zk_opcodes" } diff --git a/benches/src/default_gas_costs.rs b/benches/src/default_gas_costs.rs index ed10c1c3333..4cd52c675c0 100644 --- a/benches/src/default_gas_costs.rs +++ b/benches/src/default_gas_costs.rs @@ -90,6 +90,10 @@ pub fn default_gas_costs() -> GasCostsValues { wqmm: 6, xor: 2, xori: 2, + // TODO: Change + eadd: 2, + emul: 2, + epar: DependentCost::LightOperation { base: 2, units_per_gas: 30 }, aloc: DependentCost::LightOperation { base: 2, units_per_gas: 35, diff --git a/crates/client/assets/schema.sdl b/crates/client/assets/schema.sdl index 54db4ec0995..b873b548073 100644 --- a/crates/client/assets/schema.sdl +++ b/crates/client/assets/schema.sdl @@ -442,6 +442,8 @@ type GasCosts { wqmm: U64! xor: U64! xori: U64! + eadd: U64! + emul: U64! alocDependentCost: DependentCost! bldd: DependentCost bsiz: DependentCost @@ -466,6 +468,7 @@ type GasCosts { smo: DependentCost! srwq: DependentCost! swwq: DependentCost! + epar: DependentCost! contractRoot: DependentCost! stateRoot: DependentCost! vmInitialization: DependentCost! diff --git a/crates/client/src/client/schema/chain.rs b/crates/client/src/client/schema/chain.rs index 7f76de69d16..d53768225ad 100644 --- a/crates/client/src/client/schema/chain.rs +++ b/crates/client/src/client/schema/chain.rs @@ -284,6 +284,8 @@ pub struct GasCosts { pub wqmm: U64, pub xor: U64, pub xori: U64, + pub eadd: U64, + pub emul: U64, pub aloc_dependent_cost: DependentCost, pub bsiz: Option, @@ -309,6 +311,7 @@ pub struct GasCosts { pub smo: DependentCost, pub srwq: DependentCost, pub swwq: DependentCost, + pub epar: DependentCost, // Non-opcodes prices pub contract_root: DependentCost, @@ -415,6 +418,8 @@ impl TryFrom for fuel_core_types::fuel_tx::GasCosts { wqmm: value.wqmm.into(), xor: value.xor.into(), xori: value.xori.into(), + eadd: value.eadd.into(), + emul: value.emul.into(), aloc: value.aloc_dependent_cost.into(), bsiz: value.bsiz.map(Into::into).unwrap_or(fuel_core_types::fuel_tx::consensus_parameters::DependentCost::free()), @@ -440,6 +445,7 @@ impl TryFrom for fuel_core_types::fuel_tx::GasCosts { smo: value.smo.into(), srwq: value.srwq.into(), swwq: value.swwq.into(), + epar: value.epar.into(), contract_root: value.contract_root.into(), state_root: value.state_root.into(), vm_initialization: value.vm_initialization.into(), From e8fe7f4b92ae96dd16ba1c1c1ce4ea895f73528f Mon Sep 17 00:00:00 2001 From: AurelienFT Date: Thu, 14 Nov 2024 13:57:33 +0100 Subject: [PATCH 2/2] Add boilerplate for benches and fmt --- benches/benches/vm_set/crypto.rs | 22 ++++++++++++++++++++++ benches/src/default_gas_costs.rs | 5 ++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/benches/benches/vm_set/crypto.rs b/benches/benches/vm_set/crypto.rs index cb266a4df36..a0ed05105c1 100644 --- a/benches/benches/vm_set/crypto.rs +++ b/benches/benches/vm_set/crypto.rs @@ -154,4 +154,26 @@ pub fn run(c: &mut Criterion) { ); } bench_ed19.finish(); + + // TODO: Update with real values + // ec add + run_group_ref( + &mut c.benchmark_group("ecadd"), + "eadd", + VmBench::new(op::eadd(1, 1, 1, 1)), + ); + + // ec mul + run_group_ref( + &mut c.benchmark_group("ecmul"), + "emul", + VmBench::new(op::emul(1, 1, 1, 1)), + ); + + // ec pairing + run_group_ref( + &mut c.benchmark_group("ecpair"), + "epar", + VmBench::new(op::epar(1, 1, 1, 1)), + ); } diff --git a/benches/src/default_gas_costs.rs b/benches/src/default_gas_costs.rs index 4cd52c675c0..dc221857f85 100644 --- a/benches/src/default_gas_costs.rs +++ b/benches/src/default_gas_costs.rs @@ -93,7 +93,10 @@ pub fn default_gas_costs() -> GasCostsValues { // TODO: Change eadd: 2, emul: 2, - epar: DependentCost::LightOperation { base: 2, units_per_gas: 30 }, + epar: DependentCost::LightOperation { + base: 2, + units_per_gas: 30, + }, aloc: DependentCost::LightOperation { base: 2, units_per_gas: 35,