Check that HFS object is always new

This commit is contained in:
Oleksandr
2026-02-12 13:12:04 -05:00
parent 10864f1959
commit cb1bf20ab4
3 changed files with 15 additions and 0 deletions

View File

@@ -110,6 +110,12 @@ struct HostFunctions
return j_;
}
virtual bool
checkSelf() const
{
return true;
}
virtual Expected<std::uint32_t, HostFunctionError>
getLedgerSqn() const
{

View File

@@ -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<Bytes> const&
getData() const
{

View File

@@ -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())