diff --git a/.circleci/config.yml b/.circleci/config.yml index 68626408f222..931ce476a347 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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 diff --git a/.circleci/osx_install_dependencies.sh b/.circleci/osx_install_dependencies.sh index 5436c31fe05f..dff85b489ca3 100755 --- a/.circleci/osx_install_dependencies.sh +++ b/.circleci/osx_install_dependencies.sh @@ -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 diff --git a/scripts/install_evmone.ps1 b/scripts/install_evmone.ps1 index 5864f249159d..7295afa01ee3 100644 --- a/scripts/install_evmone.ps1 +++ b/scripts/install_evmone.ps1 @@ -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/ diff --git a/test/Common.h b/test/Common.h index b5963c88750a..3adb980a0d05 100644 --- a/test/Common.h +++ b/test/Common.h @@ -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 {}; diff --git a/test/evmc/README.md b/test/evmc/README.md index 9381b4f53eda..35fb11901c49 100644 --- a/test/evmc/README.md +++ b/test/evmc/README.md @@ -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) diff --git a/test/evmc/bytes.hpp b/test/evmc/bytes.hpp new file mode 100644 index 000000000000..34ddc2f2cfef --- /dev/null +++ b/test/evmc/bytes.hpp @@ -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 +#include +#include +#include + +namespace evmc +{ +/// The char traits for byte-like types. +/// +/// See: https://en.cppreference.com/w/cpp/string/char_traits. +template +struct byte_traits : std::char_traits +{ + 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(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>; + +/// String view of unsigned chars representing bytes. +using bytes_view = std::basic_string_view>; +} // namespace evmc diff --git a/test/evmc/evmc.h b/test/evmc/evmc.h index 571c97f474e0..bec847597cc0 100644 --- a/test/evmc/evmc.h +++ b/test/evmc/evmc.h @@ -44,7 +44,7 @@ enum * * @see @ref versioning */ - EVMC_ABI_VERSION = 11 + EVMC_ABI_VERSION = 12 }; @@ -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. */ @@ -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; @@ -179,7 +181,7 @@ 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. @@ -187,24 +189,43 @@ struct evmc_message * 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). */ }; /** @@ -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, @@ -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 }; diff --git a/test/evmc/evmc.hpp b/test/evmc/evmc.hpp index 91386c46f857..2dfabf82608d 100644 --- a/test/evmc/evmc.hpp +++ b/test/evmc/evmc.hpp @@ -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; - /// 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. diff --git a/test/evmc/helpers.h b/test/evmc/helpers.h index 683567ef13ff..a5f6c3637ff0 100644 --- a/test/evmc/helpers.h +++ b/test/evmc/helpers.h @@ -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 ""; } diff --git a/test/evmc/hex.hpp b/test/evmc/hex.hpp index 31bbe519534e..a2505b71fed2 100644 --- a/test/evmc/hex.hpp +++ b/test/evmc/hex.hpp @@ -3,6 +3,7 @@ // Licensed under the Apache License, Version 2.0. #pragma once +#include #include #include #include @@ -11,13 +12,6 @@ namespace evmc { -/// String of uint8_t chars. -using bytes = std::basic_string; - -/// String view of uint8_t chars. -using bytes_view = std::basic_string_view; - - /// Encode a byte to a hex string. inline std::string hex(uint8_t b) noexcept { diff --git a/test/evmc/mocked_host.hpp b/test/evmc/mocked_host.hpp index 205a136b3800..2b37113ad10b 100644 --- a/test/evmc/mocked_host.hpp +++ b/test/evmc/mocked_host.hpp @@ -6,16 +6,13 @@ #include #include #include -#include #include +#include #include #include namespace evmc { -/// The string of bytes. -using bytes = std::basic_string; - /// Extended value (with original value and access flag) for account storage. struct StorageValue {