-
Notifications
You must be signed in to change notification settings - Fork 272
Coherence between state/storage updates in state circuit - MPT circuit #217
Comments
From MPT circuit perspective this is even easier and at first I thought we will have something like this, but then I got the impression we would better like not to have these intermediate state roots in the state circuit? But yes, MPT can be quickly changed according to the proposal. |
Mostly for my understanding, I've tried to synthesize @han0110's proposal with the option 2 from #200 (comment) and came up with this: From privacy-scaling-explorations/zkevm-circuits#591, we add
We also add two advice columns,
(It's possible that we can elminate the When
is the last access to
which proves that updating For With these, the state circuit proves that The main thing that's missing in the state circuit for this is the sequence of intermediate state roots. Does the MPT circuit have access to these already? @han0110, @ed255 , @miha-stopar, does my description here match what you guys have in mind? |
I'm unsure if we want to reduce the lookup size. But note that we can RLC the prev_values with the curr ones. So from: Not sure if it's worth TBH. But just leaving the thought here. |
Yes, intermediate state roots are returned by MPT witness generator together with other witness data. |
@z2trillion The lookup process described here is exactly what I imagined! Also:
My thought was to get rid of them in the beginning (less column and less constraint), but I realized it might be related to how we aggregate different circuits together, so I also think it's make more sense to keep them now. |
Your description matches exactly the way I have in mind :) The main points for me are:
|
@lispc had proposed (#210 (comment)) RLC'ing all the columns of a lookup together by default. In this case,
Is that no longer the plan, if it ever was? |
I made a draft PR adding mpt lookups to the state circuit: privacy-scaling-explorations/zkevm-circuits#621. |
Specs PR for this #236 |
The EVM circuit tracks all accesses to the execution state that happen during a transaction via lookups to the
rw_table
in the state circuit. The only accesses that should be allowed are those tracked via the EVM circuit, so we must guarantee that therw_table
doesn't contain more entries than the ones in the EVM circuit.To achieve this, the original design assigns a sequential counter to each rw access, and with it we can verify that the number of accesses in the EVM circuit and in the
rw_table
are the same. (this counter may be removed in favor of using the shuffle argument instead of lookups, which already guarantees that the items are the same in both sides).A similar situation happens between the state circuit and the MPT circuit, which verifies the storage and state trie updates. We must guarantee that the MPT circuit doesn't do more updates than the ones tracked in the state circuit. To achieve this the current design defines the
mpt_counter
, which is a sequential counter used for each update from the state circuit, that is used to verify that the number of updates in the MPT circuit match.Nevertheless a different design proposed by @han0110 is possible. Currently the updates in the MPT circuit are chained so that the
prevUpdate.curStateRoot == curUpdate.prevStateRoot
. The proposal consist of removing the chaining in the MPT circuit (so that each update in the MPT circuit is disconnected), and to track the state roots in the state circuit by adding the columnsprevStateRoot
andcurStateRoot
. The state circuit would guarantee that every storage/account update is chained via theprevStateRoot
andcurStateRoot
and then expose theprevStateRoot
of the first update and thecurStateRoot
of the last update as public inputs (in order to verify that they match withprevBlock.StateRoot
andcurBlock.StateRoot
). This change would require adding theprevStateRoot
andcurStateRoot
in the MPT lookup table. Following this approach removes the need to have thempt_counter
, which should simplify the design and implementation.So the MPT lookup would change from
to
@miha-stopar What do you think about this proposal?
The text was updated successfully, but these errors were encountered: