Skip to content

Commit

Permalink
Handle exceptions, convert all proxies to fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
hedgar2017 committed Apr 12, 2024
1 parent 763bdd6 commit c643379
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 66 deletions.
61 changes: 23 additions & 38 deletions Cargo.lock

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

Original file line number Diff line number Diff line change
Expand Up @@ -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![]))
}

///
Expand Down
8 changes: 4 additions & 4 deletions compiler_tester/src/directories/matter_labs/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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"),
Expand All @@ -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"),
Expand All @@ -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"),
Expand Down
36 changes: 19 additions & 17 deletions compiler_tester/src/test/case/input/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<M>(
let mut result = match vm.execute::<M>(
name.clone(),
self.address,
self.caller,
Expand All @@ -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
};
Expand Down Expand Up @@ -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]);
Expand Down
10 changes: 6 additions & 4 deletions compiler_tester/src/vm/eravm/system_contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -260,15 +259,18 @@ 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) {
solidity_file_paths.push(path);
}
}
}

let solidity_optimizer_settings =
era_compiler_llvm_context::OptimizerSettings::evm_interpreter();
let solidity_mode = SolidityMode::new(
Expand Down
6 changes: 6 additions & 0 deletions configs/solc-bin-default.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 7 additions & 1 deletion configs/solc-bin-upstream.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
16 changes: 16 additions & 0 deletions configs/solc-bin-zkevm-candidate-0.8.25.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
16 changes: 16 additions & 0 deletions configs/solc-bin-zkevm-reference-0.8.25.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
3 changes: 3 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[toolchain]
profile = "default"
channel = "1.77.2"
Binary file modified system-contracts-stable-build
Binary file not shown.

0 comments on commit c643379

Please sign in to comment.