Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.

Commit bae6f57

Browse files
committed
everything compiles now
1 parent 95774d8 commit bae6f57

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+311
-388
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ ethers-etherscan = { git = "https://github.com/scroll-tech/ethers-rs.git", branc
6565
halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "sync-halo2-lib-0.4.0" }
6666
[patch."https://github.com/privacy-scaling-explorations/poseidon.git"]
6767
poseidon = { git = "https://github.com/scroll-tech/poseidon.git", branch = "sync-halo2-lib-0.4.0" }
68-
[patch."https://github.com/privacy-scaling-explorations/halo2wrong.git"]
69-
maingate = { git = "https://github.com/scroll-tech/halo2wrong", branch = "halo2-ecc-snark-verifier-0323" }
68+
# [patch."https://github.com/privacy-scaling-explorations/halo2wrong.git"]
69+
# maingate = { git = "https://github.com/scroll-tech/halo2wrong", branch = "halo2-ecc-snark-verifier-0323" }
7070

7171
# Definition of benchmarks profile to use.
7272
[profile.bench]

eth-types/src/evm_types.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Evm types needed for parsing instruction sets as well
22
33
use serde::{Deserialize, Serialize};
4-
use std::fmt;
4+
use std::{fmt, marker::ConstParamTy};
55

66
pub mod block_utils;
77
pub mod gas_utils;
@@ -78,8 +78,7 @@ mod gas_create {
7878
// [gasCreate2Eip3860](https://github.com/ethereum/go-ethereum/blob/eb83e7c54021573eaceb14236af3a7a8c64f6027/core/vm/gas_table.go#L321)
7979
// (similar for CREATE).
8080
// 1. size <= 49152 (MaxInitCodeSize)
81-
// 2. gasCost = memoryGasCost + (2 + 6) * ((size + 31) / 32) should not
82-
// overflow for Uint64.
81+
// 2. gasCost = memoryGasCost + (2 + 6) * ((size + 31) / 32) should not overflow for Uint64.
8382
// No need to constrain the second condition, since the maximum gas cost
8483
// cannot overflow for Uint64 (36028809887100925 calculated by
8584
// `memorySize = 0x1FFFFFFFE0` and `size = 49152`) if the first condition is
@@ -106,7 +105,7 @@ mod gas_create {
106105
pub use gas_create::*;
107106

108107
/// Defines the gas consumption.
109-
#[derive(Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
108+
#[derive(Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Serialize, Deserialize, ConstParamTy)]
110109
pub struct GasCost(pub u64);
111110

112111
impl fmt::Debug for GasCost {

eth-types/src/lib.rs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//#![deny(unsafe_code)] Allowed now until we find a
1212
// better way to handle downcasting from Operation into it's variants.
1313
#![allow(clippy::upper_case_acronyms)] // Too pedantic
14+
#![feature(adt_const_params)]
1415

1516
#[macro_use]
1617
pub mod macros;
@@ -25,7 +26,7 @@ pub mod sign_types;
2526

2627
pub use bytecode::Bytecode;
2728
pub use error::Error;
28-
use halo2_proofs::halo2curves::{bn256::Fr, group::ff::PrimeField};
29+
use halo2_proofs::halo2curves::{bn256::Fr, ff::FromUniformBytes, group::ff::PrimeField};
2930

3031
use crate::evm_types::{
3132
memory::Memory, stack::Stack, storage::Storage, Gas, GasCost, OpcodeId, ProgramCounter,
@@ -46,15 +47,33 @@ use std::{collections::HashMap, fmt, str::FromStr};
4647
/// Trait used to reduce verbosity with the declaration of the [`FieldExt`]
4748
/// trait and its repr.
4849
pub trait Field:
49-
PrimeField<Repr = [u8; 32]> + hash_circuit::hash::Hashable + std::convert::From<Fr>
50+
PrimeField<Repr = [u8; 32]>
51+
+ hash_circuit::hash::Hashable
52+
+ std::convert::From<Fr>
53+
+ FromUniformBytes<64>
54+
+ From<bool>
5055
{
56+
/// Re-expose zero element as a function
57+
fn zero() -> Self {
58+
Self::ZERO
59+
}
60+
61+
/// Re-expose one element as a function
62+
fn one() -> Self {
63+
Self::ONE
64+
}
65+
66+
/// Expose the lower 128 bits
67+
fn get_lower_128(&self) -> u128 {
68+
u128::from_le_bytes(self.to_repr().as_ref()[..16].try_into().unwrap())
69+
}
5170
}
5271

5372
// Impl custom `Field` trait for BN256 Fr to be used and consistent with the
5473
// rest of the workspace.
5574
impl Field for Fr {}
5675

57-
// Impl custom `Field` trait for BN256 Frq to be used and consistent with the
76+
// Impl custom `Field` trait for BN256 Fq to be used and consistent with the
5877
// rest of the workspace.
5978
// impl Field for Fq {}
6079

eth-types/src/sign_types.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ use ethers_core::{
1717
use halo2_proofs::{
1818
arithmetic::CurveAffine,
1919
halo2curves::{
20+
ff::FromUniformBytes,
2021
group::{
2122
ff::{Field as GroupField, PrimeField},
2223
prime::PrimeCurveAffine,
2324
Curve,
2425
},
2526
secp256k1::{Fp, Fq, Secp256k1Affine},
26-
Coordinates, ff::FromUniformBytes,
27+
Coordinates,
2728
},
2829
};
2930
use lazy_static::lazy_static;

gadgets/src/batched_is_zero.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ mod test {
158158
impl<F: Field, const N: usize> Circuit<F> for TestCircuit<F, N> {
159159
type Config = TestCircuitConfig<N>;
160160
type FloorPlanner = SimpleFloorPlanner;
161+
type Params = ();
161162

162163
fn without_witnesses(&self) -> Self {
163164
Self::default()

gadgets/src/evm_word.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ mod tests {
177177
// commitment which will be provided as public inputs.
178178
type Config = (WordConfig<F>, Column<Instance>);
179179
type FloorPlanner = SimpleFloorPlanner;
180+
type Params = ();
180181

181182
fn without_witnesses(&self) -> Self {
182183
Self::default()

gadgets/src/is_equal.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ mod tests {
149149
impl<F: Field, const RHS: u64> Circuit<F> for TestCircuit<F, RHS> {
150150
type Config = TestCircuitConfig<F, RHS>;
151151
type FloorPlanner = SimpleFloorPlanner;
152+
type Params = ();
152153

153154
fn without_witnesses(&self) -> Self {
154155
Self::default()

gadgets/src/is_zero.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ mod test {
222222
impl<F: Field> Circuit<F> for TestCircuit<F> {
223223
type Config = TestCircuitConfig<F>;
224224
type FloorPlanner = SimpleFloorPlanner;
225+
type Params = ();
225226

226227
fn without_witnesses(&self) -> Self {
227228
Self::default()
@@ -349,6 +350,7 @@ mod test {
349350
impl<F: Field> Circuit<F> for TestCircuit<F> {
350351
type Config = TestCircuitConfig<F>;
351352
type FloorPlanner = SimpleFloorPlanner;
353+
type Params = ();
352354

353355
fn without_witnesses(&self) -> Self {
354356
Self::default()

gadgets/src/less_than.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ mod test {
254254
impl<F: Field> Circuit<F> for TestCircuit<F> {
255255
type Config = TestCircuitConfig<F>;
256256
type FloorPlanner = SimpleFloorPlanner;
257+
type Params = ();
257258

258259
fn without_witnesses(&self) -> Self {
259260
Self::default()
@@ -376,6 +377,7 @@ mod test {
376377
impl<F: Field> Circuit<F> for TestCircuit<F> {
377378
type Config = TestCircuitConfig<F>;
378379
type FloorPlanner = SimpleFloorPlanner;
380+
type Params = ();
379381

380382
fn without_witnesses(&self) -> Self {
381383
Self::default()

gadgets/src/monotone.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ mod test {
138138
{
139139
type Config = TestCircuitConfig;
140140
type FloorPlanner = SimpleFloorPlanner;
141+
type Params = ();
141142

142143
fn without_witnesses(&self) -> Self {
143144
Self::default()

gadgets/src/mul_add.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,7 @@ mod test {
501501
impl<F: Field> Circuit<F> for TestCircuit<F> {
502502
type Config = TestCircuitConfig<F>;
503503
type FloorPlanner = SimpleFloorPlanner;
504+
type Params = ();
504505

505506
fn configure(meta: &mut halo2_proofs::plonk::ConstraintSystem<F>) -> Self::Config {
506507
let q_enable = meta.complex_selector();

rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nightly-2022-12-10
1+
nightly-2023-10-27

zkevm-circuits/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ serde.workspace = true
3232
serde_json.workspace = true
3333

3434
hash-circuit.workspace = true
35-
misc-precompiled-circuit = { package = "misc-precompiled-circuit", git = "https://github.com/scroll-tech/misc-precompiled-circuit.git", tag = "v0.1.0" }
35+
misc-precompiled-circuit = { package = "misc-precompiled-circuit", git = "https://github.com/scroll-tech/misc-precompiled-circuit.git", branch = "sync-halo2-lib-0.4.0" }
3636

37-
halo2-base = { git = "https://github.com/scroll-tech/halo2-lib", tag = "v0.1.5", default-features=false, features=["halo2-pse","display"] }
38-
halo2-ecc = { git = "https://github.com/scroll-tech/halo2-lib", tag = "v0.1.5", default-features=false, features=["halo2-pse","display"] }
37+
halo2-base = { git = "https://github.com/scroll-tech/halo2-lib", branch = "sync-halo2-lib-0.4.0", default-features=false, features=["halo2-pse","display"] }
38+
halo2-ecc = { git = "https://github.com/scroll-tech/halo2-lib", branch = "sync-halo2-lib-0.4.0", default-features=false, features=["halo2-pse","display"] }
3939

40-
maingate = { git = "https://github.com/privacy-scaling-explorations/halo2wrong", tag = "v2023_02_02" }
40+
# maingate = { git = "https://github.com/privacy-scaling-explorations/halo2wrong", tag = "v2023_02_02" }
4141

4242
num-bigint.workspace = true
4343
subtle.workspace = true

zkevm-circuits/src/bytecode_circuit/bytecode_unroller.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pub fn unroll_to_hash_input<F: Field, const BYTES_IN_FIELD: usize, const INPUT_L
8181
if cache.len() == BYTES_IN_FIELD {
8282
let mut buf: [u8; 64] = [0; 64];
8383
U256::from_big_endian(&cache).to_little_endian(&mut buf[0..32]);
84-
msgs.push(F::from_bytes_wide(&buf));
84+
msgs.push(F::from_uniform_bytes(&buf));
8585
cache.clear();
8686
}
8787
(msgs, cache)

zkevm-circuits/src/bytecode_circuit/dev.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pub type CircuitConfig<F> = super::circuit::BytecodeCircuitConfig<F>;
2828
impl<F: Field> Circuit<F> for BytecodeCircuit<F> {
2929
type Config = (CircuitConfig<F>, Challenges);
3030
type FloorPlanner = SimpleFloorPlanner;
31+
type Params = ();
3132

3233
fn without_witnesses(&self) -> Self {
3334
Self::default()

zkevm-circuits/src/copy_circuit/dev.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use halo2_proofs::{
1414
impl<F: Field> Circuit<F> for CopyCircuit<F> {
1515
type Config = (CopyCircuitConfig<F>, Challenges<Challenge>);
1616
type FloorPlanner = SimpleFloorPlanner;
17+
type Params = ();
1718

1819
fn without_witnesses(&self) -> Self {
1920
Self::default()

zkevm-circuits/src/copy_circuit/test.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,9 @@ fn assert_error_matches(result: Result<(), Vec<VerifyFailure>>, names: Vec<&str>
528528
VerifyFailure::CellNotAssigned { .. } => panic!(),
529529
VerifyFailure::ConstraintPoisoned { .. } => panic!(),
530530
VerifyFailure::Permutation { .. } => panic!(),
531+
&VerifyFailure::InstanceCellNotAssigned { .. } | &VerifyFailure::Shuffle { .. } => {
532+
todo!()
533+
}
531534
}
532535
}
533536
}

zkevm-circuits/src/evm_circuit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ use crate::util::MockChallenges as Challenges;
445445
impl<F: Field> Circuit<F> for EvmCircuit<F> {
446446
type Config = (EvmCircuitConfig<F>, Challenges);
447447
type FloorPlanner = SimpleFloorPlanner;
448+
type Params = ();
448449

449450
fn without_witnesses(&self) -> Self {
450451
Self::default()

zkevm-circuits/src/evm_circuit/execution.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ use bus_mapping::util::read_env_var;
2828
use eth_types::{Field, ToLittleEndian};
2929
use gadgets::util::not;
3030
use halo2_proofs::{
31-
arithmetic::FieldExt,
3231
circuit::{Layouter, Region, Value},
3332
plonk::{
3433
Advice, Assigned, Column, ConstraintSystem, Error, Expression, FirstPhase, Fixed, Selector,
@@ -223,7 +222,7 @@ use sstore::SstoreGadget;
223222
use stop::StopGadget;
224223
use swap::SwapGadget;
225224

226-
pub(crate) trait ExecutionGadget<F: FieldExt> {
225+
pub(crate) trait ExecutionGadget<F: Field> {
227226
const NAME: &'static str;
228227

229228
const EXECUTION_STATE: ExecutionState;

zkevm-circuits/src/evm_circuit/execution/mulmod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ impl<F: Field> ExecutionGadget<F> for MulModGadget<F> {
5858
let d = cb.query_word_rlc();
5959
let e = cb.query_word_rlc();
6060

61-
// 1. k1 * n + a_reduced == a
61+
// 1. k1 * n + a_reduced == a
6262
let modword = ModGadget::construct(cb, [&a, &n, &a_reduced]);
6363

64-
// 2. a_reduced * b + 0 == d * 2^256 + e
64+
// 2. a_reduced * b + 0 == d * 2^256 + e
6565
let mul512_left = MulAddWords512Gadget::construct(cb, [&a_reduced, &b, &d, &e], None);
6666

67-
// 3. k2 * n + r == d * 2^256 + e
67+
// 3. k2 * n + r == d * 2^256 + e
6868
let mul512_right = MulAddWords512Gadget::construct(cb, [&k, &n, &d, &e], Some(&r));
6969

7070
// (r < n ) or n == 0

zkevm-circuits/src/evm_circuit/execution/precompiles/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::marker::ConstParamTy;
2+
13
use eth_types::{Field, ToScalar};
24
use gadgets::util::Expr;
35
use halo2_proofs::{circuit::Value, plonk::Error};

zkevm-circuits/src/evm_circuit/execution/precompiles/modexp.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ impl<F: Field> ModExpInputs<F> {
419419
input_limbs.assign(region, offset, val_r)?;
420420
}
421421

422-
for (val, input_bytes) in values.zip([&self.base, &self.exp, &self.modulus]) {
422+
for (&val, input_bytes) in values.iter().zip([&self.base, &self.exp, &self.modulus]) {
423423
assign_word(region, offset, input_bytes, val)?;
424424
}
425425

@@ -977,6 +977,7 @@ mod test {
977977
precompile::PrecompileCalls,
978978
};
979979
use eth_types::{bytecode, word, ToWord};
980+
use ethers_core::k256::elliptic_curve::PrimeField;
980981
use itertools::Itertools;
981982
use mock::TestContext;
982983

@@ -985,7 +986,7 @@ mod test {
985986
#[test]
986987
fn test_limbs() {
987988
use crate::table::ModExpTable;
988-
use halo2_proofs::{arithmetic::FieldExt, halo2curves::bn256::Fr};
989+
use halo2_proofs::halo2curves::bn256::Fr;
989990
use misc_precompiled_circuit::circuits::modexp::Number;
990991
use num_bigint::BigUint;
991992

zkevm-circuits/src/evm_circuit/step.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::marker::ConstParamTy;
2+
13
use super::util::{CachedRegion, CellManager, CellType};
24
use crate::{
35
evm_circuit::{
@@ -9,9 +11,8 @@ use crate::{
911
witness::Transaction,
1012
};
1113
use bus_mapping::{evm::OpcodeId, precompile::PrecompileCalls};
12-
use eth_types::evm_types::GasCost;
14+
use eth_types::{evm_types::GasCost, Field};
1315
use halo2_proofs::{
14-
arithmetic::FieldExt,
1516
circuit::Value,
1617
plonk::{Advice, Column, ConstraintSystem, Error, Expression},
1718
};
@@ -36,7 +37,7 @@ impl From<PrecompileCalls> for ExecutionState {
3637
}
3738

3839
#[allow(non_camel_case_types)]
39-
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, EnumIter)]
40+
#[derive(ConstParamTy, Clone, Copy, Debug, PartialEq, Eq, Hash, EnumIter)]
4041
pub enum ExecutionState {
4142
// Internal state
4243
BeginTx,
@@ -433,7 +434,7 @@ pub(crate) struct DynamicSelectorHalf<F> {
433434
pub(crate) target_pairs: Vec<Cell<F>>,
434435
}
435436

436-
impl<F: FieldExt> DynamicSelectorHalf<F> {
437+
impl<F: Field> DynamicSelectorHalf<F> {
437438
pub(crate) fn new(cell_manager: &mut CellManager<F>, count: usize) -> Self {
438439
let target_pairs = cell_manager.query_cells(CellType::StoragePhase1, (count + 1) / 2);
439440
let target_odd = cell_manager.query_cell(CellType::StoragePhase1);
@@ -567,7 +568,7 @@ pub(crate) struct Step<F> {
567568
pub(crate) cell_manager: CellManager<F>,
568569
}
569570

570-
impl<F: FieldExt> Step<F> {
571+
impl<F: Field> Step<F> {
571572
pub(crate) fn new(
572573
meta: &mut ConstraintSystem<F>,
573574
advices: [Column<Advice>; STEP_WIDTH],

0 commit comments

Comments
 (0)