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

Commit

Permalink
Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Brechtpd committed Sep 20, 2023
1 parent 1027a95 commit 4115e83
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
14 changes: 3 additions & 11 deletions zkevm-circuits/src/circuit_tools/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,13 @@ impl<F: Field, C: CellType, MB: MemoryBank<F, C>> Index<C> for Memory<F, C, MB>
type Output = MB;

fn index(&self, tag: C) -> &Self::Output {
if let Some(bank) = self.banks.get(&tag) {
bank
} else {
unreachable!()
}
self.banks.get(&tag).expect("bank exists")
}
}

impl<F: Field, C: CellType, MB: MemoryBank<F, C>> IndexMut<C> for Memory<F, C, MB> {
fn index_mut(&mut self, tag: C) -> &mut Self::Output {
if let Some(bank) = self.banks.get_mut(&tag) {
bank
} else {
unreachable!()
}
self.banks.get_mut(&tag).expect("bank exists")
}
}

Expand All @@ -56,7 +48,7 @@ impl<F: Field, C: CellType, MB: MemoryBank<F, C>> Memory<F, C, MB> {
}
}

pub(crate) fn add_rw(
pub(crate) fn add_memory_bank(
&mut self,
meta: &mut ConstraintSystem<F>,
cb: &mut ConstraintBuilder<F, C>,
Expand Down
10 changes: 5 additions & 5 deletions zkevm-circuits/src/mpt_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,23 +258,23 @@ impl<F: Field> MPTConfig<F> {
state_cm.add_columns(meta, &mut cb.base, lu(MptTableType::Mult), 2, false, 2);

let mut memory = Memory::new();
memory.add_rw(meta, &mut cb.base, &mut state_cm, MptCellType::MemKeyC, 2);
memory.add_rw(meta, &mut cb.base, &mut state_cm, MptCellType::MemKeyS, 2);
memory.add_rw(
memory.add_memory_bank(meta, &mut cb.base, &mut state_cm, MptCellType::MemKeyC, 2);
memory.add_memory_bank(meta, &mut cb.base, &mut state_cm, MptCellType::MemKeyS, 2);
memory.add_memory_bank(
meta,
&mut cb.base,
&mut state_cm,
MptCellType::MemParentC,
2,
);
memory.add_rw(
memory.add_memory_bank(
meta,
&mut cb.base,
&mut state_cm,
MptCellType::MemParentS,
2,
);
memory.add_rw(meta, &mut cb.base, &mut state_cm, MptCellType::MemMain, 2);
memory.add_memory_bank(meta, &mut cb.base, &mut state_cm, MptCellType::MemMain, 2);

let mut ctx = MPTContext {
mpt_table,
Expand Down

0 comments on commit 4115e83

Please sign in to comment.