Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
zkevm-circuits
zkevm-circuits
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Package Registry
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar

新注册的用户请输入邮箱并保存,随后登录邮箱激活账号。后续可直接使用邮箱登录!

  • zkp
  • zkevm-circuitszkevm-circuits
  • Wiki
    • Zkevm docs
  • 7 copy

7 copy · Changes

Page history
copy update authored 1 year ago by geruiwang's avatar geruiwang
Hide whitespace changes
Inline Side-by-side
Showing with 30 additions and 3 deletions
+30 -3
  • zkevm-docs/7-copy.markdown zkevm-docs/7-copy.markdown +30 -3
  • No files found.
zkevm-docs/7-copy.markdown
View page @ 32706f02
......@@ -20,7 +20,7 @@ Copy类操作指的是在EVM中进行不定长的一段数据数据拷贝,例
![Figure 1](/image/copy-location.jpg)
- CODECOPY:从bytecode到memory
- CODECOPY, EXTCODECOPY:从bytecode到memory
- CALLDATACOPY:从calldata(state中的)到memory
- RETURN:从memory到returndata
- RETURNDATACOPY:从returndata到memory
......@@ -113,5 +113,32 @@ pub enum Type {
具体的,Lookup1的情况视src type而定:
- Zero:不进行lookup
- Memory、Calldata、Returndata:来源是此子表格的(tag=常数Memory/Calldata/Returndata, src id, src pointer + cnt, src stamp + cnt, byte, is_write=常数0),去向是state table的(tag, call_id, pointer_lo, stamp, value_lo, is_write)
- 未完待续
\ No newline at end of file
- Memory、Calldata、Returndata:来源是此子表格的(tag=常数Memory/Calldata/Returndata, src id, src pointer + cnt, src stamp + cnt, byte, is_write=常数0),去向是state table的(tag, call_id, pointer_lo, stamp, value_lo, is_write),即`LookupEntry::State`
- Bytecode:来源是此子表格的(src pointer + cnt, src_id, byte),去向是bytecode table的(pc, addr, bytecode),即`LookupEntry::Bytecode`(并非BytecodeFull)
- PublicCalldata:来源是此子表格的(tag=常数Calldata, src id, src pointer + cnt, byte),去向是public table的(tag, tx_idx, idx, value),即`LookupEntry::Public`。注意此tag是Public的Tag。(Public代码还未完善)
Lookup2的情况视dst type而定:
- Zero:不进行lookup
- Memory、Calldata、Returndata:类似Lookup1,把is_write=常数1
- PublicLog:来源是此子表格的(tag=常数tx_log, log_tag=常数bytes, dst id, src pointer + cnt, dst stamp (不加cnt), byte, len),去向是public table的(tag, log_tag, tx_idx, idx, log_id, value, len),即`LookupEntry::Public`。注意此tag是Public的Tag。(Public代码还未完善)
## Core中的用法
Core子电路的执行状态中,遇到和copy相关的状态,做法如下。
### CODECOPY, EXTCODECOPY
此指令遇到位数不足时,会填充0。因此,在得到 offset length dst_offset (这三个数从栈获得)后,需要判断是否需要填充,会得到两个length:normal_length, zero_length。从core进行两个copy的lookup。一个的src type是bytecode,另一个的src type是zero。这两个copy的lookup的排布,可以在cnt=2行的前9个格子和次9个格子。对于每个copy的lookup,用门约束约束其各个位置的值,然后用lookup约束从core向copy去查找表即可。
> 判断是否需要填充可以放到Arithmetic子电路里,通过lookup去获得normal_length, zero_length。
### CALLDATACOPY
此指令遇到位数不足时,会填充0。不过,在读取CALLDATA时,我们可以让CALLDATA的默认值为0(类似MEMORY的设计)。因此,不需要像CODECOPY一样弄。此指令只需一个copy的lookup,可以在cnt=2行的前9个格子。
### RETURN
此指令遇到位数不足时,会填充0。不过,在读取MEMORY时,默认值为0。因此,不需要像CODECOPY一样弄。此指令只需一个copy的lookup。
### RETURNDATACOPY
此指令遇到位数不足时,会报错。因此,此指令只需一个copy的lookup。
Clone repository
  • basics
    • evm
    • halo2
  • code notes
    • binary_number_with_real_selector
    • how to use macro
    • simple_lt
    • simple_lt_word
  • Home
  • image
  • zkevm docs
    • 1 introduction
    • 10 public
    • 11 fixed
    • 12 exp
    • 13 keccak
    • 14 comparisons
    • 15 differences
View All Pages

Copyright © 2024 ChainWeaver Org. All Rights Reserved. 版权所有。

京ICP备2023035722号-3

京公网安备 11010802044225号