Skip to content
This repository was archived by the owner on Apr 8, 2026. It is now read-only.

Commit f96ed08

Browse files
committed
cpp: Deprecate helpers.hpp
1 parent 0a3d2e7 commit f96ed08

File tree

3 files changed

+15
-26
lines changed

3 files changed

+15
-26
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
In C++ API `evmc::result::raw()` renamed to `evmc::result::release_raw()`.
2323
- Changed: [[#311](https://github.com/ethereum/evmc/pull/311)]
2424
In `evmc_load_and_create()` the `error_code` is optional (can be `NULL`).
25+
- Deprecated: [[#358](https://github.com/ethereum/evmc/pull/358)]
26+
The usage of `evmc/helpers.hpp` has been deprecated. Use `evmc/evmc.hpp`
27+
which provides the same features.
2528
- Fixed:
2629
[[#261](https://github.com/ethereum/evmc/issues/261),
2730
[#263](https://github.com/ethereum/evmc/pull/263)]

include/evmc/helpers.hpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,39 +18,47 @@
1818
#include <functional>
1919

2020
/// The comparator for std::map<evmc_address, ...>.
21+
EVMC_DEPRECATED
2122
inline bool operator<(const evmc_address& a, const evmc_address& b)
2223
{
2324
return std::memcmp(a.bytes, b.bytes, sizeof(a.bytes)) < 0;
2425
}
2526

2627
/// The comparator for std::map<evmc_bytes32, ...>.
28+
EVMC_DEPRECATED
2729
inline bool operator<(const evmc_bytes32& a, const evmc_bytes32& b)
2830
{
2931
return std::memcmp(a.bytes, b.bytes, sizeof(a.bytes)) < 0;
3032
}
3133

3234
/// The comparator for equality.
35+
EVMC_DEPRECATED
3336
inline bool operator==(const evmc_address& a, const evmc_address& b)
3437
{
3538
return std::memcmp(a.bytes, b.bytes, sizeof(a.bytes)) == 0;
3639
}
3740

3841
/// The comparator for equality.
42+
EVMC_DEPRECATED
3943
inline bool operator==(const evmc_bytes32& a, const evmc_bytes32& b)
4044
{
4145
return std::memcmp(a.bytes, b.bytes, sizeof(a.bytes)) == 0;
4246
}
4347

4448
/// Check if the address is zero (all bytes are zeros).
49+
EVMC_DEPRECATED
4550
inline bool is_zero(const evmc_address& address) noexcept
4651
{
47-
return address == evmc_address{};
52+
constexpr auto zero = evmc_address{};
53+
return std::memcmp(address.bytes, zero.bytes, sizeof(zero.bytes)) == 0;
4854
}
4955

5056
/// Check if the hash is zero (all bytes are zeros).
57+
EVMC_DEPRECATED
5158
inline bool is_zero(const evmc_bytes32& x) noexcept
5259
{
53-
return x == evmc_bytes32{};
60+
constexpr auto zero = evmc_bytes32{};
61+
return std::memcmp(x.bytes, zero.bytes, sizeof(zero.bytes)) == 0;
5462
}
5563

5664
/// Parameters for the fnv1a hash function, specialized by the hash result size (size_t).
@@ -98,7 +106,7 @@ namespace std
98106
{
99107
/// Hash operator template specialization for evmc_address needed for unordered containers.
100108
template <>
101-
struct hash<evmc_address>
109+
struct EVMC_DEPRECATED hash<evmc_address>
102110
{
103111
/// Hash operator using FNV1a.
104112
size_t operator()(const evmc_address& s) const noexcept
@@ -109,7 +117,7 @@ struct hash<evmc_address>
109117

110118
/// Hash operator template needed for std::unordered_set and others using hashes.
111119
template <>
112-
struct hash<evmc_bytes32>
120+
struct EVMC_DEPRECATED hash<evmc_bytes32>
113121
{
114122
/// Hash operator using FNV1a.
115123
size_t operator()(const evmc_bytes32& s) const noexcept

test/unittests/test_helpers.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// Licensed under the Apache License, Version 2.0.
44

55
#include <evmc/helpers.h>
6-
#include <evmc/helpers.hpp>
76

87
#include <gtest/gtest.h>
98

@@ -27,27 +26,6 @@ static constexpr size_t optionalDataSize =
2726
static_assert(optionalDataSize >= sizeof(evmc_result_optional_storage),
2827
"evmc_result's optional data space is too small");
2928

30-
31-
TEST(helpers, fnv1a)
32-
{
33-
const uint8_t text[] = {'E', 'V', 'M', 'C'};
34-
const auto h = fnv1a(text, sizeof(text));
35-
EXPECT_EQ(h, sizeof(size_t) == 8 ? 0x15e05d6d22fed89a : 0xffaa6a9a);
36-
}
37-
38-
TEST(helpers, is_zero)
39-
{
40-
auto a = evmc_address{};
41-
EXPECT_TRUE(is_zero(a));
42-
a.bytes[0] = 1;
43-
EXPECT_FALSE(is_zero(a));
44-
45-
auto b = evmc_bytes32{};
46-
EXPECT_TRUE(is_zero(b));
47-
b.bytes[0] = 1;
48-
EXPECT_FALSE(is_zero(b));
49-
}
50-
5129
TEST(helpers, release_result)
5230
{
5331
auto r1 = evmc_result{};

0 commit comments

Comments
 (0)