From 78e3bacdc42d19d1041cbd39fbca049fe0eeeb25 Mon Sep 17 00:00:00 2001 From: CPerezz Date: Thu, 5 Jan 2023 17:36:10 +0100 Subject: [PATCH] fix: Add empty row in MPT table to prevent testing panics As pointed by @lispc in https://github.com/privacy-scaling-explorations/zkevm-circuits/pull/1024#issuecomment-1372217747, Halo2 currently has a bug which prevents it to render correctly the errors for an empty region with a `ConstraintError` on it. An issue has been filled for this so that we can fix it in https://github.com/privacy-scaling-explorations/halo2/issues/117. Meanwhile a new tag is not released for Halo2 with a fix, this fix will temporarily be needed and a reminder to remove it has been created in https://github.com/privacy-scaling-explorations/zkevm-circuits/issues/1032 --- zkevm-circuits/src/table.rs | 3 ++- zkevm-circuits/src/witness/mpt.rs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/zkevm-circuits/src/table.rs b/zkevm-circuits/src/table.rs index 9200051218..1b7d9a1667 100644 --- a/zkevm-circuits/src/table.rs +++ b/zkevm-circuits/src/table.rs @@ -534,8 +534,9 @@ impl MptTable { updates: &MptUpdates, randomness: Value, ) -> Result<(), Error> { + self.assign(region, 0, &MptUpdateRow([Value::known(F::zero()); 7]))?; for (offset, row) in updates.table_assignments(randomness).iter().enumerate() { - self.assign(region, offset, row)?; + self.assign(region, offset + 1, row)?; } Ok(()) } diff --git a/zkevm-circuits/src/witness/mpt.rs b/zkevm-circuits/src/witness/mpt.rs index 2ea84372c5..8a7fcfdd05 100644 --- a/zkevm-circuits/src/witness/mpt.rs +++ b/zkevm-circuits/src/witness/mpt.rs @@ -37,7 +37,7 @@ pub struct MptUpdates(HashMap); /// The field element encoding of an MPT update, which is used by the MptTable #[derive(Debug, Clone, Copy)] -pub struct MptUpdateRow([F; 7]); +pub struct MptUpdateRow(pub(crate) [F; 7]); impl MptUpdates { pub(crate) fn get(&self, row: &Rw) -> Option {