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

Add circuit for RETURNDATASIZE opcode#703

Merged
han0110 merged 46 commits into
privacy-ethereum:mainfrom
xiaodino:xiaodino/returndatasize
Oct 29, 2022
Merged

Add circuit for RETURNDATASIZE opcode#703
han0110 merged 46 commits into
privacy-ethereum:mainfrom
xiaodino:xiaodino/returndatasize

Conversation

@xiaodino
Copy link
Copy Markdown
Contributor

No description provided.

@github-actions github-actions Bot added crate-bus-mapping Issues related to the bus-mapping workspace member crate-zkevm-circuits Issues related to the zkevm-circuits workspace member labels Aug 22, 2022
@CPerezz CPerezz self-requested a review August 23, 2022 07:25
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.

Great work! And thanks for submitting a PR for it.

I have some things that should probably be addressed. Specifically with the testing cases applied here.

Aside from that the rest looks good! 😄

Comment thread bus-mapping/src/evm/opcodes/returndatasize.rs Outdated
Comment thread bus-mapping/src/evm/opcodes/returndatasize.rs
Comment thread zkevm-circuits/src/evm_circuit/execution.rs Outdated
Comment thread zkevm-circuits/src/evm_circuit/execution/returndatasize.rs Outdated
Comment thread zkevm-circuits/src/evm_circuit/execution/returndatasize.rs Outdated
Copy link
Copy Markdown
Contributor Author

@xiaodino xiaodino left a comment

Choose a reason for hiding this comment

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

@CPerezz Thanks for the feedbacks. They have been addressed.

@xiaodino xiaodino requested a review from CPerezz August 27, 2022 07:46
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!! Thanks for your work on the comments @xiaodino

Requesting one more review before merging.
Maybe @roynalnaruto can check this?

@CPerezz CPerezz requested a review from roynalnaruto August 29, 2022 07:43
@roynalnaruto
Copy link
Copy Markdown
Collaborator

I'll review this PR before end of today.

@CPerezz
Copy link
Copy Markdown
Contributor

CPerezz commented Aug 29, 2022

@xiaodino please can you fix the issues with rustfmt?

xiaodino and others added 11 commits August 29, 2022 10:15
Signed-off-by: smtmfft <smtm@taiko.xyz>

Signed-off-by: smtmfft <smtm@taiko.xyz>
)

i.e., only if it is not root call.

RETURN spec:

The `RETURN` opcode terminates the call successfully with return data for the
caller.

It behaves differently in different scenarios:

- `is_create` and `is_root`
    - A. Returns the specified memory chunk as deployment code.
    - B. End the execution
- `is_create` and `not is_root`
    - A. Returns the specified memory chunk as deployment code.
    - C. Restores caller's context and switch to it.
- `not is_create` and `is_root`
    - B. End the execution
- `not is_create` and `not is_root`
    - D. Returns the specified memory chunk to the caller.
    - C. Restores caller's context and switch to it.

Signed-off-by: smtmfft <smtmfft@taikocha.in>

Signed-off-by: smtmfft <smtmfft@taikocha.in>
Co-authored-by: smtmfft <smtmfft@taikocha.in>
@xiaodino
Copy link
Copy Markdown
Contributor Author

The issues with rustfmt have been fixed.

@CPerezz
Copy link
Copy Markdown
Contributor

CPerezz commented Sep 12, 2022

@roynalnaruto I actually don't really agree with the U256 instead of U64 used for the value RLC.

See: #703 (comment)

@roynalnaruto
Copy link
Copy Markdown
Collaborator

@roynalnaruto I actually don't really agree with the U256 instead of U64 used for the value RLC.

See: #703 (comment)

I mentioned that since geth uses uint64, so I thought we should stick to 8 bytes (N_BYTES_U64). N_BYTES_MEMORY_ADDRESS was 5 bytes.

@Brechtpd
Copy link
Copy Markdown
Collaborator

I think in most opcodes we do use N_BYTES_MEMORY_WORD_SIZE for storing a similar value (memory length/memory offsets in MemoryAddress types). Though a small difference here is that this opcode on its own does not not need any memory expansion (which is where the gas cost would overflow a 64bit value for these 5-byte sizes/offsets already) because it's a simple getter. So in that aspect N_BYTES_U64 could make sense instead, but of course the RETURN will already have done the memory expansion so it is as impossible to have bigger values than N_BYTES_MEMORY_WORD_SIZE as in all other uses cases where that is used I believe.

So good points to make for both I feel, but practically N_BYTES_MEMORY_WORD_SIZE should be as okay as its use in other opcodes. On the other hand, using N_BYTES_U64 won't make that much difference.

@z2trillion z2trillion requested a review from a team September 23, 2022 05:36
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! After rebase we could merge this.

Comment thread bus-mapping/src/evm/opcodes/return.rs
@xiaodino xiaodino requested review from han0110 and removed request for roynalnaruto October 28, 2022 05:54
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! Once the CI passes we can merge this.

@xiaodino
Copy link
Copy Markdown
Contributor Author

LGTM! Once the CI passes we can merge this.

CI passed!

@han0110 han0110 merged commit 103ddd7 into privacy-ethereum:main Oct 29, 2022
@pinkiebell pinkiebell mentioned this pull request Nov 5, 2022
19 tasks
lispc added a commit that referenced this pull request Aug 3, 2023
* speedup ci using verify_at_rows

* use verify_at_rows to speedup super circuit ci tests
lispc added a commit that referenced this pull request Aug 28, 2023
…s for the dummy chunk proofs to avoid dummy chunk proofgen time (#712)

* partiall address review comments of #670

* disable disable_proof_agg by default

* fix soundness issues with data hash

* add fixed cells for chunk_is_valid

* fix typo

* well... need morning coffee

* typo in readme

* fix soundness issue in is_smaller_than

* [feat] unify u8 u16 lookup table (#694)

* add range table

* replace Range256Table of rlp_circuit_fsm

* replace u16_table of tx_circuit

* use TableColumn

* add type alias

* use type alias

* annotate lookup column

* opt min_num_rows_block in poseidon_circuit (#700)

prune debug prints and lint

* speedup ci using verify_at_rows (#703)

* speedup ci using verify_at_rows

* use verify_at_rows to speedup super circuit ci tests

* update super circuit row estimation API (#695)

* remove num_of_chunks in aggregation circuit's instance column (#704)

Co-authored-by: kunxian xia <xiakunxian130@gmail.com>

* fix: lost tx_type when doing type conversion (#710)

* fix condition (#708)

* gates for zero checks

* statement 1 is correct

* reenable statements 3,6,7

* reenable statement 4

* everything seems to work again

* update aggregation test accordingly

* update spec

* minor clean up

* Fix fmt.

* Make `ChunkHash` fields public.

* fix decompose function

* update figures

* clean up

* address comments

* add is_final checks

* update readme

* constraint hash input length

* fix clippy

---------

Co-authored-by: Akase Cho <lightsing@users.noreply.github.com>
Co-authored-by: Ho <noel.wei@gmail.com>
Co-authored-by: Zhang Zhuo <mycinbrin@gmail.com>
Co-authored-by: kunxian xia <xiakunxian130@gmail.com>
Co-authored-by: Steven Gu <asongala@163.com>
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants