Skip to content

Commit

Permalink
RLP
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed May 6, 2022
1 parent 45fa067 commit 07c6b2f
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 376 deletions.
2 changes: 2 additions & 0 deletions test/state/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

add_library(evmone-state INTERFACE)
add_library(evmone::state ALIAS evmone-state)
target_link_libraries(evmone-state INTERFACE ethash::keccak)
target_sources(
evmone-state PRIVATE
rlp.hpp
utils.hpp
)
27 changes: 27 additions & 0 deletions test/state/utils.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// evmone: Fast Ethereum Virtual Machine implementation
// Copyright 2022 The evmone Authors.
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include <ethash/keccak.hpp>
#include <evmc/evmc.hpp>
#include <evmc/hex.hpp>
#include <cstring>

namespace evmone
{
using evmc::bytes;
using evmc::bytes_view;

/// Better than ethash::hash256 because has some additional handy constructors.
using hash256 = evmc::bytes32;

inline hash256 keccak256(bytes_view data) noexcept
{
const auto eh = ethash::keccak256(data.data(), data.size());
hash256 h;
std::memcpy(h.bytes, eh.bytes, sizeof(h)); // TODO: Use std::bit_cast.
return h;
}
} // namespace evmone
Loading

0 comments on commit 07c6b2f

Please sign in to comment.