Skip to content

Commit f3d2c49

Browse files
committed
Upgrade EVMC hex utilities (v10.0.0-alpha.6)
1 parent 4a5dada commit f3d2c49

File tree

9 files changed

+17
-18
lines changed

9 files changed

+17
-18
lines changed

evmc

Submodule evmc updated from 9587f90 to afac844

lib/evmone/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ add_library(evmone
3030
vm.cpp
3131
vm.hpp
3232
)
33-
target_link_libraries(evmone PUBLIC evmc::evmc intx::intx PRIVATE evmc::instructions evmc::hex ethash::keccak)
33+
target_link_libraries(evmone PUBLIC evmc::evmc intx::intx PRIVATE evmc::instructions ethash::keccak)
3434
target_include_directories(evmone PUBLIC
3535
$<BUILD_INTERFACE:${include_dir}>$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
3636
)

test/bench/bench.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -286,14 +286,11 @@ std::tuple<int, std::vector<BenchmarkCase>> parseargs(int argc, char** argv)
286286
if (!code_hex_file.empty())
287287
{
288288
std::ifstream file{code_hex_file};
289-
std::string code_hex{
290-
std::istreambuf_iterator<char>{file}, std::istreambuf_iterator<char>{}};
291-
code_hex.erase(std::remove_if(code_hex.begin(), code_hex.end(),
292-
[](auto x) { return std::isspace(x); }),
293-
code_hex.end());
294-
295-
BenchmarkCase b{code_hex_file, from_hex(code_hex)};
296-
b.inputs.emplace_back("", from_hex(input_hex), from_hex(expected_output_hex));
289+
BenchmarkCase b{code_hex_file,
290+
from_spaced_hex(std::istreambuf_iterator<char>{file}, std::istreambuf_iterator<char>{})
291+
.value()};
292+
b.inputs.emplace_back(
293+
"", from_hex(input_hex).value(), from_hex(expected_output_hex).value());
297294

298295
return {0, {std::move(b)}};
299296
}

test/unittests/eof_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ TEST(eof, read_valid_eof1_header)
5757

5858
for (const auto& test_case : test_cases)
5959
{
60-
const auto code = from_hex(test_case.code);
60+
const auto code = from_spaced_hex(test_case.code).value();
6161
const auto header = read_valid_eof1_header(bytes_view(code).begin());
6262
EXPECT_EQ(header.code_size, test_case.code_size) << test_case.code;
6363
EXPECT_EQ(header.data_size, test_case.data_size) << test_case.code;

test/unittests/evm_fixture.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class evm : public testing::TestWithParam<evmc::VM*>
6767
/// The `gas_used` field will be updated accordingly.
6868
void execute(int64_t gas, bytes_view code, std::string_view input_hex = {}) noexcept
6969
{
70-
const auto input = from_hex(input_hex);
70+
const auto input = from_hex(input_hex).value();
7171
msg.input_data = input.data();
7272
msg.input_size = input.size();
7373
msg.gas = gas;

test/utils/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ add_library(testutils STATIC
1010
utils.hpp
1111
)
1212

13-
target_link_libraries(testutils PRIVATE evmc::instructions evmc::hex)
13+
target_link_libraries(testutils PRIVATE evmc::instructions)
1414
target_include_directories(testutils PUBLIC ${PROJECT_SOURCE_DIR})
1515

1616
add_library(testutils-dump STATIC dump.cpp dump.hpp)

test/utils/bytecode.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct bytecode : bytes
2525

2626
template <typename T,
2727
typename = typename std::enable_if_t<std::is_convertible_v<T, std::string_view>>>
28-
bytecode(T hex) : bytes{from_hex(hex)}
28+
bytecode(T hex) : bytes{from_spaced_hex(hex).value()}
2929
{}
3030

3131
bytecode(uint64_t n) : bytes{push(n)} {}
@@ -111,7 +111,7 @@ inline bytecode push(bytes_view data)
111111

112112
inline bytecode push(std::string_view hex_data)
113113
{
114-
return push(from_hex(hex_data));
114+
return push(from_spaced_hex(hex_data).value());
115115
}
116116

117117
inline bytecode push(const intx::uint256& value)

test/utils/utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ bytes from_hexx(const std::string& hexx)
3030
hex.replace(pos, length, replacement);
3131
position_correction += replacement.length() - length;
3232
}
33-
return from_hex(hex);
33+
return from_spaced_hex(hex).value();
3434
}

test/utils/utils.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// evmone: Fast Ethereum Virtual Machine implementation
2-
// Copyright 2018-2019 The evmone Authors.
2+
// Copyright 2018 The evmone Authors.
33
// SPDX-License-Identifier: Apache-2.0
44
#pragma once
55

@@ -8,11 +8,13 @@
88
using evmc::bytes;
99
using evmc::bytes_view;
1010
using evmc::from_hex;
11+
using evmc::from_spaced_hex;
1112
using evmc::hex;
1213

14+
1315
inline bytes operator""_hex(const char* s, size_t size)
1416
{
15-
return from_hex({s, size});
17+
return from_spaced_hex({s, size}).value();
1618
}
1719

1820
/// Decodes the hexx encoded string.

0 commit comments

Comments
 (0)