Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Commit

Permalink
🎨 cargo fmt + Cargo.toml update opcodes version
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaMasych committed May 27, 2024
1 parent da2ff85 commit 8ad9745
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 21 deletions.
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ serde = { version = "1", features = ["derive"] }
static_assertions = "1"
num_enum = "0.6"

zkevm_opcode_defs = { git = "https://github.com/matter-labs/era-zkevm_opcode_defs.git", branch = "v1.5.0" }
# zkevm_opcode_defs = { path = "../era-zkevm_opcode_defs" }
# TODO: change to use matter-labs when everything is merged:
# zkevm_opcode_defs = { git = "https://github.com/matter-labs/era-zkevm_opcode_defs.git", branch = "dl-precompiles" }
# zkevm_opcode_defs = { git = "https://github.com/distributed-lab/era-zkevm_opcode_defs.git", branch = "feature/ec-and-modexp-precompiles" }
zkevm_opcode_defs = { path = "../era-zkevm_opcode_defs" }


[dev-dependencies]
Expand Down
12 changes: 8 additions & 4 deletions src/precompiles/ecadd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ impl<const B: bool> Precompile for ECAddPrecompile<B> {
value_is_pointer: false,
rw_flag: true,
};
let x_result_query = memory.execute_partial_query(monotonic_cycle_counter, x_result_query);
let x_result_query =
memory.execute_partial_query(monotonic_cycle_counter, x_result_query);

// Writing resultant y coordinate
write_location.index.0 += 1;
Expand All @@ -187,7 +188,8 @@ impl<const B: bool> Precompile for ECAddPrecompile<B> {
value_is_pointer: false,
rw_flag: true,
};
let y_result_query = memory.execute_partial_query(monotonic_cycle_counter, y_result_query);
let y_result_query =
memory.execute_partial_query(monotonic_cycle_counter, y_result_query);

if B {
round_witness.writes[0] = ok_or_err_query;
Expand Down Expand Up @@ -224,7 +226,8 @@ impl<const B: bool> Precompile for ECAddPrecompile<B> {
value_is_pointer: false,
rw_flag: true,
};
let x_result_query = memory.execute_partial_query(monotonic_cycle_counter, x_result_query);
let x_result_query =
memory.execute_partial_query(monotonic_cycle_counter, x_result_query);

let y_result_query = MemoryQuery {
timestamp: timestamp_to_write,
Expand All @@ -233,7 +236,8 @@ impl<const B: bool> Precompile for ECAddPrecompile<B> {
value_is_pointer: false,
rw_flag: true,
};
let y_result_query = memory.execute_partial_query(monotonic_cycle_counter, y_result_query);
let y_result_query =
memory.execute_partial_query(monotonic_cycle_counter, y_result_query);

if B {
round_witness.writes[0] = ok_or_err_query;
Expand Down
12 changes: 8 additions & 4 deletions src/precompiles/ecmul.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ impl<const B: bool> Precompile for ECMulPrecompile<B> {
value_is_pointer: false,
rw_flag: true,
};
let x_result_query = memory.execute_partial_query(monotonic_cycle_counter, x_result_query);
let x_result_query =
memory.execute_partial_query(monotonic_cycle_counter, x_result_query);

// Writing resultant y coordinate
write_location.index.0 += 1;
Expand All @@ -170,7 +171,8 @@ impl<const B: bool> Precompile for ECMulPrecompile<B> {
value_is_pointer: false,
rw_flag: true,
};
let y_result_query = memory.execute_partial_query(monotonic_cycle_counter, y_result_query);
let y_result_query =
memory.execute_partial_query(monotonic_cycle_counter, y_result_query);

if B {
round_witness.writes[0] = ok_or_err_query;
Expand Down Expand Up @@ -207,7 +209,8 @@ impl<const B: bool> Precompile for ECMulPrecompile<B> {
value_is_pointer: false,
rw_flag: true,
};
let x_result_query = memory.execute_partial_query(monotonic_cycle_counter, x_result_query);
let x_result_query =
memory.execute_partial_query(monotonic_cycle_counter, x_result_query);

write_location.index.0 += 1;
let empty_result = U256::zero();
Expand All @@ -218,7 +221,8 @@ impl<const B: bool> Precompile for ECMulPrecompile<B> {
value_is_pointer: false,
rw_flag: true,
};
let y_result_query = memory.execute_partial_query(monotonic_cycle_counter, y_result_query);
let y_result_query =
memory.execute_partial_query(monotonic_cycle_counter, y_result_query);

if B {
round_witness.writes[0] = ok_or_err_query;
Expand Down
11 changes: 7 additions & 4 deletions src/precompiles/ecpairing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,10 +462,13 @@ pub mod tests {
])
.unwrap();

println!("{:?}", vec![
[x1_1, y1_1, x2_1, y2_1, x3_1, y3_1],
[x1_2, y1_2, x2_2, y2_2, x3_2, y3_2],
]);
println!(
"{:?}",
vec![
[x1_1, y1_1, x2_1, y2_1, x3_1, y3_1],
[x1_2, y1_2, x2_2, y2_2, x3_2, y3_2],
]
);

assert_eq!(result, true);
}
Expand Down
6 changes: 3 additions & 3 deletions src/precompiles/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ use zkevm_opcode_defs::system_params::ECMUL_INNER_FUNCTION_PRECOMPILE_ADDRESS;
use zkevm_opcode_defs::system_params::ECPAIRING_INNER_FUNCTION_PRECOMPILE_ADDRESS;
use zkevm_opcode_defs::system_params::MODEXP_INNER_FUNCTION_PRECOMPILE_ADDRESS;
use zkevm_opcode_defs::system_params::{
ECRECOVER_INNER_FUNCTION_PRECOMPILE_ADDRESS, KECCAK256_ROUND_FUNCTION_PRECOMPILE_ADDRESS,
SHA256_ROUND_FUNCTION_PRECOMPILE_ADDRESS, ECADD_INNER_FUNCTION_PRECOMPILE_ADDRESS,
SECP256R1_VERIFY_PRECOMPILE_ADDRESS,
ECADD_INNER_FUNCTION_PRECOMPILE_ADDRESS, ECRECOVER_INNER_FUNCTION_PRECOMPILE_ADDRESS,
KECCAK256_ROUND_FUNCTION_PRECOMPILE_ADDRESS, SECP256R1_VERIFY_PRECOMPILE_ADDRESS,
SHA256_ROUND_FUNCTION_PRECOMPILE_ADDRESS,
};

use zkevm_opcode_defs::PrecompileCallABI;
Expand Down
7 changes: 3 additions & 4 deletions src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ use zkevm_opcode_defs::{
use crate::{
aux::{MemoryPage, PubdataCost, Timestamp},
precompiles::{
ecrecover::ECRecoverPrecompile, keccak256::Keccak256Precompile,
secp256r1_verify::Secp256r1VerifyPrecompile, sha256::Sha256Precompile,
ecadd::ECAddPrecompile, ecmul::ECMulPrecompile, ecpairing::ECPairingPrecompile,
modexp::ModexpPrecompile,
ecrecover::ECRecoverPrecompile, keccak256::Keccak256Precompile, modexp::ModexpPrecompile,
secp256r1_verify::Secp256r1VerifyPrecompile, sha256::Sha256Precompile,
},
queries::{DecommittmentQuery, LogQuery, MemoryQuery},
};
Expand Down Expand Up @@ -65,7 +64,7 @@ pub enum PrecompileCyclesWitness {
ECPairing(Vec<<ECPairingPrecompile<true> as Precompile>::CycleWitness>),
Modexp(Vec<<ModexpPrecompile<true> as Precompile>::CycleWitness>),
Secp256r1Verify(Vec<<Secp256r1VerifyPrecompile<true> as Precompile>::CycleWitness>),
}
}

// ALL traits here are for execution and NOT for witness generation. They can depend on one another, but should
// not have large interconnections.
Expand Down

0 comments on commit 8ad9745

Please sign in to comment.