Skip to content

Commit

Permalink
Replace O=2 option with advanced
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed Aug 29, 2022
1 parent f623b68 commit 73198c2
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 36 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 3 additions & 12 deletions lib/evmone/vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<VM*>(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")
{
Expand Down
6 changes: 3 additions & 3 deletions test/bench/bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions test/fuzzer/fuzzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ template <typename T1, typename T2>
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", ""}}},
};


Expand Down
4 changes: 2 additions & 2 deletions test/integration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 $<TARGET_FILE:evmc::tool> --vm $<TARGET_FILE:evmone>,O=0,histogram run 6000808080800101010200)
add_test(NAME ${PREFIX}/histogram COMMAND $<TARGET_FILE:evmc::tool> --vm $<TARGET_FILE:evmone>,histogram run 6000808080800101010200)
set_tests_properties(
${PREFIX}/histogram PROPERTIES PASS_REGULAR_EXPRESSION
"--- # HISTOGRAM depth=0
Expand All @@ -19,7 +19,7 @@ PUSH1,1
DUP1,4
")

add_test(NAME ${PREFIX}/trace COMMAND $<TARGET_FILE:evmc::tool> --vm $<TARGET_FILE:evmone>,O=0,trace run 60006002800103)
add_test(NAME ${PREFIX}/trace COMMAND $<TARGET_FILE:evmc::tool> --vm $<TARGET_FILE:evmone>,trace run 60006002800103)
set_tests_properties(
${PREFIX}/trace PROPERTIES PASS_REGULAR_EXPRESSION
"{\"depth\":0,\"rev\":\"London\",\"static\":false}
Expand Down
6 changes: 3 additions & 3 deletions test/unittests/evm_fixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<evmc::VM*>& info) noexcept
{
Expand Down
15 changes: 5 additions & 10 deletions test/unittests/evmone_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/unittests/tracing_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<evmone::VM*>(m_baseline_vm.get_raw_pointer())}
{}

Expand Down

0 comments on commit 73198c2

Please sign in to comment.