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#907

Merged
z2trillion merged 15 commits into
privacy-ethereum:mainfrom
scroll-tech:feat/account-non-existing-proof
Dec 2, 2022
Merged

Support non-existing proofs in RwTable#907
z2trillion merged 15 commits into
privacy-ethereum:mainfrom
scroll-tech:feat/account-non-existing-proof

Conversation

@silathdiir
Copy link
Copy Markdown
Contributor

Close #895

Supposed to move privacy-ethereum/zkevm-specs#291 from spec to circuit.

@silathdiir silathdiir requested a review from a team November 16, 2022 04:11
@github-actions github-actions Bot added crate-bus-mapping Issues related to the bus-mapping workspace member crate-zkevm-circuits Issues related to the zkevm-circuits workspace member labels Nov 16, 2022
@silathdiir silathdiir marked this pull request as draft November 16, 2022 06:09
@silathdiir silathdiir marked this pull request as ready for review November 17, 2022 08:24
@silathdiir silathdiir marked this pull request as draft November 17, 2022 14:33
Copy link
Copy Markdown
Collaborator

@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!

/// Config for StateCircuit
#[derive(Clone)]
pub struct StateCircuitConfig<F> {
selector: Column<Fixed>, // Figure out why you get errors when this is Selector.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not sure what's the error, but perhaps because gates require to have a fixed column in the expression (lookups don't)?

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.

I originally left this comment. Gates require a fixed column, but Selector is a fixed column. I think the check in halo2 may not have taken this into account, but I have not investigated deeper.

@silathdiir silathdiir marked this pull request as ready for review November 21, 2022 10:46
@silathdiir silathdiir force-pushed the feat/account-non-existing-proof branch from 3ce32a7 to 9a3ef55 Compare November 22, 2022 10:38
@ChihChengLiang
Copy link
Copy Markdown
Collaborator

@z2trillion Can you take a look into this PR when you have time?

@z2trillion z2trillion self-requested a review November 23, 2022 19:29
/// Config for StateCircuit
#[derive(Clone)]
pub struct StateCircuitConfig<F> {
selector: Column<Fixed>, // Figure out why you get errors when this is Selector.
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.

I originally left this comment. Gates require a fixed column, but Selector is a fixed column. I think the check in halo2 may not have taken this into account, but I have not investigated deeper.

Comment thread zkevm-circuits/src/state_circuit.rs Outdated
// For Rw::AccountStorage, identify if committed value or new value is zero.
// Will do lookup for ProofType::StorageDoesNotExist if both are zero,
// otherwise do lookup for ProofType::StorageChanged (either is non-zero).
is_initial_value_zero: Column<Advice>,
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.

Can you combine these two with a BatchedIsZeroGadget?

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.

Fixed to merge both is_initial_value_zero and is_new_value_zero to one column is_non_exist as:

(F::one() - committed_value * committed_value.invert()) *
    (F::one() - new_value * new_value.invert())

And it made degree reduce from 13 to 12.

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.

It would be better to use the BatchedIsZeroGadget in zkevm-circuits/src/evm_circuit/util/math_gadget.rs.

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 tried to replace this field with BatchedIsZeroGadget, but it seems that the first parameter of function BatchedIsZeroGadget::construct is evm_circuit::constraint_builder::ConstraintBuilder (not state_circuit::constraint_builder::ConstraintBuilder).

And it seems that the state_circuit::constraint_builder::ConstraintBuilder needs this StateCircuitConfig (this field belongs to) to construct here.

@z2trillion Any suggestion to refactor BatchedIsZeroGadget or state_circuit::constraint_builder::ConstraintBuilder? Thanks.

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.

Sorry about this. I didn't realize that BatchedIsZeroGadget requires the evm ConstraintBuilder to construct. Can you just add a todo here: "TODO: use BatchedIsZeroGadget here once it no longer requires the evm circuit constraint builder."

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.

Yes. I see. Thanks 🙏.
I will add TODO: use BatchedIsZeroGadget here once it no longer requires the evm circuit constraint builder. in the BALANCE circuit PR #683 (which will use this non-existing proof code).

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 saw the PR #961. Thanks.

@z2trillion z2trillion self-requested a review December 2, 2022 19:29
@z2trillion z2trillion merged commit 92f3d72 into privacy-ethereum:main Dec 2, 2022
@z2trillion z2trillion deleted the feat/account-non-existing-proof branch December 2, 2022 19:36
0x8f701 pushed a commit to dompute/zkevm-circuits that referenced this pull request Sep 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

crate-bus-mapping Issues related to the bus-mapping workspace member crate-zkevm-circuits Issues related to the zkevm-circuits workspace member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support non-existing proofs in RwTable for circuit

4 participants