Skip to content

Commit

Permalink
Merge pull request #572 from ewasm/evmc-v10
Browse files Browse the repository at this point in the history
Upgrade EVMC to version 10.0.0
  • Loading branch information
axic authored Sep 20, 2022
2 parents 558004c + 6dfd3ae commit 65dc1bd
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 26 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
4 changes: 2 additions & 2 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion evmc
Submodule evmc updated 119 files
30 changes: 15 additions & 15 deletions src/eei.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -405,15 +405,15 @@ 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))
takeInterfaceGas(GasSchedule::storageStoreCreate - GasSchedule::storageStoreChange);

// 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)
Expand All @@ -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);
}
Expand Down Expand Up @@ -464,15 +464,15 @@ 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;

switch (kind) {
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)) {
Expand All @@ -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;
}
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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{};
}
Expand Down Expand Up @@ -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);
}

Expand Down
10 changes: 6 additions & 4 deletions src/hera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,16 @@ pair<evmc_status_code, bytes> 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)
Expand All @@ -148,12 +149,13 @@ pair<evmc_status_code, bytes> 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<WasmEngine> engine = wasmEngineCreateFn();
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 65dc1bd

Please sign in to comment.