Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add zk opcodes #2439

Draft
wants to merge 2 commits into
base: use-storage-read-with-offset
Choose a base branch
from
Draft
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
18 changes: 9 additions & 9 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
22 changes: 22 additions & 0 deletions benches/benches/vm_set/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
);
}
7 changes: 7 additions & 0 deletions benches/src/default_gas_costs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ 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,
Expand Down
3 changes: 3 additions & 0 deletions crates/client/assets/schema.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,8 @@ type GasCosts {
wqmm: U64!
xor: U64!
xori: U64!
eadd: U64!
emul: U64!
alocDependentCost: DependentCost!
bldd: DependentCost
bsiz: DependentCost
Expand All @@ -466,6 +468,7 @@ type GasCosts {
smo: DependentCost!
srwq: DependentCost!
swwq: DependentCost!
epar: DependentCost!
contractRoot: DependentCost!
stateRoot: DependentCost!
vmInitialization: DependentCost!
Expand Down
6 changes: 6 additions & 0 deletions crates/client/src/client/schema/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<DependentCost>,
Expand All @@ -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,
Expand Down Expand Up @@ -415,6 +418,8 @@ impl TryFrom<GasCosts> 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()),
Expand All @@ -440,6 +445,7 @@ impl TryFrom<GasCosts> 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(),
Expand Down
Loading