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

CODECOPY opcode#391

Merged
icemelon merged 13 commits into
privacy-ethereum:mainfrom
scroll-tech:feat/codecopy
Apr 8, 2022
Merged

CODECOPY opcode#391
icemelon merged 13 commits into
privacy-ethereum:mainfrom
scroll-tech:feat/codecopy

Conversation

@roynalnaruto
Copy link
Copy Markdown
Collaborator

@roynalnaruto roynalnaruto commented Mar 16, 2022

Specs PR: privacy-ethereum/zkevm-specs#148

TODOs:

@github-actions github-actions Bot added the T-opcode Type: opcode-related and focused PR/Issue label Mar 16, 2022
@github-actions github-actions Bot added the crate-zkevm-circuits Issues related to the zkevm-circuits workspace member label Mar 21, 2022
@roynalnaruto
Copy link
Copy Markdown
Collaborator Author

@han0110 In the specs lookup implementation here, we check if there's one and only one match and return it. But it does allow optional fields.

How can this be done in the Rust impl?

As I see it, this would have to be changed to:

            Self::Bytecode {
                hash,
                tag,
                index,
                opt_is_code,
                value,
            } => {
                if let Some(is_code) = opt_is_code {
                    vec![hash.clone(), tag.clone(), index.clone(), value.clone(), is_code.clone()]
                } else {
                    vec![hash.clone(), tag.clone(), index.clone(), value.clone()]
                }
            }

Also the layout of bytecode table will have to be modified so that is_code column follows the value column. Wdyt?

@han0110
Copy link
Copy Markdown
Contributor

han0110 commented Mar 21, 2022

In spec we try not to annoying developer to provide all of witness to pass a verification, so lookup is made to be like a normal map lookup, then we can use partial value to get the full row.

But in circuit, we have to provide all, so current approach makes sense me. I think we can stick to this now, because there is another idea that can help to make all of these more sense. (see here https://hackmd.io/Pmd8xoZWRVmko8LkRNhABQ)

@github-actions github-actions Bot added the crate-bus-mapping Issues related to the bus-mapping workspace member label Mar 22, 2022
@roynalnaruto
Copy link
Copy Markdown
Collaborator Author

Bus-mapping PR added here: scroll-tech#123

@roynalnaruto
Copy link
Copy Markdown
Collaborator Author

@han0110 @CPerezz @ed255 Would be great if this PR is reviewed, since the specs for CODECOPY have been merged already.

@ChihChengLiang ChihChengLiang requested review from a team and han0110 and removed request for a team April 5, 2022 14:45
@ChihChengLiang
Copy link
Copy Markdown
Collaborator

Sorry @roynalnaruto for the delay, I'll help review this too.

@roynalnaruto roynalnaruto requested a review from a team April 5, 2022 18:07
Comment thread bus-mapping/src/circuit_input_builder.rs Outdated
Comment thread zkevm-circuits/src/evm_circuit/table.rs Outdated
Comment thread zkevm-circuits/src/evm_circuit/witness.rs Outdated
Comment thread zkevm-circuits/src/evm_circuit/table.rs Outdated
Comment thread zkevm-circuits/src/evm_circuit/execution.rs Outdated
Comment thread zkevm-circuits/src/bytecode_circuit/bytecode_unroller.rs
Comment thread zkevm-circuits/src/bytecode_circuit/bytecode_unroller.rs
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.

Only got some nitpicks, others look good to me.

Comment thread zkevm-circuits/src/evm_circuit/table.rs
Comment thread zkevm-circuits/src/evm_circuit/execution/codecopy.rs Outdated
Comment thread zkevm-circuits/src/evm_circuit/execution/copy_code_to_memory.rs Outdated
Comment thread zkevm-circuits/src/evm_circuit/execution/copy_code_to_memory.rs Outdated
Copy link
Copy Markdown
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 modulo other review comments.

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.

LGTM! It will be nice to see its part of bus-mapping implemented next (it's fine to me to implement it in further PR), then #419 doesn't need to worry about that, thanks!

@roynalnaruto
Copy link
Copy Markdown
Collaborator Author

roynalnaruto commented Apr 7, 2022

It will be nice to see its part of bus-mapping implemented next

@han0110 It's already in progress here: scroll-tech#123.

Once I'm done with the internal call cases for calldataload and calldatacopy (bus-mapping), I will wrap this up.

Comment thread zkevm-circuits/src/evm_circuit/execution/copy_code_to_memory.rs Outdated
Comment thread zkevm-circuits/src/bytecode_circuit/bytecode_unroller.rs
Comment thread zkevm-circuits/src/evm_circuit/execution/codecopy.rs
@roynalnaruto
Copy link
Copy Markdown
Collaborator Author

In that case, I think either way looks good to me.

I've made the change where Length = 0, Byte = 1 and Padding = 2

@roynalnaruto roynalnaruto requested a review from icemelon April 8, 2022 01:03
Comment thread zkevm-circuits/src/evm_circuit/execution/memory_copy.rs Outdated
Comment thread zkevm-circuits/src/evm_circuit/witness.rs Outdated
Comment thread zkevm-circuits/src/evm_circuit/execution/copy_code_to_memory.rs Outdated
Copy link
Copy Markdown
Collaborator

@icemelon icemelon left a comment

Choose a reason for hiding this comment

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

LGTM!

@icemelon icemelon merged commit 358b3a6 into privacy-ethereum:main Apr 8, 2022
@icemelon icemelon deleted the feat/codecopy branch April 8, 2022 20:54
@icemelon
Copy link
Copy Markdown
Collaborator

icemelon commented Apr 8, 2022

Thanks for the contribution @roynalnaruto

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 T-opcode Type: opcode-related and focused PR/Issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants