Skip to content

Commit cf4ab5a

Browse files
committed
fix mpt table assignment
1 parent ec3a3af commit cf4ab5a

File tree

2 files changed

+33
-27
lines changed

2 files changed

+33
-27
lines changed

src/lib.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@ impl<Fp: FieldExt> Circuit<Fp> for SimpleTrie<Fp> {
158158
}
159159

160160
fn configure(meta: &mut ConstraintSystem<Fp>) -> Self::Config {
161-
let layer = LayerGadget::configure(meta, 2,
161+
let layer = LayerGadget::configure(
162+
meta,
163+
2,
162164
MPTOpGadget::min_free_cols(),
163165
MPTOpGadget::min_ctrl_types(),
164166
);
@@ -440,11 +442,12 @@ impl EthTrieConfig {
440442
rows: usize,
441443
) -> Result<(), Error> {
442444
let mpt_entries = tbl_tips.into_iter().zip(ops).map(|(proof_type, op)| {
443-
if let Some(rand) = randomness {
444-
MPTEntry::from_op(proof_type, op, rand)
445-
} else {
446-
MPTEntry::from_op_no_base(proof_type, op)
447-
}
445+
MPTEntry::from_op(proof_type, op, randomness.unwrap_or_default())
446+
//if let Some(rand) = randomness {
447+
// MPTEntry::from_op(proof_type, op, rand)
448+
//} else {
449+
// MPTEntry::from_op_no_base(proof_type, op)
450+
//}
448451
});
449452

450453
let mpt_tbl = MPTTable::construct(

src/mpt_table.rs

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ impl<F: FieldExt> MPTTable<F> {
502502
RangeCheckChip::construct(config.range_check_u8.clone()).load(layouter)?;
503503

504504
layouter.assign_region(
505-
|| "mpt table",
505+
|| "mpt table inside",
506506
|mut region| {
507507
for (offset, entry) in self.entries.iter().enumerate() {
508508
for (index, col) in config.proof_sel.as_slice().iter().copied().enumerate() {
@@ -520,26 +520,29 @@ impl<F: FieldExt> MPTTable<F> {
520520
)?;
521521
}
522522

523-
if let Some(base_entries) = entry.base {
524-
for (val, col) in base_entries.iter().zip(
525-
[
526-
config.address,
527-
config.storage_key,
528-
config.proof_type,
529-
config.new_root,
530-
config.old_root,
531-
config.new_value,
532-
config.old_value,
533-
]
534-
.as_slice(),
535-
) {
536-
region.assign_advice(
537-
|| format!("assign for mpt table offset {}", offset),
538-
*col,
539-
offset,
540-
|| Value::known(*val),
541-
)?;
542-
}
523+
let values = match entry.base {
524+
Some(base_entries) => base_entries.map(|x| Value::known(x)),
525+
None => [Value::unknown(); 7],
526+
};
527+
528+
for (val, col) in values.iter().zip(
529+
[
530+
config.address,
531+
config.storage_key,
532+
config.proof_type,
533+
config.new_root,
534+
config.old_root,
535+
config.new_value,
536+
config.old_value,
537+
]
538+
.as_slice(),
539+
) {
540+
region.assign_advice(
541+
|| format!("assign for mpt table offset {}", offset),
542+
*col,
543+
offset,
544+
|| *val,
545+
)?;
543546
}
544547

545548
config.storage_key_2.assign(

0 commit comments

Comments
 (0)