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
  • 4 core

4 core · Changes

Page history
modify docs --story=1 authored Aug 07, 2024 by gz Xu's avatar gz Xu
Show whitespace changes
Inline Side-by-side
Showing with 12 additions and 9 deletions
+12 -9
  • zkevm-docs/4-core.markdown zkevm-docs/4-core.markdown +12 -9
  • No files found.
zkevm-docs/4-core.markdown
View page @ 9b80e7e6
......@@ -7,8 +7,12 @@
```rust
pub struct CoreCircuitConfig<F: Field, const NUM_STATE_HI_COL: usize, const NUM_STATE_LO_COL: usize>
{
/// block index, the index of the block in the chunk, repeated for rows in one block
pub block_idx: Column<Advice>,
/// Transaction index, the index inside the block, repeated for rows in one transaction
pub tx_idx: Column<Advice>,
/// whether the current transaction is a transaction to create a contract
pub tx_is_create: Column<Advice>,
/// Call id, unique for each call, repeated for rows in one execution state
pub call_id: Column<Advice>,
/// Contract code address, repeated for rows in one execution state
......@@ -22,8 +26,9 @@ pub struct CoreCircuitConfig<F: Field, const NUM_STATE_HI_COL: usize, const NUM_
...
}
```
- block_idx:表示当前交易所在的区块是chunk的第几个
- tx_idx: 表示交易是区块的第几笔
- tx_is_create:表示当前交易用于创建合约
- call_id:在处理执行轨迹的时候,遇到新的call,就给其分配一个唯一的id (不是每次增加1)
- code_addr:当前运行的合约代码的地址
- pc:当前程序计数器的位置
......@@ -62,11 +67,8 @@ pub struct CoreCircuitConfig<F: Field, const NUM_STATE_HI_COL: usize, const NUM_
pub enum ExecutionState {
......
STOP,
ADD,
MUL,
SUB,
ADD_SUB_MUL_DIV_MOD,
EXP,
DIV_MOD,
ADDMOD,
MULMOD,
POP,
......@@ -76,19 +78,20 @@ pub enum ExecutionState {
......
}
```
我们可以注意到,这两个名称“DIV_MOD”,“AND_OR_XOR”由下划线分隔了,意味着他们可以处理多个功能、逻辑相近的指令(DIV和MOD,AND、OR和XOR)。以逻辑运算指令AND、OR和XOR为例,尽管它们运算不同,但是操作模式相似。因此为了减少重复代码,可以使用一个执行状态处理这三种指令。
我们可以注意到,这两个名称“ADD_SUB_MUL_DIV_MOD”,“AND_OR_XOR”由下划线分隔了,意味着他们可以处理多个功能、逻辑相近的指令(ADD、SUB、DIV和MOD,AND、OR和XOR)。以逻辑运算指令AND、OR和XOR为例,尽管它们运算不同,但是操作模式相似。因此为了减少重复代码,可以使用一个执行状态处理这三种指令。
#### 3.1.2 zkEVM电路内部的状态
在zkEVM电路中为了处理一些非EVM指令的流程,需要使用一些内部状态。EVM中不存在此概念。包括但不限于:
```rust
pub enum ExecutionState {
......
END_PADDING, // it has to be the first state as it is the padding state
BEGIN_TX_1, // start a tx, part one
BEGIN_TX_2, // start a tx, part two
END_BLOCK,
END_TX,
BEGIN_TX_3, // start a tx, part three
BEGIN_BLOCK,
BEGIN_CHUNK,
END_BLOCK,
END_CHUNK,
......
}
```
......
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号