Skip to content

Commit

Permalink
fix: handle REVERT and subtract 2500 gas
Browse files Browse the repository at this point in the history
  • Loading branch information
hedgar2017 committed May 1, 2024
1 parent e56dbbb commit 1c82972
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 53 deletions.
30 changes: 15 additions & 15 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 @@ -9,6 +9,7 @@ use serde::Deserialize;
use crate::compilers::mode::Mode;

use self::variant::Variant;
use self::variant::extended::Extended;

///
/// The Matter Labs compiler test metadata expected data variant.
Expand All @@ -33,8 +34,13 @@ impl Expected {
///
/// Creates EVM interpreter benchmark expected data.
///
pub fn successful_evm_interpreter_benchmark() -> Self {
Self::Single(Variant::Simple(vec![]))
pub fn successful_evm_interpreter_benchmark(exception: bool) -> Self {
Self::Single(Variant::Extended(Extended {
return_data: vec![],
events: vec![],
exception,
compiler_version: None,
}))
}

///
Expand Down
37 changes: 4 additions & 33 deletions compiler_tester/src/directories/matter_labs/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ impl MatterLabsTest {
for pair_of_bytecodes in evm_contracts.chunks(2) {
let full = &pair_of_bytecodes[0];
let template = &pair_of_bytecodes[1];
let exception = full.contains("REVERT");

metadata_cases.push(MatterLabsCase {
comment: None,
Expand All @@ -339,7 +340,7 @@ impl MatterLabsTest {
value: None,
storage: HashMap::new(),
expected: Some(
MatterLabsCaseInputExpected::successful_evm_interpreter_benchmark(),
MatterLabsCaseInputExpected::successful_evm_interpreter_benchmark(false),
),
},
MatterLabsCaseInput {
Expand All @@ -354,41 +355,11 @@ impl MatterLabsTest {
value: None,
storage: HashMap::new(),
expected: Some(
MatterLabsCaseInputExpected::successful_evm_interpreter_benchmark(),
),
},
MatterLabsCaseInput {
comment: None,
instance: "Proxy".to_owned(),
caller: default_caller_address(),
method: "#fallback".to_owned(),
calldata: MatterLabsCaseInputCalldata::List(vec![
"Benchmark.address".to_owned(),
format!("{template}.address"),
]),
value: None,
storage: HashMap::new(),
expected: Some(
MatterLabsCaseInputExpected::successful_evm_interpreter_benchmark(),
),
},
MatterLabsCaseInput {
comment: None,
instance: "Proxy".to_owned(),
caller: default_caller_address(),
method: "#fallback".to_owned(),
calldata: MatterLabsCaseInputCalldata::List(vec![
"Benchmark.address".to_owned(),
format!("{full}.address"),
]),
value: None,
storage: HashMap::new(),
expected: Some(
MatterLabsCaseInputExpected::successful_evm_interpreter_benchmark(),
MatterLabsCaseInputExpected::successful_evm_interpreter_benchmark(exception),
),
},
],
expected: MatterLabsCaseInputExpected::successful_evm_interpreter_benchmark(),
expected: MatterLabsCaseInputExpected::successful_evm_interpreter_benchmark(exception),
ignore: false,
cycles: None,
})
Expand Down
2 changes: 1 addition & 1 deletion compiler_tester/src/test/case/input/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl Runtime {
.return_data
.remove(0)
.unwrap_certain_as_ref()
.as_u64()
.as_u64() - EraVM::EVM_INTERPRETER_GAS_OVERHEAD
} else {
0
};
Expand Down
3 changes: 3 additions & 0 deletions compiler_tester/src/vm/eravm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ impl EraVM {
pub const DEFAULT_BENCHMARK_CALLER_ADDRESS: &'static str =
"eeaffc9ff130f15d470945fd04b9017779c95dbf";

/// The extra amount of gas consumed by every call to the EVM interpreter.
pub const EVM_INTERPRETER_GAS_OVERHEAD: u64 = 2500;

///
/// Creates and initializes a new EraVM instance.
///
Expand Down
2 changes: 1 addition & 1 deletion solidity
Submodule solidity updated 69 files
+13 −49 .circleci/config.yml
+1 −0 Changelog.md
+5 −0 docs/_static/css/toggle.css
+25 −12 docs/contracts/errors.rst
+17 −12 docs/control-structures.rst
+5 −9 docs/introduction-to-smart-contracts.rst
+290 −14 libsmtutil/CHCSmtLib2Interface.cpp
+6 −3 libsmtutil/CHCSmtLib2Interface.h
+2 −0 libsmtutil/CMakeLists.txt
+19 −11 libsmtutil/SMTLib2Interface.cpp
+8 −1 libsmtutil/SMTLib2Interface.h
+97 −0 libsmtutil/SMTLib2Parser.cpp
+96 −0 libsmtutil/SMTLib2Parser.h
+1 −0 libsolidity/analysis/GlobalContext.cpp
+25 −2 libsolidity/analysis/PostTypeChecker.cpp
+1 −0 libsolidity/analysis/PostTypeChecker.h
+3 −2 libsolidity/ast/TypeProvider.cpp
+1 −1 libsolidity/ast/TypeProvider.h
+10 −2 libsolidity/ast/Types.cpp
+3 −0 libsolidity/ast/Types.h
+6 −0 libsolidity/codegen/ExpressionCompiler.cpp
+86 −23 libsolidity/codegen/YulUtilFunctions.cpp
+21 −1 libsolidity/codegen/YulUtilFunctions.h
+42 −43 libsolidity/codegen/ir/IRGeneratorForStatements.cpp
+1 −0 libsolidity/codegen/ir/IRGeneratorForStatements.h
+1 −1 libsolidity/interface/CompilerStack.cpp
+3 −1 libsolidity/interface/SMTSolverCommand.cpp
+1 −1 libsolidity/interface/SMTSolverCommand.h
+2 −2 scripts/build_emscripten.sh
+8 −3 scripts/docker/buildpack-deps/Dockerfile.emscripten
+33 −11 scripts/docker/buildpack-deps/Dockerfile.ubuntu.clang.ossfuzz
+29 −14 scripts/docker/buildpack-deps/Dockerfile.ubuntu2004
+32 −14 scripts/docker/buildpack-deps/Dockerfile.ubuntu2204
+29 −13 scripts/docker/buildpack-deps/Dockerfile.ubuntu2204.clang
+1 −0 test/cmdlineTests/model_checker_invariants_contract_eld/args
+4 −0 test/cmdlineTests/model_checker_invariants_contract_eld/err
+8 −0 test/cmdlineTests/model_checker_invariants_contract_eld/input.sol
+1 −0 test/cmdlineTests/require_overload/err
+1 −0 test/cmdlineTests/require_with_error_ir/args
+14 −0 test/cmdlineTests/require_with_error_ir/input.sol
+267 −0 test/cmdlineTests/require_with_error_ir/output
+1 −0 test/cmdlineTests/require_with_string_ir/args
+13 −0 test/cmdlineTests/require_with_string_ir/input.sol
+290 −0 test/cmdlineTests/require_with_string_ir/output
+4 −0 test/cmdlineTests/~documentation_examples/test.sh
+2 −2 test/externalTests/brink.sh
+1 −1 test/externalTests/ens.sh
+0 −87 test/externalTests/perpetual-pools.sh
+4 −4 test/externalTests/uniswap.sh
+4 −4 test/libsolidity/ASTJSON/used_errors.json
+21 −0 test/libsolidity/semanticTests/errors/require_different_errors_same_parameters.sol
+20 −0 test/libsolidity/semanticTests/errors/require_error_function_pointer_parameter.sol
+20 −0 test/libsolidity/semanticTests/errors/require_error_multiple_arguments.sol
+20 −0 test/libsolidity/semanticTests/errors/require_error_string_literal.sol
+22 −0 test/libsolidity/semanticTests/errors/require_error_string_memory.sol
+20 −0 test/libsolidity/semanticTests/errors/require_error_uint256.sol
+28 −0 test/libsolidity/semanticTests/errors/require_evaluation_order.sol
+17 −0 test/libsolidity/semanticTests/errors/require_inherited_error.sol
+1 −1 test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_tuple_from_error_event.sol
+1 −1 test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_tuple_from_invalid_operator.sol
+9 −0 test/libsolidity/syntaxTests/errors/abi_decode_error_constructor.sol
+8 −0 test/libsolidity/syntaxTests/errors/abi_encode_error_constructor.sol
+1 −1 test/libsolidity/syntaxTests/errors/assert_with_error.sol
+2 −1 test/libsolidity/syntaxTests/errors/require_custom.sol
+8 −0 test/libsolidity/syntaxTests/errors/require_custom_legacy.sol
+15 −0 test/libsolidity/syntaxTests/errors/require_nested.sol
+1 −1 test/libsolidity/syntaxTests/errors/selector_on_instance.sol
+1 −1 test/libsolidity/syntaxTests/revertStatement/error_used_elsewhere.sol
+13 −0 test/libsolidity/syntaxTests/revertStatement/require_nested.sol
2 changes: 1 addition & 1 deletion tests

0 comments on commit 1c82972

Please sign in to comment.