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

CODECOPY opcode#148

Merged
han0110 merged 16 commits into
privacy-ethereum:masterfrom
scroll-tech:feat/codecopy
Apr 1, 2022
Merged

CODECOPY opcode#148
han0110 merged 16 commits into
privacy-ethereum:masterfrom
scroll-tech:feat/codecopy

Conversation

@roynalnaruto
Copy link
Copy Markdown
Collaborator

@roynalnaruto roynalnaruto commented Mar 16, 2022

@CPerezz
Copy link
Copy Markdown
Contributor

CPerezz commented Mar 16, 2022

Hey @roynalnaruto! I saw the PR for the circuits already up and ready for review.
Could we set it in Draft and focus on merging this one first? As until we don't have a merged spec we can't approve a circuit PR directly.

@roynalnaruto roynalnaruto marked this pull request as ready for review March 17, 2022 04:16
@roynalnaruto
Copy link
Copy Markdown
Collaborator Author

Hey @roynalnaruto! I saw the PR for the circuits already up and ready for review. Could we set it in Draft and focus on merging this one first? As until we don't have a merged spec we can't approve a circuit PR directly.

@CPerezz I just had to push an unchanged change and rebase with upstream. I've now opened this PR.

@han0110
Copy link
Copy Markdown
Contributor

han0110 commented Mar 17, 2022

Hi @roynalnaruto, thanks for working on this!

Have you considered about retrieving the CodeSize information from bytecode_table? Bytecode circuit already has it, but just currently not designed to be lookup-able (see #102 for more discussion).

Also state trie doesn't contain the CodeSize of account, so we can't rely on MPT circuit to open its value, then we still need to check it with the one in Bytecode circuit every time when we access an account, so I think it doesn't makes too much sense to have such information maintained in State circuit.

Copy link
Copy Markdown
Contributor

@CPerezz CPerezz left a comment

Choose a reason for hiding this comment

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

Some nits/questions.
Overall is looking good! :)

Comment thread src/zkevm_specs/evm/execution/codecopy.py
Comment thread src/zkevm_specs/evm/execution/codecopy.py Outdated
Comment thread src/zkevm_specs/evm/execution/copy_code_to_memory.py Outdated
@CPerezz
Copy link
Copy Markdown
Contributor

CPerezz commented Mar 17, 2022

@han0110 made an excellent point there!
Bytecode table should be a place that allows us to leverage info holded now by te State circuit.

Worth considering to refactor this in that regard.

@roynalnaruto
Copy link
Copy Markdown
Collaborator Author

@han0110 @CPerezz I will check more on #102 and refactor the CodeSize part. Thanks for the review :)

@roynalnaruto roynalnaruto requested a review from CPerezz March 18, 2022 06:46
@roynalnaruto
Copy link
Copy Markdown
Collaborator Author

@han0110 @CPerezz I've added a commit to extend the bytecode circuit (and related code/tests) that:

  1. Adds tags Length and Byte as BytecodeFieldTag
  2. Adds a row to the bytecode circuit (for every bytecode) for its length
  3. CODECOPY makes use of instruction.bytecode_length(code_hash) to fetch the bytecode size

Copy link
Copy Markdown
Contributor

@han0110 han0110 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! Although I thought you could just change the interface in table.py without needing to worry about updating bytecode.py itself.

Currently Bytecode circuit is modified to have access to previous row and next row, which seems hard to track all the branches (also brings some duplication I think), I have submitted another proposal #151 that I always want to try, if you are interesting perhaps you can have a look and implement it in another PR.

Comment thread src/zkevm_specs/bytecode.py Outdated
Comment thread src/zkevm_specs/bytecode.py Outdated
Comment thread src/zkevm_specs/evm/table.py Outdated
Comment thread src/zkevm_specs/evm/typing.py Outdated
Comment thread src/zkevm_specs/util/param.py Outdated
@roynalnaruto
Copy link
Copy Markdown
Collaborator Author

roynalnaruto commented Mar 19, 2022

I have submitted another proposal #151 that I always want to try, if you are interesting perhaps you can have a look and implement it in another PR.

@han0110 Yes, I think the proposal makes a lot of sense. I would like to take that up and refactor the bytecode circuit. But I believe that should be done as a separate PR, once this one is approved and merged (just trying to avoid too many changes and potential conflicts for others working on this repo). Wdyt?

@roynalnaruto roynalnaruto requested a review from han0110 March 19, 2022 10:22
Comment thread src/zkevm_specs/evm/execution/codecopy.py Outdated
Comment thread src/zkevm_specs/evm/step.py Outdated
Comment thread src/zkevm_specs/evm/execution/codecopy.py Outdated
Comment thread src/zkevm_specs/evm/execution/copy_code_to_memory.py
Comment thread src/zkevm_specs/evm/table.py Outdated
@han0110
Copy link
Copy Markdown
Contributor

han0110 commented Mar 21, 2022

Yes, I think the proposal makes a lot of sense. I would like to take that up and refactor the bytecode circuit. But I believe that should be done as a separate PR, once this one is approved and merged (just trying to avoid too many changes and potential conflicts for others working on this repo). Wdyt?

Sure, let's do it in another PR.

@roynalnaruto roynalnaruto requested a review from han0110 March 21, 2022 08:13
Comment thread src/zkevm_specs/evm/table.py Outdated
Comment thread src/zkevm_specs/evm/execution/codecopy.py Outdated
Copy link
Copy Markdown
Contributor

@han0110 han0110 left a comment

Choose a reason for hiding this comment

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

All LGTM now. Great work!

@roynalnaruto
Copy link
Copy Markdown
Collaborator Author

@CPerezz and @icemelon would be good to have your reviews on the PR :)

Copy link
Copy Markdown
Contributor

@CPerezz CPerezz left a comment

Choose a reason for hiding this comment

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

LGTM!! Nice job!!!

Only a small nit in the markdown file 🙂

Comment thread specs/opcode/39CODECOPY.md Outdated
@ChihChengLiang
Copy link
Copy Markdown
Collaborator

@roynalnaruto Can we rebase this and merge?

@han0110 han0110 merged commit 81028ae into privacy-ethereum:master Apr 1, 2022
@han0110 han0110 mentioned this pull request Apr 1, 2022
@roynalnaruto roynalnaruto deleted the feat/codecopy branch August 22, 2022 13:10
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.

4 participants