Skip to content

Commit

Permalink
Update evmc to 12.0.0 and evmone to 0.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rodiazet committed Aug 8, 2024
1 parent f99c239 commit 7e91b78
Show file tree
Hide file tree
Showing 13 changed files with 152 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .circleci/osx_install_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ then
rm -rf "$z3_dir"

# evmone
evmone_version="0.11.0"
evmone_version="0.12.0"
if [[ $(uname -m) == 'arm64' ]]
then
# evmone does not provide any builds for apple silicon yet. so lets just build it locally.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ RUN set -ex; \
# EVMONE
RUN set -ex; \
cd /usr/src; \
git clone --branch="v0.11.0" --recurse-submodules https://github.com/ethereum/evmone.git; \
git clone --branch="v0.12.0" --recurse-submodules https://github.com/ethereum/evmone.git; \
cd evmone; \
mkdir build; \
cd build; \
Expand Down
2 changes: 1 addition & 1 deletion scripts/docker/buildpack-deps/Dockerfile.ubuntu2004
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ FROM base AS libraries

# EVMONE
RUN set -ex; \
wget -O /usr/src/evmone.tar.gz https://github.com/ethereum/evmone/releases/download/v0.11.0/evmone-0.11.0-linux-x86_64.tar.gz; \
wget -O /usr/src/evmone.tar.gz https://github.com/ethereum/evmone/releases/download/v0.12.0/evmone-0.12.0-linux-x86_64.tar.gz; \
test "$(sha256sum /usr/src/evmone.tar.gz)" = "051dbe523da165658ced63619ea2c05925516aac3061951da96d3f0962560719 /usr/src/evmone.tar.gz"; \
cd /usr; \
tar -xf /usr/src/evmone.tar.gz; \
Expand Down
2 changes: 1 addition & 1 deletion scripts/docker/buildpack-deps/Dockerfile.ubuntu2204
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ FROM base AS libraries
# EVMONE
RUN set -ex; \
cd /usr/src; \
git clone --branch="v0.11.0" --recurse-submodules https://github.com/ethereum/evmone.git; \
git clone --branch="v0.12.0" --recurse-submodules https://github.com/ethereum/evmone.git; \
cd evmone; \
mkdir build; \
cd build; \
Expand Down
2 changes: 1 addition & 1 deletion scripts/docker/buildpack-deps/Dockerfile.ubuntu2204.clang
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ ENV CXX clang++
# EVMONE
RUN set -ex; \
cd /usr/src; \
git clone --branch="v0.11.0" --recurse-submodules https://github.com/ethereum/evmone.git; \
git clone --branch="v0.12.0" --recurse-submodules https://github.com/ethereum/evmone.git; \
cd evmone; \
mkdir build; \
cd build; \
Expand Down
2 changes: 1 addition & 1 deletion scripts/install_evmone.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ $ErrorActionPreference = "Stop"
# Needed for Invoke-WebRequest to work via CI.
$progressPreference = "silentlyContinue"

Invoke-WebRequest -URI "https://github.com/ethereum/evmone/releases/download/v0.11.0/evmone-0.11.0-windows-amd64.zip" -OutFile "evmone.zip"
Invoke-WebRequest -URI "https://github.com/ethereum/evmone/releases/download/v0.12.0/evmone-0.12.0-windows-amd64.zip" -OutFile "evmone.zip"
tar -xf evmone.zip "bin/evmone.dll"
mkdir deps
mv bin/evmone.dll deps
6 changes: 3 additions & 3 deletions test/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ namespace solidity::test

#ifdef _WIN32
static constexpr auto evmoneFilename = "evmone.dll";
static constexpr auto evmoneDownloadLink = "https://github.com/ethereum/evmone/releases/download/v0.11.0/evmone-0.11.0-windows-amd64.zip";
static constexpr auto evmoneDownloadLink = "https://github.com/ethereum/evmone/releases/download/v0.12.0/evmone-0.12.0-windows-amd64.zip";
#elif defined(__APPLE__)
static constexpr auto evmoneFilename = "libevmone.dylib";
static constexpr auto evmoneDownloadLink = "https://github.com/ethereum/evmone/releases/download/v0.11.0/evmone-0.11.0-darwin-x86_64.tar.gz";
static constexpr auto evmoneDownloadLink = "https://github.com/ethereum/evmone/releases/download/v0.12.0/evmone-0.12.0-darwin-x86_64.tar.gz";
#else
static constexpr auto evmoneFilename = "libevmone.so";
static constexpr auto evmoneDownloadLink = "https://github.com/ethereum/evmone/releases/download/v0.11.0/evmone-0.11.0-linux-x86_64.tar.gz";
static constexpr auto evmoneDownloadLink = "https://github.com/ethereum/evmone/releases/download/v0.12.0/evmone-0.12.0-linux-x86_64.tar.gz";
#endif

struct ConfigException: public util::Exception {};
Expand Down
93 changes: 93 additions & 0 deletions test/evmc/bytes.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// EVMC: Ethereum Client-VM Connector API.
// Copyright 2024 The EVMC Authors.
// Licensed under the Apache License, Version 2.0.
#pragma once

#include <algorithm>
#include <cstring>
#include <string>
#include <string_view>

namespace evmc
{
/// The char traits for byte-like types.
///
/// See: https://en.cppreference.com/w/cpp/string/char_traits.
template <typename T>
struct byte_traits : std::char_traits<char>
{
static_assert(sizeof(T) == 1, "type must be a byte");

using char_type = T; ///< The byte type.

/// Assigns c2 to c1.
static constexpr void assign(char_type& c1, const char_type& c2) { c1 = c2; }

/// Assigns value to each byte in [ptr, ptr+count).
static constexpr char_type* assign(char_type* ptr, std::size_t count, char_type value)
{
std::fill_n(ptr, count, value);
return ptr;
}

/// Returns true if bytes are equal.
static constexpr bool eq(char_type a, char_type b) { return a == b; }

/// Returns true if byte a is less than byte b.
static constexpr bool lt(char_type a, char_type b) { return a < b; }

/// Copies count bytes from src to dest. Performs correctly even if ranges overlap.
static constexpr char_type* move(char_type* dest, const char_type* src, std::size_t count)
{
if (dest < src)
std::copy_n(src, count, dest);
else if (src < dest)
std::copy_backward(src, src + count, dest + count);
return dest;
}

/// Copies count bytes from src to dest. The ranges must not overlap.
static constexpr char_type* copy(char_type* dest, const char_type* src, std::size_t count)
{
std::copy_n(src, count, dest);
return dest;
}

/// Compares lexicographically the bytes in two ranges of equal length.
static constexpr int compare(const char_type* a, const char_type* b, std::size_t count)
{
for (; count != 0; --count, ++a, ++b)
{
if (lt(*a, *b))
return -1;
if (lt(*b, *a))
return 1;
}
return 0;
}

/// Returns the length of a null-terminated byte string.
// TODO: Not constexpr
static std::size_t length(const char_type* s)
{
return std::strlen(reinterpret_cast<const char*>(s));
}

/// Finds the value in the range of bytes and returns the pointer to the first occurrence
/// or nullptr if not found.
static constexpr const char_type* find(const char_type* s,
std::size_t count,
const char_type& value)
{
const auto end = s + count;
const auto p = std::find(s, end, value);
return p != end ? p : nullptr;
}
};

/// String of unsigned chars representing bytes.
using bytes = std::basic_string<unsigned char, byte_traits<unsigned char>>;

/// String view of unsigned chars representing bytes.
using bytes_view = std::basic_string_view<unsigned char, byte_traits<unsigned char>>;
} // namespace evmc
65 changes: 46 additions & 19 deletions test/evmc/evmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ enum
*
* @see @ref versioning
*/
EVMC_ABI_VERSION = 11
EVMC_ABI_VERSION = 12
};


Expand Down Expand Up @@ -79,7 +79,8 @@ enum evmc_call_kind
The value param ignored. */
EVMC_CALLCODE = 2, /**< Request CALLCODE. */
EVMC_CREATE = 3, /**< Request CREATE. */
EVMC_CREATE2 = 4 /**< Request CREATE2. Valid since Constantinople.*/
EVMC_CREATE2 = 4, /**< Request CREATE2. Valid since Constantinople.*/
EVMC_EOFCREATE = 5 /**< Request EOFCREATE. Valid since Prague.*/
};

/** The flags for ::evmc_message. */
Expand Down Expand Up @@ -168,7 +169,8 @@ struct evmc_message
/**
* The optional value used in new contract address construction.
*
* Needed only for a Host to calculate created address when kind is ::EVMC_CREATE2.
* Needed only for a Host to calculate created address when kind is ::EVMC_CREATE2 or
* ::EVMC_EOFCREATE.
* Ignored in evmc_execute_fn().
*/
evmc_bytes32 create2_salt;
Expand All @@ -179,32 +181,51 @@ struct evmc_message
* For ::EVMC_CALLCODE or ::EVMC_DELEGATECALL this may be different from
* the evmc_message::recipient.
* Not required when invoking evmc_execute_fn(), only when invoking evmc_call_fn().
* Ignored if kind is ::EVMC_CREATE or ::EVMC_CREATE2.
* Ignored if kind is ::EVMC_CREATE, ::EVMC_CREATE2 or ::EVMC_EOFCREATE.
*
* In case of ::EVMC_CAPABILITY_PRECOMPILES implementation, this fields should be inspected
* to identify the requested precompile.
*
* Defined as `c` in the Yellow Paper.
*/
evmc_address code_address;

/**
* The code to be executed.
*/
const uint8_t* code;

/**
* The length of the code to be executed.
*/
size_t code_size;
};

/** The hashed initcode used for TXCREATE instruction. */
typedef struct evmc_tx_initcode
{
evmc_bytes32 hash; /**< The initcode hash. */
const uint8_t* code; /**< The code. */
size_t code_size; /**< The length of the code. */
} evmc_tx_initcode;

/** The transaction and block data for execution. */
struct evmc_tx_context
{
evmc_uint256be tx_gas_price; /**< The transaction gas price. */
evmc_address tx_origin; /**< The transaction origin account. */
evmc_address block_coinbase; /**< The miner of the block. */
int64_t block_number; /**< The block number. */
int64_t block_timestamp; /**< The block timestamp. */
int64_t block_gas_limit; /**< The block gas limit. */
evmc_uint256be block_prev_randao; /**< The block previous RANDAO (EIP-4399). */
evmc_uint256be chain_id; /**< The blockchain's ChainID. */
evmc_uint256be block_base_fee; /**< The block base fee per gas (EIP-1559, EIP-3198). */
evmc_uint256be blob_base_fee; /**< The blob base fee (EIP-7516). */
const evmc_bytes32* blob_hashes; /**< The array of blob hashes (EIP-4844). */
size_t blob_hashes_count; /**< The number of blob hashes (EIP-4844). */
evmc_uint256be tx_gas_price; /**< The transaction gas price. */
evmc_address tx_origin; /**< The transaction origin account. */
evmc_address block_coinbase; /**< The miner of the block. */
int64_t block_number; /**< The block number. */
int64_t block_timestamp; /**< The block timestamp. */
int64_t block_gas_limit; /**< The block gas limit. */
evmc_uint256be block_prev_randao; /**< The block previous RANDAO (EIP-4399). */
evmc_uint256be chain_id; /**< The blockchain's ChainID. */
evmc_uint256be block_base_fee; /**< The block base fee per gas (EIP-1559, EIP-3198). */
evmc_uint256be blob_base_fee; /**< The blob base fee (EIP-7516). */
const evmc_bytes32* blob_hashes; /**< The array of blob hashes (EIP-4844). */
size_t blob_hashes_count; /**< The number of blob hashes (EIP-4844). */
const evmc_tx_initcode* initcodes; /**< The array of transaction initcodes (TXCREATE). */
size_t initcodes_count; /**< The number of transaction initcodes (TXCREATE). */
};

/**
Expand Down Expand Up @@ -1007,7 +1028,6 @@ enum evmc_revision
/**
* The Cancun revision.
*
* The future next revision after Shanghai.
* https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/cancun.md
*/
EVMC_CANCUN = 12,
Expand All @@ -1019,15 +1039,22 @@ enum evmc_revision
*/
EVMC_PRAGUE = 13,

/**
* The Osaka revision.
*
* The future next revision after Prague.
*/
EVMC_OSAKA = 14,

/** The maximum EVM revision supported. */
EVMC_MAX_REVISION = EVMC_PRAGUE,
EVMC_MAX_REVISION = EVMC_OSAKA,

/**
* The latest known EVM revision with finalized specification.
*
* This is handy for EVM tools to always use the latest revision available.
*/
EVMC_LATEST_STABLE_REVISION = EVMC_SHANGHAI
EVMC_LATEST_STABLE_REVISION = EVMC_CANCUN
};


Expand Down
3 changes: 0 additions & 3 deletions test/evmc/evmc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ static_assert(EVMC_LATEST_STABLE_REVISION <= EVMC_MAX_REVISION,
/// @ingroup cpp
namespace evmc
{
/// String view of uint8_t chars.
using bytes_view = std::basic_string_view<uint8_t>;

/// The big-endian 160-bit hash suitable for keeping an Ethereum address.
///
/// This type wraps C ::evmc_address to make sure objects of this type are always initialized.
Expand Down
2 changes: 2 additions & 0 deletions test/evmc/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ static inline const char* evmc_revision_to_string(enum evmc_revision rev)
return "Cancun";
case EVMC_PRAGUE:
return "Prague";
case EVMC_OSAKA:
return "Osaka";
}
return "<unknown>";
}
Expand Down
8 changes: 1 addition & 7 deletions test/evmc/hex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Licensed under the Apache License, Version 2.0.
#pragma once

#include <evmc/bytes.hpp>
#include <evmc/filter_iterator.hpp>
#include <cstdint>
#include <optional>
Expand All @@ -11,13 +12,6 @@

namespace evmc
{
/// String of uint8_t chars.
using bytes = std::basic_string<uint8_t>;

/// String view of uint8_t chars.
using bytes_view = std::basic_string_view<uint8_t>;


/// Encode a byte to a hex string.
inline std::string hex(uint8_t b) noexcept
{
Expand Down
5 changes: 1 addition & 4 deletions test/evmc/mocked_host.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@
#include <evmc/evmc.hpp>
#include <algorithm>
#include <cassert>
#include <map>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>

namespace evmc
{
/// The string of bytes.
using bytes = std::basic_string<uint8_t>;

/// Extended value (with original value and access flag) for account storage.
struct StorageValue
{
Expand Down

0 comments on commit 7e91b78

Please sign in to comment.