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

Circuit for opcode calldatacopy #297

Merged

Conversation

scroll-dev
Copy link
Collaborator

@scroll-dev scroll-dev commented Jan 21, 2022

We verify the CALLDATACOPY using two gadgets: CallDataCopyGadget and CopyToMemoryGadget.

  • The CallDataCopyGadget checks the stack values including memory offset, data offset, and length, and then set the proper state in the CopyToMemoryGadget.
  • The CopyToMemoryGadget, which associates with an internal ExecutionState CopyToMemory, can span over multiple steps, depending on the amount of data to be copied. It can copy data from either transaction call data (root call) or memory (internal call) to the memory in the callee. Since CopyToMemoryGadget is an internal state, it only increases the rw counter while keeps the same for the rest of context, such as pc, sp, gas.

Here is a diagram showing how CALLDATACOPY is handled with these two gadgets.

Untitled Diagram

Spec: privacy-scaling-explorations/zkevm-specs#111

We leave the bus-mapping implementation of CALLDATACOPY to next PR as it is non-trivial and needs to generate multiple steps (related to #309).

@github-actions github-actions bot added crate-bus-mapping Issues related to the bus-mapping workspace member T-opcode Type: opcode-related and focused PR/Issue crate-zkevm-circuits Issues related to the zkevm-circuits workspace member labels Jan 21, 2022
@github-actions github-actions bot removed the crate-bus-mapping Issues related to the bus-mapping workspace member label Jan 25, 2022
Copy link
Collaborator

@DreamWuGit DreamWuGit left a comment

Choose a reason for hiding this comment

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

Overall LGTM!

@DreamWuGit
Copy link
Collaborator

DreamWuGit commented Feb 17, 2022

@han0110 @ChihChengLiang could you have a look ? we have ongoing PR reply on part of this !

@ChihChengLiang
Copy link
Collaborator

We can prioritize merging this. Can we do rebase again?

Copy link
Collaborator

@ChihChengLiang ChihChengLiang left a comment

Choose a reason for hiding this comment

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

LGTM

@ChihChengLiang ChihChengLiang merged commit e213e88 into privacy-scaling-explorations:main Feb 22, 2022
zemse pushed a commit to zemse/zkevm-circuits that referenced this pull request Mar 22, 2023
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 T-opcode Type: opcode-related and focused PR/Issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants