From 6a2e7d2327e45b411f9ce93f592dd065b7cb7206 Mon Sep 17 00:00:00 2001 From: Mason Liang Date: Mon, 6 Nov 2023 15:41:23 -0500 Subject: [PATCH] Add fixed column to lookup_exprs for mpt circuit --- src/gadgets/mpt_update.rs | 7 ++++--- src/mpt.rs | 10 +++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/gadgets/mpt_update.rs b/src/gadgets/mpt_update.rs index cedd72c4..5a35e517 100644 --- a/src/gadgets/mpt_update.rs +++ b/src/gadgets/mpt_update.rs @@ -45,7 +45,7 @@ lazy_static! { } pub trait MptUpdateLookup { - fn lookup(&self) -> [Query; 8]; + fn lookup(&self) -> [Query; 7]; } #[derive(Clone)] @@ -77,8 +77,10 @@ pub struct MptUpdateConfig { } impl MptUpdateLookup for MptUpdateConfig { - fn lookup(&self) -> [Query; 8] { + fn lookup(&self) -> [Query; 7] { let is_start = || self.segment_type.current_matches(&[SegmentType::Start]); + // Note that one non-start rows, all 7 queries will be 0. This corresponds to a valid + // mpt proof in that in an empty trie, the zero address has nonce = 0. let old_root_rlc = self.second_phase_intermediate_values[0].current() * is_start(); let new_root_rlc = self.second_phase_intermediate_values[1].current() * is_start(); let proof_type = self.proof_type.current() * is_start(); @@ -90,7 +92,6 @@ impl MptUpdateLookup for MptUpdateConfig { * is_start(); let storage_key_rlc = self.storage_key_rlc.current() * is_start(); [ - is_start().into(), address, storage_key_rlc, proof_type, diff --git a/src/mpt.rs b/src/mpt.rs index 12ce206c..da923762 100644 --- a/src/mpt.rs +++ b/src/mpt.rs @@ -1,5 +1,5 @@ use crate::{ - constraint_builder::{ConstraintBuilder, SelectorColumn}, + constraint_builder::{ConstraintBuilder, Query, SelectorColumn}, gadgets::{ byte_bit::ByteBitGadget, byte_representation::ByteRepresentationConfig, @@ -76,7 +76,6 @@ impl MptCircuitConfig { // exist in an mpt with root = 0 (i.e. the mpt is empty). let is_final_row = SelectorColumn(cs.fixed_column()); let padding_row_expressions = [ - 1.into(), 0.into(), 0.into(), (MPTProofType::AccountDoesNotExist as u64).into(), @@ -173,7 +172,12 @@ impl MptCircuitConfig { } pub fn lookup_exprs(&self, meta: &mut VirtualCells<'_, F>) -> [Expression; 8] { - self.mpt_update.lookup().map(|q| q.run(meta)) + std::iter::once(Query::from(self.selector.current())) + .chain(self.mpt_update.lookup().into_iter()) + .map(|q| q.run(meta)) + .collect::>() + .try_into() + .unwrap() } /// The number of minimum number of rows required for the mpt circuit.