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

Feat/cancun #31

Merged
merged 61 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
a2770f3
Squashed 'evm_arithmetization/' changes from d547f8d5..016b000e
Nashtare Feb 14, 2024
2552e45
Merge commit 'a2770f36b6c03f00978c0f266531028094eaff44' into feat/cancun
Nashtare Feb 14, 2024
d43c8e2
Implement EIP-4788 for Cancun (#40)
Nashtare Feb 18, 2024
8926efd
Implement Blob transactions (type-3) and BLOBHASH opcode (#50)
Nashtare Feb 21, 2024
5f5485c
Merge remote-tracking branch 'origin/main' into cancun-main
Nashtare Feb 26, 2024
d739a7a
Merge pull request #61 from 0xPolygonZero/cancun-main
Nashtare Feb 26, 2024
f084287
Fix beacons root contract bytecode (#70)
Nashtare Feb 29, 2024
e57e753
Merge branch 'main' into feat/cancun
Nashtare Mar 6, 2024
23b7a28
LxLy exit roots (#90)
wborgeaud Mar 8, 2024
e6b137c
Eip 1153 (TLOAD/TSTORE) (#59)
4l0n50 Mar 9, 2024
d243628
Merge remote-tracking branch 'origin/main' into feat/cancun
Nashtare Mar 11, 2024
6eca575
Remove blobbasefee from block header (#100)
Nashtare Mar 11, 2024
deb4f1c
Remove blobbasefee from block header
Nashtare Mar 11, 2024
2e4258c
Merge branch 'main' into feat/cancun
Nashtare Mar 11, 2024
8c7ccb0
Remove prints
Nashtare Mar 11, 2024
366e0a2
Fix MCOPY from rebasing (#103)
Nashtare Mar 11, 2024
05fd0c1
Fix storage write for beacons root contract (#102)
Nashtare Mar 12, 2024
4f3e858
EIP-4844 part 2: Point evaluation precompile (#133)
Nashtare Apr 4, 2024
9cd5cc7
Merge remote-tracking branch 'origin/develop' into feat/cancun
Nashtare Apr 10, 2024
bfc622a
Some fixes to Cancun (#187)
Nashtare Apr 24, 2024
45d19c8
Merge remote-tracking branch 'origin/develop' into feat/cancun
Nashtare May 1, 2024
b1d0416
Insert blob versioned hashes in signature payload for hashing (#209)
Nashtare May 2, 2024
57a62a4
Fix KZG precompile context setup (#210)
Nashtare May 2, 2024
f0022eb
Fix txn type encoding for receipts (#214)
Nashtare May 3, 2024
56aa543
Merge remote-tracking branch 'origin/develop' into feat/cancun
Nashtare May 3, 2024
f225a5d
Add blob gas fee burn for type-3 txns (#219)
Nashtare May 3, 2024
052e476
Update decoder processing for cancun (#207)
Nashtare May 4, 2024
06e45bf
cancun: Add a full block test (#223)
Nashtare May 6, 2024
a5f5421
Fix KZG precompile I/O (#213)
Nashtare May 6, 2024
23ee01b
Fix selfdestruct address listing (#225)
Nashtare May 6, 2024
afb9633
Fix withdrawals without txns and add test for empty block (#228)
Nashtare May 16, 2024
c610b93
Merge remote-tracking branch 'origin/develop' into feat/cancun
Nashtare May 20, 2024
abf919d
doc: update README (#242)
Nashtare May 22, 2024
aa36464
Cleanup and bring back deadcode lint (#232)
Nashtare May 23, 2024
9af4bf7
Merge branch 'develop' into feat/cancun
Nashtare May 24, 2024
aea633c
fix(cancun): dummy payloads and public input retrieval (#249)
Nashtare May 27, 2024
d3e8357
fix: encode calldata for EIP-4780 as U256 (#253)
Nashtare May 28, 2024
82d4901
fix: handle KZG precompile errors properly (#251)
Nashtare May 28, 2024
e48f8e9
fix(cancun): `mcopy` check offsets and overwrites (#252)
Nashtare May 29, 2024
275c2dd
fix(cancun): correct search loop in transient storage (#257)
Nashtare Jun 3, 2024
ef6b99d
perf: Charge gas before tload search (#272)
Nashtare Jun 10, 2024
b2c510d
Merge remote-tracking branch 'origin/develop' into feat/cancun
Nashtare Jun 10, 2024
2ffda4f
fix: add check on decoded versioned hashes (#278)
Nashtare Jun 13, 2024
2ad611a
Merge branch 'develop' into feat/cancun
Nashtare Jun 14, 2024
b7cea48
Merge branch 'develop' into feat/cancun
Nashtare Jun 24, 2024
dfc733d
Merge remote-tracking branch 'origin/develop' into feat/cancun
Nashtare Jun 27, 2024
6536269
Merge branch 'develop' into feat/cancun
Nashtare Jul 1, 2024
b3ef414
fix: Fix CI job
Nashtare Jul 1, 2024
51256ac
fix: pacify clippy
Nashtare Jul 1, 2024
59cdfad
fix: Add beacon roots touched slots into `state_access` with native t…
Nashtare Jul 3, 2024
858d6a1
Merge branch 'develop' into feat/cancun
Nashtare Jul 8, 2024
adf00d8
feat(cancun): update test blocks (#365)
Nashtare Jul 9, 2024
7ff44ed
fix: failed to send proof
atanmarko Jul 9, 2024
f9212b5
feat: cancun jerigon test network (#367)
atanmarko Jul 9, 2024
71bcb27
Merge branch 'develop' into feat/cancun
Nashtare Jul 10, 2024
5ae6629
fix(cancun): properly update accumulator in fake_exponential() (#376)
Nashtare Jul 10, 2024
ddca6be
Merge branch 'develop' into feat/cancun
Nashtare Jul 10, 2024
3cdecff
fix(cancun): tweak ranges in integration tests (#377)
Nashtare Jul 11, 2024
60db32c
`cancun`: cleanup pre-release (#392)
Nashtare Jul 15, 2024
34de2fd
Merge remote-tracking branch 'origin/develop' into feat/cancun
Nashtare Jul 15, 2024
a7384fa
Merge remote-tracking branch 'origin/develop' into feat/cancun
Nashtare Jul 15, 2024
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
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/[email protected] --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 <[email protected]>",
"William Borgeaud <[email protected]>",
"Daniel Lubarov <[email protected]>",
"William Borgeaud <[email protected]>",
]
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
Loading