diff --git a/src/xrpld/app/misc/WamrVM.cpp b/src/xrpld/app/misc/WamrVM.cpp index fb1852bd00..8f7c9b1c36 100644 --- a/src/xrpld/app/misc/WamrVM.cpp +++ b/src/xrpld/app/misc/WamrVM.cpp @@ -93,11 +93,17 @@ wamr_log_to_rippled( { beast::Journal j = WasmEngine::instance().getJournal(); - // Format the variadic args - char const* safeFile = file ? file : ""; - std::ostringstream oss; - oss << "WAMR (" << safeFile << ":" << line << "): "; + + // Format the variadic args + if (file) + { + oss << "WAMR (" << file << ":" << line << "): "; + } + else + { + oss << "WAMR: "; + } va_list args; va_start(args, fmt); @@ -114,7 +120,6 @@ wamr_log_to_rippled( #ifdef DEBUG_OUTPUT_WAMR std::cerr << oss.str() << std::endl; #endif - // } void @@ -544,9 +549,8 @@ ModuleWrapper::buildImports( if (impCnt != importTypes.num_elems) { print_wasm_error( - std::string("Imports not finished: ") + - std::to_string(wimports.num_elems) + "/" + - std::to_string(importTypes.num_elems), + std::string("Imports not finished: ") + std::to_string(impCnt) + + "/" + std::to_string(importTypes.num_elems), nullptr, j_); } diff --git a/src/xrpld/app/misc/WasmHostFuncImpl.cpp b/src/xrpld/app/misc/WasmHostFuncImpl.cpp index 9e2ec00d18..6c19db6dc4 100644 --- a/src/xrpld/app/misc/WasmHostFuncImpl.cpp +++ b/src/xrpld/app/misc/WasmHostFuncImpl.cpp @@ -455,11 +455,17 @@ Expected WasmHostFunctionsImpl::getNFT(AccountID const& account, uint256 const& nftId) { if (!account || !nftId) + { + getJournal().trace() << "WAMR getNFT: Invalid account or NFT ID"; return Unexpected(HF_ERR_INVALID_PARAMS); + } auto obj = nft::findToken(ctx.view(), account, nftId); if (!obj) + { + getJournal().trace() << "WAMR getNFT: NFT not found"; return Unexpected(HF_ERR_LEDGER_OBJ_NOT_FOUND); + } Slice const s = obj->at(sfURI); return Bytes(s.begin(), s.end()); @@ -476,15 +482,15 @@ WasmHostFunctionsImpl::trace( #else auto j = ctx.journal.trace(); #endif - j << msg; if (!asHex) - j << std::string_view( - reinterpret_cast(data.data()), data.size()); + j << "WAMR TRACE (" << leKey.key << "): " << msg << " - " + << std::string_view( + reinterpret_cast(data.data()), data.size()); else { auto const hex = boost::algorithm::hex(std::string(data.begin(), data.end())); - j << hex; + j << "WAMR DEV TRACE (" << leKey.key << "): " << msg << " - " << hex; } return msg.size() + data.size() * (asHex ? 2 : 1); @@ -499,7 +505,7 @@ WasmHostFunctionsImpl::traceNum(std::string const& msg, int64_t data) auto j = ctx.journal.trace(); #endif - j << msg << data; + j << "WAMR DEV TRACE (" << leKey.key << "): " << msg << " - " << data; return msg.size() + sizeof(data); } diff --git a/src/xrpld/app/misc/WasmHostFuncWrapper.cpp b/src/xrpld/app/misc/WasmHostFuncWrapper.cpp index e4196263d6..b654c16aa5 100644 --- a/src/xrpld/app/misc/WasmHostFuncWrapper.cpp +++ b/src/xrpld/app/misc/WasmHostFuncWrapper.cpp @@ -685,8 +685,11 @@ getNFT_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) RET(nftRaw.error()); } - if (nftRaw->size() < uint256::bytes * 2) + if (nftRaw->size() != uint256::bytes) { + hf->getJournal().trace() + << "WAMR getNFT: Invalid NFT data size: " << nftRaw->size() + << ", expected " << (uint256::bytes); RET(HF_ERR_INVALID_PARAMS); }