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 authored Nov 09, 2023 by geruiwang's avatar geruiwang
Hide whitespace changes
Inline Side-by-side
Showing with 43 additions and 14 deletions
+43 -14
  • zkevm-docs/7-copy.markdown zkevm-docs/7-copy.markdown +43 -14
  • No files found.
zkevm-docs/7-copy.markdown
View page @ c1a718ec
......@@ -62,27 +62,56 @@ pub struct Row {
}
```
其中,Type是
```rust
pub enum Type {
#[default]
/// Zero value for padding, under which id, pointer, and stamp are default value
Zero,
/// Memory in state sub-circuit
Memory,
/// Calldata in state sub-circuit
Calldata,
/// Returndata in state sub-circuit
Returndata,
/// Log in public sub-circuit
PublicLog,
/// Calldata in public sub-circuit
PublicCalldata,
/// Bytecode in bytecode sub-circuit
Bytecode,
}
```
例子:CODECOPY,从bytecode拷贝到memory。例子里长度为8,被拷贝的数据为0xabcd......见下表。
| byte | src type | dst type | src id | src pointer | src stamp | dst id | dst pointer | dst stamp | cnt | len |
|------|------------|----------|---------------|-------------|-----------|--------|---------------|------------|-----|-----|
| 0xab | bytecode=5 | memory=0 | contract addr | some offset | nil | callid | some mem addr | some stamp | 0 | 8 |
| 0xcd | bytecode=5 | memory=0 | contract addr | some offset | nil | callid | some mem addr | some stamp | 1 | 8 |
| ... | bytecode=5 | memory=0 | contract addr | some offset | nil | callid | some mem addr | some stamp | 2 | 8 |
| | bytecode=5 | memory=0 | contract addr | some offset | nil | callid | some mem addr | some stamp | 3 | 8 |
| | bytecode=5 | memory=0 | contract addr | some offset | nil | callid | some mem addr | some stamp | 4 | 8 |
| | bytecode=5 | memory=0 | contract addr | some offset | nil | callid | some mem addr | some stamp | 5 | 8 |
| | bytecode=5 | memory=0 | contract addr | some offset | nil | callid | some mem addr | some stamp | 6 | 8 |
| | bytecode=5 | memory=0 | contract addr | some offset | nil | callid | some mem addr | some stamp | 7 | 8 |
| byte | src type | src id | src pointer | src stamp | dst type | dst id | dst pointer | dst stamp | cnt | len |
|------|------------|---------------|-------------|-----------|----------|--------|---------------|------------|-----|-----|
| 0xab | `Bytecode` | contract addr | some offset | nil | `Memory` | callid | some mem addr | some stamp | 0 | 8 |
| 0xcd | `Bytecode` | contract addr | some offset | nil | `Memory` | callid | some mem addr | some stamp | 1 | 8 |
| ... | `Bytecode` | contract addr | some offset | nil | `Memory` | callid | some mem addr | some stamp | 2 | 8 |
| | `Bytecode` | contract addr | some offset | nil | `Memory` | callid | some mem addr | some stamp | 3 | 8 |
| | `Bytecode` | contract addr | some offset | nil | `Memory` | callid | some mem addr | some stamp | 4 | 8 |
| | `Bytecode` | contract addr | some offset | nil | `Memory` | callid | some mem addr | some stamp | 5 | 8 |
| | `Bytecode` | contract addr | some offset | nil | `Memory` | callid | some mem addr | some stamp | 6 | 8 |
| | `Bytecode` | contract addr | some offset | nil | `Memory` | callid | some mem addr | some stamp | 7 | 8 |
### 门约束
TODO
- 若 len-cnt-1==0 OR len==0: next cnt=0
- 否则: next cnt=cnt+1; next src type, dst type, src xx, dst xx, len... same as cur
- 若 len==0: 说明此行是pad行,则cur的 src type, dst type, src xx, dst xx, len 全部是nil或者默认值
### Lookup
每一行,都要进行两个约束,向Copy的来源和Copy的去向进行查找表。查找表的来源都是此子表格的一行(的某些列),去向是“Copy的来源或Copy的去向”。
每一行,都要进行两个约束,向Copy的来源和Copy的去向进行查找表。查找表的来源都是此子表格的一行(的某些列),去向是“Copy的来源或Copy的去向”。我们称为Lookup1和Lookup2。
以上面为例,每一行,要进行:
- 去向为bytecode的查找表,含义是确定拷贝的数据没错
- 去向为state(具体tag为memory)的查找表,含义是确定拷贝的数据确实写进去了
\ No newline at end of file
- Lookup1:去向为bytecode的查找表,含义是确定拷贝的数据没错
- Lookup2:去向为state(具体tag为memory)的查找表,含义是确定拷贝的数据确实写进去了
具体的,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
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号