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

fix: PUSH, DUP, SWAP on the EVM interpreter #21

Merged
merged 2 commits into from
May 15, 2024
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: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[submodule "tests"]
path = tests
url = https://github.com/matter-labs/era-compiler-tests
branch = v1.5.0
branch = main
[submodule "solidity"]
path = solidity
url = https://github.com/ethereum/solidity
Expand Down
130 changes: 65 additions & 65 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; 55] = [
pub const EVM_OPCODES: [&'static str; 119] = [
"ADD",
"MUL",
"SUB",
Expand Down Expand Up @@ -84,70 +84,70 @@ 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",
"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",
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,20 @@ impl EVMContract {
///
/// Returns the init code.
///
pub fn init_code(&self) -> String {
"608060405234801561000f575f80fd5b5060c08061001c5f395ff3fe".to_owned()
pub fn init_code(&self, size: usize) -> String {
format!("608060405234801561000f575f80fd5b50{}8061001c5f395ff3fe", if size <= 0xff {
format!("60{:02x}", size)
} else if size <= 0xffff {
format!("61{:04x}", size)
} else {
panic!("The bytecode is too large");
})
}

///
/// Returns the runtime code.
///
pub fn runtime_code(&self) -> String {
let mut runtime_code = self.runtime_code.repeat(16 /* TODO */).to_owned();
runtime_code.push_str("00");
runtime_code
format!("{}00", self.runtime_code)
}
}
8 changes: 3 additions & 5 deletions compiler_tester/src/directories/matter_labs/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,9 @@ impl MatterLabsTest {
let mut instances = BTreeMap::new();

for (instance, evm_contract) in self.metadata.evm_contracts.iter() {
let mut bytecode = evm_contract.init_code();
bytecode.push_str(evm_contract.runtime_code().as_str());
let runtime_code = evm_contract.runtime_code();
let mut bytecode = evm_contract.init_code(runtime_code.len());
bytecode.push_str(runtime_code.as_str());

let bytecode = hex::decode(bytecode.as_str()).map_err(|error| {
anyhow::anyhow!("Invalid bytecode of EVM instance `{}`: {}", instance, error)
Expand Down Expand Up @@ -318,9 +319,6 @@ impl MatterLabsTest {
for pair_of_bytecodes in evm_contracts.chunks(2) {
let full = &pair_of_bytecodes[0];
let template = &pair_of_bytecodes[1];
if full.starts_with("DUP") || full.starts_with("SWAP") || full.starts_with("PUSH") {
continue;
}
let exception = full.contains("REVERT");

metadata_cases.push(MatterLabsCase {
Expand Down
2 changes: 1 addition & 1 deletion solidity
Submodule solidity updated 230 files
2 changes: 1 addition & 1 deletion tests