diff --git a/src/test/app/WasmHostFuncImpl_test.cpp b/src/test/app/WasmHostFuncImpl_test.cpp index 2f19b7dc30..b8d86f375b 100644 --- a/src/test/app/WasmHostFuncImpl_test.cpp +++ b/src/test/app/WasmHostFuncImpl_test.cpp @@ -1373,14 +1373,6 @@ struct WasmHostFuncImpl_test : public beast::unit_test::suite if (BEAST_EXPECT(!tooBig.has_value())) BEAST_EXPECT( tooBig.error() == HostFunctionError::DATA_FIELD_TOO_LARGE); - - // Should fail if ledger object not found (use a bogus keylet) - auto const bogusKeylet = keylet::escrow(env.master, 999999); - WasmHostFunctionsImpl hfs2(ac, bogusKeylet); - auto const notFound = hfs2.updateData(Slice(data.data(), data.size())); - if (BEAST_EXPECT(!notFound.has_value())) - BEAST_EXPECT( - notFound.error() == HostFunctionError::LEDGER_OBJ_NOT_FOUND); } void diff --git a/src/xrpld/app/misc/WasmHostFuncImpl.cpp b/src/xrpld/app/misc/WasmHostFuncImpl.cpp index 4adb99a447..1b95a0dbf3 100644 --- a/src/xrpld/app/misc/WasmHostFuncImpl.cpp +++ b/src/xrpld/app/misc/WasmHostFuncImpl.cpp @@ -453,11 +453,7 @@ WasmHostFunctionsImpl::updateData(Slice const& data) { return Unexpected(HostFunctionError::DATA_FIELD_TOO_LARGE); } - auto sle = ctx.view().peek(leKey); - if (!sle) - return Unexpected(HostFunctionError::LEDGER_OBJ_NOT_FOUND); - sle->setFieldVL(sfData, data); - ctx.view().update(sle); + data_ = Bytes(data.begin(), data.end()); return 0; } diff --git a/src/xrpld/app/misc/WasmHostFuncImpl.h b/src/xrpld/app/misc/WasmHostFuncImpl.h index a6051bb1c7..a56c237943 100644 --- a/src/xrpld/app/misc/WasmHostFuncImpl.h +++ b/src/xrpld/app/misc/WasmHostFuncImpl.h @@ -32,6 +32,7 @@ class WasmHostFunctionsImpl : public HostFunctions static int constexpr MAX_CACHE = 256; std::array, MAX_CACHE> cache; + std::optional data_; void const* rt_ = nullptr; @@ -75,6 +76,12 @@ public: return ctx.journal; } + std::optional const& + getData() const + { + return data_; + } + Expected getLedgerSqn() override; diff --git a/src/xrpld/app/tx/detail/Escrow.cpp b/src/xrpld/app/tx/detail/Escrow.cpp index f0389c06ad..9ba02cc877 100644 --- a/src/xrpld/app/tx/detail/Escrow.cpp +++ b/src/xrpld/app/tx/detail/Escrow.cpp @@ -1279,6 +1279,12 @@ EscrowFinish::doApply() auto re = runEscrowWasm( wasm, ESCROW_FUNCTION_NAME, {}, &ledgerDataProvider, allowance); JLOG(j_.trace()) << "Escrow WASM ran"; + + if (auto const& data = ledgerDataProvider.getData(); data.has_value()) + { + slep->setFieldVL(sfData, makeSlice(*data)); + } + if (re.has_value()) { auto reValue = re.value().result;