From cb1bf20ab4f0c57eb14db7e05f5b638cece980d7 Mon Sep 17 00:00:00 2001 From: Oleksandr <115580134+oleks-rip@users.noreply.github.com> Date: Thu, 12 Feb 2026 13:12:04 -0500 Subject: [PATCH] Check that HFS object is always new --- src/xrpld/app/wasm/HostFunc.h | 6 ++++++ src/xrpld/app/wasm/HostFuncImpl.h | 7 +++++++ src/xrpld/app/wasm/detail/WasmiVM.cpp | 2 ++ 3 files changed, 15 insertions(+) diff --git a/src/xrpld/app/wasm/HostFunc.h b/src/xrpld/app/wasm/HostFunc.h index 8ca02efed1..ea1e171332 100644 --- a/src/xrpld/app/wasm/HostFunc.h +++ b/src/xrpld/app/wasm/HostFunc.h @@ -110,6 +110,12 @@ struct HostFunctions return j_; } + virtual bool + checkSelf() const + { + return true; + } + virtual Expected getLedgerSqn() const { diff --git a/src/xrpld/app/wasm/HostFuncImpl.h b/src/xrpld/app/wasm/HostFuncImpl.h index b86a02254f..fc171088b6 100644 --- a/src/xrpld/app/wasm/HostFuncImpl.h +++ b/src/xrpld/app/wasm/HostFuncImpl.h @@ -74,6 +74,13 @@ public: return rt_; } + virtual bool + checkSelf() const override + { + return !currentLedgerObj_ && !data_ && + std::ranges::find_if(cache_, [](auto& p) { return !!p; }) == cache_.end(); + } + std::optional const& getData() const { diff --git a/src/xrpld/app/wasm/detail/WasmiVM.cpp b/src/xrpld/app/wasm/detail/WasmiVM.cpp index c0454fceec..ff93e70ef0 100644 --- a/src/xrpld/app/wasm/detail/WasmiVM.cpp +++ b/src/xrpld/app/wasm/detail/WasmiVM.cpp @@ -782,6 +782,8 @@ WasmiEngine::runHlp( #ifndef WASM_PERF_TESTS if (wasmCode.empty()) throw std::runtime_error("empty module"); + if (!hfs.checkSelf()) + throw std::runtime_error("hfs isn't clean"); #else // re-using module only for perf tests if (!wasmCode.empty())