From 73198c2a87dac5eeb3ce9c434da204f2296dae6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Fri, 26 Aug 2022 13:28:46 +0200 Subject: [PATCH] Replace `O=2` option with `advanced` --- README.md | 4 +++- circle.yml | 4 ++-- lib/evmone/vm.cpp | 15 +++------------ test/bench/bench.cpp | 6 +++--- test/fuzzer/fuzzer.cpp | 4 ++-- test/integration/CMakeLists.txt | 4 ++-- test/unittests/evm_fixture.cpp | 6 +++--- test/unittests/evmone_test.cpp | 15 +++++---------- test/unittests/tracing_test.cpp | 2 +- 9 files changed, 24 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 69399db1b7..0ce795a2a5 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,9 @@ The codebase of _evmone_ is optimized to provide fast and efficient execution of 3. The [intx] library is used to provide 256-bit integer precision. 4. The [ethash] library is used to provide Keccak hash function implementation needed for the special `KECCAK256` instruction. -5. Contains two interpreters: **Baseline** (default) and **Advanced**. +5. Contains two interpreters: + - **Baseline** (default) + - **Advanced** (select with the `advanced` option) ### Baseline Interpreter diff --git a/circle.yml b/circle.yml index 4de041e924..dabcd94a8b 100644 --- a/circle.yml +++ b/circle.yml @@ -327,12 +327,12 @@ jobs: name: "Silkworm-driven consensus tests (Advanced)" working_directory: ~/build no_output_timeout: 20m - command: ~/silkworm/consensus --evm lib/libevmone.so,O=2 --tests ~/tests --threads $CMAKE_BUILD_PARALLEL_LEVEL + command: ~/silkworm/consensus --evm lib/libevmone.so,advanced --tests ~/tests --threads $CMAKE_BUILD_PARALLEL_LEVEL - run: name: "Silkworm-driven consensus tests (Baseline)" working_directory: ~/build no_output_timeout: 20m - command: ~/silkworm/consensus --evm lib/libevmone.so,O=0 --tests ~/tests --threads $CMAKE_BUILD_PARALLEL_LEVEL + command: ~/silkworm/consensus --evm lib/libevmone.so --tests ~/tests --threads $CMAKE_BUILD_PARALLEL_LEVEL - collect_coverage_gcc - upload_coverage: flags: consensus diff --git a/lib/evmone/vm.cpp b/lib/evmone/vm.cpp index c346c03224..108a278e5d 100644 --- a/lib/evmone/vm.cpp +++ b/lib/evmone/vm.cpp @@ -33,19 +33,10 @@ evmc_set_option_result set_option(evmc_vm* c_vm, char const* c_name, char const* const auto value = (c_value != nullptr) ? std::string_view{c_value} : std::string_view{}; auto& vm = *static_cast(c_vm); - if (name == "O") + if (name == "advanced") { - if (value == "0") - { - c_vm->execute = evmone::baseline::execute; - return EVMC_SET_OPTION_SUCCESS; - } - else if (value == "2") - { - c_vm->execute = evmone::advanced::execute; - return EVMC_SET_OPTION_SUCCESS; - } - return EVMC_SET_OPTION_INVALID_VALUE; + c_vm->execute = evmone::advanced::execute; + return EVMC_SET_OPTION_SUCCESS; } else if (name == "cgoto") { diff --git a/test/bench/bench.cpp b/test/bench/bench.cpp index b92954b10e..9a72da9d83 100644 --- a/test/bench/bench.cpp +++ b/test/bench/bench.cpp @@ -317,9 +317,9 @@ int main(int argc, char** argv) if (ec != 0) return ec; - registered_vms["advanced"] = evmc::VM{evmc_create_evmone(), {{"O", "2"}}}; - registered_vms["baseline"] = evmc::VM{evmc_create_evmone(), {{"O", "0"}}}; - registered_vms["bnocgoto"] = evmc::VM{evmc_create_evmone(), {{"O", "0"}, {"cgoto", "no"}}}; + registered_vms["advanced"] = evmc::VM{evmc_create_evmone(), {{"advanced", ""}}}; + registered_vms["baseline"] = evmc::VM{evmc_create_evmone()}; + registered_vms["bnocgoto"] = evmc::VM{evmc_create_evmone(), {{"cgoto", "no"}}}; register_benchmarks(benchmark_cases); register_synthetic_benchmarks(); RunSpecifiedBenchmarks(); diff --git a/test/fuzzer/fuzzer.cpp b/test/fuzzer/fuzzer.cpp index ab10302879..b6bd2535e8 100644 --- a/test/fuzzer/fuzzer.cpp +++ b/test/fuzzer/fuzzer.cpp @@ -55,10 +55,10 @@ template static auto print_input = std::getenv("PRINT"); /// The reference VM: evmone Baseline -static auto ref_vm = evmc::VM{evmc_create_evmone(), {{"O", "0"}}}; +static auto ref_vm = evmc::VM{evmc_create_evmone()}; static evmc::VM external_vms[] = { - evmc::VM{evmc_create_evmone(), {{"O", "2"}}}, + evmc::VM{evmc_create_evmone(), {{"advanced", ""}}}, }; diff --git a/test/integration/CMakeLists.txt b/test/integration/CMakeLists.txt index ca33041cd4..d6169e8cac 100644 --- a/test/integration/CMakeLists.txt +++ b/test/integration/CMakeLists.txt @@ -7,7 +7,7 @@ set(PREFIX ${PROJECT_NAME}/integration) get_target_property(EVMONE_LIB_TYPE evmone TYPE) if(EVMONE_LIB_TYPE STREQUAL SHARED_LIBRARY) - add_test(NAME ${PREFIX}/histogram COMMAND $ --vm $,O=0,histogram run 6000808080800101010200) + add_test(NAME ${PREFIX}/histogram COMMAND $ --vm $,histogram run 6000808080800101010200) set_tests_properties( ${PREFIX}/histogram PROPERTIES PASS_REGULAR_EXPRESSION "--- # HISTOGRAM depth=0 @@ -19,7 +19,7 @@ PUSH1,1 DUP1,4 ") - add_test(NAME ${PREFIX}/trace COMMAND $ --vm $,O=0,trace run 60006002800103) + add_test(NAME ${PREFIX}/trace COMMAND $ --vm $,trace run 60006002800103) set_tests_properties( ${PREFIX}/trace PROPERTIES PASS_REGULAR_EXPRESSION "{\"depth\":0,\"rev\":\"London\",\"static\":false} diff --git a/test/unittests/evm_fixture.cpp b/test/unittests/evm_fixture.cpp index f439491f77..173dccfd85 100644 --- a/test/unittests/evm_fixture.cpp +++ b/test/unittests/evm_fixture.cpp @@ -9,9 +9,9 @@ namespace evmone::test { namespace { -evmc::VM advanced_vm{evmc_create_evmone(), {{"O", "2"}}}; -evmc::VM baseline_vm{evmc_create_evmone(), {{"O", "0"}}}; -evmc::VM bnocgoto_vm{evmc_create_evmone(), {{"O", "0"}, {"cgoto", "no"}}}; +evmc::VM advanced_vm{evmc_create_evmone(), {{"advanced", ""}}}; +evmc::VM baseline_vm{evmc_create_evmone()}; +evmc::VM bnocgoto_vm{evmc_create_evmone(), {{"cgoto", "no"}}}; const char* print_vm_name(const testing::TestParamInfo& info) noexcept { diff --git a/test/unittests/evmone_test.cpp b/test/unittests/evmone_test.cpp index 87b93f2226..a80dfd39e0 100644 --- a/test/unittests/evmone_test.cpp +++ b/test/unittests/evmone_test.cpp @@ -32,18 +32,13 @@ TEST(evmone, set_option_invalid) vm->destroy(vm); } -TEST(evmone, set_option_optimization_level) +TEST(evmone, set_option_advanced) { auto vm = evmc::VM{evmc_create_evmone()}; - EXPECT_EQ(vm.set_option("O", ""), EVMC_SET_OPTION_INVALID_VALUE); - EXPECT_EQ(vm.set_option("O", "0"), EVMC_SET_OPTION_SUCCESS); - EXPECT_EQ(vm.set_option("O", "1"), EVMC_SET_OPTION_INVALID_VALUE); - EXPECT_EQ(vm.set_option("O", "2"), EVMC_SET_OPTION_SUCCESS); - EXPECT_EQ(vm.set_option("O", "3"), EVMC_SET_OPTION_INVALID_VALUE); - - EXPECT_EQ(vm.set_option("O", "20"), EVMC_SET_OPTION_INVALID_VALUE); - EXPECT_EQ(vm.set_option("O", "21"), EVMC_SET_OPTION_INVALID_VALUE); - EXPECT_EQ(vm.set_option("O", "22"), EVMC_SET_OPTION_INVALID_VALUE); + EXPECT_EQ(vm.set_option("advanced", ""), EVMC_SET_OPTION_SUCCESS); + + // This will also enable Advanced. + EXPECT_EQ(vm.set_option("advanced", "no"), EVMC_SET_OPTION_SUCCESS); } TEST(evmone, set_option_cgoto) diff --git a/test/unittests/tracing_test.cpp b/test/unittests/tracing_test.cpp index 57d65e7987..03a4af6a4c 100644 --- a/test/unittests/tracing_test.cpp +++ b/test/unittests/tracing_test.cpp @@ -23,7 +23,7 @@ class tracing : public Test std::ostringstream trace_stream; tracing() - : m_baseline_vm{evmc_create_evmone(), {{"O", "0"}}}, + : m_baseline_vm{evmc_create_evmone()}, vm{*static_cast(m_baseline_vm.get_raw_pointer())} {}