Skip to content

Commit

Permalink
Merge pull request #60 from topos-protocol/cancun
Browse files Browse the repository at this point in the history
Adapt for Cancun HF
  • Loading branch information
Nashtare authored Jul 20, 2024
2 parents 457fcbd + 9994cec commit 8842ec2
Show file tree
Hide file tree
Showing 10 changed files with 435 additions and 267 deletions.
310 changes: 201 additions & 109 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ keywords = ["cryptography", "SNARK", "PLONK", "FRI", "plonky2"]
categories = ["cryptography"]

[workspace.dependencies]
anyhow = { version = "1.0.71", features = ["backtrace"] }
anyhow = { version = "1.0.86", features = ["backtrace"] }
clap = {version = "4.2.7", features = ["derive"] }
ethereum-types = "0.14.1"
flexi_logger = { version = "0.25.4", features = ["async"] }
Expand All @@ -27,8 +27,8 @@ tokio = { version = "1.28.1" }

# zk-evm dependencies
plonky2 = "0.2.2"
mpt_trie = "0.3.0"
evm_arithmetization = "0.2.0"
mpt_trie = { git = "https://github.com/0xPolygonZero/zk_evm", tag = "v0.6.0" }
evm_arithmetization = { git = "https://github.com/0xPolygonZero/zk_evm", tag = "v0.6.0" }

[profile.release]
opt-level = 3
Expand Down
129 changes: 65 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ The test runner supports secondary arguments to customize the testing flow. Whil
below are listed the most useful ones:

* `--blacklist-path` (short `b`): An optional relative path to a blacklist file containing test variants to prevent from running.
This can be used to skip particularly heavy or badly configured tests. A default [blacklist](./shanghai_heavy_tests_blacklist.txt)
This can be used to skip particularly heavy or badly configured tests. A default [blacklist](./cancun_heavy_tests_blacklist.txt)
is provided to allow any modern laptop to run witness generation for all test variants in about 40min.
* `--variant-filter` (short `v`): Only run specified test variants (either a single value or a range), e.g. `0` or `0..=5`
for instance. Note that the variant `n` for test `foo` isn't represented as `foo_n`, as variants keep the same naming
Expand Down Expand Up @@ -75,10 +75,10 @@ for this altered test, we log it as valid. If it fails, then we flag the test as

## Coverage [zk_evm v0.4.0]

The results below have been obtained against [zk_evm v0.4.0](https://github.com/0xPolygonZero/zk_evm/releases/tag/v0.4.0).
The results below have been obtained against [zk_evm v0.6.0](https://github.com/0xPolygonZero/zk_evm/releases/tag/v0.6.0).

All test vectors have been fetched from [ethereum/legacytests](https://github.com/ethereum/legacytests/tree/master) from
commit [8077d24](https://github.com/ethereum/legacytests/commit/8077d241740de5a448e41156fd33740f562d3b56).
commit [b2e6c9e](https://github.com/ethereum/legacytests/commit/b2e6c9e43ede7eec9c5b2997c14a892e7eb2f124).

The total number of tests below excludes:

Expand All @@ -89,73 +89,74 @@ The total number of tests below excludes:

| Total | :white_check_mark: | :x: | Coverage |
|:-----:|:------------------:|:------:|:----------:|
| 14904 | 14896 | 8 [^1] | 99.95 % |
| 14670 | 14662 | 8 [^1] | 99.95% |

[^1]: These tests have an impossible initial configuration (i.e. empty accounts with non-empty storage),
and end up not being provable.

### Extended results

| Test Folder Name | Total | :white_check_mark: | :x: | Coverage |
|:------------------------------------:|:-----:|:------------------:|:---:|:------------:|
| Shanghai | 26 | 26 | 0 | 100.00 % |
| stArgsZeroOneBalance | 96 | 96 | 0 | 100.00 % |
| stAttackTest | 2 | 2 | 0 | 100.00 % |
| stBadOpcode | 340 | 340 | 0 | 100.00 % |
| stBugs | 9 | 9 | 0 | 100.00 % |
| stCallCodes | 86 | 86 | 0 | 100.00 % |
| stCallCreateCallCodeTest | 55 | 55 | 0 | 100.00 % |
| stCallDelegateCodesCallCodeHomestead | 58 | 58 | 0 | 100.00 % |
| stCallDelegateCodesHomestead | 58 | 58 | 0 | 100.00 % |
| stChainId | 2 | 2 | 0 | 100.00 % |
| stCodeCopyTest | 2 | 2 | 0 | 100.00 % |
| stCodeSizeLimit | 7 | 7 | 0 | 100.00 % |
| stCreate2 | 184 | 181 | 3 | 98.37 % |
| stCreateTest | 204 | 204 | 0 | 100.00 % |
| stDelegatecallTestHomestead | 31 | 31 | 0 | 100.00 % |
| stEIP150Specific | 25 | 25 | 0 | 100.00 % |
| stEIP150singleCodeGasPrices | 340 | 340 | 0 | 100.00 % |
| stEIP1559 | 949 | 949 | 0 | 100.00 % |
| stEIP158Specific | 8 | 8 | 0 | 100.00 % |
| stEIP2930 | 140 | 140 | 0 | 100.00 % |
| stEIP3607 | 5 | 5 | 0 | 100.00 % |
| stExample | 38 | 38 | 0 | 100.00 % |
| stExtCodeHash | 69 | 68 | 1 | 98.56 % |
| stHomesteadSpecific | 5 | 5 | 0 | 100.00 % |
| stInitCodeTest | 22 | 22 | 0 | 100.00 % |
| stLogTests | 46 | 46 | 0 | 100.00 % |
| stMemExpandingEIP150Calls | 10 | 10 | 0 | 100.00 % |
| stMemoryStressTest | 82 | 79 | 0 | 100.00 % |
| stMemoryTest | 567 | 567 | 0 | 100.00 % |
| stNonZeroCallsTest | 24 | 24 | 0 | 100.00 % |
| stPreCompiledContracts | 956 | 956 | 0 | 100.00 % |
| stPreCompiledContracts2 | 246 | 246 | 0 | 100.00 % |
| stQuadraticComplexityTest | 28 | 28 | 0 | 100.00 % |
| stRandom | 310 | 310 | 0 | 100.00 % |
| stRandom2 | 221 | 221 | 0 | 100.00 % |
| stRecursiveCreate | 2 | 2 | 0 | 100.00 % |
| stRefundTest | 26 | 26 | 0 | 100.00 % |
| stReturnDataTest | 247 | 247 | 0 | 100.00 % |
| stRevertTest | 270 | 270 | 0 | 100.00 % |
| stSLoadTest | 1 | 1 | 0 | 100.00 % |
| stSStoreTest | 475 | 471 | 4 | 99.16 % |
| stSelfBalance | 42 | 42 | 0 | 100.00 % |
| stShift | 42 | 42 | 0 | 100.00 % |
| stSolidityTest | 23 | 23 | 0 | 100.00 % |
| stSpecialTest | 19 | 19 | 0 | 100.00 % |
| stStackTests | 375 | 375 | 0 | 100.00 % |
| stStaticCall | 455 | 455 | 0 | 100.00 % |
| stStaticFlagEnabled | 34 | 34 | 0 | 100.00 % |
| stSystemOperationsTest | 83 | 83 | 0 | 100.00 % |
| stTimeConsuming | 5187 | 5187 | 0 | 100.00 % |
| stTransactionTest | 162 | 162 | 0 | 100.00 % |
| stTransitionTest | 6 | 6 | 0 | 100.00 % |
| stWalletTest | 46 | 46 | 0 | 100.00 % |
| stZeroCallsRevert | 16 | 16 | 0 | 100.00 % |
| stZeroCallsTest | 24 | 24 | 0 | 100.00 % |
| stZeroKnowledge2 | 519 | 519 | 0 | 100.00 % |
| stZeroKnowledge | 944 | 944 | 0 | 100.00 % |
| VMTests | 649 | 649 | 0 | 100.00 % |
| Test Folder Name | Total | :white_check_mark: | :x: | Cov |
|:------------------------------------:|:-----:|:------------------:|:---:|:------:|
| Cancun | 185 | 185 | 0 | 100.00 |
| Shanghai | 23 | 23 | 0 | 100.00 |
| stArgsZeroOneBalance | 96 | 96 | 0 | 100.00 |
| stAttackTest | 2 | 2 | 0 | 100.00 |
| stBadOpcode | 334 | 334 | 0 | 100.00 |
| stBugs | 9 | 9 | 0 | 100.00 |
| stCallCodes | 86 | 86 | 0 | 100.00 |
| stCallCreateCallCodeTest | 55 | 55 | 0 | 100.00 |
| stCallDelegateCodesCallCodeHomestead | 58 | 58 | 0 | 100.00 |
| stCallDelegateCodesHomestead | 58 | 58 | 0 | 100.00 |
| stChainId | 2 | 2 | 0 | 100.00 |
| stCodeCopyTest | 2 | 2 | 0 | 100.00 |
| stCodeSizeLimit | 7 | 7 | 0 | 100.00 |
| stCreate2 | 181 | 178 | 0 | 98.34 |
| stCreateTest | 197 | 197 | 0 | 100.00 |
| stDelegatecallTestHomestead | 31 | 31 | 0 | 100.00 |
| stEIP150Specific | 25 | 25 | 0 | 100.00 |
| stEIP150singleCodeGasPrices | 340 | 340 | 0 | 100.00 |
| stEIP1559 | 949 | 949 | 0 | 100.00 |
| stEIP158Specific | 8 | 8 | 0 | 100.00 |
| stEIP2930 | 140 | 140 | 0 | 100.00 |
| stEIP3607 | 5 | 5 | 0 | 100.00 |
| stExample | 38 | 38 | 0 | 100.00 |
| stExtCodeHash | 69 | 68 | 1 | 98.56 |
| stHomesteadSpecific | 5 | 5 | 0 | 100.00 |
| stInitCodeTest | 22 | 22 | 0 | 100.00 |
| stLogTests | 46 | 46 | 0 | 100.00 |
| stMemExpandingEIP150Calls | 10 | 10 | 0 | 100.00 |
| stMemoryStressTest | 82 | 79 | 0 | 100.00 |
| stMemoryTest | 567 | 567 | 0 | 100.00 |
| stNonZeroCallsTest | 24 | 24 | 0 | 100.00 |
| stPreCompiledContracts | 956 | 956 | 0 | 100.00 |
| stPreCompiledContracts2 | 246 | 246 | 0 | 100.00 |
| stQuadraticComplexityTest | 23 | 23 | 0 | 100.00 |
| stRandom | 310 | 310 | 0 | 100.00 |
| stRandom2 | 221 | 221 | 0 | 100.00 |
| stRecursiveCreate | 1 | 1 | 0 | 100.00 |
| stRefundTest | 26 | 26 | 0 | 100.00 |
| stReturnDataTest | 247 | 247 | 0 | 100.00 |
| stRevertTest | 270 | 270 | 0 | 100.00 |
| stSLoadTest | 1 | 1 | 0 | 100.00 |
| stSStoreTest | 475 | 471 | 4 | 99.16 |
| stSelfBalance | 42 | 42 | 0 | 100.00 |
| stShift | 42 | 42 | 0 | 100.00 |
| stSolidityTest | 23 | 23 | 0 | 100.00 |
| stSpecialTest | 19 | 19 | 0 | 100.00 |
| stStackTests | 209 | 209 | 0 | 100.00 |
| stStaticCall | 455 | 455 | 0 | 100.00 |
| stStaticFlagEnabled | 34 | 34 | 0 | 100.00 |
| stSystemOperationsTest | 83 | 83 | 0 | 100.00 |
| stTimeConsuming | 5187 | 5187 | 0 | 100.00 |
| stTransactionTest | 162 | 162 | 0 | 100.00 |
| stTransitionTest | 6 | 6 | 0 | 100.00 |
| stWalletTest | 46 | 46 | 0 | 100.00 |
| stZeroCallsRevert | 16 | 16 | 0 | 100.00 |
| stZeroCallsTest | 24 | 24 | 0 | 100.00 |
| stZeroKnowledge2 | 519 | 519 | 0 | 100.00 |
| stZeroKnowledge | 800 | 800 | 0 | 100.00 |
| VMTests | 571 | 571 | 0 | 100.00 |


## Other
Expand Down
72 changes: 72 additions & 0 deletions cancun_heavy_tests_blacklist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
QuadraticComplexitySolidity_CallDataCopy_d0g1v0_Cancun

CALLBlake2f_d9g0v0_Cancun
CALLCODEBlake2f_d1g3v0_Cancun
CALLCODEBlake2f_d4g1v0_Cancun
CALLCODEBlake2f_d4g3v0_Cancun
CALLCODEBlake2f_d6g2v0_Cancun
CALLCODEBlake2f_d8g0v0_Cancun
CALLCODEBlake2f_d8g2v0_Cancun
CALLCODEBlake2f_d9g0v0_Cancun
CALLCODEBlake2f_d9g1v0_Cancun
CALLCODEBlake2f_d9g3v0_Cancun
Call1MB1024Calldepth_d0g1v0_Cancun
Call50000_d0g1v0_Cancun
Call50000_ecrec_d0g1v0_Cancun
Call50000_identity2_d0g1v0_Cancun
Call50000_identity_d0g1v0_Cancun
Call50000_rip160_d0g1v0_Cancun
Call50000_sha256_d0g0v0_Cancun
Call50000_sha256_d0g1v0_Cancun
Callcode50000_d0g1v0_Cancun
ContractCreationSpam_d0g0v0_Cancun
JUMPI_Bounds_d0g0v0_Cancun
JUMPI_Bounds_d0g1v0_Cancun
JUMP_Bounds2_d0g0v0_Cancun
JUMP_Bounds2_d0g1v0_Cancun
JUMP_Bounds_d0g0v0_Cancun
JUMP_Bounds_d0g1v0_Cancun
Return50000_2_d0g0v0_Cancun
Return50000_2_d0g1v0_Cancun
Return50000_d0g0v0_Cancun
Return50000_d0g1v0_Cancun
costRevert_d11g0v0_Cancun
costRevert_d25g0v0_Cancun
costRevert_d4g0v0_Cancun
loopExp_d10g0v0_Cancun
loopExp_d11g0v0_Cancun
loopExp_d12g0v0_Cancun
loopExp_d13g0v0_Cancun
loopExp_d14g0v0_Cancun
loopExp_d8g0v0_Cancun
loopExp_d9g0v0_Cancun
loopMul_d0g0v0_Cancun
loopMul_d2g0v0_Cancun
randomStatetest159_d0g0v0_Cancun
randomStatetest163_d0g0v0_Cancun
randomStatetest185_d0g0v0_Cancun
randomStatetest326_d0g0v0_Cancun
randomStatetest36_d0g0v0_Cancun
randomStatetest418_d0g0v0_Cancun
randomStatetest476_d0g0v0_Cancun
randomStatetest48_d0g0v0_Cancun
randomStatetest547_d0g0v0_Cancun
randomStatetest583_d0g0v0_Cancun
stateRevert_d4g0v0_Cancun
static_Call1MB1024Calldepth_d1g0v0_Cancun
static_Call50000_d1g0v0_Cancun
static_Call50000_ecrec_d0g0v0_Cancun
static_Call50000_ecrec_d1g0v0_Cancun
static_Call50000_identity2_d0g0v0_Cancun
static_Call50000_identity2_d1g0v0_Cancun
static_Call50000_identity_d0g0v0_Cancun
static_Call50000_identity_d1g0v0_Cancun
static_Call50000_rip160_d0g0v0_Cancun
static_Call50000_rip160_d1g0v0_Cancun
static_Call50000_sha256_d0g0v0_Cancun
static_Call50000_sha256_d1g0v0_Cancun
static_LoopCallsThenRevert_d0g0v0_Cancun
static_LoopCallsThenRevert_d0g1v0_Cancun
static_Return50000_2_d0g0v0_Cancun
15_tstoreCannotBeDosd_d0g0v0_Cancun
21_tstoreCannotBeDosdOOO_d0g0v0_Cancun
1 change: 1 addition & 0 deletions common/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ impl ParsedTestManifest {
gas_used_after: t_var.plonky2_metadata.block_metadata.block_gas_used,
withdrawals: t_var.plonky2_metadata.withdrawals,
block_hashes: BlockHashes::default(),
global_exit_roots: vec![], // not part of Ethereum tests
};

TestVariantRunInfo {
Expand Down
1 change: 1 addition & 0 deletions eth_test_parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ethereum-types = { workspace = true }
flexi_logger = { workspace = true }
futures = { workspace = true }
hex = { version = "0.4.3", features = ["serde"] }
hex-literal = "0.4.1"
keccak-hash = { workspace = true }
log = { workspace = true }
rlp = "0.5.2"
Expand Down
36 changes: 18 additions & 18 deletions eth_test_parser/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ pub(crate) const ETH_TESTS_REPO_LOCAL_PATH: &str = "eth_tests";
pub(crate) const GENERAL_GROUP: &str = MAIN_TEST_DIR;
pub(crate) const TEST_GROUPS: [&str; 1] = ["GeneralStateTests"];
// The following subgroups contain subfolders unlike the other test folders.
pub(crate) const SPECIAL_TEST_SUBGROUPS: [&str; 2] = ["Shanghai", "VMTests"];
pub(crate) const SPECIAL_TEST_SUBGROUPS: [&str; 3] = ["Cancun", "Shanghai", "VMTests"];

/// These test variants are used for stress testing. As such, they have
/// unrealistic scenarios that go beyond the provable bounds of the zkEVM.
/// Witness generation for these variants is still possible, but takes too
/// much time to be useful and usable in testing occuring regularly.
pub(crate) const UNPROVABLE_VARIANTS: [&str; 17] = [
"CALLBlake2f_d9g0v0_Shanghai",
"CALLCODEBlake2f_d9g0v0_Shanghai",
"Call50000_d0g1v0_Shanghai",
"Callcode50000_d0g1v0_Shanghai",
"static_Call50000_d1g0v0_Shanghai",
"static_Call50000_ecrec_d0g0v0_Shanghai",
"static_Call50000_ecrec_d1g0v0_Shanghai",
"static_Call50000_identity2_d0g0v0_Shanghai",
"static_Call50000_identity2_d1g0v0_Shanghai",
"static_Call50000_identity_d0g0v0_Shanghai",
"static_Call50000_identity_d1g0v0_Shanghai",
"static_Call50000_rip160_d0g0v0_Shanghai",
"static_Call50000_sha256_d0g0v0_Shanghai",
"static_Call50000_sha256_d1g0v0_Shanghai",
"static_Return50000_2_d0g0v0_Shanghai",
"Return50000_d0g1v0_Shanghai",
"Return50000_2_d0g1v0_Shanghai",
"CALLBlake2f_d9g0v0_Cancun",
"CALLCODEBlake2f_d9g0v0_Cancun",
"Call50000_d0g1v0_Cancun",
"Callcode50000_d0g1v0_Cancun",
"static_Call50000_d1g0v0_Cancun",
"static_Call50000_ecrec_d0g0v0_Cancun",
"static_Call50000_ecrec_d1g0v0_Cancun",
"static_Call50000_identity2_d0g0v0_Cancun",
"static_Call50000_identity2_d1g0v0_Cancun",
"static_Call50000_identity_d0g0v0_Cancun",
"static_Call50000_identity_d1g0v0_Cancun",
"static_Call50000_rip160_d0g0v0_Cancun",
"static_Call50000_sha256_d0g0v0_Cancun",
"static_Call50000_sha256_d1g0v0_Cancun",
"static_Return50000_2_d0g0v0_Cancun",
"Return50000_d0g1v0_Cancun",
"Return50000_2_d0g1v0_Cancun",
];
Loading

0 comments on commit 8842ec2

Please sign in to comment.