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 Sep 13, 2024
1 parent 10e6263 commit 890ad92
Show file tree
Hide file tree
Showing 11 changed files with 160 additions and 66 deletions.
12 changes: 6 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ version: 2.1
parameters:
ubuntu-2004-docker-image:
type: string
# solbuildpackpusher/solidity-buildpack-deps:ubuntu2004-24
default: "solbuildpackpusher/solidity-buildpack-deps@sha256:b8b645fa7ab40d55f2d16eac295d16ca01ec51d32be7d668ae6eaecd47dbd763"
# solbuildpackpusher/solidity-buildpack-deps:ubuntu2004-25
default: "solbuildpackpusher/solidity-buildpack-deps@sha256:b3f321fb2d8e7a41ca9328672061c1840e5cd3fb5be503aa158d1c508deacf0a"
ubuntu-2204-docker-image:
type: string
# solbuildpackpusher/solidity-buildpack-deps:ubuntu2204-9
default: "solbuildpackpusher/solidity-buildpack-deps@sha256:80247de9655b1f39afd4ac22b14266bc9b9a0d64b283ae8fb9cb5b8250e4e77d"
# solbuildpackpusher/solidity-buildpack-deps:ubuntu2204-10
default: "solbuildpackpusher/solidity-buildpack-deps@sha256:ba2d878c26d681a7d6c1922258b47c2e5dd61d0e46ab4c6a4862b473e61997b6"
ubuntu-2204-clang-docker-image:
type: string
# solbuildpackpusher/solidity-buildpack-deps:ubuntu2204.clang-8
default: "solbuildpackpusher/solidity-buildpack-deps@sha256:2662376fe0e1ec2d346495a19a6d64508c1048d5a7325d8600c33c343fa64a0f"
# solbuildpackpusher/solidity-buildpack-deps:ubuntu2204.clang-9
default: "solbuildpackpusher/solidity-buildpack-deps@sha256:703cdad5fa5c8686a3080ebb1aea1485ded2446561bf56e2945a87f2fa20a446"
ubuntu-2404-docker-image:
type: string
# solbuildpackpusher/solidity-buildpack-deps:ubuntu2404-1
Expand Down
28 changes: 6 additions & 22 deletions .circleci/osx_install_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,26 +112,10 @@ then
rm -rf "$z3_dir"

# evmone
evmone_version="0.11.0"
if [[ $(uname -m) == 'arm64' ]]
then
# evmone does not provide any builds for apple silicon yet. so lets just build it locally.
# be aware that we are only building the arm version here, we don't build a universal binary.
git clone https://github.com/ethereum/evmone.git
cd evmone
git checkout "v${evmone_version}"
git submodule update --init
cmake -S . -B build
cmake --build build
cd build
sudo make install
cd ../..
rm -rf evmone
else
evmone_package="evmone-${evmone_version}-darwin-x86_64.tar.gz"
wget "https://github.com/ethereum/evmone/releases/download/v${evmone_version}/${evmone_package}"
validate_checksum "$evmone_package" 83ed20676681d9a31bd30cac399ab7c615ccab8adb8087cc2c7e9cd22b4d2efc
tar xzpf "$evmone_package" -C /usr/local
rm "$evmone_package"
fi
evmone_version="0.12.0"
evmone_package="evmone-${evmone_version}-darwin-arm64.tar.gz"
wget "https://github.com/ethereum/evmone/releases/download/v${evmone_version}/${evmone_package}"
validate_checksum "$evmone_package" e164e0d2b985cc1cca07b501538b2e804bf872d1d8d531f9241d518a886234a6
sudo tar xzpf "$evmone_package" -C /usr/local
rm "$evmone_package"
fi
2 changes: 1 addition & 1 deletion scripts/install_evmone.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ $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"
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
2 changes: 1 addition & 1 deletion test/evmc/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# EVMC

This is an import of [EVMC](https://github.com/ethereum/evmc) version [11.0.0](https://github.com/ethereum/evmc/releases/tag/v11.0.0).
This is an import of [EVMC](https://github.com/ethereum/evmc) version [12.0.0](https://github.com/ethereum/evmc/releases/tag/v12.0.0).

Steps when upgrading:
- Copy all from [include/evmc](https://github.com/ethereum/evmc/tree/master/include/evmc) to [test/evmc](https://github.com/ethereum/solidity/tree/develop/test/evmc)
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 890ad92

Please sign in to comment.