Skip to content

Commit 6840e30

Browse files
authored
Merge pull request #31 from 0xPolygonZero/feat/cancun
Implement Cancun HF support.
2 parents 65624db + a7384fa commit 6840e30

File tree

148 files changed

+17674
-12952
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+17674
-12952
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ jobs:
187187
- name: Run the script
188188
run: |
189189
pushd zero_bin/tools
190-
./prove_stdio.sh artifacts/witness_b19240705.json
190+
./prove_stdio.sh artifacts/witness_b19807080.json
191191
192192
simple_proof_witness_only:
193193
name: Execute bash script to generate the proof witness for a small block.
@@ -200,7 +200,7 @@ jobs:
200200
- name: Run the script
201201
run: |
202202
pushd zero_bin/tools
203-
./prove_stdio.sh artifacts/witness_b19240705.json test_only
203+
./prove_stdio.sh artifacts/witness_b19807080.json test_only
204204
205205
multi_blocks_proof_regular:
206206
name: Execute bash script to generate and verify a proof for multiple blocks using parallel proving.
@@ -213,7 +213,7 @@ jobs:
213213
- name: Run the script
214214
run: |
215215
pushd zero_bin/tools
216-
./prove_stdio.sh artifacts/witness_b2_b7.json
216+
./prove_stdio.sh artifacts/witness_b3_b6.json
217217
218218
lints:
219219
name: Rustdoc, Formatting and Clippy

.github/workflows/jerigon.yml

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ jobs:
2929
uses: actions/checkout@v4
3030
with:
3131
repository: 0xPolygonZero/jerigon-test-network
32-
path: test-jerigon-network
32+
ref: 'feat/kurtosis-network'
33+
path: jerigon-test-network
3334

3435
- name: Install nightly toolchain
3536
uses: dtolnay/rust-toolchain@nightly
@@ -49,37 +50,49 @@ jobs:
4950
with:
5051
cache-on-failure: true
5152

52-
- name: Run jerigon test network with docker compose
53+
- name: Install kurtosis
5354
run: |
54-
cd test-jerigon-network
55-
docker-compose -f docker-compose.yml up -d
56-
docker logs -f smart-contracts
57-
echo "Jerigon network is up and running, ready for testing"
55+
echo "deb [trusted=yes] https://apt.fury.io/kurtosis-tech/ /" | sudo tee /etc/apt/sources.list.d/kurtosis.list
56+
sudo apt update
57+
sudo apt install kurtosis-cli
5858
59-
- name: Rpc test with curl
59+
#It is much easier to use cast tool in scripts so install foundry
60+
- name: Install Foundry
61+
uses: foundry-rs/foundry-toolchain@v1
62+
63+
- name: Run cancun test network
6064
run: |
61-
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id":83}' localhost:8545
62-
env:
63-
RUST_LOG: info
64-
65+
docker pull ghcr.io/0xpolygonzero/erigon:feat-zero
66+
kurtosis run --enclave cancun-testnet github.com/ethpandaops/ethereum-package@4.0.0 --args-file jerigon-test-network/network_params.yml
67+
68+
- name: Generate blocks with transactions
69+
run: |
70+
ETH_RPC_URL="$(kurtosis port print cancun-testnet el-2-erigon-lighthouse ws-rpc)"
71+
cast rpc eth_blockNumber --rpc-url $ETH_RPC_URL
72+
cd jerigon-test-network && set -a && source .env && set +a
73+
bash ./tests/generate_transactions.sh
74+
6575
- name: Run prove blocks in test_only mode
6676
run: |
77+
ETH_RPC_URL="$(kurtosis port print cancun-testnet el-2-erigon-lighthouse ws-rpc)"
6778
cd zero_bin/tools
68-
OUTPUT_TO_TERMINAL=true ./prove_rpc.sh 0x2 0x3 http://localhost:8546 jerigon true 0 0 test_only
79+
ulimit -n 8192
80+
OUTPUT_TO_TERMINAL=true ./prove_rpc.sh 0x1 0xf $ETH_RPC_URL jerigon true 3000 100 test_only
6981
echo "Proving blocks in test_only mode finished"
7082
7183
7284
- name: Run prove blocks in real mode
7385
run: |
86+
ETH_RPC_URL="$(kurtosis port print cancun-testnet el-2-erigon-lighthouse ws-rpc)"
7487
cd zero_bin/tools
7588
rm -rf proofs/* circuits/* ./proofs.json test.out verify.out leader.out
76-
OUTPUT_TO_TERMINAL=true RUN_VERIFICATION=true ./prove_rpc.sh 0x4 0x5 http://localhost:8546 jerigon true
89+
OUTPUT_TO_TERMINAL=true RUN_VERIFICATION=true ./prove_rpc.sh 0x2 0x8 $ETH_RPC_URL jerigon true 3000 100
7790
echo "Proving blocks in real mode finished"
7891
7992
- name: Shut down network
8093
run: |
81-
cd test-jerigon-network
82-
docker-compose -f docker-compose.yml down -v
94+
kurtosis enclave rm -f cancun-testnet
95+
kurtosis engine stop
8396
8497
8598

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
[workspace]
22
members = [
3-
"compat",
4-
"evm_arithmetization",
5-
"mpt_trie",
6-
"proc_macro",
7-
"proof_gen",
8-
"smt_trie",
9-
"trace_decoder",
10-
"zero_bin/common",
11-
"zero_bin/leader",
12-
"zero_bin/ops",
13-
"zero_bin/prover",
14-
"zero_bin/rpc",
15-
"zero_bin/verifier",
16-
"zero_bin/worker",
3+
"compat",
4+
"evm_arithmetization",
5+
"mpt_trie",
6+
"proc_macro",
7+
"proof_gen",
8+
"smt_trie",
9+
"trace_decoder",
10+
"zero_bin/common",
11+
"zero_bin/leader",
12+
"zero_bin/ops",
13+
"zero_bin/prover",
14+
"zero_bin/rpc",
15+
"zero_bin/verifier",
16+
"zero_bin/worker",
1717
]
1818
resolver = "2"
1919

@@ -28,18 +28,18 @@ categories = ["cryptography::cryptocurrencies"]
2828
[workspace.dependencies]
2929
__compat_primitive_types = { version = "0.12.2", package = "primitive-types" }
3030
alloy = { git = "https://github.com/alloy-rs/alloy", tag = 'v0.1.1', default-features = false, features = [
31-
"consensus",
32-
"reqwest",
33-
"json-rpc",
34-
"rlp",
35-
"rpc",
36-
"rpc-client",
37-
"rpc-types-eth",
38-
"rpc-types-trace",
39-
"providers",
40-
"transports",
41-
"transport-http",
42-
"rpc-types-debug",
31+
"consensus",
32+
"reqwest",
33+
"json-rpc",
34+
"rlp",
35+
"rpc",
36+
"rpc-client",
37+
"rpc-types-eth",
38+
"rpc-types-trace",
39+
"providers",
40+
"transports",
41+
"transport-http",
42+
"rpc-types-debug",
4343
] }
4444
anyhow = "1.0.86"
4545
async-stream = "0.3.5"
@@ -59,7 +59,6 @@ enumn = "0.1.13"
5959
env_logger = "0.11.3"
6060
eth_trie = "0.4.0"
6161
ethereum-types = "0.14.1"
62-
evm_arithmetization = { path = "evm_arithmetization", version = "0.3.0" }
6362
futures = "0.3.30"
6463
hashbrown = "0.14.5"
6564
hex = "0.4.3"
@@ -72,7 +71,6 @@ itertools = "0.13.0"
7271
keccak-hash = "0.10.0"
7372
log = "0.4.21"
7473
lru = "0.12.3"
75-
mpt_trie = { path = "mpt_trie", version = "0.4.0" }
7674
num = "0.4.3"
7775
num-bigint = "0.4.5"
7876
num-traits = "0.2.19"
@@ -84,7 +82,6 @@ paste = "1.0.15"
8482
pest = "2.7.10"
8583
pest_derive = "2.7.10"
8684
pretty_env_logger = "0.5.0"
87-
proof_gen = { path = "proof_gen", version = "0.3.0" }
8885
rand = "0.8.5"
8986
rand_chacha = "0.3.1"
9087
ripemd = "0.1.3"
@@ -96,21 +93,26 @@ serde_json = "1.0.118"
9693
serde_path_to_error = "0.1.16"
9794
serde_with = "3.8.1"
9895
sha2 = "0.10.8"
99-
smt_trie = { path = "smt_trie", version = "0.1.0" }
10096
static_assertions = "1.1.0"
10197
thiserror = "1.0.61"
10298
tiny-keccak = "2.0.2"
10399
tokio = { version = "1.38.0", features = ["full"] }
104100
toml = "0.8.14"
105101
tower = "0.4"
106-
trace_decoder = { path = "trace_decoder", version = "0.5.0" }
107102
tracing = "0.1"
108103
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
109104
u4 = "0.1.0"
110105
uint = "0.9.5"
111106
url = "2.5.2"
112107
winnow = "0.6.13"
113108

109+
# local dependencies
110+
evm_arithmetization = { path = "evm_arithmetization", version = "0.3.0" }
111+
mpt_trie = { path = "mpt_trie", version = "0.4.0" }
112+
proof_gen = { path = "proof_gen", version = "0.3.0" }
113+
smt_trie = { path = "smt_trie", version = "0.1.0" }
114+
trace_decoder = { path = "trace_decoder", version = "0.5.0" }
115+
114116
# zero-bin related dependencies
115117
ops = { path = "zero_bin/ops" }
116118
prover = { path = "zero_bin/prover" }

compat/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "compat"
33
version = "0.1.0"
4-
publish = false # TODO(<owner>): https://github.com/0xPolygonZero/zk_evm/issues/314 find a better place for this
4+
publish = false # TODO(<owner>): https://github.com/0xPolygonZero/zk_evm/issues/314 find a better place for this
55
edition.workspace = true
66
license.workspace = true
77
repository.workspace = true
@@ -10,5 +10,5 @@ keywords.workspace = true
1010
categories.workspace = true
1111

1212
[dependencies]
13-
alloy = {workspace = true }
13+
alloy = { workspace = true }
1414
__compat_primitive_types = { workspace = true }

docs/arithmetization/cpulogic.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,15 @@ \subsection{Privileged instructions}
7878
\item[0x21.] \texttt{KECCAK\_GENERAL}. Pops 2 elements (a Memory address, followed by a length $\ell$) and pushes the hash of the memory portion starting at the
7979
constructed address and of length $\ell$. It is similar to KECCAK256 (0x20) instruction, but can be applied to any memory section (i.e. even privileged ones).
8080

81-
\item[0x49.] \texttt{PROVER\_INPUT}. Pushes a single prover input onto the stack.
82-
8381
\item[0xC0-0xDF.] \texttt{MSTORE\_32BYTES}. Pops 2 elements from the stack (a Memory address, and then a value), and pushes
8482
a new address' onto the stack. The value is being decomposed into bytes and written to memory, starting from the fetched address. The new address being pushed is computed as the
8583
initial address + the length of the byte sequence being written to memory. Note that similarly to PUSH (0x60-0x7F) instructions, there are 32 MSTORE\_32BYTES instructions, each
8684
corresponding to a target byte length (length 0 is ignored, for the same reasons as MLOAD\_32BYTES, see below). Writing to memory an integer fitting in $n$ bytes with a length $\ell < n$ will
8785
result in the integer being truncated. On the other hand, specifying a length $\ell$ greater than the byte size of the value being written will result in padding with zeroes. This
8886
process is heavily used when resetting memory sections (by calling MSTORE\_32BYTES\_32 with the value 0).
8987

88+
\item[0xEE.] \texttt{PROVER\_INPUT}. Pushes a single prover input onto the stack.
89+
9090
\item[0xF6.] \texttt{GET\_CONTEXT}. Pushes the current context onto the stack. The kernel always has context 0.
9191

9292
\item[0xF7.] \texttt{SET\_CONTEXT}. Pops the top element of the stack and updates the current context to this value. It is usually used when calling another contract or precompile,

evm_arithmetization/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ name = "evm_arithmetization"
33
description = "Implementation of STARKs for the Ethereum Virtual Machine"
44
version = "0.3.0"
55
authors = [
6-
"Daniel Lubarov <daniel@lubarov.com>",
7-
"William Borgeaud <williamborgeaud@gmail.com>",
6+
"Daniel Lubarov <daniel@lubarov.com>",
7+
"William Borgeaud <williamborgeaud@gmail.com>",
88
]
99
readme = "README.md"
1010
categories = ["cryptography"]
@@ -38,6 +38,7 @@ rand_chacha = { workspace = true }
3838
rlp = { workspace = true }
3939
rlp-derive = { workspace = true }
4040
serde = { workspace = true, features = ["derive"] }
41+
sha2 = { workspace = true }
4142
static_assertions = { workspace = true }
4243
hashbrown = { workspace = true }
4344
tiny-keccak = { workspace = true }
@@ -51,15 +52,14 @@ zk_evm_proc_macro = { workspace = true }
5152
criterion = { workspace = true }
5253
hex = { workspace = true }
5354
ripemd = { workspace = true }
54-
sha2 = { workspace = true }
5555

5656
[features]
5757
default = ["parallel"]
5858
asmtools = ["hex"]
5959
parallel = [
60-
"plonky2/parallel",
61-
"plonky2_maybe_rayon/parallel",
62-
"starky/parallel",
60+
"plonky2/parallel",
61+
"plonky2_maybe_rayon/parallel",
62+
"starky/parallel",
6363
]
6464

6565
[[bin]]

evm_arithmetization/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Provable Stateless ZK-EVM
22

3-
Included here is an implementation of a stateless, recursive ZK-EVM client implemented using Plonky2. It currently supports the full Merkle-Patricia Trie and has all Shanghai opcodes implemented.
3+
Included here is an implementation of a stateless, recursive ZK-EVM client implemented using Plonky2. It currently supports the full Merkle-Patricia Trie and has all Cancun opcodes implemented.
44

55
## Performance
66

@@ -10,7 +10,8 @@ Furthermore the implementation itself is highly optimized to provide fast provin
1010

1111
## Ethereum Compatibility
1212

13-
The aim of this module is to initially provide full ethereum compatibility. Today, all [EVM tests](https://github.com/0xPolygonZero/evm-tests) for the Shanghai hardfork are implemented. Work is progressing on supporting the upcoming [Cancun](https://github.com/0xPolygonZero/plonky2/labels/cancun) EVM changes. Furthermore, this prover uses the full ethereum state tree and hashing modes.
13+
The aim of this module is to initially provide full Ethereum compatibility.
14+
It is currently fully [Cancun](https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/cancun.md) HF compatible.
1415

1516
## Audits
1617

0 commit comments

Comments
 (0)