Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translation #1

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/kakarot-docs.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 12 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,42 @@
# Website
# 网站

This website is built using [Docusaurus](https://docusaurus.io/), a modern
static website generator.
该网站使用现代静态网站生成器[Docusaurus 3](https://docusaurus.io/)制作。

### Installation
### 安装

```
$ pnpm install
```

### Local Development
### 本地开发

```
$ pnpm run start
```

This command starts a local development server and opens up a browser window.
Most changes are reflected live without having to restart the server.
该命令启动本地开发服务器并打开浏览器窗口。
大多数更改都是实时反映的,而无需重新启动服务器。

### Build
### 构建

```
$ pnpm build
```

This command generates static content into the `build` directory and can be
served using any static contents hosting service.
该命令生成静态内容到 `build`目录中,并且可以使用任何静态内容托管服务提供服务。

### Deployment
### 开发

Using SSH:
使用SSH:

```
$ USE_SSH=true pnpm deploy
```

Not using SSH:
不使用SSH:

```
$ GIT_USER=<Your GitHub username> pnpm deploy
```

If you are using GitHub pages for hosting, this command is a convenient way to
build the website and push to the `gh-pages` branch.
如果您正在使用GitHub Pages进行托管,则此命令是一种方便的方法建立网站并推送到`gh-pages`分支。
4 changes: 2 additions & 2 deletions docs/architecture/_category_.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"label": "Architecture Deep Dive",
"label": "架构深入探讨",
"position": 4,
"link": {
"type": "generated-index",
"description": "Deep Dive into all the concepts associated with Kakarot zkEVM: from what is a zkEVM to how it works under the hood"
"description": "深入探讨与Kakarot zkEVM相关的所有概念:从什么是zkEVM到它在幕后是如何工作的。"
}
}
171 changes: 51 additions & 120 deletions docs/architecture/understanding-kakarot.md
Original file line number Diff line number Diff line change
@@ -1,162 +1,93 @@
---
title: Kakarot zkEVM under the hood
title: Kakarot zkEVM 在幕后运行
sidebar_position: 2
---

## Kakarot, the zkEVM built in Cairo
## 在Cairo建造的zkEVM Kakarot

Kakarot is a zkEVM built in [Cairo](https://www.cairo-lang.org/), the provable
language that powers [Starknet](https://starkware.co/starknet/) and all the
StarknetOS chains (also called CairoVM chains, or Starknet appchains). Kakarot
is an Ethereum-compatible Layer 2, a
[so-called zkRollup](https://ethereum.org/developers/docs/scaling/zk-rollups).
Beyond compatibility, Kakarot strives to push more innovations to the L2 space,
and to add new features such as native account abstraction to the EVM. Kakarot's
driving ethos is to _Prove, Scale and Innovate_ 🥕.
Kakarot 是一个在 [Cairo](https://www.cairo-lang.org/) 中构建的 zkEVM,这是一个可证明的语言,为 [Starknet](https://starkware.co/starknet/) 和所有 StarknetOS 链(也称为 CairoVM 链或 Starknet 应用链)提供支持。Kakarot 是一个与以太坊兼容的 Layer 2,一个所谓的 [zkRollup](https://ethereum.org/developers/docs/scaling/zk-rollups)。除了兼容性外,Kakarot 还致力于向 L2 领域推动更多创新,并添加新功能,如原生账户抽象到 EVM。Kakarot 的主导理念是“证明、扩展和创新” 🥕。

In concrete terms, Kakarot is an Ethereum-compatible zk-Rollup:

- Ethereum-compatible: use Kakarot and Ethereum in the same way.
- Zero-Knowledge (zk): no compromise on security, maximized integrity derived
from maths.
- Rollup: Enjoy lower costs than on Ethereum mainnet.
具体而言,Kakarot 是一个与以太坊兼容的 zk-Rollup:

For users:
- 与以太坊兼容:以与以太坊相同的方式使用 Kakarot 和以太坊。
- 零知识(zk):不妥协于安全性,通过数学实现最大化的数据完整性。
- Rollup:享受比以太坊主网更低的成本。

- For end users, use Kakarot in the same way as Ethereum mainnet: interact with
dApps using any EVM wallet, e.g. Metamask or Rabby.
- For developers and teams, you can build on Kakarot using the Ethereum
ecosystem's standard tools: Solidity or Vyper, Foundry, Hardhat, Etherjs etc.
对于用户:

Discover the Kakarot explorer and other useful links on the
[survival guide](../survival-guide) page.
- 对于终端用户,可以像使用以太坊主网一样使用 Kakarot:通过任何 EVM 钱包与 dApp 进行交互,例如 Metamask 或 Rabby。
- 对于开发者和团队,您可以使用以太坊生态系统的标准工具构建 Kakarot:Solidity 或 Vyper、Foundry、Hardhat、Ether.js 等。

Note: Kakarot is not a privacy chain. Zero-knowledge technologies can be used
for two (non-excluding) purposes, Scaling or Privacy. Kakarot uses the former to
scale Ethereum.
在 [survival guide](../survival-guide) 页面上发现 Kakarot 浏览器和其他有用的链接。

## How does Kakarot work under the hood?
注意:Kakarot 不是一个隐私链。零知识技术可以用于两种(非排斥)目的,即扩展或隐私。Kakarot 使用前者来扩展以太坊。

### Kakarot is an implementation of the EVM in Cairo

Under the hood, Kakarot zkEVM is a Cairo program that implement the EVM
instruction set. The EVM is the blueprint, Kakarot implements it in Cairo.
## Kakarot 在底层是如何工作的?

> Cairo is the first Turing-complete language for creating provable programs for
> general computation.
### Kakarot 是在 Cairo 中实现的 EVM

Cairo is like any a programming language, but made for writing provable
software. It means that whatever is written in Cairo is, by design, _zk_. Using
Cairo means that we leverage cryptography without having to think about it, it
sort of "comes for free" just by using this language and not, say, rust.
在底层,Kakarot zkEVM 是一个实现了 EVM 指令集的 Cairo 程序。EVM 是蓝图,Kakarot 在 Cairo 中实现了它。

> Cairo 是第一个用于创建可证明通用计算程序的图灵完备语言。
> 通用计算。

Cairo 跟其他任何编程语言都一样,但是专门用于编写可证明的软件。这意味着无论在 Cairo 中写什么,从设计上都是零知识的。使用 Cairo 意味着我们利用了密码学,而无需考虑它,使用这种语言而不是 Rust 等语言,这样的功能“免费”提供了。

---

Diagram - Kakarot zkEVM high-level architecture:
图表 - Kakarot zkEVM 的高级架构:

![Kakarot zkEVM architecture diagram](../../static/diagrams/kakarot_zkevm.png)

---

Kakarot - the network - is composed of three parts: the Core EVM in Cairo, an
RPC layer (RPC server and EVM indexer) and an underlying CairoVM client (a
StarknetOS chain).
Kakarot - 网络 - 由三个部分组成:Cairo 中的核心 EVM、一个 RPC 层(RPC 服务器和 EVM 索引器)和一个底层 CairoVM 客户端(一个 StarknetOS 链)。

### Kakarot 运行在底层的 StarknetOS 客户端上

### Kakarot runs on an underlying StarknetOS client
Kakarot 核心 EVM,即前面提到的我们的新 EVM 实现,部署在一个底层的 StarknetOS 链上。这意味着 Kakarot 作为一组 Cairo 智能合约在 CairoVM 驱动的链上运行。这个 CairoVM 链对用户来说是“不可见”的。用户只能通过以太坊兼容的方式通过 RPC 层与 Kakarot 进行交互。在 Kakarot zkEVM 中唯一暴露的接口是以太坊 JSON-RPC 规范。在未来,我们可以利用这一点,允许开发者编写自己的 Cairo 预编译合约,就像 [Arbitrum Stylus](https://arbitrum.io/stylus) 引入了 Rust、C 和 C++ 一样。

The Kakarot core EVM, i.e. as said previously our new EVM implementation, is
deployed on an underlying StarknetOS chain. This means that Kakarot is running
as a set of Cairo smart contracts on a CairoVM-powered chain. This CairoVM chain
is "invisible" to the user. Users only interact with Kakarot through the RPC
layer in an Ethereum-compatible way. The only exposed interface in Kakarot zkEVM
is the Ethereum JSON-RPC specification. In the future, we could leverage this to
allow developers to write their own Cairo-precompiled contracts, as
[Arbitrum Stylus](https://arbitrum.io/stylus) introduced Rust, C, and C++
together with the EVM.

---

Diagram - Kakarot RPC Layer
图表 - Kakarot RPC

![Kakarot RPC Layer](../../static/diagrams/kakarot_rpc.png)

---
Kakarot L2由用Cairo编写的EVM和一个RPC层组成,以允许用户以以太坊格式与之交互。所有Cairo执行跟踪都是可证明的,这使得Kakarot能够批处理区块并使用[Starkware Shared prover](https://starkware.co/tech-stack/)(SHARP)提交证明到L1。由于Cairo是一个充满活力的生态系统,未来将出现其他证明器实现,比如[Stark Platinum Prover](https://github.com/lambdaclass/lambdaworks/tree/main/provers)。这将实现多重证明安全,并增加Kakarot网络的健壮性。

在Kakarot zkEVM中,关于EVM程序及其Cairo等价物的设计选择如下所述。它们可能随着时间的推移而发生架构变化。免责声明:所有这些设计选择对用户都是不可见的:

- 每个EVM智能合约(称为Contract Account)都部署为一个唯一的Starknet智能合约。这个Starknet智能合约存储着自己的字节码和EVM存储槽。
- 每个EVM用户拥有的账户(称为Externally Owned Account (EOA))都部署为一个Starknet智能合约钱包。
- 它具有一个Starknet格式的地址(31字节的十六进制字符串),该地址与用户EOA EVM地址(20字节的十六进制字符串)唯一映射。对于用户来说,这是不可见的。
- 它的ETH(代币与通证)原生余额在Kakarot系统中是以ERC20原生通证的形式计价的。对于用户来说,这是不可见的。
- 它的行为完全像一个EOA,使用与以太坊主网相同的签名和验证方案,未来可以扩展支持创新功能!
- 用户发送的EVM交易被包装在Starknet交易中。衍生的EVM交易哈希与底层Starknet交易哈希一一对应。由于签名验证是在Cairo程序中完成的,因此交易在RPC层被打包([despite being wrapped at the RPC level](https://github.com/kkrt-labs/kakarot-rpc/blob/bcadfc9b38ac934f73832b3a3485c15f08d66218/src/eth_rpc/servers/eth_rpc.rs#L236))时仍然可以被证明地进行处理。对于用户来说,这是不可见的。
- 新的状态根使用Pedersen哈希计算,而不是keccak,因为keccak在零知识友好性方面存在问题。这不会对EVM兼容性产生影响。
- 状态trie使用Pedersen MPT计算,而不是[Keccak MPT](https://ethereum.org/developers/docs/data-structures-and-encoding/patricia-merkle-trie)。请注意,交易trie和收据trie都是作为keccak MPT进行计算的,用于区块浏览器,但作为证明承诺的Pedersen MPT进行计算。

总之,任何在Cairo中编写的东西都是可以证明的。Kakarot在Cairo中实现了EVM规范。这是设计上可证明的。所有Cairo的工作都是在幕后完成的。对于用户来说,这是不可见的。他们正在与一个EVM链进行交互。

Kakarot与其他zkEVM的区别

Kakarot zkEVM可能是最高级的zkEVM。在数学语言和多项式到人类可理解的语言之间的尺度上,Kakarot比其他zkEVM更接近于人类可读的语言。这对用户有两方面的影响:

- 由于Kakarot是建立在Cairo之上的,因此Kakarot作为一个代码库非常精简(比其他zkEVM轻一个数量级),因此非常容易维护、适应以太坊的变化或添加新功能(例如本地账户抽象)。
- Cairo(通过Starknet)是一个充满活力的生态系统,Kakarot可以轻松受益于其所有创新(相同的底层技术栈)。长期的想法可能包括并行执行、seed-less钱包(例如只依赖于面部识别)、Celestia DA集成等。

总之,通过在未来几年押注于CairoVM,Kakarot利用了整个Cairo(因此Starknet)生态系统。Cairo是生产中最先进的高级零知识工具箱,首先是[StarkEx](https://www.theblock.co/post/237064/starkex-layer-2-records-1-trillion-in-on-chain-trading-volume-since-june-2020),现在是Starknet。

To put it simply, Kakarot L2 is composed of an EVM written in Cairo and an RPC
layer to allow users to interact with it in an Ethereum format. All Cairo
execution traces are provable by design, which allows Kakarot to batch blocks
and submit proofs to L1 using the
[Starkware Shared prover](https://starkware.co/tech-stack/) (SHARP). Because
Cairo is a vibrant ecosystem, other prover implementations in the future will
emerge, such as Lambdaclass'
[Stark Platinum Prover](https://github.com/lambdaclass/lambdaworks/tree/main/provers).
This will enable multi-proof security and increase robustness of the Kakarot
network.

In Kakarot zkEVM, the design choices regarding EVM programs and their Cairo
equivalents are explained below. They are subject to architecture changes over
time. **🎙️ Disclaimer 🎙️: all these designs choices are invisible to the user**:

- each EVM smart contract (so-called _Contract Account_) is deployed as a unique
Starknet smart contract. This Starknet smart contract stores its own bytecode
and EVM storage slots.
- each EVM user-owned account (so-called _Externally Owned Account (EOA)_) is
deployed as a Starknet smart contract wallet.
- It has a Starknet formatted address (31 bytes hex string), which is uniquely
mapped to the user EOA EVM address (20 bytes hex string). For the user, this
is invisible.
- Its native balance in ETH (coin vs. token) is denominated in ERC20 native
token under the hood in the Kakarot system. For the user, this is invisible.
- It behaves exactly like an EOA, uses the same signature and validation
scheme as Ethereum mainnet, though it can be extended in the future to
support innovative features!
- EVM transactions that are sent by users are wrapped in Starknet transactions.
The derived EVM Transaction hashes are mapped 1-to-1 with underlying Starknet
transaction hashes. Since signature verification is done in a Cairo program,
transactions are provably processed with integrity
[despite being wrapped at the RPC level](https://github.com/kkrt-labs/kakarot-rpc/blob/bcadfc9b38ac934f73832b3a3485c15f08d66218/src/eth_rpc/servers/eth_rpc.rs#L236).
For the user, this is invisible.
- new state roots are computed using Pedersen hash and not keccak because of the
zk-unfriendliness of keccak. This does not hurt EVM compatibility at the
applicative level.
- the state trie is computed using Pedersen MPT and not
[Keccak MPT](https://ethereum.org/developers/docs/data-structures-and-encoding/patricia-merkle-trie).
Note that the transaction trie and receipt trie are both computed as keccak
MPTs, for block explorers, but as pedersen MPTs for the proof commitment.

TL;DR - whatever is written in Cairo can be proven. Kakarot implements the EVM
specification in Cairo. It is provable by design. All the Cairo magic is done
under the hood. For the user, this is invisible. They are interacting with an
EVM chain.

## The difference between Kakarot and other zkEVMs

Kakarot zkEVM is probably the most high-level zkEVM. On the scale of maths
language and polynomials to human understandable language, Kakarot is closer to
human readable language than any other zkEVM. This matters to users in two ways:

- Because Kakarot is built on Cairo, Kakarot as a codebase is extremely slim (an
order of magnitude lighter than other zkEVMs) and thus extremely easy to
maintain, adapt to Ethereum changes, or add new features to (e.g. native
account abstraction).
- Cairo (through Starknet) is a vibrant ecosystem and Kakarot can benefit from
all its innovations with ease (same underlying tech stack). Ideas on the long
term could include parallel execution, seed-less wallets (e.g. rely on face ID
only), Celestia DA integration and more.

TL;DR - By betting on the CairoVM for the years to come, Kakarot leverages the
entire Cairo (and thus Starknet) ecosystem. Cairo is the most advanced
high-level zk-toolbox in production, first with
[StarkEx](https://www.theblock.co/post/237064/starkex-layer-2-records-1-trillion-in-on-chain-trading-volume-since-june-2020)
and now Starknet.

---

Diagram - How to build a zkEVM:
图表 - 如何构建 zkEVM

![Different ways to build a zkEVM: low-level circuits or intermediary zkVM](../../static/diagrams/how_to_build_a_zkevm.png)

We believe that in focusing only on engineering, our approach is scalable and
sustainable.
我们相信,只专注于工程设计,我们的方法是可扩展和可持续的。

<!-- For information unrelated to documentation effort, link to external URLs to decrease the area to maintain: docs should contain doc-related content, and for other content (e.g. how did Kakarot start, what is the roadmap, etc.), use other media -->
Loading