Skip to content

Receipts Trie code together with Generic Struct Extraction and Non-consecutive Blocks#453

Open
Zyouell wants to merge 55 commits into
zyouell/receipt-rebasefrom
zyouell/receipts-with-nonconsecutive-blocks
Open

Receipts Trie code together with Generic Struct Extraction and Non-consecutive Blocks#453
Zyouell wants to merge 55 commits into
zyouell/receipt-rebasefrom
zyouell/receipts-with-nonconsecutive-blocks

Conversation

@Zyouell

@Zyouell Zyouell commented Feb 10, 2025

Copy link
Copy Markdown
Contributor

This PR adds the functionality to the Receipt based circuits to work even if a block contains no relevant receipts. It does this by using dummy proofs for the value_extraction proof on the MPT side and an empty proof for the block proof on the verifiable_db side.

This way the IVC proof still links all the blocks together but if no rows are added to the table for a specific block the tree doesn't change. This PR resolves CRY-37.

silathdiir and others added 30 commits February 6, 2025 10:28
- Move the dependencies (including version) to the workspace
`Cargo.toml`.
- Update the available dependencies. As update `alloy` to `0.4` (`0.5`
and `0.6` of alloy could not work with integration test).
- Keep the current version of `ethereum-types` and `rlp`, since both is
related with our forked `eth-trie.rs`.

Integration test could work.
@nicholas-mainardi nicholas-mainardi changed the base branch from zyouell/receipt-rebase to zyouell/receipt-ncb-merge February 10, 2025 11:54
@linear

linear Bot commented Feb 10, 2025

Copy link
Copy Markdown

@Zyouell Zyouell marked this pull request as ready for review February 10, 2025 12:00
@nicholas-mainardi nicholas-mainardi changed the base branch from zyouell/receipt-ncb-merge to zyouell/receipt-rebase February 10, 2025 13:38
Comment thread mp2-v1/src/values_extraction/gadgets/column_info.rs Outdated
Comment thread mp2-v1/src/values_extraction/gadgets/metadata_gadget.rs Outdated
Comment thread mp2-v1/src/values_extraction/mod.rs
Comment thread mp2-v1/src/values_extraction/mod.rs
Comment thread mp2-v1/tests/common/ivc.rs Outdated
Comment thread mp2-v1/tests/common/ivc.rs Outdated

@nicholas-mainardi nicholas-mainardi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks definitely better now, thanks for the changes, most of the issues seem addressed. Left some other comments but most of them are minor ones and should be quicker to address than the previous ones

Comment thread mp2-common/src/mpt_sequential/key.rs Outdated
Comment thread mp2-common/src/mpt_sequential/key.rs Outdated
Comment thread mp2-v1/src/values_extraction/gadgets/metadata_gadget.rs Outdated
Comment thread mp2-v1/src/values_extraction/leaf_receipt.rs
Comment thread mp2-v1/src/values_extraction/planner/receipts.rs Outdated
/// Extension extra input should be a single child proof
Extension(Vec<u8>),
/// Branch extra inputs should be a list of child proofs
Branch(Vec<Vec<u8>>),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For Branch and Extension variant I think that we shouldn't have the proofs here as inputs, as proofs are expected to be stored and handled in a storage handled by the caller. Instead we should employ proof identifier here, so that the external code can use these identifiers to fetch the proofs from the proof storage

Comment thread mp2-v1/tests/common/receipt_trie.rs Outdated
Comment thread mp2-v1/tests/common/receipt_trie.rs Outdated
"Error while generating proof for node {{ inner: {:?} }}",
e
))
})?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The generated proof should also be added to the proof storage here, as we do with any other generated proof

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was under the impression the integration test didn't store proofs for value extraction, only the final extraction proofs, at least the current code in storage_trie.rs doesn't store proofs for any of the nodes it generates proofs for

Comment thread mp2-common/src/eth.rs Outdated
Comment thread mp2-common/src/eth.rs Outdated

@nicholas-mainardi nicholas-mainardi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Besides for the planner changes, everything else looks good to me! Added another quick comment for the IVC proof logic.

Some(key) => Ok(Some(self.storage.get_proof_exact(&ProofKey::IVC(key))?)),
None => Ok(None),
},
Err(_) => Ok(None),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't we return the error here instead? I think that we are returning None because we are relying on the fact that get_previous_epoch will return an error only if the current block number bn does not exist in the tree, which would happen if this is the first block we are proving with IVC and there were no events extracted. But this looks as a rather unsafe assumption to me. I think it would be better to check, before calling get_previous_epoch, whether index.current_epoch() == bn, and return None if this isn't the case; if we have this check before calling get_previous_epoch, then we can just return the error here. Wdyt?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants