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

Use BinaryNumberChip in LexicographicOrderingConfig to lower degree#566

Merged
ed255 merged 62 commits into
privacy-ethereum:mainfrom
scroll-tech:fix/lex
Jun 27, 2022
Merged

Use BinaryNumberChip in LexicographicOrderingConfig to lower degree#566
ed255 merged 62 commits into
privacy-ethereum:mainfrom
scroll-tech:fix/lex

Conversation

@z2trillion
Copy link
Copy Markdown
Contributor

@z2trillion z2trillion commented Jun 13, 2022

fixes #561

@z2trillion z2trillion requested a review from miha-stopar as a code owner June 13, 2022 21:40
@z2trillion z2trillion marked this pull request as draft June 13, 2022 21:40
@github-actions github-actions Bot added the crate-zkevm-circuits Issues related to the zkevm-circuits workspace member label Jun 13, 2022
@z2trillion z2trillion mentioned this pull request Jun 14, 2022
15 tasks
Comment thread zkevm-circuits/src/state_circuit.rs
pub tag_bits: [Expression<F>; 4],
pub id: MpiQueries<F, N_LIMBS_ID>,
pub is_id_unchanged: Expression<F>,
pub is_tag_and_id_unchanged: Expression<F>,
Copy link
Copy Markdown
Collaborator

@DreamWuGit DreamWuGit Jun 15, 2022

Choose a reason for hiding this comment

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

we also need is_tag_unchanged and is_id_unchanged is_field_tag_unchanged, I have used them in PR #552 , I believe others Op constraint will need in the near future .

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.

we can add them later when they're needed.

@github-actions github-actions Bot added the CI Issues related to the Continuous Integration mechanisms of the repository. label Jun 16, 2022
@z2trillion
Copy link
Copy Markdown
Contributor Author

I left the shift description in the top of the file because I think it's much easier to understand. In my mind, the gadget is showing "one of C0, ..., C31 is non-zero and fits into 16 bits" by using an RLC to avoid overflowing.

Comment thread zkevm-circuits/src/state_circuit/lexicographic_ordering.rs
Comment thread zkevm-circuits/src/state_circuit/lexicographic_ordering.rs Outdated
@miha-stopar
Copy link
Copy Markdown
Collaborator

I left the shift description in the top of the file because I think it's much easier to understand. In my mind, the gadget is showing "one of C0, ..., C31 is non-zero and fits into 16 bits" by using an RLC to avoid overflowing.

Just thought it might be a bit confusing if docs are different from the implementation. Perhaps leave the shifts in the comment, but mention that RLC is used to lower the degree?

BTW, a naive question: wouldn't be possible to implement the approach with RLC without BinaryNumberChip?

@z2trillion
Copy link
Copy Markdown
Contributor Author

z2trillion commented Jun 22, 2022

No it wouldn't be possible because we need to use the BinaryNumberChip to represent first_different_limb. Without the BinaryNumberChip, we can't have low-degree constraints that are conditional on the value of first_different_limb.

@miha-stopar
Copy link
Copy Markdown
Collaborator

No it wouldn't be possible because we need to use the BinaryNumberChip to represent first_different_limb. Without the BinaryNumberChip, we can't have low-degree constraints that are conditional on the value of first_different_limb.

Of course, got it now. Thanks! Perhaps add a comment that there are two optimisations to reduce the degree: RLC and BinaryNumberChip. The PR looks cool to me! Just one consideration: seems like BinaryNumberChip could be useful elsewhere too, perhaps it could be put in evm_circuit/util?

Copy link
Copy Markdown
Contributor

@ed255 ed255 left a comment

Choose a reason for hiding this comment

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

Overall looks good! Very interesting use of the RLC to verify the equality between a large window of values!

I've added some notes and comments with suggestions; all are small details. Please take a look!

Comment thread zkevm-circuits/src/state_circuit/lexicographic_ordering.rs Outdated
Comment thread zkevm-circuits/src/state_circuit/lexicographic_ordering.rs
Comment thread zkevm-circuits/src/state_circuit/lexicographic_ordering.rs
Comment thread zkevm-circuits/src/state_circuit/lexicographic_ordering.rs Outdated
Comment thread zkevm-circuits/src/state_circuit/lexicographic_ordering.rs
Comment thread zkevm-circuits/src/state_circuit/lexicographic_ordering.rs Outdated
Comment thread zkevm-circuits/src/state_circuit/lexicographic_ordering.rs
@z2trillion
Copy link
Copy Markdown
Contributor Author

Of course, got it now. Thanks! Perhaps add a comment that there are two optimisations to reduce the degree: RLC and BinaryNumberChip. The PR looks cool to me! Just one consideration: seems like BinaryNumberChip could be useful elsewhere too, perhaps it could be put in evm_circuit/util?

I don't think it makes sense to move it into evm_circuit/util right now, since it's only used in by the state circuit at the moment.

@z2trillion z2trillion requested review from ed255 and miha-stopar June 24, 2022 22:11
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!

Copy link
Copy Markdown
Contributor

@ed255 ed255 left a comment

Choose a reason for hiding this comment

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

LGTM!

@ed255 ed255 merged commit e6dda06 into privacy-ethereum:main Jun 27, 2022
@z2trillion z2trillion deleted the fix/lex branch June 30, 2022 05:57
jonathanpwang pushed a commit to axiom-crypto/zkevm-circuits that referenced this pull request Aug 1, 2023
…um#566)

* stage

* support tx gas cost in RLP circuit

* lookup to RLP table for TxDataGasCost
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix state circuit order and packing issue

5 participants