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

Support non-existing proofs in RwTable#291

Merged
ed255 merged 1 commit into
masterfrom
feature/non-exist-proofs
Oct 5, 2022
Merged

Support non-existing proofs in RwTable#291
ed255 merged 1 commit into
masterfrom
feature/non-exist-proofs

Conversation

@ed255
Copy link
Copy Markdown
Contributor

@ed255 ed255 commented Oct 3, 2022

  • Add AccountFieldType.NonExisting in order to perform lookups from the EVM circuit that use non-existing proofs (for accounts) from the MPT Circuit via the State circuit.
  • Add MPTProofType.NonExistingStorageProof so that the MPT Circuit can prove non-existence of storage keys.
  • Update State Circuit to transparently use MPTProofType.NonExistingStorageProof for Storage entries when the MPT Lookup has committedValue == 0 and value == 0.

The change that makes the State Circuit support non-existing proofs on the Storage Tag will require 2 IsZero gadgets (which require a column each). I'm not sure if there is any free column to be reused on Storage rows in the State Circuit, or 2 new columns need to be allocated.
I believe non-existence storage proofs support can be handled in 3 different ways:

  • a. Add a new RwTable field called NonExistenceStorage. Require all EVM circuits that perform storage read/writes to check if the proof is of non-existence (by adding 1 or 2 IsZero gadgets, depending on whether it's read or write). Then conditionally lookup to RwTable with NonExistenceStorage or `Storage.
  • b. Transparently support Storage rows that require non-existence proofs via the RwTable. Let the StateCircuit figure out if the MPT lookup must be Storage or NonExistenceStorage by checking if value and valuePrev are 0 (with 2 IsZero gadgets)
  • c. Add support for Storage modifications where valuePrev and value are 0 in the MPT Circuit.

In #249 we discussed not doing option (c). I think option (b) is the best because it's transparent to the EVM Circuit, and also allows merging changes (for example, for an address and key there's a read where value=0, and then a write where value=v, the state circuit only performs 1 MPT lookup).
@z2trillion what do you think about this?

Resolve #249

@ed255 ed255 force-pushed the feature/non-exist-proofs branch from a192343 to 5503116 Compare October 3, 2022 14:11
@ed255 ed255 mentioned this pull request Oct 3, 2022
@z2trillion
Copy link
Copy Markdown
Contributor

I'm not sure if there is any free column to be reused on Storage rows in the State Circuit, or 2 new columns need to be allocated.

We will need to add two additional columns, since the storage rows use all of the existing ones.

@ed255 ed255 force-pushed the feature/non-exist-proofs branch from 5503116 to ff5c524 Compare October 3, 2022 14:43
Comment thread src/zkevm_specs/state.py Outdated
Copy link
Copy Markdown
Contributor

@miha-stopar miha-stopar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

- Add AccountFieldType.NonExisting in order to perform lookups from the EVM
  circuit that use non-existing proofs (for accounts) from the MPT Circuit via
  the State circuit.
- Add MPTProofType.NonExistingStorageProof so that the MPT Circuit can prove
  non-existence of storage keys.
- Update State Circuit to transparently use
  MPTProofType.NonExistingStorageProof for Storage entries when  the MPT Lookup
  has committedValue == 0 and value == 0.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MPT table API for proof of non-existance

3 participants