From 735aa0c5175bf40805109ff825f7e8e830263f7b Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Fri, 16 Sep 2022 13:43:39 +0200 Subject: [PATCH 1/3] Upgrade EVMC to version 10.0.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Paweł Bylica --- README.md | 2 +- evmc | 2 +- src/eei.cpp | 30 +++++++++++++++--------------- src/hera.cpp | 10 ++++++---- 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 571b66f4c..e647fd74f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Hera ![Status](https://circleci.com/gh/ewasm/hera.svg?style=shield&circle-token=:circle-token) -Hera is an [ewasm] (revision 4) virtual machine implemented in C++ conforming to [EVMC] ABIv9. +Hera is an [ewasm] (revision 4) virtual machine implemented in C++ conforming to [EVMC] ABIv10. It is designed to leverage various Wasm backends, both interpreters and AOT/JITs. diff --git a/evmc b/evmc index 18bea410e..05819e343 160000 --- a/evmc +++ b/evmc @@ -1 +1 @@ -Subproject commit 18bea410e24929ebd185c789e6255242ea0f426c +Subproject commit 05819e343de23fae05fda0b5a23eeb0da3a320b7 diff --git a/src/eei.cpp b/src/eei.cpp index bfca94726..539c5dafd 100644 --- a/src/eei.cpp +++ b/src/eei.cpp @@ -108,7 +108,7 @@ void WasmEngine::collectBenchmarkingData() HERA_DEBUG << "): " << dec; - evmc::bytes32 result = m_host.get_storage(m_msg.destination, path); + evmc::bytes32 result = m_host.get_storage(m_msg.recipient, path); if (useHex) { @@ -181,7 +181,7 @@ void WasmEngine::collectBenchmarkingData() takeInterfaceGas(GasSchedule::base); - storeAddress(m_msg.destination, resultOffset); + storeAddress(m_msg.recipient, resultOffset); } void EthereumInterface::eeiGetExternalBalance(uint32_t addressOffset, uint32_t resultOffset) @@ -307,7 +307,7 @@ void WasmEngine::collectBenchmarkingData() takeInterfaceGas(GasSchedule::base); - storeUint256(m_host.get_tx_context().block_difficulty, offset); + storeUint256(m_host.get_tx_context().block_prev_randao, offset); } int64_t EthereumInterface::eeiGetBlockGasLimit() @@ -355,7 +355,7 @@ void WasmEngine::collectBenchmarkingData() bytes data(length, '\0'); loadMemory(dataOffset, data, length); - m_host.emit_log(m_msg.destination, data.data(), length, topics.data(), numberOfTopics); + m_host.emit_log(m_msg.recipient, data.data(), length, topics.data(), numberOfTopics); } int64_t EthereumInterface::eeiGetBlockNumber() @@ -405,7 +405,7 @@ void WasmEngine::collectBenchmarkingData() const auto path = loadBytes32(pathOffset); const auto value = loadBytes32(valueOffset); - const auto current = m_host.get_storage(m_msg.destination, path); + const auto current = m_host.get_storage(m_msg.recipient, path); // Charge the right amount in case of the create case. if (is_zero(current) && !is_zero(value)) @@ -413,7 +413,7 @@ void WasmEngine::collectBenchmarkingData() // We do not need to take care about the delete case (gas refund), the client does it. - m_host.set_storage(m_msg.destination, path, value); + m_host.set_storage(m_msg.recipient, path, value); } void EthereumInterface::eeiStorageLoad(uint32_t pathOffset, uint32_t resultOffset) @@ -423,7 +423,7 @@ void WasmEngine::collectBenchmarkingData() takeInterfaceGas(GasSchedule::storageLoad); evmc::bytes32 path = loadBytes32(pathOffset); - evmc::bytes32 result = m_host.get_storage(m_msg.destination, path); + evmc::bytes32 result = m_host.get_storage(m_msg.recipient, path); storeBytes32(result, resultOffset); } @@ -464,7 +464,7 @@ void WasmEngine::collectBenchmarkingData() ensureCondition(gas >= 0, ArgumentOutOfRange, "Negative gas supplied."); evmc_message call_message; - call_message.destination = loadAddress(addressOffset); + call_message.recipient = loadAddress(addressOffset); call_message.flags = m_msg.flags & EVMC_STATIC; call_message.depth = m_msg.depth + 1; @@ -472,7 +472,7 @@ void WasmEngine::collectBenchmarkingData() case EEICallKind::Call: case EEICallKind::CallCode: call_message.kind = (kind == EEICallKind::CallCode) ? EVMC_CALLCODE : EVMC_CALL; - call_message.sender = m_msg.destination; + call_message.sender = m_msg.recipient; call_message.value = loadUint128(valueOffset); if ((kind == EEICallKind::Call) && !evmc::is_zero(call_message.value)) { @@ -487,7 +487,7 @@ void WasmEngine::collectBenchmarkingData() case EEICallKind::CallStatic: call_message.kind = EVMC_CALL; call_message.flags |= EVMC_STATIC; - call_message.sender = m_msg.destination; + call_message.sender = m_msg.recipient; call_message.value = {}; break; } @@ -539,7 +539,7 @@ void WasmEngine::collectBenchmarkingData() return 1; // Only charge callNewAccount gas if the account is new and non-zero value is being transferred per EIP161. - if ((kind == EEICallKind::Call) && !m_host.account_exists(call_message.destination)) + if ((kind == EEICallKind::Call) && !m_host.account_exists(call_message.recipient)) takeInterfaceGas(GasSchedule::callNewAccount); } @@ -587,8 +587,8 @@ void WasmEngine::collectBenchmarkingData() evmc_message create_message; - create_message.destination = {}; - create_message.sender = m_msg.destination; + create_message.recipient = {}; + create_message.sender = m_msg.recipient; create_message.value = loadUint128(valueOffset); if (m_msg.depth >= 1024) @@ -655,7 +655,7 @@ void WasmEngine::collectBenchmarkingData() if (!m_host.account_exists(address)) takeInterfaceGas(GasSchedule::callNewAccount); - m_host.selfdestruct(m_msg.destination, address); + m_host.selfdestruct(m_msg.recipient, address); throw EndExecution{}; } @@ -840,7 +840,7 @@ void WasmEngine::collectBenchmarkingData() bool EthereumInterface::enoughSenderBalanceFor(evmc::uint256be const& value) { - evmc::uint256be balance = m_host.get_balance(m_msg.destination); + evmc::uint256be balance = m_host.get_balance(m_msg.recipient); return safeLoadUint128(balance) >= safeLoadUint128(value); } diff --git a/src/hera.cpp b/src/hera.cpp index 55504a584..9d22f41c7 100644 --- a/src/hera.cpp +++ b/src/hera.cpp @@ -116,15 +116,16 @@ pair callSystemContract( .flags = EVMC_STATIC, .depth = 0, .gas = gas, - .destination = address, + .recipient = address, .sender = {}, .input_data = input.data(), .input_size = input.size(), .value = {}, .create2_salt = {}, + .code_address = address, }; - evmc::result result = context.call(message); + evmc::Result result = context.call(message); bytes ret; if (result.status_code == EVMC_SUCCESS && result.output_data) @@ -148,12 +149,13 @@ pair locallyExecuteSystemContract( .flags = EVMC_STATIC, .depth = 0, .gas = gas, - .destination = address, + .recipient = address, .sender = {}, .input_data = input.data(), .input_size = input.size(), .value = {}, .create2_salt = {}, + .code_address = address, }; unique_ptr engine = wasmEngineCreateFn(); @@ -299,7 +301,7 @@ evmc_result hera_execute( bytes run_code{state_code}; // replace executable code if replacement is supplied - auto preload = hera->contract_preload_list.find(msg->destination); + auto preload = hera->contract_preload_list.find(msg->recipient); if (preload != hera->contract_preload_list.end()) { HERA_DEBUG << "Overriding contract.\n"; run_code = preload->second; From 80333b4a50f65187382f63c7835a1ab2e0789d77 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Sun, 18 Sep 2022 11:44:06 +0200 Subject: [PATCH 2/3] Update Cable to latest master MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Paweł Bylica --- circle.yml | 4 ++-- cmake/cable | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/circle.yml b/circle.yml index b916e3416..09ccd0abb 100644 --- a/circle.yml +++ b/circle.yml @@ -249,12 +249,12 @@ jobs: linux-gcc-shared-coverage: environment: - - BUILD_TYPE: Debug + - BUILD_TYPE: Coverage - CXX: g++ - CC: gcc - GENERATOR: Unix Makefiles - BUILD_PARALLEL_JOBS: 4 - - CMAKE_OPTIONS: -DCOVERAGE=ON -DBUILD_SHARED_LIBS=ON -DHERA_DEBUGGING=ON -DHERA_BINARYEN=ON -DHERA_WABT=ON -DHERA_WAVM=ON + - CMAKE_OPTIONS: -DBUILD_SHARED_LIBS=ON -DHERA_DEBUGGING=ON -DHERA_BINARYEN=ON -DHERA_WABT=ON -DHERA_WAVM=ON - TESTETH_OPTIONS: --evmc benchmark=true docker: - image: ethereum/cpp-build-env:9 diff --git a/cmake/cable b/cmake/cable index 3fb12ab54..ec1ae18d2 160000 --- a/cmake/cable +++ b/cmake/cable @@ -1 +1 @@ -Subproject commit 3fb12ab54d42ecebeedd399f9146f88b1f8fdcbc +Subproject commit ec1ae18d248da75af235f5fa512cfaf2b650ae70 From 6dfd3aec62be84d5a11d41f17c1f16e996aff310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Tue, 20 Sep 2022 10:00:00 +0200 Subject: [PATCH 3/3] cmake: Fix GNUInstallDirs warning --- CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a3254873b..5848ad533 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,12 +5,10 @@ if(NOT EXISTS ${CMAKE_SOURCE_DIR}/evmc/.git OR NOT EXISTS ${CMAKE_SOURCE_DIR}/cm endif() include(cmake/cable/bootstrap.cmake) -include(CableBuildInfo) include(CableBuildType) include(CableCompilerSettings) include(CableToolchains) include(CMakePackageConfigHelpers) -include(GNUInstallDirs) include(Hunter/init) @@ -23,6 +21,9 @@ set(CMAKE_DEBUG_POSTFIX "") project(hera) set(PROJECT_VERSION 0.5.0) +include(CableBuildInfo) +include(GNUInstallDirs) + cable_configure_compiler() if(CABLE_COMPILER_GNULIKE) # TODO: fix the warnings instead