Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/action/interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ class BaseInterpreterImpl {
break;
}
default:
ZEN_LOG_ERROR("unimplemented opcode : {%d}", Opcode);
ZEN_LOG_ERROR("unimplemented opcode : 0x%x", Opcode);
ZEN_ASSERT_TODO();
break;
}
Expand Down
10 changes: 5 additions & 5 deletions src/tests/evm_test_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,14 @@ inline std::string decimalToHex(const std::string &DecimalStr) {
return "0";
}
if (TrimmedStr[0] == '-') {
ZEN_LOG_ERROR("Negative values are not supported. Value: {}",
ZEN_LOG_ERROR("Negative values are not supported. Value: %s",
DecimalStr.c_str());
return "0";
Comment thread
cmgCr marked this conversation as resolved.
}
for (char C : TrimmedStr) {
if (!std::isdigit(C)) {
ZEN_LOG_ERROR(
"Invalid decimal string (contains non-digit characters). Value: {}",
"Invalid decimal string (contains non-digit characters). Value: %s",
DecimalStr.c_str());
return "0";
}
Expand All @@ -162,11 +162,11 @@ inline std::string decimalToHex(const std::string &DecimalStr) {
try {
Value = std::stoull(TrimmedStr);
} catch (const std::out_of_range &E) {
ZEN_LOG_ERROR("Value exceeds uint64_t range. Value: {}",
ZEN_LOG_ERROR("Value exceeds uint64_t range. Value: %s",
DecimalStr.c_str());
return "0";
} catch (const std::invalid_argument &E) {
ZEN_LOG_ERROR("Invalid decimal string (parsing failed). Value: {}",
ZEN_LOG_ERROR("Invalid decimal string (parsing failed). Value: %s",
DecimalStr.c_str());
Comment thread
cmgCr marked this conversation as resolved.
return "0";
}
Expand All @@ -175,7 +175,7 @@ inline std::string decimalToHex(const std::string &DecimalStr) {
std::string HexStr = S.str();
if (HexStr.size() > 64) {
ZEN_LOG_ERROR(
"Hex value exceeds 64 characters (uint256 max). Length: {}, Value: {}",
"Hex value exceeds 64 characters (uint256 max). Length: %zu, Value: %s",
HexStr.size(), HexStr.c_str());
HexStr = HexStr.substr(HexStr.size() - 64);
}
Expand Down
32 changes: 17 additions & 15 deletions src/tests/evm_test_host.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ class ZenMockedEVMHost : public evmc::MockedHost {
if (It == accounts.end() || It->second.code.empty()) {
// No contract found, return parent result
ZEN_LOG_DEBUG(
"No contract found for code address {}, return parent result",
"No contract found for code address %s, return parent result",
evmc::hex(evmc::bytes_view(CodeAddr.bytes, 20)).c_str());
Comment thread
cmgCr marked this conversation as resolved.
if (Msg.kind == EVMC_CALL && !applyCallValueTransfer(Msg)) {
return ParentResult;
Expand All @@ -504,7 +504,7 @@ class ZenMockedEVMHost : public evmc::MockedHost {
const auto &ContractCode = It->second.code;
if (ContractCode.empty()) {
ZEN_LOG_DEBUG(
"Contract code is empty for recipient {}",
"Contract code is empty for recipient %s",
evmc::hex(evmc::bytes_view(Msg.recipient.bytes, 20)).c_str());
return ParentResult;
}
Expand All @@ -517,7 +517,7 @@ class ZenMockedEVMHost : public evmc::MockedHost {
auto ModRet =
RT->loadEVMModule(ModName, ContractCode.data(), ContractCode.size());
if (!ModRet) {
ZEN_LOG_ERROR("Failed to load EVM module: {}", ModName.c_str());
ZEN_LOG_ERROR("Failed to load EVM module: %s", ModName.c_str());
return ParentResult;
}

Expand All @@ -526,15 +526,15 @@ class ZenMockedEVMHost : public evmc::MockedHost {
IsolationPtr Iso(nullptr, IsolationDeleter{RT});
Iso.reset(RT->createManagedIsolation());
if (!Iso) {
ZEN_LOG_ERROR("Failed to create isolation for module: {}",
ZEN_LOG_ERROR("Failed to create isolation for module: %s",
ModName.c_str());
return ParentResult;
}

// Create EVM instance
auto InstRet = Iso->createEVMInstance(*Mod, Msg.gas);
if (!InstRet) {
ZEN_LOG_ERROR("Failed to create EVM instance for module: {}",
ZEN_LOG_ERROR("Failed to create EVM instance for module: %s",
ModName.c_str());
return ParentResult;
}
Expand Down Expand Up @@ -573,7 +573,7 @@ class ZenMockedEVMHost : public evmc::MockedHost {
RT->callEVMMain(*Inst, CallMsg, ExecResult);
}
} catch (const std::exception &E) {
ZEN_LOG_ERROR("Error in recursive call: {}", E.what());
ZEN_LOG_ERROR("Error in recursive call: %s", E.what());
restoreHostState(StateSnapshot);
return ParentResult;
}
Expand All @@ -599,7 +599,7 @@ class ZenMockedEVMHost : public evmc::MockedHost {

} catch (const std::exception &E) {
// On error, return parent result
ZEN_LOG_ERROR("Error in recursive call: {}", E.what());
ZEN_LOG_ERROR("Error in recursive call: %s", E.what());
restoreHostState(StateSnapshot);
return ParentResult;
}
Expand Down Expand Up @@ -695,7 +695,7 @@ class ZenMockedEVMHost : public evmc::MockedHost {
if (!IsNewAccount) {
ensureAccountHasCodeHash(It->second);
if (isCreateCollision(It->second)) {
ZEN_LOG_ERROR("Create collision at address {}",
ZEN_LOG_ERROR("Create collision at address %s",
evmc::hex(NewAddr).c_str());
auto SenderIt = accounts.find(Msg.sender);
if (SenderIt != accounts.end() &&
Expand All @@ -721,7 +721,7 @@ class ZenMockedEVMHost : public evmc::MockedHost {
auto ModRet = RT->loadEVMModule(ModName, InitcodePtr, InitcodeSize);
if (!ModRet) {
restoreHostState(StateSnapshot);
ZEN_LOG_ERROR("Failed to load EVM module: {}", ModName.c_str());
ZEN_LOG_ERROR("Failed to load EVM module: %s", ModName.c_str());
return evmc::Result{EVMC_FAILURE, Msg.gas, 0, NewAddr};
}
EVMModule *Mod = *ModRet;
Expand All @@ -730,15 +730,15 @@ class ZenMockedEVMHost : public evmc::MockedHost {
Iso.reset(RT->createManagedIsolation());
if (!Iso) {
restoreHostState(StateSnapshot);
ZEN_LOG_ERROR("Failed to create isolation for module: {}",
ZEN_LOG_ERROR("Failed to create isolation for module: %s",
ModName.c_str());
return evmc::Result{EVMC_FAILURE, Msg.gas, 0, NewAddr};
}

auto InstRet = Iso->createEVMInstance(*Mod, Msg.gas);
if (!InstRet) {
restoreHostState(StateSnapshot);
ZEN_LOG_ERROR("Failed to create EVM instance for module: {}",
ZEN_LOG_ERROR("Failed to create EVM instance for module: %s",
ModName.c_str());
return evmc::Result{EVMC_FAILURE, Msg.gas, 0, NewAddr};
}
Expand All @@ -761,8 +761,10 @@ class ZenMockedEVMHost : public evmc::MockedHost {
intx::be::load<intx::uint256>(SenderAcc.balance);
if (SenderBalance < Value) {
restoreHostState(StateSnapshot);
ZEN_LOG_ERROR("Insufficient balance for CREATE: have {}, need {}",
SenderBalance, Value);
const auto SenderBalanceStr = intx::to_string(SenderBalance);
const auto ValueStr = intx::to_string(Value);
ZEN_LOG_ERROR("Insufficient balance for CREATE: have %s, need %s",
SenderBalanceStr.c_str(), ValueStr.c_str());
return evmc::Result{EVMC_INSUFFICIENT_BALANCE, Msg.gas, 0, NewAddr};
}
SenderBalance -= Value;
Expand Down Expand Up @@ -799,7 +801,7 @@ class ZenMockedEVMHost : public evmc::MockedHost {
}
} catch (const std::exception &E) {
restoreHostState(StateSnapshot);
ZEN_LOG_ERROR("Error in handleCreate execution: {}", E.what());
ZEN_LOG_ERROR("Error in handleCreate execution: %s", E.what());
return evmc::Result{EVMC_FAILURE, Msg.gas, 0, evmc::address{}};
}

Expand Down Expand Up @@ -889,7 +891,7 @@ class ZenMockedEVMHost : public evmc::MockedHost {
CreateResult.create_address = NewAddr;
return CreateResult;
} catch (const std::exception &E) {
ZEN_LOG_ERROR("Error in handleCreate: {}", E.what());
ZEN_LOG_ERROR("Error in handleCreate: %s", E.what());
restoreHostState(StateSnapshot);
return evmc::Result{EVMC_FAILURE, Msg.gas, 0, evmc::address{}};
}
Expand Down
Loading