mirror of
https://github.com/Xahau/xahaud.git
synced 2026-08-27 18:20:53 +00:00
Compare commits
1 Commits
jsontx
...
fixHookMem
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
04b704e8e1 |
@@ -124,9 +124,6 @@ find_package(date REQUIRED)
|
||||
find_package(xxHash REQUIRED)
|
||||
find_package(magic_enum REQUIRED)
|
||||
|
||||
find_package(fmt REQUIRED)
|
||||
target_link_libraries(ripple_libs INTERFACE fmt::fmt)
|
||||
|
||||
include(deps/WasmEdge)
|
||||
if(TARGET nudb::core)
|
||||
set(nudb nudb::core)
|
||||
|
||||
@@ -35,7 +35,6 @@ class Xrpl(ConanFile):
|
||||
'soci/4.0.3@xahaud/stable',
|
||||
'xxhash/0.8.2',
|
||||
'zlib/1.3.1',
|
||||
'fmt/12.1.0',
|
||||
]
|
||||
|
||||
tool_requires = [
|
||||
@@ -192,7 +191,6 @@ class Xrpl(ConanFile):
|
||||
'sqlite3::sqlite',
|
||||
'xxhash::xxhash',
|
||||
'zlib::zlib',
|
||||
'fmt::fmt',
|
||||
]
|
||||
if self.options.rocksdb:
|
||||
libxrpl.requires.append('rocksdb::librocksdb')
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#define featureHooksUpdate2 "1"
|
||||
#define fix20250131 "1"
|
||||
#define fixGuardDepth32 "1"
|
||||
#define fixHookMemoryMissing "1"
|
||||
namespace hook_api {
|
||||
struct Rules
|
||||
{
|
||||
@@ -267,6 +268,7 @@ enum hook_log_code : uint16_t {
|
||||
CUSTOM_SECTION_DISALLOWED =
|
||||
86, // the wasm contained a custom section (id=0)
|
||||
INTERNAL_ERROR = 87, // an internal error described by the log text
|
||||
MEMORY_MISSING = 88, // hook wasm did not contain a memory section
|
||||
// RH NOTE: only HookSet msgs got log codes, possibly all Hook log lines
|
||||
// should get a code?
|
||||
};
|
||||
@@ -445,6 +447,7 @@ getImportWhitelist(Rules const& rules)
|
||||
enum GuardRulesVersion : uint64_t {
|
||||
GuardRuleFix20250131 = 0x00000001,
|
||||
GuardRuleDepth32 = 0x00000002,
|
||||
GuardRuleMemoryMissing = 0x00000004,
|
||||
};
|
||||
|
||||
inline uint64_t
|
||||
@@ -455,6 +458,8 @@ getGuardRulesVersion(Rules const& rules)
|
||||
version |= GuardRuleFix20250131;
|
||||
if (rules.enabled(fixGuardDepth32))
|
||||
version |= GuardRuleDepth32;
|
||||
if (rules.enabled(fixHookMemoryMissing))
|
||||
version |= GuardRuleMemoryMissing;
|
||||
return version;
|
||||
}
|
||||
|
||||
|
||||
@@ -893,6 +893,7 @@ validateGuards(
|
||||
int last_import_number = -1;
|
||||
int import_count = 0;
|
||||
int last_section_type = 0;
|
||||
bool has_memory_section = false;
|
||||
for (int i = 8, j = 0; i < wasm.size();)
|
||||
{
|
||||
if (j == i)
|
||||
@@ -1181,11 +1182,24 @@ validateGuards(
|
||||
func_type_map[j] = type_idx;
|
||||
}
|
||||
}
|
||||
else if (section_type == 5) // memory section
|
||||
{
|
||||
has_memory_section = true;
|
||||
}
|
||||
|
||||
i = next_section;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((rulesVersion & hook_api::GuardRuleMemoryMissing) &&
|
||||
!has_memory_section)
|
||||
{
|
||||
GUARDLOG(hook::log::MEMORY_MISSING)
|
||||
<< "Malformed transaction. Hook did not contain a memory section."
|
||||
<< "\n";
|
||||
return {};
|
||||
}
|
||||
|
||||
// we must subtract import_count from the hook and cbak function in order to
|
||||
// be able to look them up in the functions section. this is a rule of the
|
||||
// webassembly spec note that at this point in execution we are guarenteed
|
||||
|
||||
@@ -150,23 +150,32 @@
|
||||
WasmEdge_CallingFrameContext const& frameCtx __VA_OPT__( \
|
||||
COMMA __VA_ARGS__))
|
||||
|
||||
#define HOOK_SETUP() \
|
||||
using enum hook_api::hook_return_code; \
|
||||
try \
|
||||
{ \
|
||||
[[maybe_unused]] ApplyContext& applyCtx = hookCtx.applyCtx; \
|
||||
[[maybe_unused]] auto& view = applyCtx.view(); \
|
||||
[[maybe_unused]] auto j = applyCtx.app.journal("View"); \
|
||||
[[maybe_unused]] WasmEdge_MemoryInstanceContext* memoryCtx = \
|
||||
WasmEdge_CallingFrameGetMemoryInstance(&frameCtx, 0); \
|
||||
[[maybe_unused]] unsigned char* memory = \
|
||||
WasmEdge_MemoryInstanceGetPointer(memoryCtx, 0, 0); \
|
||||
[[maybe_unused]] const uint64_t memory_length = \
|
||||
WasmEdge_MemoryInstanceGetPageSize(memoryCtx) * \
|
||||
WasmEdge_kPageSize; \
|
||||
[[maybe_unused]] auto& api = hookCtx.api(); \
|
||||
if (!memoryCtx || !memory || !memory_length) \
|
||||
return INTERNAL_ERROR;
|
||||
#define HOOK_SETUP() \
|
||||
using enum hook_api::hook_return_code; \
|
||||
try \
|
||||
{ \
|
||||
[[maybe_unused]] ApplyContext& applyCtx = hookCtx.applyCtx; \
|
||||
[[maybe_unused]] auto& view = applyCtx.view(); \
|
||||
[[maybe_unused]] auto j = applyCtx.app.journal("View"); \
|
||||
[[maybe_unused]] WasmEdge_MemoryInstanceContext* memoryCtx = \
|
||||
WasmEdge_CallingFrameGetMemoryInstance(&frameCtx, 0); \
|
||||
if (!memoryCtx) \
|
||||
{ \
|
||||
JLOG(j.warn()) << "HookError[" << HC_ACC() \
|
||||
<< "]: wasm memory is unavailable"; \
|
||||
if (view.rules().enabled(fixHookMemoryMissing)) \
|
||||
{ \
|
||||
hookCtx.result.exitType = hook_api::ExitType::WASM_ERROR; \
|
||||
hookCtx.result.exitReason = ""; \
|
||||
return INTERNAL_ERROR; \
|
||||
} \
|
||||
} \
|
||||
[[maybe_unused]] unsigned char* memory = \
|
||||
WasmEdge_MemoryInstanceGetPointer(memoryCtx, 0, 0); \
|
||||
[[maybe_unused]] const uint64_t memory_length = \
|
||||
WasmEdge_MemoryInstanceGetPageSize(memoryCtx) * \
|
||||
WasmEdge_kPageSize; \
|
||||
[[maybe_unused]] auto& api = hookCtx.api();
|
||||
|
||||
#define HOOK_TEARDOWN() \
|
||||
} \
|
||||
|
||||
@@ -1,557 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012-2014 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_PROTOCOL_JSONTXSIGNATURES_H_INCLUDED
|
||||
#define RIPPLE_PROTOCOL_JSONTXSIGNATURES_H_INCLUDED
|
||||
|
||||
#include <xrpl/json/json_reader.h>
|
||||
#include <xrpl/json/json_writer.h>
|
||||
#include <xrpl/protocol/PublicKey.h>
|
||||
#include <xrpl/protocol/SField.h>
|
||||
#include <xrpl/protocol/STParsedJSON.h>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <fmt/format.h>
|
||||
#include <limits>
|
||||
#include <map>
|
||||
#include <functional>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// jsontx: plaintext-JSON signing support (featureJsonTx)
|
||||
//
|
||||
// The delta is attacker-controlled: it arrives over the wire beside a binary
|
||||
// transaction and is not covered by the signature it helps reconstruct. Every
|
||||
// bound below is therefore explicit, and unsanitize_jsontx accepts only the
|
||||
// exact encoding sanitize_jsontx would have produced.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
static constexpr std::size_t jsontx_max_text = 8192; // canonical and original
|
||||
static constexpr std::size_t jsontx_max_diff = 1024; // delta bytes
|
||||
static constexpr std::size_t jsontx_max_ops = 256; // delta instructions
|
||||
static constexpr std::size_t jsontx_min_copy = 4; // encoder match threshold
|
||||
static constexpr std::size_t jsontx_max_cand = 64; // encoder candidate cap
|
||||
|
||||
// Case-insensitive field-name -> canonical SField. Built once from
|
||||
// SField::knownCodeToField, the same table doServerDefinitions publishes, using
|
||||
// its serializability filter (useful, binary, non-pseudo). sfInvalid if
|
||||
// unknown.
|
||||
static SField const&
|
||||
jsontx_field(std::string const& name)
|
||||
{
|
||||
static auto const tbl = [] {
|
||||
std::unordered_map<std::string, SField const*> m;
|
||||
for (auto const& [code, f] : SField::knownCodeToField)
|
||||
if (f->isUseful() && f->isBinary() && f->fieldType < 10000 &&
|
||||
!f->fieldName.empty())
|
||||
m.emplace(boost::algorithm::to_lower_copy(f->fieldName), f);
|
||||
return m;
|
||||
}();
|
||||
|
||||
auto const i = tbl.find(boost::algorithm::to_lower_copy(name));
|
||||
return i == tbl.end() ? sfInvalid : *i->second;
|
||||
}
|
||||
|
||||
// Civil calendar arithmetic (Howard Hinnant's algorithm), used in both
|
||||
// directions. Pure integer maths - no strptime, no timegm, no locale, no
|
||||
// tzdata - because these conversions decide whether a signature verifies and
|
||||
// so must give the same answer on every node forever.
|
||||
static constexpr std::int64_t
|
||||
jsontx_days(int y, unsigned m, unsigned d) // days from 1970-01-01
|
||||
{
|
||||
y -= m <= 2;
|
||||
std::int64_t const era = (y >= 0 ? y : y - 399) / 400;
|
||||
unsigned const yoe = static_cast<unsigned>(y - era * 400);
|
||||
unsigned const doy = (153 * (m + (m > 2 ? -3 : 9)) + 2) / 5 + d - 1;
|
||||
unsigned const doe = yoe * 365 + yoe / 4 - yoe / 100 + doy;
|
||||
return era * 146097 + doe - 719468;
|
||||
}
|
||||
|
||||
static constexpr std::int64_t jsontx_epoch_day = jsontx_days(2000, 1, 1);
|
||||
|
||||
// 9999-12-31T23:59:59.999Z: past this toISOString() switches to expanded years
|
||||
// (+275760-09-13T...) and the fixed 24 character shape no longer holds
|
||||
static constexpr std::uint64_t jsontx_max_time =
|
||||
(static_cast<std::uint64_t>(jsontx_days(9999, 12, 31) - jsontx_epoch_day) *
|
||||
86400 +
|
||||
86399) *
|
||||
1000 +
|
||||
999;
|
||||
|
||||
static_assert(jsontx_epoch_day == 10957); // matches chrono.h epoch_offset
|
||||
|
||||
// Strict Date().toISOString() -> milliseconds since the ripple epoch. Exactly
|
||||
// YYYY-MM-DDTHH:MM:SS.sssZ, always UTC, always three fractional digits.
|
||||
static std::uint64_t
|
||||
jsontx_iso(std::string const& s)
|
||||
{
|
||||
static constexpr char pat[] = "0000-00-00T00:00:00.000Z";
|
||||
if (s.size() != 24)
|
||||
throw std::runtime_error("jsontx: Time must be an ISO 8601 instant");
|
||||
for (std::size_t i = 0; i < 24; ++i)
|
||||
if (pat[i] == '0' ? !std::isdigit(static_cast<unsigned char>(s[i]))
|
||||
: s[i] != pat[i])
|
||||
throw std::runtime_error("jsontx: malformed Time");
|
||||
|
||||
auto const n = [&s](std::size_t i, std::size_t c) {
|
||||
int v = 0;
|
||||
while (c--)
|
||||
v = v * 10 + (s[i++] - '0');
|
||||
return v;
|
||||
};
|
||||
int const y = n(0, 4), mo = n(5, 2), d = n(8, 2), h = n(11, 2),
|
||||
mi = n(14, 2), se = n(17, 2), ms = n(20, 3);
|
||||
if (mo < 1 || mo > 12)
|
||||
throw std::runtime_error("jsontx: Time month out of range");
|
||||
bool const leap = (y % 4 == 0 && y % 100 != 0) || y % 400 == 0;
|
||||
int const dim =
|
||||
mo == 2 ? (leap ? 29 : 28) : ((mo % 2 == 1) == (mo <= 7) ? 31 : 30);
|
||||
// 60 is rejected: JS cannot emit a leap second and the ledger cannot
|
||||
// represent one
|
||||
if (d < 1 || d > dim || h > 23 || mi > 59 || se > 59)
|
||||
throw std::runtime_error("jsontx: Time out of range");
|
||||
|
||||
std::int64_t const t = (jsontx_days(y, mo, d) - jsontx_epoch_day) * 86400 +
|
||||
h * 3600 + mi * 60 + se;
|
||||
if (t < 0)
|
||||
throw std::runtime_error("jsontx: Time precedes the ripple epoch");
|
||||
return static_cast<std::uint64_t>(t) * 1000 + ms;
|
||||
}
|
||||
|
||||
// The exact inverse. Total over [0, jsontx_max_time] and injective, so sfTime
|
||||
// and its ISO spelling are two views of one value and the delta carries
|
||||
// nothing for the field.
|
||||
static std::string
|
||||
jsontx_iso_str(std::uint64_t ms)
|
||||
{
|
||||
if (ms > jsontx_max_time)
|
||||
throw std::runtime_error("jsontx: Time out of range");
|
||||
std::int64_t const z =
|
||||
static_cast<std::int64_t>(ms / 86400000) + jsontx_epoch_day + 719468;
|
||||
unsigned const tod = static_cast<unsigned>(ms / 1000 % 86400);
|
||||
std::int64_t const era = (z >= 0 ? z : z - 146096) / 146097;
|
||||
unsigned const doe = static_cast<unsigned>(z - era * 146097);
|
||||
unsigned const yoe = (doe - doe / 1460 + doe / 36524 - doe / 146096) / 365;
|
||||
unsigned const doy = doe - (365 * yoe + yoe / 4 - yoe / 100);
|
||||
unsigned const mp = (5 * doy + 2) / 153;
|
||||
unsigned const d = doy - (153 * mp + 2) / 5 + 1;
|
||||
unsigned const m = mp + (mp < 10 ? 3 : -9);
|
||||
return fmt::format(
|
||||
"{:04}-{:02}-{:02}T{:02}:{:02}:{:02}.{:03}Z",
|
||||
static_cast<std::int64_t>(yoe) + era * 400 + (m <= 2),
|
||||
m,
|
||||
d,
|
||||
tod / 3600,
|
||||
tod / 60 % 60,
|
||||
tod % 60,
|
||||
static_cast<unsigned>(ms % 1000));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// jsoncpp compatibility
|
||||
//
|
||||
// This is xrpl's vendored jsoncpp, which predates JSON_HAS_INT64: Json::Int is
|
||||
// int and Json::UInt is unsigned int, both 32 bit, and there is no isInt64 /
|
||||
// asInt64 / asUInt64. Reader::decodeNumber yields intValue or uintValue only
|
||||
// while the digits fit in 32 bits; on overflow, and for any token carrying a
|
||||
// '.' or an exponent, it falls through to decodeDouble and the number arrives
|
||||
// as a realValue.
|
||||
//
|
||||
// So a large integer is not lost, but it is no longer held as an integer, and
|
||||
// the digits the signer wrote are recoverable only while the double is an
|
||||
// exact integer view of them. That holds to 2^53; above it consecutive doubles
|
||||
// are more than 1 apart and distinct decimal integers collapse onto the same
|
||||
// double. Past that point the value is refused rather than guessed at.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
static constexpr double jsontx_exact_max = 9007199254740992.0; // 2^53
|
||||
|
||||
// Exact integer view of a json number. False if v is not a number at all, or
|
||||
// is one this build cannot reproduce digit for digit.
|
||||
static bool
|
||||
jsontx_exact(Json::Value const& v, std::int64_t& out)
|
||||
{
|
||||
switch (v.type())
|
||||
{
|
||||
case Json::intValue:
|
||||
out = v.asInt();
|
||||
return true;
|
||||
case Json::uintValue:
|
||||
out = static_cast<std::int64_t>(v.asUInt());
|
||||
return true;
|
||||
case Json::realValue:
|
||||
break;
|
||||
default: // including booleanValue, which isIntegral() would admit
|
||||
return false;
|
||||
}
|
||||
double const d = v.asDouble();
|
||||
if (!std::isfinite(d) || d != std::trunc(d) || d < -jsontx_exact_max ||
|
||||
d > jsontx_exact_max)
|
||||
return false;
|
||||
out = static_cast<std::int64_t>(d);
|
||||
return true;
|
||||
}
|
||||
|
||||
// STI_UINT64 renders as a fixed 16 digit hex string and so needs the value
|
||||
// unsigned. A negative is refused rather than wrapped: the old
|
||||
// static_cast<std::uint64_t>(v.asDouble()) was undefined for a negative or
|
||||
// oversized double, and a silent wrap would let -1 and 18446744073709551615
|
||||
// canonicalize to the same bytes.
|
||||
static std::uint64_t
|
||||
jsontx_u64(Json::Value const& v)
|
||||
{
|
||||
std::int64_t n = 0;
|
||||
if (!jsontx_exact(v, n) || n < 0)
|
||||
throw std::runtime_error(
|
||||
"jsontx: UInt64 must be an exact non-negative integer");
|
||||
return static_cast<std::uint64_t>(n);
|
||||
}
|
||||
|
||||
// Renders a javascript number as an exact integer. Anything this build cannot
|
||||
// reproduce digit for digit - a fraction, an infinity, a magnitude past 2^53 -
|
||||
// is rejected outright: shortest-round-trip rendering of a double is not
|
||||
// portable enough to sit in a consensus preimage, and nothing in a transaction
|
||||
// needs one. Fractional amounts arrive as strings, which is what the ledger
|
||||
// wants anyway.
|
||||
static std::string
|
||||
jsontx_num(Json::Value const& v)
|
||||
{
|
||||
std::int64_t n = 0;
|
||||
if (!jsontx_exact(v, n))
|
||||
throw std::runtime_error("jsontx: number must be an exact integer");
|
||||
return std::to_string(n);
|
||||
}
|
||||
|
||||
// Returns { sanitized, diff }. `sanitized` is the canonical form: whitespace
|
||||
// stripped, field names capitalized to their xahau spelling, members reordered
|
||||
// by field code, numbers reformatted per field type. `diff` is a binary delta
|
||||
// which, applied to `sanitized` by unsanitize_jsontx, reproduces `raw` byte for
|
||||
// byte. Throws on anything it cannot canonicalize.
|
||||
static std::pair<std::string, std::string>
|
||||
sanitize_jsontx(std::string_view raw)
|
||||
{
|
||||
if (raw.size() > jsontx_max_text)
|
||||
throw std::runtime_error("jsontx: document too large");
|
||||
|
||||
Json::Value jv;
|
||||
if (Json::Reader r; !r.parse(raw.data(), raw.data() + raw.size(), jv) ||
|
||||
!jv.isObject())
|
||||
throw std::runtime_error("jsontx: malformed json");
|
||||
|
||||
// (a plain recursive lambda; deducing-this would drop the std::function)
|
||||
std::function<
|
||||
void(Json::Value const&, SerializedTypeID, SField const*, std::string&)>
|
||||
emit = [&](Json::Value const& v,
|
||||
SerializedTypeID ty,
|
||||
SField const* fld,
|
||||
std::string& o) {
|
||||
if (v.isObject())
|
||||
{
|
||||
auto keys = v.getMemberNames();
|
||||
o += '{';
|
||||
if (ty == STI_OBJECT) // keys are xahau fields
|
||||
{
|
||||
std::vector<std::pair<SField const*, std::string>> ks;
|
||||
for (auto const& k : keys)
|
||||
{
|
||||
auto const& f = jsontx_field(k);
|
||||
if (f == sfInvalid)
|
||||
throw std::runtime_error(
|
||||
"jsontx: unknown field '" + k + "'");
|
||||
ks.emplace_back(&f, k);
|
||||
}
|
||||
std::sort(
|
||||
ks.begin(), ks.end(), [](auto const& a, auto const& b) {
|
||||
return a.first->fieldCode < b.first->fieldCode;
|
||||
});
|
||||
for (std::size_t n = 0; n < ks.size(); ++n)
|
||||
{
|
||||
auto const& [f, k] = ks[n];
|
||||
if (n && f == ks[n - 1].first) // e.g. "Fee" and "fee"
|
||||
throw std::runtime_error(
|
||||
"jsontx: duplicate field '" + f->fieldName +
|
||||
"'");
|
||||
if (o.back() != '{')
|
||||
o += ',';
|
||||
o += Json::valueToQuotedString(f->fieldName.c_str()) +
|
||||
':';
|
||||
emit(v[k], f->fieldType, f, o);
|
||||
}
|
||||
}
|
||||
else // amount / issue style subobject: lexicographic, quoted
|
||||
{
|
||||
std::sort(keys.begin(), keys.end());
|
||||
for (auto const& k : keys)
|
||||
{
|
||||
if (o.back() != '{')
|
||||
o += ',';
|
||||
o += Json::valueToQuotedString(k.c_str()) + ':';
|
||||
emit(v[k], STI_NOTPRESENT, nullptr, o);
|
||||
}
|
||||
}
|
||||
o += '}';
|
||||
}
|
||||
else if (v.isArray())
|
||||
{
|
||||
o += '[';
|
||||
for (auto const& e : v)
|
||||
{
|
||||
if (o.back() != '[')
|
||||
o += ',';
|
||||
emit(e, STI_OBJECT, nullptr, o);
|
||||
}
|
||||
o += ']';
|
||||
}
|
||||
else if (v.isString())
|
||||
{
|
||||
// Time is spelled Date().toISOString() in the preimage and
|
||||
// stored as an sfTime u64 of milliseconds. Re-emitting the
|
||||
// round-tripped spelling rather than the input is what makes
|
||||
// the canonical form a fixed point: any string that is not
|
||||
// exactly what jsontx_iso_str produces is rejected here.
|
||||
if (fld && *fld == sfTime)
|
||||
o += Json::valueToQuotedString(
|
||||
jsontx_iso_str(jsontx_iso(v.asString())).c_str());
|
||||
else
|
||||
o += Json::valueToQuotedString(v.asCString());
|
||||
}
|
||||
else if (v.isBool())
|
||||
o += v.asBool() ? "true" : "false";
|
||||
else if (v.isNull())
|
||||
throw std::runtime_error("jsontx: null value");
|
||||
else if (ty == STI_UINT8 || ty == STI_UINT16 || ty == STI_UINT32)
|
||||
o += jsontx_num(v); // small ints stay bare
|
||||
else if (ty == STI_UINT64)
|
||||
o += '"' + fmt::format("{:016X}", jsontx_u64(v)) + '"';
|
||||
else // amounts, u64, everything else the ledger wants as a string
|
||||
o += Json::valueToQuotedString(jsontx_num(v).c_str());
|
||||
};
|
||||
|
||||
std::string out;
|
||||
emit(jv, STI_OBJECT, nullptr, out);
|
||||
|
||||
// Greedy copy/insert delta over `raw`, sourcing from `out`.
|
||||
// op 0x00 <varint len> <bytes> literal
|
||||
// op 0x01 <varint off> <varint len> copy from sanitized
|
||||
std::string diff, lit;
|
||||
auto const gram = [](std::string_view s, std::size_t i) {
|
||||
return std::uint32_t(std::uint8_t(s[i])) << 24 |
|
||||
std::uint32_t(std::uint8_t(s[i + 1])) << 16 |
|
||||
std::uint32_t(std::uint8_t(s[i + 2])) << 8 |
|
||||
std::uint32_t(std::uint8_t(s[i + 3]));
|
||||
};
|
||||
auto const varint = [](std::string& o, std::uint64_t v) {
|
||||
do
|
||||
{
|
||||
std::uint8_t const c = v & 0x7F;
|
||||
v >>= 7;
|
||||
o += static_cast<char>(c | (v ? 0x80 : 0));
|
||||
} while (v);
|
||||
};
|
||||
auto const flush = [&] {
|
||||
if (lit.empty())
|
||||
return;
|
||||
diff += char(0);
|
||||
varint(diff, lit.size());
|
||||
diff += lit;
|
||||
lit.clear();
|
||||
};
|
||||
|
||||
// This encoder is normative - unsanitize_jsontx only accepts its exact
|
||||
// output - so it must emit identical bytes on every node and every stdlib.
|
||||
// An unordered container would not: bucket order for equal keys is
|
||||
// unspecified, and with a candidate cap that changes which match wins.
|
||||
std::map<std::uint32_t, std::vector<std::uint32_t>> idx;
|
||||
for (std::size_t i = 0; i + jsontx_min_copy <= out.size(); ++i)
|
||||
idx[gram(out, i)].push_back(i);
|
||||
|
||||
for (std::size_t i = 0; i < raw.size();)
|
||||
{
|
||||
std::size_t bo = 0, bl = 0;
|
||||
if (i + jsontx_min_copy <= raw.size())
|
||||
if (auto const it = idx.find(gram(raw, i)); it != idx.end())
|
||||
{
|
||||
std::size_t tried = 0;
|
||||
for (auto const off : it->second) // ascending, so ties keep
|
||||
{ // the lowest offset
|
||||
if (++tried > jsontx_max_cand)
|
||||
break;
|
||||
std::size_t l = 0;
|
||||
while (i + l < raw.size() && off + l < out.size() &&
|
||||
out[off + l] == raw[i + l])
|
||||
++l;
|
||||
if (l > bl)
|
||||
bl = l, bo = off;
|
||||
}
|
||||
}
|
||||
if (bl >= jsontx_min_copy)
|
||||
{
|
||||
flush();
|
||||
diff += char(1);
|
||||
varint(diff, bo);
|
||||
varint(diff, bl);
|
||||
i += bl;
|
||||
}
|
||||
else
|
||||
lit += raw[i++];
|
||||
}
|
||||
flush();
|
||||
|
||||
return {std::move(out), std::move(diff)};
|
||||
}
|
||||
|
||||
// Applies an UNTRUSTED delta to a canonical form the node derived itself.
|
||||
// Copies read only from `sanitized`, never from the output being built, so a
|
||||
// short delta cannot expand geometrically. Offsets and lengths are range
|
||||
// checked before use, varints are length- and minimality-bounded, and the two
|
||||
// encodings the encoder can never emit - an unmerged literal run, and a copy
|
||||
// abutting the previous copy in the source - are rejected. Throws on anything
|
||||
// else.
|
||||
static std::string
|
||||
unsanitize_jsontx(std::string_view sanitized, std::string_view diff)
|
||||
{
|
||||
if (sanitized.size() > jsontx_max_text || diff.size() > jsontx_max_diff)
|
||||
throw std::runtime_error("jsontx: oversize delta input");
|
||||
|
||||
std::string out;
|
||||
std::size_t p = 0, ops = 0, prevEnd = 0;
|
||||
int prev = -1;
|
||||
|
||||
auto const varint = [&](std::uint64_t max) -> std::uint64_t {
|
||||
std::uint64_t v = 0;
|
||||
for (int s = 0; s <= 21; s += 7) // four bytes; caps far under a shift
|
||||
{ // wide enough to be undefined
|
||||
if (p >= diff.size())
|
||||
throw std::runtime_error("jsontx: truncated delta");
|
||||
std::uint8_t const c = diff[p++];
|
||||
v |= std::uint64_t(c & 0x7F) << s;
|
||||
if (c & 0x80)
|
||||
continue;
|
||||
if (s && !(c & 0x7F))
|
||||
throw std::runtime_error("jsontx: non-minimal varint");
|
||||
if (v > max)
|
||||
throw std::runtime_error("jsontx: delta value out of range");
|
||||
return v;
|
||||
}
|
||||
throw std::runtime_error("jsontx: overlong varint");
|
||||
};
|
||||
|
||||
while (p < diff.size())
|
||||
{
|
||||
if (++ops > jsontx_max_ops)
|
||||
throw std::runtime_error("jsontx: too many delta ops");
|
||||
|
||||
std::uint8_t const op = diff[p++];
|
||||
if (op > 1)
|
||||
throw std::runtime_error("jsontx: unknown delta op");
|
||||
|
||||
std::size_t n = 0;
|
||||
if (op == 0) // literal
|
||||
{
|
||||
if (prev == 0)
|
||||
throw std::runtime_error("jsontx: unmerged literal run");
|
||||
n = varint(jsontx_max_text);
|
||||
if (n == 0 || n > diff.size() - p)
|
||||
throw std::runtime_error("jsontx: bad literal length");
|
||||
if (out.size() + n > jsontx_max_text)
|
||||
throw std::runtime_error("jsontx: delta expands too far");
|
||||
out += diff.substr(p, n);
|
||||
p += n;
|
||||
}
|
||||
else // copy from the canonical form
|
||||
{
|
||||
auto const off = varint(sanitized.size());
|
||||
n = varint(sanitized.size() - off);
|
||||
if (n < jsontx_min_copy)
|
||||
throw std::runtime_error("jsontx: undersize copy");
|
||||
if (prev == 1 && off == prevEnd)
|
||||
throw std::runtime_error("jsontx: unmerged copy run");
|
||||
if (out.size() + n > jsontx_max_text)
|
||||
throw std::runtime_error("jsontx: delta expands too far");
|
||||
out += sanitized.substr(off, n);
|
||||
prevEnd = off + n;
|
||||
}
|
||||
prev = op;
|
||||
}
|
||||
|
||||
if (out.empty())
|
||||
throw std::runtime_error("jsontx: empty delta");
|
||||
return out;
|
||||
}
|
||||
|
||||
// The complete untrusted-side check, in one place so the RPC path and the
|
||||
// relay/consensus path cannot drift. Takes the transaction exactly as it came
|
||||
// off the wire and returns the reconstructed preimage.
|
||||
static std::string
|
||||
jsontx_verify(STTx const& stx, std::string_view diff)
|
||||
{
|
||||
if (!stx.isFieldPresent(sfTxnSignature) || stx.isFieldPresent(sfSigners))
|
||||
throw std::runtime_error("jsontx: expects a lone TxnSignature");
|
||||
|
||||
// Out comes everything the signer did not have in front of them: the
|
||||
// signature, and (once the field exists) the delta carrier. SigningPubKey
|
||||
// stays. It being inside the preimage is what binds key to signature and
|
||||
// stops a third party re-signing a captured preimage under their own key.
|
||||
auto txj = stx.STObject::getJson(JsonOptions::none);
|
||||
txj.removeMember(sfTxnSignature.fieldName);
|
||||
|
||||
// sfTime is a u64 of milliseconds on the wire and an ISO 8601 instant in
|
||||
// the preimage. The two are a bijection over the representable range, so
|
||||
// this is a rewrite rather than a reconstruction and the delta carries
|
||||
// nothing for the field.
|
||||
if (stx.isFieldPresent(sfTime))
|
||||
txj[sfTime.fieldName] = jsontx_iso_str(stx.getFieldU64(sfTime));
|
||||
|
||||
auto const pkb = stx.getSigningPubKey();
|
||||
if (publicKeyType(makeSlice(pkb)) != KeyType::ed25519)
|
||||
throw std::runtime_error("jsontx: SigningPubKey must be ed25519");
|
||||
|
||||
// canonical form, derived only from data the node has already validated
|
||||
auto const san = sanitize_jsontx(Json::FastWriter{}.write(txj)).first;
|
||||
|
||||
// reconstruct the signed preimage under the caps above
|
||||
auto const raw = unsanitize_jsontx(san, diff);
|
||||
|
||||
// Bind the preimage to the transaction. This is the load-bearing check,
|
||||
// not a sanity check: a delta of pure literals can reconstruct ANY text,
|
||||
// so without it any ed25519 signature the key ever produced over anything
|
||||
// at all would authorise this transaction. Comparing the delta too - not
|
||||
// just the canonical form - makes the delta a pure function of the
|
||||
// preimage, which rules out a second delta reconstructing the same bytes
|
||||
// and yielding a second valid transaction id.
|
||||
auto const [san2, diff2] = sanitize_jsontx(raw);
|
||||
if (san2 != san || diff2 != diff)
|
||||
throw std::runtime_error("jsontx: preimage does not match transaction");
|
||||
|
||||
if (!verify(
|
||||
PublicKey(makeSlice(pkb)),
|
||||
makeSlice(raw),
|
||||
makeSlice(stx.getFieldVL(sfTxnSignature))))
|
||||
throw std::runtime_error("jsontx: signature does not verify");
|
||||
|
||||
return raw;
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
#endif
|
||||
@@ -34,7 +34,7 @@
|
||||
// If you add an amendment here, then do not forget to increment `numFeatures`
|
||||
// in include/xrpl/protocol/Feature.h.
|
||||
|
||||
XRPL_FEATURE(JsonTx, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (HookMemoryMissing, Supported::yes, VoteBehavior::DefaultYes)
|
||||
XRPL_FIX (HookMap, Supported::yes, VoteBehavior::DefaultYes)
|
||||
XRPL_FIX (GuardDepth32, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(NamedHooks, Supported::yes, VoteBehavior::DefaultNo)
|
||||
|
||||
@@ -153,7 +153,6 @@ TYPED_SFIELD(sfOutstandingAmount, UINT64, 25, SField::sMD_BaseTen|SFie
|
||||
TYPED_SFIELD(sfMPTAmount, UINT64, 26, SField::sMD_BaseTen|SField::sMD_Default)
|
||||
TYPED_SFIELD(sfIssuerNode, UINT64, 27)
|
||||
TYPED_SFIELD(sfSubjectNode, UINT64, 28)
|
||||
TYPED_SFIELD(sfTime, UINT64, 96)
|
||||
TYPED_SFIELD(sfTouchCount, UINT64, 97)
|
||||
TYPED_SFIELD(sfAccountIndex, UINT64, 98)
|
||||
TYPED_SFIELD(sfAccountCount, UINT64, 99)
|
||||
@@ -294,7 +293,6 @@ TYPED_SFIELD(sfAssetClass, VL, 29)
|
||||
TYPED_SFIELD(sfProvider, VL, 30)
|
||||
TYPED_SFIELD(sfMPTokenMetadata, VL, 31)
|
||||
TYPED_SFIELD(sfCredentialType, VL, 32)
|
||||
TYPED_SFIELD(sfJsonTxDelta, VL, 96)
|
||||
TYPED_SFIELD(sfHookName, VL, 97)
|
||||
TYPED_SFIELD(sfRemarkValue, VL, 98)
|
||||
TYPED_SFIELD(sfRemarkName, VL, 99)
|
||||
|
||||
@@ -630,7 +630,6 @@ JSS(server_status); // out: NetworkOPs
|
||||
JSS(server_version); // out: NetworkOPs
|
||||
JSS(settle_delay); // out: AccountChannels
|
||||
JSS(severity); // in: LogLevel
|
||||
JSS(sig);
|
||||
JSS(signature); // out: NetworkOPs, ChannelAuthorize
|
||||
JSS(signature_verified); // out: ChannelVerify
|
||||
JSS(signing_key); // out: NetworkOPs
|
||||
|
||||
@@ -49,8 +49,6 @@ TxFormats::TxFormats()
|
||||
{sfNetworkID, soeOPTIONAL},
|
||||
{sfHookParameters, soeOPTIONAL},
|
||||
{sfHookName, soeOPTIONAL},
|
||||
{sfTime, soeOPTIONAL},
|
||||
{sfJsonTxDelta, soeOPTIONAL},
|
||||
};
|
||||
|
||||
#pragma push_macro("UNWRAP")
|
||||
|
||||
@@ -3081,6 +3081,100 @@ public:
|
||||
ter(temMALFORMED));
|
||||
}
|
||||
|
||||
void
|
||||
testWasmMissingMemory(FeatureBitset features)
|
||||
{
|
||||
testcase("missing memory");
|
||||
using namespace jtx;
|
||||
|
||||
auto const alice = Account{"alice"};
|
||||
auto const bob = Account{"bob"};
|
||||
auto const carol = Account{"carol"};
|
||||
|
||||
TestHook missing_memory_wasm = wasm[R"[test.hook](
|
||||
(module
|
||||
(type $rollback_type
|
||||
(func (param i32 i32 i64) (result i64)))
|
||||
(type $guard_type (func (param i32 i32) (result i32)))
|
||||
(type $hook_type (func (param i32) (result i64)))
|
||||
(import "env" "rollback"
|
||||
(func $rollback (type $rollback_type)))
|
||||
(import "env" "_g" (func $_g (type $guard_type)))
|
||||
(func $hook (type $hook_type) (param i32) (result i64)
|
||||
i32.const 1
|
||||
i32.const 1
|
||||
i64.const 0
|
||||
call $rollback
|
||||
drop
|
||||
i32.const 1
|
||||
i32.const 1
|
||||
call $_g
|
||||
drop
|
||||
i64.const 0)
|
||||
(export "hook" (func $hook)))
|
||||
)[test.hook]"];
|
||||
|
||||
for (auto const& withFix : {false, true})
|
||||
{
|
||||
// test if the Hook is created before the Amendment is enabled
|
||||
Env env{*this, features - fixHookMemoryMissing};
|
||||
env.fund(XRP(10000), alice, bob, carol);
|
||||
|
||||
env(ripple::test::jtx::hook(alice, {{hso(missing_memory_wasm)}}, 0),
|
||||
M("Install missing memory hook"),
|
||||
HSFEE);
|
||||
env.close();
|
||||
|
||||
if (withFix)
|
||||
{
|
||||
env.enableFeature(fixHookMemoryMissing);
|
||||
env.close();
|
||||
}
|
||||
|
||||
env(pay(bob, alice, XRP(1)),
|
||||
M("Test missing memory hook"),
|
||||
fee(XRP(1)),
|
||||
ter(tecHOOK_REJECTED));
|
||||
|
||||
auto meta = env.meta();
|
||||
BEAST_REQUIRE(meta);
|
||||
BEAST_REQUIRE(meta->isFieldPresent(sfHookExecutions));
|
||||
|
||||
auto const& hookExecutions = meta->getFieldArray(sfHookExecutions);
|
||||
BEAST_REQUIRE(hookExecutions.size() == 1);
|
||||
auto const& e = hookExecutions[0];
|
||||
|
||||
auto const expectedExitType = withFix
|
||||
? hook_api::ExitType::WASM_ERROR
|
||||
: hook_api::ExitType::UNSET;
|
||||
BEAST_EXPECT(
|
||||
e.getFieldU8(sfHookResult) ==
|
||||
static_cast<uint8_t>(expectedExitType));
|
||||
BEAST_EXPECT(e.getFieldVL(sfHookReturnString).size() == 0);
|
||||
BEAST_EXPECT(
|
||||
e.getFieldU64(sfHookReturnCode) ==
|
||||
0x8000000000000001 /* INTERNAL_ERROR */);
|
||||
}
|
||||
|
||||
for (auto const& withFix : {false, true})
|
||||
{
|
||||
// test if the Hook is created after the Amendment is enabled
|
||||
auto f = features - fixHookMemoryMissing;
|
||||
if (withFix)
|
||||
f = f | fixHookMemoryMissing;
|
||||
Env env{*this, f};
|
||||
env.fund(XRP(10000), alice, bob, carol);
|
||||
|
||||
auto const expectedTer =
|
||||
withFix ? TER{temMALFORMED} : TER{tesSUCCESS};
|
||||
env(ripple::test::jtx::hook(alice, {{hso(missing_memory_wasm)}}, 0),
|
||||
M("Install missing memory hook"),
|
||||
HSFEE,
|
||||
ter(expectedTer));
|
||||
env.close();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_accept(FeatureBitset features)
|
||||
{
|
||||
@@ -15077,6 +15171,8 @@ public:
|
||||
void
|
||||
testWithFeatures(FeatureBitset features)
|
||||
{
|
||||
testWasmMissingMemory(features);
|
||||
return;
|
||||
testHooksOwnerDir(features);
|
||||
testHooksDisabled(features);
|
||||
testTxStructure(features);
|
||||
@@ -15103,6 +15199,7 @@ public:
|
||||
testFillCopy(features);
|
||||
|
||||
testWasm(features);
|
||||
testWasmMissingMemory(features);
|
||||
test_accept(features);
|
||||
test_rollback(features);
|
||||
|
||||
|
||||
@@ -191,6 +191,42 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
}},
|
||||
|
||||
/* ==== WASM: 1 ==== */
|
||||
{R"[test.hook](
|
||||
(module
|
||||
(type $rollback_type
|
||||
(func (param i32 i32 i64) (result i64)))
|
||||
(type $guard_type (func (param i32 i32) (result i32)))
|
||||
(type $hook_type (func (param i32) (result i64)))
|
||||
(import "env" "rollback"
|
||||
(func $rollback (type $rollback_type)))
|
||||
(import "env" "_g" (func $_g (type $guard_type)))
|
||||
(func $hook (type $hook_type) (param i32) (result i64)
|
||||
i32.const 1
|
||||
i32.const 1
|
||||
i64.const 0
|
||||
call $rollback
|
||||
drop
|
||||
i32.const 1
|
||||
i32.const 1
|
||||
call $_g
|
||||
drop
|
||||
i64.const 0)
|
||||
(export "hook" (func $hook)))
|
||||
)[test.hook]",
|
||||
{
|
||||
0x00U, 0x61U, 0x73U, 0x6DU, 0x01U, 0x00U, 0x00U, 0x00U, 0x01U, 0x13U,
|
||||
0x03U, 0x60U, 0x03U, 0x7FU, 0x7FU, 0x7EU, 0x01U, 0x7EU, 0x60U, 0x02U,
|
||||
0x7FU, 0x7FU, 0x01U, 0x7FU, 0x60U, 0x01U, 0x7FU, 0x01U, 0x7EU, 0x02U,
|
||||
0x19U, 0x02U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x08U, 0x72U, 0x6FU, 0x6CU,
|
||||
0x6CU, 0x62U, 0x61U, 0x63U, 0x6BU, 0x00U, 0x00U, 0x03U, 0x65U, 0x6EU,
|
||||
0x76U, 0x02U, 0x5FU, 0x67U, 0x00U, 0x01U, 0x03U, 0x02U, 0x01U, 0x02U,
|
||||
0x07U, 0x08U, 0x01U, 0x04U, 0x68U, 0x6FU, 0x6FU, 0x6BU, 0x00U, 0x02U,
|
||||
0x0AU, 0x16U, 0x01U, 0x14U, 0x00U, 0x41U, 0x01U, 0x41U, 0x01U, 0x42U,
|
||||
0x00U, 0x10U, 0x00U, 0x1AU, 0x41U, 0x01U, 0x41U, 0x01U, 0x10U, 0x01U,
|
||||
0x1AU, 0x42U, 0x00U, 0x0BU,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 2 ==== */
|
||||
{R"[test.hook](
|
||||
(module
|
||||
(type (;0;) (func (param i32 i32) (result i64)))
|
||||
@@ -240,7 +276,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x0BU,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 2 ==== */
|
||||
/* ==== WASM: 3 ==== */
|
||||
{R"[test.hook](
|
||||
(module
|
||||
(type (;0;) (func (param i32 i32) (result i64)))
|
||||
@@ -294,7 +330,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x14U, 0x10U, 0x00U, 0x1AU, 0x0CU, 0x00U, 0x0BU, 0x0BU,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 3 ==== */
|
||||
/* ==== WASM: 4 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -361,7 +397,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x80U, 0x80U, 0x00U, 0x20U, 0x02U, 0x0BU,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 4 ==== */
|
||||
/* ==== WASM: 5 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -467,7 +503,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x6AU, 0x24U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x20U, 0x03U, 0x0BU,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 5 ==== */
|
||||
/* ==== WASM: 6 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -542,7 +578,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x6AU, 0x24U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x20U, 0x05U, 0x0BU,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 6 ==== */
|
||||
/* ==== WASM: 7 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g(uint32_t, uint32_t);
|
||||
@@ -1159,7 +1195,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x78U, 0x29U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x33U, 0x32U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 7 ==== */
|
||||
/* ==== WASM: 8 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g(uint32_t, uint32_t);
|
||||
@@ -1588,7 +1624,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 8 ==== */
|
||||
/* ==== WASM: 9 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -1794,7 +1830,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x3DU, 0x20U, 0x30U, 0x78U, 0x45U, 0x31U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 9 ==== */
|
||||
/* ==== WASM: 10 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -1916,7 +1952,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x58U, 0x4EU, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 10 ==== */
|
||||
/* ==== WASM: 11 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -2049,7 +2085,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x4FU, 0x4EU, 0x43U, 0x45U, 0x53U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 11 ==== */
|
||||
/* ==== WASM: 12 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -2129,7 +2165,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x54U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 12 ==== */
|
||||
/* ==== WASM: 13 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -2174,7 +2210,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x30U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 13 ==== */
|
||||
/* ==== WASM: 14 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -2493,7 +2529,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x80U, 0x80U, 0x80U, 0x00U, 0x0BU,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 14 ==== */
|
||||
/* ==== WASM: 15 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -3279,7 +3315,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x37U, 0x36U, 0x33U, 0x4CU, 0x4CU, 0x20U, 0x29U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 15 ==== */
|
||||
/* ==== WASM: 16 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -3669,7 +3705,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x80U, 0x80U, 0x80U, 0x00U, 0x0BU,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 16 ==== */
|
||||
/* ==== WASM: 17 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -3850,7 +3886,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x38U, 0x4CU, 0x4CU, 0x29U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 17 ==== */
|
||||
/* ==== WASM: 18 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -4039,7 +4075,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x29U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 18 ==== */
|
||||
/* ==== WASM: 19 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -4278,7 +4314,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x00U, 0x42U, 0x00U, 0x10U, 0x85U, 0x80U, 0x80U, 0x80U, 0x00U, 0x0BU,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 19 ==== */
|
||||
/* ==== WASM: 20 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -4980,7 +5016,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x38U, 0x35U, 0x35U, 0x32U, 0x55U, 0x29U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 20 ==== */
|
||||
/* ==== WASM: 21 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -6325,7 +6361,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x20U, 0x29U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 21 ==== */
|
||||
/* ==== WASM: 22 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -6427,7 +6463,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x84U, 0x80U, 0x80U, 0x80U, 0x00U, 0x0BU,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 22 ==== */
|
||||
/* ==== WASM: 23 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -6470,7 +6506,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x00U, 0x0BU,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 23 ==== */
|
||||
/* ==== WASM: 24 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -6618,7 +6654,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x34U, 0x34U, 0x4CU, 0x4CU, 0x2CU, 0x20U, 0x33U, 0x29U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 24 ==== */
|
||||
/* ==== WASM: 25 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -6946,7 +6982,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x38U, 0x34U, 0x39U, 0x30U, 0x4CU, 0x4CU, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 25 ==== */
|
||||
/* ==== WASM: 26 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -7151,7 +7187,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x10U, 0x85U, 0x80U, 0x80U, 0x80U, 0x00U, 0x0BU,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 26 ==== */
|
||||
/* ==== WASM: 27 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -7835,7 +7871,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x20U, 0x3DU, 0x3DU, 0x20U, 0x30U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 27 ==== */
|
||||
/* ==== WASM: 28 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -8130,7 +8166,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x32U, 0x34U, 0x31U, 0x36U, 0x55U, 0x4CU, 0x4CU, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 28 ==== */
|
||||
/* ==== WASM: 29 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -8843,7 +8879,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x31U, 0x33U, 0x33U, 0x38U, 0x20U, 0x29U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 29 ==== */
|
||||
/* ==== WASM: 30 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -8928,7 +8964,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x30U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x32U, 0x30U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 30 ==== */
|
||||
/* ==== WASM: 31 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -8990,7 +9026,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x80U, 0x80U, 0x00U, 0x0BU,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 31 ==== */
|
||||
/* ==== WASM: 32 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -9067,7 +9103,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x31U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x33U, 0x32U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 32 ==== */
|
||||
/* ==== WASM: 33 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -9144,7 +9180,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x31U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x33U, 0x32U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 33 ==== */
|
||||
/* ==== WASM: 34 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -9401,7 +9437,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x00U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 34 ==== */
|
||||
/* ==== WASM: 35 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -9559,7 +9595,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x04U, 0x00U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 35 ==== */
|
||||
/* ==== WASM: 36 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -9912,7 +9948,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x00U, 0x2AU, 0x04U, 0x00U, 0x00U, 0x31U, 0x04U, 0x00U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 36 ==== */
|
||||
/* ==== WASM: 37 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -9945,7 +9981,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x20U, 0x01U, 0x0BU,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 37 ==== */
|
||||
/* ==== WASM: 38 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -10172,7 +10208,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 38 ==== */
|
||||
/* ==== WASM: 39 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -10203,7 +10239,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x80U, 0x80U, 0x00U, 0x1AU, 0x20U, 0x01U, 0x0BU,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 39 ==== */
|
||||
/* ==== WASM: 40 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -10514,7 +10550,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 40 ==== */
|
||||
/* ==== WASM: 41 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -10591,7 +10627,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x33U, 0x32U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 41 ==== */
|
||||
/* ==== WASM: 42 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -10625,7 +10661,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x80U, 0x80U, 0x00U, 0x1AU, 0x20U, 0x01U, 0x0BU,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 42 ==== */
|
||||
/* ==== WASM: 43 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -10712,7 +10748,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x32U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 43 ==== */
|
||||
/* ==== WASM: 44 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -10746,7 +10782,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x0BU,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 44 ==== */
|
||||
/* ==== WASM: 45 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -10886,7 +10922,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x54U, 0x5FU, 0x4DU, 0x45U, 0x54U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 45 ==== */
|
||||
/* ==== WASM: 46 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -11076,7 +11112,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x31U, 0x34U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 46 ==== */
|
||||
/* ==== WASM: 47 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -11230,7 +11266,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 47 ==== */
|
||||
/* ==== WASM: 48 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -11391,7 +11427,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 48 ==== */
|
||||
/* ==== WASM: 49 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -11548,7 +11584,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x53U, 0x4CU, 0x4FU, 0x54U, 0x53U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 49 ==== */
|
||||
/* ==== WASM: 50 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -11633,7 +11669,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x74U, 0x79U, 0x70U, 0x65U, 0x28U, 0x29U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 50 ==== */
|
||||
/* ==== WASM: 51 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -11890,7 +11926,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x00U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 51 ==== */
|
||||
/* ==== WASM: 52 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -12128,7 +12164,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x3EU, 0x20U, 0x30U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 52 ==== */
|
||||
/* ==== WASM: 53 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -12224,7 +12260,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x53U, 0x54U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 53 ==== */
|
||||
/* ==== WASM: 54 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -12334,7 +12370,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x20U, 0x31U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 54 ==== */
|
||||
/* ==== WASM: 55 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -12464,7 +12500,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x30U, 0x30U, 0x30U, 0x4CU, 0x4CU, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 55 ==== */
|
||||
/* ==== WASM: 56 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -12738,7 +12774,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x30U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 56 ==== */
|
||||
/* ==== WASM: 57 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -12875,7 +12911,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x2CU, 0x20U, 0x73U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x31U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 57 ==== */
|
||||
/* ==== WASM: 58 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -13169,7 +13205,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x5FU, 0x53U, 0x4CU, 0x4FU, 0x54U, 0x53U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 58 ==== */
|
||||
/* ==== WASM: 59 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -13403,7 +13439,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x5FU, 0x53U, 0x4CU, 0x4FU, 0x54U, 0x53U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 59 ==== */
|
||||
/* ==== WASM: 60 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -13699,7 +13735,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x2CU, 0x20U, 0x31U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x30U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 60 ==== */
|
||||
/* ==== WASM: 61 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -13903,7 +13939,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x6EU, 0x74U, 0x32U, 0x22U, 0x20U, 0x2BU, 0x20U, 0x69U, 0x29U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 61 ==== */
|
||||
/* ==== WASM: 62 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -14020,7 +14056,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x69U, 0x29U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 62 ==== */
|
||||
/* ==== WASM: 63 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -14129,7 +14165,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x6EU, 0x74U, 0x65U, 0x6EU, 0x74U, 0x32U, 0x22U, 0x29U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 63 ==== */
|
||||
/* ==== WASM: 64 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -14402,7 +14438,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 64 ==== */
|
||||
/* ==== WASM: 65 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
#define sfInvoiceID ((5U << 16U) + 17U)
|
||||
@@ -14621,7 +14657,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x30U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x33U, 0x32U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 65 ==== */
|
||||
/* ==== WASM: 66 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -14733,7 +14769,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x58U, 0x49U, 0x53U, 0x54U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 66 ==== */
|
||||
/* ==== WASM: 67 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
#define sfInvoiceID ((5U << 16U) + 17U)
|
||||
@@ -14869,7 +14905,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x3DU, 0x20U, 0x33U, 0x32U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 67 ==== */
|
||||
/* ==== WASM: 68 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -15005,7 +15041,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x49U, 0x47U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 68 ==== */
|
||||
/* ==== WASM: 69 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -15144,7 +15180,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x66U, 0x28U, 0x64U, 0x61U, 0x74U, 0x61U, 0x32U, 0x29U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 69 ==== */
|
||||
/* ==== WASM: 70 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -15256,7 +15292,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x30U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 70 ==== */
|
||||
/* ==== WASM: 71 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -15350,7 +15386,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x61U, 0x64U, 0x5BU, 0x69U, 0x5DU, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 71 ==== */
|
||||
/* ==== WASM: 72 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -15483,7 +15519,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x64U, 0x5BU, 0x69U, 0x5DU, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 72 ==== */
|
||||
/* ==== WASM: 73 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -15571,7 +15607,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x61U, 0x74U, 0x61U, 0x29U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 73 ==== */
|
||||
/* ==== WASM: 74 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
#define sfInvoiceID ((5U << 16U) + 17U)
|
||||
@@ -15682,7 +15718,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x20U, 0x33U, 0x32U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 74 ==== */
|
||||
/* ==== WASM: 75 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -15893,7 +15929,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 75 ==== */
|
||||
/* ==== WASM: 76 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -16001,7 +16037,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x20U, 0x22U, 0x32U, 0x22U, 0x2CU, 0x20U, 0x31U, 0x29U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 76 ==== */
|
||||
/* ==== WASM: 77 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -16613,7 +16649,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 77 ==== */
|
||||
/* ==== WASM: 78 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -16800,7 +16836,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x63U, 0x65U, 0x29U, 0x20U, 0x3EU, 0x20U, 0x30U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 78 ==== */
|
||||
/* ==== WASM: 79 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -17150,7 +17186,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x20U, 0x30U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 79 ==== */
|
||||
/* ==== WASM: 80 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -17286,7 +17322,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 80 ==== */
|
||||
/* ==== WASM: 81 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -17345,7 +17381,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x64U, 0xE1U, 0xF1U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 81 ==== */
|
||||
/* ==== WASM: 82 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -17518,7 +17554,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x54U, 0x5FU, 0x45U, 0x58U, 0x49U, 0x53U, 0x54U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 82 ==== */
|
||||
/* ==== WASM: 83 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -17666,7 +17702,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x30U, 0x00U, 0x22U, 0x00U, 0x00U, 0x00U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 83 ==== */
|
||||
/* ==== WASM: 84 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -17820,7 +17856,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x0FU, 0x0BU, 0x02U, 0x56U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 84 ==== */
|
||||
/* ==== WASM: 85 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -17917,7 +17953,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x3DU, 0x20U, 0x30U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 85 ==== */
|
||||
/* ==== WASM: 86 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -17976,7 +18012,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x4FU, 0x46U, 0x5FU, 0x42U, 0x4FU, 0x55U, 0x4EU, 0x44U, 0x53U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 86 ==== */
|
||||
/* ==== WASM: 87 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -18035,7 +18071,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x4EU, 0x44U, 0x53U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 87 ==== */
|
||||
/* ==== WASM: 88 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -19864,7 +19900,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x53U, 0x4DU, 0x41U, 0x4CU, 0x4CU, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 88 ==== */
|
||||
/* ==== WASM: 89 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -21483,7 +21519,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x29U, 0x29U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 89 ==== */
|
||||
/* ==== WASM: 90 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -24416,7 +24452,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x4FU, 0x4FU, 0x5FU, 0x53U, 0x4DU, 0x41U, 0x4CU, 0x4CU, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 90 ==== */
|
||||
/* ==== WASM: 91 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -26381,7 +26417,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x54U, 0x4FU, 0x4FU, 0x5FU, 0x53U, 0x4DU, 0x41U, 0x4CU, 0x4CU, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 91 ==== */
|
||||
/* ==== WASM: 92 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -26666,7 +26702,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x30U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 92 ==== */
|
||||
/* ==== WASM: 93 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g(uint32_t, uint32_t);
|
||||
@@ -27253,7 +27289,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x4EU, 0x5FU, 0x46U, 0x41U, 0x49U, 0x4CU, 0x55U, 0x52U, 0x45U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 93 ==== */
|
||||
/* ==== WASM: 94 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -27282,7 +27318,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x0BU,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 94 ==== */
|
||||
/* ==== WASM: 95 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -27314,7 +27350,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x20U, 0x52U, 0x65U, 0x6AU, 0x65U, 0x63U, 0x74U, 0x65U, 0x64U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 95 ==== */
|
||||
/* ==== WASM: 96 ==== */
|
||||
{R"[test.hook](
|
||||
(module
|
||||
(type (;0;) (func (param i32 i32 i64) (result i64)))
|
||||
@@ -27341,7 +27377,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x41U, 0x00U, 0x41U, 0x00U, 0x42U, 0x00U, 0x10U, 0x00U, 0x0BU,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 96 ==== */
|
||||
/* ==== WASM: 97 ==== */
|
||||
{R"[test.hook](
|
||||
(module
|
||||
(type (;0;) (func (param i32 i32) (result i32)))
|
||||
@@ -27394,7 +27430,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x00U, 0x1AU, 0x0BU,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 97 ==== */
|
||||
/* ==== WASM: 98 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -34037,7 +34073,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x39U, 0x30U, 0x31U, 0x32U, 0x33U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 98 ==== */
|
||||
/* ==== WASM: 99 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -34083,7 +34119,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x0BU, 0x06U, 0x76U, 0x61U, 0x6CU, 0x75U, 0x65U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 99 ==== */
|
||||
/* ==== WASM: 100 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
@@ -34112,7 +34148,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x0BU,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 100 ==== */
|
||||
/* ==== WASM: 101 ==== */
|
||||
{R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int64_t accept (uint32_t read_ptr, uint32_t read_len, int64_t error_code);
|
||||
|
||||
@@ -26,17 +26,10 @@
|
||||
#include <xrpld/rpc/GRPCHandlers.h>
|
||||
#include <xrpld/rpc/detail/RPCHelpers.h>
|
||||
#include <xrpld/rpc/detail/TransactionSign.h>
|
||||
#include <xrpl/json/json_reader.h>
|
||||
#include <xrpl/json/json_writer.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/PublicKey.h>
|
||||
#include <xrpl/protocol/RPCErr.h>
|
||||
#include <xrpl/protocol/SField.h>
|
||||
#include <xrpl/protocol/STParsedJSON.h>
|
||||
#include <xrpl/resource/Fees.h>
|
||||
|
||||
#include <xrpl/protocol/JSONTxSignatures.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
static NetworkOPs::FailHard
|
||||
@@ -90,8 +83,7 @@ doInject(RPC::JsonContext& context)
|
||||
}
|
||||
|
||||
// {
|
||||
// tx_blob: <string> XOR tx_json: <object>
|
||||
// XOR { tx: <json text>, signature: <hex> },
|
||||
// tx_blob: <string> XOR tx_json: <object>,
|
||||
// secret: <secret>
|
||||
// }
|
||||
Json::Value
|
||||
@@ -99,18 +91,7 @@ doSubmit(RPC::JsonContext& context)
|
||||
{
|
||||
context.loadType = Resource::feeMediumBurdenRPC;
|
||||
|
||||
bool const hasJsonTx = context.ledgerMaster.getCurrentLedger()->rules().enabled(featureJsonTx);
|
||||
|
||||
bool const isJsonTx = !context.params.isMember(jss::tx_blob) &&
|
||||
context.params.isMember(jss::tx) &&
|
||||
context.params.isMember(jss::sig);
|
||||
|
||||
if (isJsonTx && !hasJsonTx)
|
||||
return RPC::make_error(
|
||||
rpcNOT_SUPPORTED, "JsonTx is not enabled yet.");
|
||||
|
||||
|
||||
if (!context.params.isMember(jss::tx_blob) && !isJsonTx)
|
||||
if (!context.params.isMember(jss::tx_blob))
|
||||
{
|
||||
auto const failType = getFailHard(context);
|
||||
|
||||
@@ -138,73 +119,18 @@ doSubmit(RPC::JsonContext& context)
|
||||
|
||||
Json::Value jvResult;
|
||||
|
||||
std::optional<Blob> ret;
|
||||
if (!isJsonTx)
|
||||
{
|
||||
ret = strUnHex(context.params[jss::tx_blob].asString());
|
||||
auto ret = strUnHex(context.params[jss::tx_blob].asString());
|
||||
|
||||
if (!ret || !ret->size())
|
||||
return rpcError(rpcINVALID_PARAMS);
|
||||
}
|
||||
if (!ret || !ret->size())
|
||||
return rpcError(rpcINVALID_PARAMS);
|
||||
|
||||
SerialIter sitTrans(makeSlice(*ret));
|
||||
|
||||
std::shared_ptr<STTx const> stTx;
|
||||
|
||||
try
|
||||
{
|
||||
if (!isJsonTx)
|
||||
{
|
||||
SerialIter sitTrans(makeSlice(*ret));
|
||||
stTx = std::make_shared<STTx const>(std::ref(sitTrans));
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string const raw = context.params[jss::tx].asString();
|
||||
auto const [san, diff] = sanitize_jsontx(raw);
|
||||
auto const sig = strUnHex(context.params[jss::sig].asString());
|
||||
if (!sig || sig->empty())
|
||||
throw std::runtime_error("JsonTx: bad signature");
|
||||
|
||||
Json::Value jv;
|
||||
if (Json::Reader r; !r.parse(san, jv))
|
||||
throw std::runtime_error("JsonTx: unparsable canonical form");
|
||||
|
||||
// The preimage carries the key but not the signature over itself.
|
||||
for (auto const& n :
|
||||
{sfTxnSignature.fieldName, sfSigners.fieldName})
|
||||
if (jv.isMember(n))
|
||||
throw std::runtime_error(
|
||||
"JsonTx: " + n + " must not appear in tx");
|
||||
if (!jv.isMember(sfSigningPubKey.fieldName))
|
||||
throw std::runtime_error("JsonTx: tx must carry SigningPubKey");
|
||||
|
||||
// Hand the parser the u64 rather than teaching STUInt64 a second
|
||||
// spelling; the ISO form only ever exists in the preimage.
|
||||
std::optional<std::uint64_t> ms;
|
||||
if (jv.isMember(sfTime.fieldName))
|
||||
{
|
||||
ms = jsontx_iso(jv[sfTime.fieldName].asString());
|
||||
jv.removeMember(sfTime.fieldName);
|
||||
}
|
||||
|
||||
STParsedJSONObject parsed("tx_json", jv);
|
||||
if (!parsed.object)
|
||||
throw std::runtime_error(
|
||||
parsed.error[jss::error_message].asString());
|
||||
if (ms)
|
||||
parsed.object->setFieldU64(sfTime, *ms);
|
||||
parsed.object->setFieldVL(sfTxnSignature, *sig);
|
||||
stTx = std::make_shared<STTx const>(std::move(*parsed.object));
|
||||
|
||||
// Round-trip the binary codec, then run the exact check a relaying
|
||||
// node will run, so this path cannot accept anything the network
|
||||
// would later reject.
|
||||
Serializer s;
|
||||
stTx->add(s);
|
||||
SerialIter si(s.slice());
|
||||
STTx const rt{si};
|
||||
if (jsontx_verify(rt, diff) != raw)
|
||||
throw std::runtime_error("JsonTx: does not round-trip");
|
||||
}
|
||||
stTx = std::make_shared<STTx const>(std::ref(sitTrans));
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
@@ -215,9 +141,7 @@ doSubmit(RPC::JsonContext& context)
|
||||
}
|
||||
|
||||
{
|
||||
// JsonTx signs the plaintext preimage rather than the binary one, so
|
||||
// the binary TxnSignature check is satisfied out of band above.
|
||||
if (!context.app.checkSigs() || isJsonTx)
|
||||
if (!context.app.checkSigs())
|
||||
forceValidity(
|
||||
context.app.getHashRouter(),
|
||||
stTx->getTransactionID(),
|
||||
|
||||
Reference in New Issue
Block a user