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

Implement bytecode refactor spec in circuit#1044

Merged
leolara merged 21 commits into
mainfrom
leo/bytecode-circuit-refactor
Feb 1, 2023
Merged

Implement bytecode refactor spec in circuit#1044
leolara merged 21 commits into
mainfrom
leo/bytecode-circuit-refactor

Conversation

@leolara

@leolara leolara commented Jan 9, 2023

Copy link
Copy Markdown
Contributor

Closes #1026


We have done the following refactor to the spec:

privacy-ethereum/zkevm-specs#151

privacy-ethereum/zkevm-specs#340

privacy-ethereum/zkevm-specs#351

This task is to implement this new spec into the bytecode circuit implementation in this repo.

@github-actions github-actions Bot added the crate-zkevm-circuits Issues related to the zkevm-circuits workspace member label Jan 9, 2023
@leolara leolara changed the title Bytecode circuit refactor (not passing tests) Implement bytecode refactor spec in circuit Jan 12, 2023
@github-actions github-actions Bot added crate-circuit-benchmarks Issues related to the circuit-benchmarks workspace member crate-integration-tests Issues related to the integration-tests workspace member T-bench Type: benchmark improvements labels Jan 15, 2023
@leolara leolara marked this pull request as ready for review January 15, 2023 12:42
@han0110 han0110 self-requested a review January 17, 2023 07:52

@han0110 han0110 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.

LGMT! Nice refactor! Only left some unimportant comments.

Comment thread zkevm-circuits/src/bytecode_circuit/circuit.rs
Comment thread zkevm-circuits/src/bytecode_circuit/circuit.rs Outdated
Comment thread zkevm-circuits/src/bytecode_circuit/circuit.rs Outdated
Comment thread zkevm-circuits/src/bytecode_circuit/circuit.rs Outdated
Comment thread zkevm-circuits/src/bytecode_circuit/circuit.rs Outdated
@leolara

leolara commented Jan 19, 2023

Copy link
Copy Markdown
Contributor Author

please @icemelon assign a reviewer

@icemelon icemelon self-requested a review January 20, 2023 07:03
@icemelon

icemelon commented Jan 20, 2023

Copy link
Copy Markdown
Collaborator

I assigned myself and will take a look this week. @leolara

@ChihChengLiang ChihChengLiang left a comment

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.

LGTM. I left some comments, but they might be out of the scope of this PR. Feel free to ignore them.

cb.require_equal(
"assert cur.hash == EMPTY_HASH",
meta.query_advice(bytecode_table.code_hash, Rotation::cur()),
empty_hash,

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.

I remember we have cb.empty_hash_rlc(), but that method was available for ConstraintBuilder but not for BaseConstraintBuilder.
No change is needed here.

Comment thread zkevm-circuits/src/bytecode_circuit/circuit.rs Outdated
meta.query_advice(keccak_table.is_enabled, Rotation::cur()),
)];

// TODO: perhaps write this explicitly so it is more readable the matching

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.

Agree we should make this more readable. One idea I have in mind is to have a function in keccak table side.
match_columns(input_rlc, length, output_hash) -> Vec<(Column, Column)>
The function is only responsible for yielding correct pairs of columns. We then add selectors and query cells here.

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 going to complain, but I actually think what you are saying makes sense.

@leolara leolara removed the request for review from icemelon February 1, 2023 09:55
@leolara leolara merged commit 306c4e6 into main Feb 1, 2023
fakedev9999 pushed a commit to kroma-network/zkevm-circuits that referenced this pull request Jul 12, 2023
* In [#1044](privacy-ethereum/zkevm-circuits#1044) PR from PSE, there was a renaming from Length to Header
  of the Bytecode Tag. However, some parts of the code were not
  properly updated, so I made the change.
fakedev9999 pushed a commit to kroma-network/zkevm-circuits that referenced this pull request Jul 12, 2023
* In PR from PSE,
  github.com/privacy-ethereum/zkevm-circuits/pull/1044
  there was a renaming from Length to Header of the Bytecode Tag.
  However, some parts of the code were not properly updated, so
  I made the change.
fakedev9999 pushed a commit to kroma-network/zkevm-circuits that referenced this pull request Jul 12, 2023
* In PR from PSE,
  github.com/privacy-ethereum/zkevm-circuits/pull/1044
  there was a renaming from Length to Header of the Bytecode Tag.
  However, some parts of the code were not properly updated, so
  I made the change.
lightscale-luke pushed a commit to kroma-network/zkevm-circuits that referenced this pull request Jul 17, 2023
* In PR from PSE,
  github.com/privacy-ethereum/zkevm-circuits/pull/1044
  there was a renaming from Length to Header of the Bytecode Tag.
  However, some parts of the code were not properly updated, so
  I made the change.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

crate-circuit-benchmarks Issues related to the circuit-benchmarks workspace member crate-integration-tests Issues related to the integration-tests workspace member crate-zkevm-circuits Issues related to the zkevm-circuits workspace member T-bench Type: benchmark improvements trigger-integration-tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement bytecode refactor spec in circuit

5 participants