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: run benchmarks on Yul impl of EVM interpreter #16

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# The debug, trace, benchmark artifacts
/debug/
/trace/
/**/*.json
/**/*.txt

# The dependency locks
# /Cargo.lock
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
[submodule "era-contracts"]
path = era-contracts
url = https://github.com/matter-labs/era-contracts
branch = sb-1-5-0-evm-eq-integration
branch = evm-equivalence-yul
67 changes: 64 additions & 3 deletions benchmark_analyzer/src/benchmark/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl Benchmark {
pub const EVM_INTERPRETER_GROUP_PREFIX: &'static str = "EVMInterpreter M3B3";

/// The EVM opcodes to test.
pub const EVM_OPCODES: [&'static str; 58] = [
pub const EVM_OPCODES: [&'static str; 119] = [
"ADD",
"MUL",
"SUB",
Expand Down Expand Up @@ -84,11 +84,72 @@ impl Benchmark {
"MSIZE",
"GAS",
"JUMPDEST",
"PUSH0",
"PUSH1",
"PUSH2",
"PUSH4",
"PUSH5",
"PUSH6",
"PUSH7",
"PUSH8",
"PUSH9",
"PUSH10",
"PUSH11",
"PUSH12",
"PUSH13",
"PUSH14",
"PUSH15",
"PUSH16",
"PUSH17",
"PUSH18",
"PUSH19",
"PUSH20",
"PUSH21",
"PUSH22",
"PUSH23",
"PUSH24",
"PUSH25",
"PUSH26",
"PUSH27",
"PUSH28",
"PUSH29",
"PUSH30",
"PUSH31",
"PUSH32",
"DUP1",
"DUP2",
"DUP3",
"DUP4",
"DUP5",
"DUP6",
"DUP7",
"DUP8",
"DUP9",
"DUP10",
"DUP11",
"DUP12",
"DUP13",
"DUP14",
"DUP15",
"DUP16",
"SWAP1",
"SWAP2",
"SWAP3",
"SWAP4",
"SWAP5",
"SWAP6",
"SWAP7",
"SWAP8",
"SWAP9",
"SWAP10",
"SWAP11",
"SWAP12",
"SWAP13",
"SWAP14",
"SWAP15",
"SWAP16",
"RETURN",
"REVERT",
"INVALID",
"SELFDESTRUCT",
];

///
Expand Down
26 changes: 11 additions & 15 deletions compiler_tester/src/vm/eravm/system_contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl SystemContracts {

/// The EVM interpreter system contract implementation path.
const PATH_EVM_INTERPRETER: &'static str =
"era-contracts/system-contracts/contracts/EvmInterpreter.sol:EvmInterpreter";
"era-contracts/system-contracts/contracts/EvmInterpreterPreprocessed.yul";

/// The `keccak256` system contract implementation path.
const PATH_KECCAK256: &'static str =
Expand Down Expand Up @@ -252,21 +252,17 @@ impl SystemContracts {
];

let mut yul_file_paths = Vec::with_capacity(yul_system_contracts.len() + 1);
for (_, path) in yul_system_contracts.iter() {
let file_path = path.split(':').next().expect("Always valid");
yul_file_paths.push(file_path.to_owned());
for (_, path) in yul_system_contracts.into_iter() {
yul_file_paths.push(path.to_owned());
}
yul_file_paths.push(Self::PATH_EVM_INTERPRETER.to_owned());
let yul_optimizer_settings =
era_compiler_llvm_context::OptimizerSettings::evm_interpreter();
let yul_mode = YulMode::new(yul_optimizer_settings, true).into();
let mut builds =
Self::compile(YulCompiler, &yul_mode, yul_file_paths, debug_config.clone())?;

let mut solidity_file_paths = Vec::with_capacity(solidity_system_contracts.len() + 1);
for (_, path) in solidity_system_contracts.iter() {
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",
Expand Down Expand Up @@ -298,6 +294,13 @@ impl SystemContracts {
debug_config,
)?);

let default_aa = builds.remove(Self::PATH_DEFAULT_AA).ok_or_else(|| {
anyhow::anyhow!("The default AA code not found in the compiler build artifacts")
})?;
let evm_interpreter = builds.remove(Self::PATH_EVM_INTERPRETER).ok_or_else(|| {
anyhow::anyhow!("The EVM interpreter code not found in the compiler build artifacts")
})?;

let mut system_contracts =
Vec::with_capacity(solidity_system_contracts.len() + yul_system_contracts.len());
system_contracts.extend(solidity_system_contracts);
Expand All @@ -311,13 +314,6 @@ impl SystemContracts {
deployed_contracts.push((address, build));
}

let default_aa = builds.remove(Self::PATH_DEFAULT_AA).ok_or_else(|| {
anyhow::anyhow!("The default AA code not found in the compiler build artifacts")
})?;
let evm_interpreter = builds.remove(Self::PATH_EVM_INTERPRETER).ok_or_else(|| {
anyhow::anyhow!("The EVM interpreter code not found in the compiler build artifacts")
})?;

println!(
" {} building system contracts in {}.{:03}s",
"Finished".bright_green().bold(),
Expand Down
Binary file modified system-contracts-stable-build
Binary file not shown.
Loading