Skip to content

Commit

Permalink
Merge pull request #31 from 0xPolygonZero/feat/cancun
Browse files Browse the repository at this point in the history
Implement Cancun HF support.
  • Loading branch information
Nashtare authored Jul 15, 2024
2 parents 65624db + a7384fa commit 6840e30
Show file tree
Hide file tree
Showing 148 changed files with 17,674 additions and 12,952 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ jobs:
- name: Run the script
run: |
pushd zero_bin/tools
./prove_stdio.sh artifacts/witness_b19240705.json
./prove_stdio.sh artifacts/witness_b19807080.json
simple_proof_witness_only:
name: Execute bash script to generate the proof witness for a small block.
Expand All @@ -200,7 +200,7 @@ jobs:
- name: Run the script
run: |
pushd zero_bin/tools
./prove_stdio.sh artifacts/witness_b19240705.json test_only
./prove_stdio.sh artifacts/witness_b19807080.json test_only
multi_blocks_proof_regular:
name: Execute bash script to generate and verify a proof for multiple blocks using parallel proving.
Expand All @@ -213,7 +213,7 @@ jobs:
- name: Run the script
run: |
pushd zero_bin/tools
./prove_stdio.sh artifacts/witness_b2_b7.json
./prove_stdio.sh artifacts/witness_b3_b6.json
lints:
name: Rustdoc, Formatting and Clippy
Expand Down
43 changes: 28 additions & 15 deletions .github/workflows/jerigon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ jobs:
uses: actions/checkout@v4
with:
repository: 0xPolygonZero/jerigon-test-network
path: test-jerigon-network
ref: 'feat/kurtosis-network'
path: jerigon-test-network

- name: Install nightly toolchain
uses: dtolnay/rust-toolchain@nightly
Expand All @@ -49,37 +50,49 @@ jobs:
with:
cache-on-failure: true

- name: Run jerigon test network with docker compose
- name: Install kurtosis
run: |
cd test-jerigon-network
docker-compose -f docker-compose.yml up -d
docker logs -f smart-contracts
echo "Jerigon network is up and running, ready for testing"
echo "deb [trusted=yes] https://apt.fury.io/kurtosis-tech/ /" | sudo tee /etc/apt/sources.list.d/kurtosis.list
sudo apt update
sudo apt install kurtosis-cli
- name: Rpc test with curl
#It is much easier to use cast tool in scripts so install foundry
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Run cancun test network
run: |
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id":83}' localhost:8545
env:
RUST_LOG: info

docker pull ghcr.io/0xpolygonzero/erigon:feat-zero
kurtosis run --enclave cancun-testnet github.com/ethpandaops/ethereum-package@4.0.0 --args-file jerigon-test-network/network_params.yml
- name: Generate blocks with transactions
run: |
ETH_RPC_URL="$(kurtosis port print cancun-testnet el-2-erigon-lighthouse ws-rpc)"
cast rpc eth_blockNumber --rpc-url $ETH_RPC_URL
cd jerigon-test-network && set -a && source .env && set +a
bash ./tests/generate_transactions.sh
- name: Run prove blocks in test_only mode
run: |
ETH_RPC_URL="$(kurtosis port print cancun-testnet el-2-erigon-lighthouse ws-rpc)"
cd zero_bin/tools
OUTPUT_TO_TERMINAL=true ./prove_rpc.sh 0x2 0x3 http://localhost:8546 jerigon true 0 0 test_only
ulimit -n 8192
OUTPUT_TO_TERMINAL=true ./prove_rpc.sh 0x1 0xf $ETH_RPC_URL jerigon true 3000 100 test_only
echo "Proving blocks in test_only mode finished"
- name: Run prove blocks in real mode
run: |
ETH_RPC_URL="$(kurtosis port print cancun-testnet el-2-erigon-lighthouse ws-rpc)"
cd zero_bin/tools
rm -rf proofs/* circuits/* ./proofs.json test.out verify.out leader.out
OUTPUT_TO_TERMINAL=true RUN_VERIFICATION=true ./prove_rpc.sh 0x4 0x5 http://localhost:8546 jerigon true
OUTPUT_TO_TERMINAL=true RUN_VERIFICATION=true ./prove_rpc.sh 0x2 0x8 $ETH_RPC_URL jerigon true 3000 100
echo "Proving blocks in real mode finished"
- name: Shut down network
run: |
cd test-jerigon-network
docker-compose -f docker-compose.yml down -v
kurtosis enclave rm -f cancun-testnet
kurtosis engine stop
1 change: 1 addition & 0 deletions Cargo.lock

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

64 changes: 33 additions & 31 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
[workspace]
members = [
"compat",
"evm_arithmetization",
"mpt_trie",
"proc_macro",
"proof_gen",
"smt_trie",
"trace_decoder",
"zero_bin/common",
"zero_bin/leader",
"zero_bin/ops",
"zero_bin/prover",
"zero_bin/rpc",
"zero_bin/verifier",
"zero_bin/worker",
"compat",
"evm_arithmetization",
"mpt_trie",
"proc_macro",
"proof_gen",
"smt_trie",
"trace_decoder",
"zero_bin/common",
"zero_bin/leader",
"zero_bin/ops",
"zero_bin/prover",
"zero_bin/rpc",
"zero_bin/verifier",
"zero_bin/worker",
]
resolver = "2"

Expand All @@ -28,18 +28,18 @@ categories = ["cryptography::cryptocurrencies"]
[workspace.dependencies]
__compat_primitive_types = { version = "0.12.2", package = "primitive-types" }
alloy = { git = "https://github.com/alloy-rs/alloy", tag = 'v0.1.1', default-features = false, features = [
"consensus",
"reqwest",
"json-rpc",
"rlp",
"rpc",
"rpc-client",
"rpc-types-eth",
"rpc-types-trace",
"providers",
"transports",
"transport-http",
"rpc-types-debug",
"consensus",
"reqwest",
"json-rpc",
"rlp",
"rpc",
"rpc-client",
"rpc-types-eth",
"rpc-types-trace",
"providers",
"transports",
"transport-http",
"rpc-types-debug",
] }
anyhow = "1.0.86"
async-stream = "0.3.5"
Expand All @@ -59,7 +59,6 @@ enumn = "0.1.13"
env_logger = "0.11.3"
eth_trie = "0.4.0"
ethereum-types = "0.14.1"
evm_arithmetization = { path = "evm_arithmetization", version = "0.3.0" }
futures = "0.3.30"
hashbrown = "0.14.5"
hex = "0.4.3"
Expand All @@ -72,7 +71,6 @@ itertools = "0.13.0"
keccak-hash = "0.10.0"
log = "0.4.21"
lru = "0.12.3"
mpt_trie = { path = "mpt_trie", version = "0.4.0" }
num = "0.4.3"
num-bigint = "0.4.5"
num-traits = "0.2.19"
Expand All @@ -84,7 +82,6 @@ paste = "1.0.15"
pest = "2.7.10"
pest_derive = "2.7.10"
pretty_env_logger = "0.5.0"
proof_gen = { path = "proof_gen", version = "0.3.0" }
rand = "0.8.5"
rand_chacha = "0.3.1"
ripemd = "0.1.3"
Expand All @@ -96,21 +93,26 @@ serde_json = "1.0.118"
serde_path_to_error = "0.1.16"
serde_with = "3.8.1"
sha2 = "0.10.8"
smt_trie = { path = "smt_trie", version = "0.1.0" }
static_assertions = "1.1.0"
thiserror = "1.0.61"
tiny-keccak = "2.0.2"
tokio = { version = "1.38.0", features = ["full"] }
toml = "0.8.14"
tower = "0.4"
trace_decoder = { path = "trace_decoder", version = "0.5.0" }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
u4 = "0.1.0"
uint = "0.9.5"
url = "2.5.2"
winnow = "0.6.13"

# local dependencies
evm_arithmetization = { path = "evm_arithmetization", version = "0.3.0" }
mpt_trie = { path = "mpt_trie", version = "0.4.0" }
proof_gen = { path = "proof_gen", version = "0.3.0" }
smt_trie = { path = "smt_trie", version = "0.1.0" }
trace_decoder = { path = "trace_decoder", version = "0.5.0" }

# zero-bin related dependencies
ops = { path = "zero_bin/ops" }
prover = { path = "zero_bin/prover" }
Expand Down
4 changes: 2 additions & 2 deletions compat/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "compat"
version = "0.1.0"
publish = false # TODO(<owner>): https://github.com/0xPolygonZero/zk_evm/issues/314 find a better place for this
publish = false # TODO(<owner>): https://github.com/0xPolygonZero/zk_evm/issues/314 find a better place for this
edition.workspace = true
license.workspace = true
repository.workspace = true
Expand All @@ -10,5 +10,5 @@ keywords.workspace = true
categories.workspace = true

[dependencies]
alloy = {workspace = true }
alloy = { workspace = true }
__compat_primitive_types = { workspace = true }
4 changes: 2 additions & 2 deletions docs/arithmetization/cpulogic.tex
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ \subsection{Privileged instructions}
\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
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).

\item[0x49.] \texttt{PROVER\_INPUT}. Pushes a single prover input onto the stack.

\item[0xC0-0xDF.] \texttt{MSTORE\_32BYTES}. Pops 2 elements from the stack (a Memory address, and then a value), and pushes
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
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
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
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
process is heavily used when resetting memory sections (by calling MSTORE\_32BYTES\_32 with the value 0).

\item[0xEE.] \texttt{PROVER\_INPUT}. Pushes a single prover input onto the stack.

\item[0xF6.] \texttt{GET\_CONTEXT}. Pushes the current context onto the stack. The kernel always has context 0.

\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,
Expand Down
12 changes: 6 additions & 6 deletions evm_arithmetization/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name = "evm_arithmetization"
description = "Implementation of STARKs for the Ethereum Virtual Machine"
version = "0.3.0"
authors = [
"Daniel Lubarov <daniel@lubarov.com>",
"William Borgeaud <williamborgeaud@gmail.com>",
"Daniel Lubarov <daniel@lubarov.com>",
"William Borgeaud <williamborgeaud@gmail.com>",
]
readme = "README.md"
categories = ["cryptography"]
Expand Down Expand Up @@ -38,6 +38,7 @@ rand_chacha = { workspace = true }
rlp = { workspace = true }
rlp-derive = { workspace = true }
serde = { workspace = true, features = ["derive"] }
sha2 = { workspace = true }
static_assertions = { workspace = true }
hashbrown = { workspace = true }
tiny-keccak = { workspace = true }
Expand All @@ -51,15 +52,14 @@ zk_evm_proc_macro = { workspace = true }
criterion = { workspace = true }
hex = { workspace = true }
ripemd = { workspace = true }
sha2 = { workspace = true }

[features]
default = ["parallel"]
asmtools = ["hex"]
parallel = [
"plonky2/parallel",
"plonky2_maybe_rayon/parallel",
"starky/parallel",
"plonky2/parallel",
"plonky2_maybe_rayon/parallel",
"starky/parallel",
]

[[bin]]
Expand Down
5 changes: 3 additions & 2 deletions evm_arithmetization/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Provable Stateless ZK-EVM

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.
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.

## Performance

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

## Ethereum Compatibility

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.
The aim of this module is to initially provide full Ethereum compatibility.
It is currently fully [Cancun](https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/cancun.md) HF compatible.

## Audits

Expand Down
Loading

0 comments on commit 6840e30

Please sign in to comment.