Skip to content

Commit 7c4ba23

Browse files
committed
sync group 0.13.0
1 parent 1b78a0d commit 7c4ba23

File tree

10 files changed

+273
-279
lines changed

10 files changed

+273
-279
lines changed

Cargo.toml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,33 @@ edition = "2021"
66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

88
[dependencies]
9-
hash-circuit = { package = "poseidon-circuit", git = "https://github.com/scroll-tech/poseidon-circuit.git", branch = "scroll-dev-0111"}
10-
halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "scroll-dev-1220" }
9+
hash-circuit = { package = "poseidon-circuit", git = "https://github.com/scroll-tech/poseidon-circuit.git", branch = "halo2-ecc-snark-verifier-0220"}
10+
halo2_proofs = { git = "https://github.com/privacy-scaling-explorations/halo2.git", tag = "v2022_09_10" }
1111
rand = "0.8"
1212
lazy_static = "1.4.0"
1313
serde = { version = "1.0", features = ["derive"] }
1414
serde_json = "1.0"
1515
num-bigint = "0.4"
1616
hex = "0.4"
1717
thiserror = "1.0"
18-
log = "0.4"
18+
19+
[patch."https://github.com/privacy-scaling-explorations/halo2.git"]
20+
halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "halo2-ecc-snark-verifier-0220" }
21+
22+
# remove once
23+
# https://github.com/privacy-scaling-explorations/poseidon/pull/7
24+
# https://github.com/privacy-scaling-explorations/halo2curves/pull/31
25+
# are merged
26+
[patch."https://github.com/privacy-scaling-explorations/poseidon.git"]
27+
poseidon = { git = "https://github.com/scroll-tech/poseidon.git", branch = "halo2-ecc-snark-verifier-0220" }
28+
29+
30+
[patch."https://github.com/privacy-scaling-explorations/halo2curves.git"]
31+
halo2curves = { git = "https://github.com/scroll-tech/halo2curves.git", branch = "halo2-ecc-snark-verifier-0220" }
32+
33+
[patch.crates-io]
34+
# temporary solution to [email protected] being yanked, tracking issue: https://github.com/ferrilab/funty/issues/7
35+
funty = { git = "https://github.com/ferrilab/funty/", rev = "7ef0d890fbcd8b3def1635ac1a877fc298488446" }
1936

2037
[features]
2138
# printout the layout of circuits for demo and some unittests
@@ -33,4 +50,4 @@ path = "integration-tests/src/main.rs"
3350

3451
[profile.test]
3552
opt-level = 3
36-
debug-assertions = true
53+
debug-assertions = true

src/eth.rs

Lines changed: 31 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ use super::mpt;
3636
use super::CtrlTransitionKind;
3737
use crate::operation::{Account, AccountOp, KeyValue};
3838
use halo2_proofs::{
39-
arithmetic::FieldExt,
4039
circuit::{Chip, Region, Value},
40+
ff::PrimeField,
4141
plonk::{Advice, Column, ConstraintSystem, Error, Expression, Selector},
4242
poly::Rotation,
4343
};
@@ -79,7 +79,7 @@ impl AccountGadget {
7979
/// + circuit selector * 1
8080
/// + exported col * 8 (MUST by following sequence: layout_flag, s_enable, old_val, new_val, key_val and 3 ext field for old/new/key_val)
8181
/// + free col * 4
82-
pub fn configure<Fp: FieldExt>(
82+
pub fn configure<Fp: PrimeField>(
8383
meta: &mut ConstraintSystem<Fp>,
8484
sel: Selector,
8585
exported: &[Column<Advice>],
@@ -126,7 +126,7 @@ impl AccountGadget {
126126
//transition
127127
meta.lookup("account row trans", |meta| {
128128
let s_enable = meta.query_advice(s_enable, Rotation::cur())
129-
* (Expression::Constant(Fp::one())
129+
* (Expression::Constant(Fp::ONE)
130130
- meta.query_advice(s_ctrl_type[0], Rotation::cur()));
131131

132132
tables.build_lookup(
@@ -184,7 +184,7 @@ impl AccountGadget {
184184
let is_diff_ext_boolean =
185185
data_ext_diff.clone() * meta.query_advice(state_change_aux[1], Rotation::cur());
186186
187-
let one = Expression::Constant(Fp::one());
187+
let one = Expression::Constant(Fp::ONE);
188188
// switch A || B to ! (!A ^ !B)
189189
let has_diff = one.clone()
190190
- (one.clone() - is_diff_boolean.clone())
@@ -217,7 +217,7 @@ impl AccountGadget {
217217
s_enable
218218
* row0
219219
* (new_nonce.clone() - old_nonce.clone())
220-
* (new_nonce - old_nonce - Expression::Constant(Fp::one())),
220+
* (new_nonce - old_nonce - Expression::Constant(Fp::ONE)),
221221
]
222222
});*/
223223

@@ -250,7 +250,7 @@ impl AccountGadget {
250250
}
251251

252252
/// assign data and enable flag for account circuit
253-
pub fn assign<'d, Fp: FieldExt>(
253+
pub fn assign<'d, Fp: PrimeField>(
254254
&self,
255255
region: &mut Region<'_, Fp>,
256256
offset: usize,
@@ -298,7 +298,7 @@ impl AccountGadget {
298298
|| "enable account circuit",
299299
self.s_enable,
300300
offset,
301-
|| Value::known(Fp::one()),
301+
|| Value::known(Fp::ONE),
302302
)?;
303303
region.assign_advice(
304304
|| "account circuit rows",
@@ -310,31 +310,31 @@ impl AccountGadget {
310310
|| "enable s_ctrl",
311311
self.s_ctrl_type[index as usize],
312312
offset,
313-
|| Value::known(Fp::one()),
313+
|| Value::known(Fp::ONE),
314314
)?;
315315
if index == LAST_ROW {
316316
region.assign_advice(
317317
|| "padding last row",
318318
self.old_state.intermediate_2,
319319
offset,
320-
|| Value::known(Fp::zero()),
320+
|| Value::known(Fp::ZERO),
321321
)?;
322322

323323
region.assign_advice(
324324
|| "padding last row",
325325
self.new_state.intermediate_2,
326326
offset,
327-
|| Value::known(Fp::zero()),
327+
|| Value::known(Fp::ZERO),
328328
)?;
329329
}
330330
let data_delta = match index {
331-
0 => [data.0.nonce - data.1.nonce, Fp::zero()],
332-
1 => [data.0.balance - data.1.balance, Fp::zero()],
331+
0 => [data.0.nonce - data.1.nonce, Fp::ZERO],
332+
1 => [data.0.balance - data.1.balance, Fp::ZERO],
333333
2 => [
334334
data.0.codehash.0 - data.1.codehash.0,
335335
data.0.codehash.1 - data.1.codehash.1,
336336
],
337-
3 => [data.0.state_root - data.1.state_root, Fp::zero()],
337+
3 => [data.0.state_root - data.1.state_root, Fp::ZERO],
338338
_ => unreachable!("no such row number"),
339339
};
340340

@@ -350,7 +350,7 @@ impl AccountGadget {
350350
offset,
351351
|| {
352352
Value::known(if bool::from(val.is_zero()) {
353-
Fp::zero()
353+
Fp::ZERO
354354
} else {
355355
val.invert().unwrap()
356356
})
@@ -362,13 +362,7 @@ impl AccountGadget {
362362
|| "is data delta",
363363
self.state_change_key,
364364
offset,
365-
|| {
366-
Value::known(if has_data_delta {
367-
Fp::one()
368-
} else {
369-
Fp::zero()
370-
})
371-
},
365+
|| Value::known(if has_data_delta { Fp::ONE } else { Fp::ZERO }),
372366
)?;
373367
}
374368

@@ -391,7 +385,7 @@ struct AccountChip<'d, F> {
391385
data: &'d Account<F>,
392386
}
393387

394-
impl<Fp: FieldExt> Chip<Fp> for AccountChip<'_, Fp> {
388+
impl<Fp: PrimeField> Chip<Fp> for AccountChip<'_, Fp> {
395389
type Config = AccountChipConfig;
396390
type Loaded = Account<Fp>;
397391

@@ -404,7 +398,7 @@ impl<Fp: FieldExt> Chip<Fp> for AccountChip<'_, Fp> {
404398
}
405399
}
406400

407-
impl<'d, Fp: FieldExt> AccountChip<'d, Fp> {
401+
impl<'d, Fp: PrimeField> AccountChip<'d, Fp> {
408402
fn lagrange_polynomial_for_row<const T: usize>(ref_n: Expression<Fp>) -> Expression<Fp> {
409403
super::lagrange_polynomial::<Fp, T, LAST_ROW>(ref_n)
410404
}
@@ -509,7 +503,7 @@ impl<'d, Fp: FieldExt> AccountChip<'d, Fp> {
509503
),
510504
(
511505
config.acc_data_fields_ext,
512-
[Fp::zero(), Fp::zero(), data.codehash.1],
506+
[Fp::ZERO, Fp::ZERO, data.codehash.1],
513507
"data field ext",
514508
),
515509
(
@@ -519,7 +513,7 @@ impl<'d, Fp: FieldExt> AccountChip<'d, Fp> {
519513
),
520514
(
521515
config.intermediate_1,
522-
[Fp::zero(), data.hash_traces(2), data.hash_traces(0)],
516+
[Fp::ZERO, data.hash_traces(2), data.hash_traces(0)],
523517
"intermedia 1",
524518
),
525519
] {
@@ -544,7 +538,7 @@ impl<'d, Fp: FieldExt> AccountChip<'d, Fp> {
544538
|| "state root padding",
545539
config.acc_data_fields_ext,
546540
self.offset + LAST_ROW,
547-
|| Value::known(Fp::zero()),
541+
|| Value::known(Fp::ZERO),
548542
)?;
549543

550544
Ok(self.offset + LAST_ROW)
@@ -564,7 +558,7 @@ struct StorageChip<'d, F> {
564558
value: Option<KeyValue<F>>,
565559
}
566560

567-
impl<'d, Fp: FieldExt> StorageChip<'d, Fp> {
561+
impl<'d, Fp: PrimeField> StorageChip<'d, Fp> {
568562
fn configure(
569563
meta: &mut ConstraintSystem<Fp>,
570564
_sel: Selector,
@@ -592,14 +586,14 @@ impl<'d, Fp: FieldExt> StorageChip<'d, Fp> {
592586
|| "val limb 0",
593587
config.v_limbs[0],
594588
self.offset,
595-
|| Value::known(self.value.as_ref().map_or_else(Fp::zero, |v| v.limb_0())),
589+
|| Value::known(self.value.as_ref().map_or(Fp::ZERO, |v| v.limb_0())),
596590
)?;
597591

598592
region.assign_advice(
599593
|| "val limb 1",
600594
config.v_limbs[1],
601595
self.offset,
602-
|| Value::known(self.value.as_ref().map_or_else(Fp::zero, |v| v.limb_1())),
596+
|| Value::known(self.value.as_ref().map_or(Fp::ZERO, |v| v.limb_1())),
603597
)?;
604598

605599
Ok(self.offset + 1)
@@ -629,7 +623,7 @@ impl StorageGadget {
629623
/// + circuit selector * 1
630624
/// + exported col * 5 (MUST by following sequence: layout_flag, s_enable, old_val, new_val, key_val)
631625
/// + free col * 4
632-
pub fn configure<Fp: FieldExt>(
626+
pub fn configure<Fp: PrimeField>(
633627
meta: &mut ConstraintSystem<Fp>,
634628
sel: Selector,
635629
exported: &[Column<Advice>],
@@ -670,7 +664,7 @@ impl StorageGadget {
670664
[].into_iter()
671665
}
672666

673-
pub fn assign<'d, Fp: FieldExt>(
667+
pub fn assign<'d, Fp: PrimeField>(
674668
&self,
675669
region: &mut Region<'_, Fp>,
676670
offset: usize,
@@ -680,21 +674,21 @@ impl StorageGadget {
680674
|| "enable storage leaf circuit",
681675
self.s_enable,
682676
offset,
683-
|| Value::known(Fp::one()),
677+
|| Value::known(Fp::ONE),
684678
)?;
685679

686680
region.assign_advice(
687681
|| "storage leaf circuit row",
688682
self.ctrl_type,
689683
offset,
690-
|| Value::known(Fp::zero()),
684+
|| Value::known(Fp::ZERO),
691685
)?;
692686

693687
region.assign_advice(
694688
|| "enable s_ctrl",
695689
self.s_ctrl_type,
696690
offset,
697-
|| Value::known(Fp::one()),
691+
|| Value::known(Fp::ONE),
698692
)?;
699693

700694
for (config, value) in [
@@ -814,7 +808,7 @@ mod test {
814808
|| "flush top row",
815809
col,
816810
0,
817-
|| Value::known(Fp::zero()),
811+
|| Value::known(Fp::ZERO),
818812
)?;
819813
}
820814

@@ -824,7 +818,7 @@ mod test {
824818
|| "flush s_ctrl",
825819
col,
826820
offset,
827-
|| Value::known(Fp::zero()),
821+
|| Value::known(Fp::ZERO),
828822
)?;
829823
}
830824
}
@@ -844,7 +838,7 @@ mod test {
844838
|| "flush last row",
845839
col,
846840
till,
847-
|| Value::known(Fp::zero()),
841+
|| Value::known(Fp::ZERO),
848842
)?;
849843
}
850844
Ok(())

0 commit comments

Comments
 (0)