From c643379d189624234ee70849de44f4c04e7e9f2a Mon Sep 17 00:00:00 2001 From: Oleksandr Zarudnyi Date: Fri, 12 Apr 2024 22:00:45 +0700 Subject: [PATCH] Handle exceptions, convert all proxies to fallback --- Cargo.lock | 61 +++++++----------- .../test/metadata/case/input/expected/mod.rs | 2 +- .../src/directories/matter_labs/test/mod.rs | 8 +-- .../src/test/case/input/runtime.rs | 36 ++++++----- .../src/vm/eravm/system_contracts.rs | 10 +-- configs/solc-bin-default.json | 6 ++ configs/solc-bin-upstream.json | 8 ++- configs/solc-bin-zkevm-candidate-0.8.25.json | 16 +++++ configs/solc-bin-zkevm-reference-0.8.25.json | 16 +++++ rust-toolchain.toml | 3 + system-contracts-stable-build | Bin 636486 -> 636514 bytes tests | 2 +- 12 files changed, 102 insertions(+), 66 deletions(-) create mode 100644 configs/solc-bin-zkevm-candidate-0.8.25.json create mode 100644 configs/solc-bin-zkevm-reference-0.8.25.json create mode 100644 rust-toolchain.toml diff --git a/Cargo.lock b/Cargo.lock index 3eba619e..32f889fb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -28,18 +28,15 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.81" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" +checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" [[package]] name = "arbitrary" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" -dependencies = [ - "derive_arbitrary", -] [[package]] name = "arrayvec" @@ -176,9 +173,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.15.4" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "byte-slice-cast" @@ -200,9 +197,9 @@ checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "cc" -version = "1.0.90" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" +checksum = "2678b2e3449475e95b0aa6f9b506a28e61b3dc8996592b983695e8ebb58a8b41" dependencies = [ "jobserver", "libc", @@ -402,17 +399,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "derive_arbitrary" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.58", -] - [[package]] name = "derive_more" version = "0.99.17" @@ -480,9 +466,9 @@ dependencies = [ [[package]] name = "encoding_rs" -version = "0.8.33" +version = "0.8.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" dependencies = [ "cfg-if", ] @@ -554,7 +540,7 @@ dependencies = [ [[package]] name = "era-compiler-solidity" version = "1.5.0" -source = "git+https://github.com/matter-labs/era-compiler-solidity?branch=v1.5.0#dcc04dbccf56cf114ae874a26a6c841ff079a848" +source = "git+https://github.com/matter-labs/era-compiler-solidity?branch=v1.5.0#ca7224b634b11c61a099ed1c6293a0e26de6dcd4" dependencies = [ "anyhow", "colored", @@ -583,7 +569,7 @@ dependencies = [ [[package]] name = "era-compiler-vyper" version = "1.5.0" -source = "git+https://github.com/matter-labs/era-compiler-vyper?branch=v1.5.0#cdfa9f1a8e3b9b646a0591262e291cb6e6f3f31d" +source = "git+https://github.com/matter-labs/era-compiler-vyper?branch=v1.5.0#868684970e70016860d134b87cf8f8879a3865c2" dependencies = [ "anyhow", "colored", @@ -841,9 +827,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" dependencies = [ "cfg-if", "libc", @@ -1157,9 +1143,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jobserver" -version = "0.1.28" +version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6" +checksum = "f08474e32172238f2827bd160c67871cdb2801430f65c3979184dc362e3ca118" dependencies = [ "libc", ] @@ -1677,9 +1663,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -1986,9 +1972,9 @@ checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" [[package]] name = "scale-info" -version = "2.11.1" +version = "2.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "788745a868b0e751750388f4e6546eb921ef714a4317fa6954f7cde114eb2eb7" +checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" dependencies = [ "bitvec", "cfg-if", @@ -1999,9 +1985,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.11.1" +version = "2.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dc2f4e8bc344b9fc3d5f74f72c2e55bfc38d28dc2ebc69c194a3df424e4d9ac" +checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", @@ -2596,9 +2582,8 @@ checksum = "2266fcb904c50fb17fda4c9a751a1715629ecf8b21f4c9d78b4890fb71525d71" [[package]] name = "vm2" version = "0.1.0" -source = "git+https://github.com/matter-labs/vm2#dbcb1e2efcdf05621c9d4dc1a3846689da2e8667" +source = "git+https://github.com/matter-labs/vm2#01b5d087cc49c0fc8589f46b62feee86f7a58da1" dependencies = [ - "arbitrary", "enum_dispatch", "primitive-types", "zk_evm_abstractions", @@ -2946,7 +2931,7 @@ checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" [[package]] name = "zk_evm" version = "1.5.0" -source = "git+https://github.com/matter-labs/zk_evm?branch=v1.5.0#8ed110284f48dd30d869b09f2f74e6d5106eb2db" +source = "git+https://github.com/matter-labs/zk_evm?branch=v1.5.0#54fd09c8777b2c3b06ab088f96bbd6bd968f6737" dependencies = [ "anyhow", "lazy_static", @@ -2991,7 +2976,7 @@ dependencies = [ [[package]] name = "zkevm_opcode_defs" version = "1.5.0" -source = "git+https://github.com/matter-labs/era-zkevm_opcode_defs?branch=v1.5.0#2aaab121eaff01e8224d8d113e446f700d88aba5" +source = "git+https://github.com/matter-labs/era-zkevm_opcode_defs?branch=v1.5.0#109d9f734804a8b9dc0531c0b576e2a0f55a40de" dependencies = [ "bitflags 2.5.0", "blake2", diff --git a/compiler_tester/src/directories/matter_labs/test/metadata/case/input/expected/mod.rs b/compiler_tester/src/directories/matter_labs/test/metadata/case/input/expected/mod.rs index c746f847..48758c9e 100644 --- a/compiler_tester/src/directories/matter_labs/test/metadata/case/input/expected/mod.rs +++ b/compiler_tester/src/directories/matter_labs/test/metadata/case/input/expected/mod.rs @@ -34,7 +34,7 @@ impl Expected { /// Creates EVM interpreter benchmark expected data. /// pub fn successful_evm_interpreter_benchmark() -> Self { - Self::Single(Variant::Simple(vec!["*".to_owned()])) + Self::Single(Variant::Simple(vec![])) } /// diff --git a/compiler_tester/src/directories/matter_labs/test/mod.rs b/compiler_tester/src/directories/matter_labs/test/mod.rs index aa049fdb..e550321b 100644 --- a/compiler_tester/src/directories/matter_labs/test/mod.rs +++ b/compiler_tester/src/directories/matter_labs/test/mod.rs @@ -331,7 +331,7 @@ impl MatterLabsTest { comment: None, instance: "Proxy".to_owned(), caller: default_caller_address(), - method: "benchmark".to_owned(), + method: "#fallback".to_owned(), calldata: MatterLabsCaseInputCalldata::List(vec![ "Benchmark.address".to_owned(), format!("{template}.address"), @@ -346,7 +346,7 @@ impl MatterLabsTest { comment: None, instance: "Proxy".to_owned(), caller: default_caller_address(), - method: "benchmark".to_owned(), + method: "#fallback".to_owned(), calldata: MatterLabsCaseInputCalldata::List(vec![ "Benchmark.address".to_owned(), format!("{full}.address"), @@ -361,7 +361,7 @@ impl MatterLabsTest { comment: None, instance: "Proxy".to_owned(), caller: default_caller_address(), - method: "benchmark".to_owned(), + method: "#fallback".to_owned(), calldata: MatterLabsCaseInputCalldata::List(vec![ "Benchmark.address".to_owned(), format!("{template}.address"), @@ -376,7 +376,7 @@ impl MatterLabsTest { comment: None, instance: "Proxy".to_owned(), caller: default_caller_address(), - method: "benchmark".to_owned(), + method: "#fallback".to_owned(), calldata: MatterLabsCaseInputCalldata::List(vec![ "Benchmark.address".to_owned(), format!("{full}.address"), diff --git a/compiler_tester/src/test/case/input/runtime.rs b/compiler_tester/src/test/case/input/runtime.rs index 2f3d0b45..7cab5f67 100644 --- a/compiler_tester/src/test/case/input/runtime.rs +++ b/compiler_tester/src/test/case/input/runtime.rs @@ -76,7 +76,7 @@ impl Runtime { ) { let name = format!("{}[{}:{}]", name_prefix, self.name, index); vm.populate_storage(self.storage.inner); - let result = match vm.execute::( + let mut result = match vm.execute::( name.clone(), self.address, self.caller, @@ -93,18 +93,21 @@ impl Runtime { let gas = if let Some(benchmark_analyzer::Benchmark::EVM_INTERPRETER_GROUP_NAME) = test_group.as_deref() { - match result.output.return_data.first() { - Some(gas) => gas.unwrap_certain_as_ref().as_u64(), - None => { - Summary::invalid( - summary, - Some(mode), - name, - "EVM interpreter gas usage value not found", - ); - return; - } + if result.output.return_data.is_empty() { + Summary::invalid( + summary, + Some(mode), + name, + "EVM interpreter gas usage value not found", + ); + return; } + result + .output + .return_data + .remove(0) + .unwrap_certain_as_ref() + .as_u64() } else { 0 }; @@ -197,12 +200,11 @@ impl Runtime { let benchmark_caller_address = web3::types::Address::from_str(EraVM::DEFAULT_BENCHMARK_CALLER_ADDRESS) .expect("Always valid"); - let evm_proxy_address = - web3::types::Address::from_low_u64_be(0x10000); + let evm_proxy_address = web3::types::Address::from_low_u64_be(0x10000); - let mut calldata = - Vec::with_capacity(era_compiler_common::BYTE_LENGTH_X32 + (era_compiler_common::BYTE_LENGTH_FIELD * 2) + self.calldata.inner.len()); - calldata.extend(crate::utils::selector("benchmark(address,address)")); + let mut calldata = Vec::with_capacity( + (era_compiler_common::BYTE_LENGTH_FIELD * 2) + self.calldata.inner.len(), + ); calldata.extend([0u8; era_compiler_common::BYTE_LENGTH_FIELD - BYTE_LENGTH_ETH_ADDRESS]); calldata.extend(benchmark_caller_address.as_bytes()); calldata.extend([0u8; era_compiler_common::BYTE_LENGTH_FIELD - BYTE_LENGTH_ETH_ADDRESS]); diff --git a/compiler_tester/src/vm/eravm/system_contracts.rs b/compiler_tester/src/vm/eravm/system_contracts.rs index b3086df0..d296c290 100644 --- a/compiler_tester/src/vm/eravm/system_contracts.rs +++ b/compiler_tester/src/vm/eravm/system_contracts.rs @@ -110,8 +110,7 @@ impl SystemContracts { "era-contracts/system-contracts/contracts/EvmGasManager.sol:EvmGasManager"; /// The EVM proxy temporary system contract implementation path. - const PATH_EVM_PROXY: &'static str = - "tests/solidity/complex/interpreter/Proxy.sol:Proxy"; + const PATH_EVM_PROXY: &'static str = "tests/solidity/complex/interpreter/Proxy.sol:Proxy"; /// /// Loads or builds the system contracts. @@ -260,7 +259,10 @@ impl SystemContracts { let file_path = path.split(':').next().expect("Always valid"); solidity_file_paths.push(file_path.to_owned()); } - for pattern in ["era-contracts/system-contracts/**/*.sol", "tests/solidity/complex/interpreter/*.sol"] { + for pattern in [ + "era-contracts/system-contracts/**/*.sol", + "tests/solidity/complex/interpreter/*.sol", + ] { for path in glob::glob(pattern)?.filter_map(Result::ok) { let path = path.to_string_lossy().to_string(); if !solidity_file_paths.contains(&path) { @@ -268,7 +270,7 @@ impl SystemContracts { } } } - + let solidity_optimizer_settings = era_compiler_llvm_context::OptimizerSettings::evm_interpreter(); let solidity_mode = SolidityMode::new( diff --git a/configs/solc-bin-default.json b/configs/solc-bin-default.json index 6c0700a0..de77783d 100644 --- a/configs/solc-bin-default.json +++ b/configs/solc-bin-default.json @@ -463,6 +463,12 @@ "destination": "./solc-bin/solc-${VERSION}" }, "0.8.24": { + "is_enabled": false, + "protocol": "https", + "source": "https://github.com/matter-labs/era-solidity/releases/download/${VERSION}-1.0.0/solc-${PLATFORM}-${VERSION}-1.0.0", + "destination": "./solc-bin/solc-${VERSION}" + }, + "0.8.25": { "is_enabled": true, "protocol": "https", "source": "https://github.com/matter-labs/era-solidity/releases/download/${VERSION}-1.0.0/solc-${PLATFORM}-${VERSION}-1.0.0", diff --git a/configs/solc-bin-upstream.json b/configs/solc-bin-upstream.json index 8db4b2e5..42e9534d 100644 --- a/configs/solc-bin-upstream.json +++ b/configs/solc-bin-upstream.json @@ -463,10 +463,16 @@ "destination": "./solc-bin-upstream/solc-0.8.23" }, "0.8.24": { - "is_enabled": true, + "is_enabled": false, "protocol": "solc-bin-list", "source": "https://raw.githubusercontent.com/ethereum/solc-bin/gh-pages/${PLATFORM}/list.json", "destination": "./solc-bin-upstream/solc-0.8.24" + }, + "0.8.25": { + "is_enabled": true, + "protocol": "solc-bin-list", + "source": "https://raw.githubusercontent.com/ethereum/solc-bin/gh-pages/${PLATFORM}/list.json", + "destination": "./solc-bin-upstream/solc-0.8.25" } }, "platforms": { diff --git a/configs/solc-bin-zkevm-candidate-0.8.25.json b/configs/solc-bin-zkevm-candidate-0.8.25.json new file mode 100644 index 00000000..7e331a7f --- /dev/null +++ b/configs/solc-bin-zkevm-candidate-0.8.25.json @@ -0,0 +1,16 @@ +{ + "binaries": { + "0.8.25": { + "is_enabled": true, + "protocol": "file", + "source": "./solc-bin/solc-${VERSION}", + "destination": "./solc-bin/solc-${VERSION}" + } + }, + "platforms": { + "linux-amd64": "linux-amd64", + "linux-arm64": "linux-arm64", + "macos-amd64": "macosx-amd64", + "macos-arm64": "macosx-arm64" + } +} diff --git a/configs/solc-bin-zkevm-reference-0.8.25.json b/configs/solc-bin-zkevm-reference-0.8.25.json new file mode 100644 index 00000000..297ce19e --- /dev/null +++ b/configs/solc-bin-zkevm-reference-0.8.25.json @@ -0,0 +1,16 @@ +{ + "binaries": { + "0.8.25": { + "is_enabled": true, + "protocol": "https", + "source": "https://github.com/matter-labs/era-solidity/releases/download/${VERSION}-1.0.0/solc-${PLATFORM}-${VERSION}-1.0.0", + "destination": "./solc-bin/solc-${VERSION}" + } + }, + "platforms": { + "linux-amd64": "linux-amd64", + "linux-arm64": "linux-arm64", + "macos-amd64": "macosx-amd64", + "macos-arm64": "macosx-arm64" + } +} diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 00000000..f2a6c9a9 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +profile = "default" +channel = "1.77.2" \ No newline at end of file diff --git a/system-contracts-stable-build b/system-contracts-stable-build index 6641e083ec7bd6cf2e4fcba75a8c46a946c8e6d1..9a6a69acc7b040f32ca67f1373c439c9d95b7c67 100644 GIT binary patch delta 638 zcmY+APe>GD7{>W#zS)^?Q@3q*WEHeslZ7z0`DS)@W;LQVyaZ-@>dztn?7A!=EbUr( zF+2#>rLYN~LnRd63L(>^@Q@wEfxgE&-*_7-iLQ(EB<{e zK0ZMvgb8t;{(0VIrtQI;VVPPXX_!M?w+3upC=@JvAa7XufH7zo2G1Eo>AY^{(nI+i zw{^?b?38aG)_bUm-Z^^C$&qG~bSB>)!^RwKcUDFkoUT9vp8XK(@vy>JK=-rC)xkuC z8TyfE*+5n$p+L$V7R!lBjG68*iAhybUCjDUBe4+M6xv^qU4r1-I zqL37>O=(n8wHG3Ln;ddV2?;Z!Vl$%e=#0Q^@UL>ruk%_+LvT$xivBF2 zcyh`Y!t}C_;le7}?>vYc7IY4NU(7h$7wZGT6vvsF-^}c9)unYc*M(xxutZts_xsK7H#2tFZLOdpSGpKQyRQ2OsU<|K zV;C59Ga2YX1?i=TPF5-4DCl4d(ZNH9u%AI4K0J8u`@Zk-cwg#WZ|hxC z)5^3ut-U}y3x`ReSSg7@nH5Nxd8|_5gwnFZsV~aJcl^vA=@Z2YPET(u2&aqsd9k1mvEh zHfU}MHN%vtG(+ko+5`C+9f$kFcyg>NMI53tT1@A?)`Smp=ZqGxdJO{}Hp;UEg`HhnBUSnRN?@+uEorM{j(o*3l4nO+u&(R!Fbn6NH`Q;8^_^&&WLNo>4)}3 z)Ts#g`PfXr@FLm=hrXH-mAJw9@+ou(lr`gw&?l z4VjD)ho*~q6b9qih$k}{J5OBMx_eGW~7x zM=c!U$jv2BMk;=3N>M81Q34&r;Z)G=Flj>oxY%c77u>M`QEG?;sG=9a#S PB)Y_qn9KTV=)$i*lLWtg diff --git a/tests b/tests index 4427fca4..5d268ea4 160000 --- a/tests +++ b/tests @@ -1 +1 @@ -Subproject commit 4427fca456f938d4f334ce5130a71e09abd3e217 +Subproject commit 5d268ea49c69d10729d6c142b6131df8ad4d80e8