From d582ae79900fdb7de3505baae5ca57684d196eae Mon Sep 17 00:00:00 2001 From: Olek <115580134+oleks-rip@users.noreply.github.com> Date: Wed, 3 Jun 2026 21:53:12 -0400 Subject: [PATCH] HF one entry point (#7393) Add one entry point for all HF for centralized exceptions handling, gas calculation and general checks. Add exception handling for HF Add FieldLocator object Switch pointers to references for HF and runtime Max size for parameters and sfData field is 1 kb now Fix Allhf unittest, to provide correct locator --- include/xrpl/protocol/Protocol.h | 5 +- include/xrpl/tx/wasm/HostFunc.h | 21 +- include/xrpl/tx/wasm/HostFuncImpl.h | 12 +- include/xrpl/tx/wasm/HostFuncWrapper.h | 207 +- include/xrpl/tx/wasm/WasmCommon.h | 51 + include/xrpl/tx/wasm/WasmImportsHelper.h | 15 +- src/libxrpl/tx/wasm/HostFuncImplGetter.cpp | 43 +- src/libxrpl/tx/wasm/HostFuncWrapper.cpp | 924 ++++----- src/libxrpl/tx/wasm/WasmiVM.cpp | 11 +- src/test/app/HostFuncImpl_test.cpp | 1812 +++-------------- src/test/app/TestHostFunctions.h | 27 +- src/test/app/Wasm_test.cpp | 32 +- .../all_host_functions/src/lib.rs | 8 +- src/test/app/wasm_fixtures/fixtures.cpp | 323 ++- src/test/app/wasm_fixtures/float_0/src/lib.rs | 7 - 15 files changed, 1050 insertions(+), 2448 deletions(-) diff --git a/include/xrpl/protocol/Protocol.h b/include/xrpl/protocol/Protocol.h index 512998081e..2e12c7fa55 100644 --- a/include/xrpl/protocol/Protocol.h +++ b/include/xrpl/protocol/Protocol.h @@ -252,10 +252,7 @@ constexpr std::uint8_t kVaultMaximumIouScale = 18; constexpr std::uint8_t kMaxAssetCheckDepth = 5; /** Maximum length of a Data field in Escrow object that can be updated by WASM code. */ -constexpr std::size_t kMaxWasmDataLength = 4 * 1024; // 4KB - -/** Maximum length of parameters passed from WASM code to host functions. */ -constexpr std::size_t kMaxWasmParamLength = 1024; // 1KB +constexpr std::size_t kMaxWasmDataLength = 1 * 1024; // 1KB /** A ledger index. */ using LedgerIndex = std::uint32_t; diff --git a/include/xrpl/tx/wasm/HostFunc.h b/include/xrpl/tx/wasm/HostFunc.h index 3fc974423c..914e9b6ed1 100644 --- a/include/xrpl/tx/wasm/HostFunc.h +++ b/include/xrpl/tx/wasm/HostFunc.h @@ -10,6 +10,9 @@ #include #include +#include +#include + namespace xrpl { namespace wasm_float { @@ -85,12 +88,12 @@ public: rt_ = std::nullopt; } - [[nodiscard]] WasmRuntimeWrapper* + [[nodiscard]] WasmRuntimeWrapper& getRT() const { if (!rt_) - return nullptr; // LCOV_EXCL_LINE - return &rt_->get(); + Throw("Wasm runtime not set"); + return rt_->get(); } [[nodiscard]] beast::Journal @@ -168,19 +171,19 @@ public: } virtual Expected - getTxNestedField(Slice const& locator) const + getTxNestedField(FieldLocator const& locator) const { return Unexpected(HostFunctionError::Internal); } virtual Expected - getCurrentLedgerObjNestedField(Slice const& locator) const + getCurrentLedgerObjNestedField(FieldLocator const& locator) const { return Unexpected(HostFunctionError::Internal); } virtual Expected - getLedgerObjNestedField(int32_t cacheIdx, Slice const& locator) const + getLedgerObjNestedField(int32_t cacheIdx, FieldLocator const& locator) const { return Unexpected(HostFunctionError::Internal); } @@ -204,19 +207,19 @@ public: } virtual Expected - getTxNestedArrayLen(Slice const& locator) const + getTxNestedArrayLen(FieldLocator const& locator) const { return Unexpected(HostFunctionError::Internal); } virtual Expected - getCurrentLedgerObjNestedArrayLen(Slice const& locator) const + getCurrentLedgerObjNestedArrayLen(FieldLocator const& locator) const { return Unexpected(HostFunctionError::Internal); } virtual Expected - getLedgerObjNestedArrayLen(int32_t cacheIdx, Slice const& locator) const + getLedgerObjNestedArrayLen(int32_t cacheIdx, FieldLocator const& locator) const { return Unexpected(HostFunctionError::Internal); } diff --git a/include/xrpl/tx/wasm/HostFuncImpl.h b/include/xrpl/tx/wasm/HostFuncImpl.h index 6741246d08..950856e828 100644 --- a/include/xrpl/tx/wasm/HostFuncImpl.h +++ b/include/xrpl/tx/wasm/HostFuncImpl.h @@ -108,13 +108,13 @@ public: getLedgerObjField(int32_t cacheIdx, SField const& fname) const override; Expected - getTxNestedField(Slice const& locator) const override; + getTxNestedField(FieldLocator const& locator) const override; Expected - getCurrentLedgerObjNestedField(Slice const& locator) const override; + getCurrentLedgerObjNestedField(FieldLocator const& locator) const override; Expected - getLedgerObjNestedField(int32_t cacheIdx, Slice const& locator) const override; + getLedgerObjNestedField(int32_t cacheIdx, FieldLocator const& locator) const override; Expected getTxArrayLen(SField const& fname) const override; @@ -126,13 +126,13 @@ public: getLedgerObjArrayLen(int32_t cacheIdx, SField const& fname) const override; Expected - getTxNestedArrayLen(Slice const& locator) const override; + getTxNestedArrayLen(FieldLocator const& locator) const override; Expected - getCurrentLedgerObjNestedArrayLen(Slice const& locator) const override; + getCurrentLedgerObjNestedArrayLen(FieldLocator const& locator) const override; Expected - getLedgerObjNestedArrayLen(int32_t cacheIdx, Slice const& locator) const override; + getLedgerObjNestedArrayLen(int32_t cacheIdx, FieldLocator const& locator) const override; Expected updateData(Slice const& data) override; diff --git a/include/xrpl/tx/wasm/HostFuncWrapper.h b/include/xrpl/tx/wasm/HostFuncWrapper.h index d917c56df9..825f5344ad 100644 --- a/include/xrpl/tx/wasm/HostFuncWrapper.h +++ b/include/xrpl/tx/wasm/HostFuncWrapper.h @@ -8,110 +8,86 @@ namespace xrpl { +#define WASM_CB_PARAMS_LIST void *env, wasm_val_vec_t const *params, wasm_val_vec_t *results +#define WASM_SECONDARY_CB_PARAMS_LIST \ + HostFunctions &hf, wasm_val_vec_t const *params, wasm_val_vec_t *results + +wasm_trap_t* HostFuncMain_wrap(WASM_CB_PARAMS_LIST); + using getLedgerSqn_proto = int32_t(uint8_t*, int32_t); -wasm_trap_t* -getLedgerSqn_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* getLedgerSqn_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using getParentLedgerTime_proto = int32_t(uint8_t*, int32_t); -wasm_trap_t* -getParentLedgerTime_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* getParentLedgerTime_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using getParentLedgerHash_proto = int32_t(uint8_t*, int32_t); -wasm_trap_t* -getParentLedgerHash_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* getParentLedgerHash_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using getBaseFee_proto = int32_t(uint8_t*, int32_t); -wasm_trap_t* -getBaseFee_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* getBaseFee_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using isAmendmentEnabled_proto = int32_t(uint8_t const*, int32_t); -wasm_trap_t* -isAmendmentEnabled_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* isAmendmentEnabled_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using cacheLedgerObj_proto = int32_t(uint8_t const*, int32_t, int32_t); -wasm_trap_t* -cacheLedgerObj_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* cacheLedgerObj_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using getTxField_proto = int32_t(int32_t, uint8_t*, int32_t); -wasm_trap_t* -getTxField_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* getTxField_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using getCurrentLedgerObjField_proto = int32_t(int32_t, uint8_t*, int32_t); -wasm_trap_t* -getCurrentLedgerObjField_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* getCurrentLedgerObjField_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using getLedgerObjField_proto = int32_t(int32_t, int32_t, uint8_t*, int32_t); -wasm_trap_t* -getLedgerObjField_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* getLedgerObjField_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using getTxNestedField_proto = int32_t(uint8_t const*, int32_t, uint8_t*, int32_t); -wasm_trap_t* -getTxNestedField_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* getTxNestedField_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using getCurrentLedgerObjNestedField_proto = int32_t(uint8_t const*, int32_t, uint8_t*, int32_t); -wasm_trap_t* -getCurrentLedgerObjNestedField_wrap( - void* env, - wasm_val_vec_t const* params, - wasm_val_vec_t* results); +wasm_trap_t* getCurrentLedgerObjNestedField_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using getLedgerObjNestedField_proto = int32_t(int32_t, uint8_t const*, int32_t, uint8_t*, int32_t); -wasm_trap_t* -getLedgerObjNestedField_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* getLedgerObjNestedField_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using getTxArrayLen_proto = int32_t(int32_t); -wasm_trap_t* -getTxArrayLen_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* getTxArrayLen_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using getCurrentLedgerObjArrayLen_proto = int32_t(int32_t); -wasm_trap_t* -getCurrentLedgerObjArrayLen_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* getCurrentLedgerObjArrayLen_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using getLedgerObjArrayLen_proto = int32_t(int32_t, int32_t); -wasm_trap_t* -getLedgerObjArrayLen_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* getLedgerObjArrayLen_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using getTxNestedArrayLen_proto = int32_t(uint8_t const*, int32_t); -wasm_trap_t* -getTxNestedArrayLen_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* getTxNestedArrayLen_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using getCurrentLedgerObjNestedArrayLen_proto = int32_t(uint8_t const*, int32_t); -wasm_trap_t* -getCurrentLedgerObjNestedArrayLen_wrap( - void* env, - wasm_val_vec_t const* params, - wasm_val_vec_t* results); +wasm_trap_t* getCurrentLedgerObjNestedArrayLen_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using getLedgerObjNestedArrayLen_proto = int32_t(int32_t, uint8_t const*, int32_t); -wasm_trap_t* -getLedgerObjNestedArrayLen_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* getLedgerObjNestedArrayLen_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using updateData_proto = int32_t(uint8_t const*, int32_t); -wasm_trap_t* -updateData_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* updateData_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using checkSignature_proto = int32_t(uint8_t const*, int32_t, uint8_t const*, int32_t, uint8_t const*, int32_t); -wasm_trap_t* -checkSignature_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* checkSignature_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using computeSha512HalfHash_proto = int32_t(uint8_t const*, int32_t, uint8_t*, int32_t); -wasm_trap_t* -computeSha512HalfHash_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* computeSha512HalfHash_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using accountKeylet_proto = int32_t(uint8_t const*, int32_t, uint8_t*, int32_t); -wasm_trap_t* -accountKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* accountKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using ammKeylet_proto = int32_t(uint8_t const*, int32_t, uint8_t const*, int32_t, uint8_t*, int32_t); -wasm_trap_t* -ammKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* ammKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using checkKeylet_proto = int32_t(uint8_t const*, int32_t, uint8_t const*, int32_t, uint8_t*, int32_t); -wasm_trap_t* -checkKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* checkKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using credentialKeylet_proto = int32_t( uint8_t const*, @@ -122,27 +98,22 @@ using credentialKeylet_proto = int32_t( int32_t, uint8_t*, int32_t); -wasm_trap_t* -credentialKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* credentialKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using delegateKeylet_proto = int32_t(uint8_t const*, int32_t, uint8_t const*, int32_t, uint8_t*, int32_t); -wasm_trap_t* -delegateKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* delegateKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using depositPreauthKeylet_proto = int32_t(uint8_t const*, int32_t, uint8_t const*, int32_t, uint8_t*, int32_t); -wasm_trap_t* -depositPreauthKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* depositPreauthKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using didKeylet_proto = int32_t(uint8_t const*, int32_t, uint8_t*, int32_t); -wasm_trap_t* -didKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* didKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using escrowKeylet_proto = int32_t(uint8_t const*, int32_t, uint8_t const*, int32_t, uint8_t*, int32_t); -wasm_trap_t* -escrowKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* escrowKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using lineKeylet_proto = int32_t( uint8_t const*, @@ -153,33 +124,27 @@ using lineKeylet_proto = int32_t( int32_t, uint8_t*, int32_t); -wasm_trap_t* -lineKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* lineKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using mptIssuanceKeylet_proto = int32_t(uint8_t const*, int32_t, uint8_t const*, int32_t, uint8_t*, int32_t); -wasm_trap_t* -mptIssuanceKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* mptIssuanceKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using mptokenKeylet_proto = int32_t(uint8_t const*, int32_t, uint8_t const*, int32_t, uint8_t*, int32_t); -wasm_trap_t* -mptokenKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* mptokenKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using nftOfferKeylet_proto = int32_t(uint8_t const*, int32_t, uint8_t const*, int32_t, uint8_t*, int32_t); -wasm_trap_t* -nftOfferKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* nftOfferKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using offerKeylet_proto = int32_t(uint8_t const*, int32_t, uint8_t const*, int32_t, uint8_t*, int32_t); -wasm_trap_t* -offerKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* offerKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using oracleKeylet_proto = int32_t(uint8_t const*, int32_t, uint8_t const*, int32_t, uint8_t*, int32_t); -wasm_trap_t* -oracleKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* oracleKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using paychanKeylet_proto = int32_t( uint8_t const*, @@ -190,130 +155,100 @@ using paychanKeylet_proto = int32_t( int32_t, uint8_t*, int32_t); -wasm_trap_t* -paychanKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* paychanKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using permissionedDomainKeylet_proto = int32_t(uint8_t const*, int32_t, uint8_t const*, int32_t, uint8_t*, int32_t); -wasm_trap_t* -permissionedDomainKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* permissionedDomainKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using signersKeylet_proto = int32_t(uint8_t const*, int32_t, uint8_t*, int32_t); -wasm_trap_t* -signersKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* signersKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using ticketKeylet_proto = int32_t(uint8_t const*, int32_t, uint8_t const*, int32_t, uint8_t*, int32_t); -wasm_trap_t* -ticketKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* ticketKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using vaultKeylet_proto = int32_t(uint8_t const*, int32_t, uint8_t const*, int32_t, uint8_t*, int32_t); -wasm_trap_t* -vaultKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* vaultKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using getNFT_proto = int32_t(uint8_t const*, int32_t, uint8_t const*, int32_t, uint8_t*, int32_t); -wasm_trap_t* -getNFT_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* getNFT_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using getNFTIssuer_proto = int32_t(uint8_t const*, int32_t, uint8_t*, int32_t); -wasm_trap_t* -getNFTIssuer_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* getNFTIssuer_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using getNFTTaxon_proto = int32_t(uint8_t const*, int32_t, uint8_t*, int32_t); -wasm_trap_t* -getNFTTaxon_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* getNFTTaxon_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using getNFTFlags_proto = int32_t(uint8_t const*, int32_t); -wasm_trap_t* -getNFTFlags_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* getNFTFlags_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using getNFTTransferFee_proto = int32_t(uint8_t const*, int32_t); -wasm_trap_t* -getNFTTransferFee_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* getNFTTransferFee_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using getNFTSerial_proto = int32_t(uint8_t const*, int32_t, uint8_t*, int32_t); -wasm_trap_t* -getNFTSerial_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* getNFTSerial_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using trace_proto = int32_t(uint8_t const*, int32_t, uint8_t const*, int32_t, int32_t); -wasm_trap_t* -trace_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* trace_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using traceNum_proto = int32_t(uint8_t const*, int32_t, int64_t); -wasm_trap_t* -traceNum_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* traceNum_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using traceAccount_proto = int32_t(uint8_t const*, int32_t, uint8_t const*, int32_t); -wasm_trap_t* -traceAccount_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* traceAccount_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using traceFloat_proto = int32_t(uint8_t const*, int32_t, uint8_t const*, int32_t); -wasm_trap_t* -traceFloat_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* traceFloat_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using traceAmount_proto = int32_t(uint8_t const*, int32_t, uint8_t const*, int32_t); -wasm_trap_t* -traceAmount_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* traceAmount_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using floatFromInt_proto = int32_t(int64_t, uint8_t*, int32_t, int32_t); -wasm_trap_t* -floatFromInt_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* floatFromInt_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using floatFromUint_proto = int32_t(uint8_t const*, int32_t, uint8_t*, int32_t, int32_t); -wasm_trap_t* -floatFromUint_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* floatFromUint_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using floatFromSTAmount_proto = int32_t(uint8_t const*, int32_t, uint8_t*, int32_t, int32_t); -wasm_trap_t* -floatFromSTAmount_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* floatFromSTAmount_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using floatFromSTNumber_proto = int32_t(uint8_t const*, int32_t, uint8_t*, int32_t, int32_t); -wasm_trap_t* -floatFromSTNumber_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* floatFromSTNumber_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using floatToInt_proto = int32_t(uint8_t const*, int32_t, uint8_t*, int32_t, int32_t); -wasm_trap_t* -floatToInt_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* floatToInt_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using floatToMantExp_proto = int32_t(uint8_t const*, int32_t, uint8_t*, int32_t, uint8_t*, int32_t); -wasm_trap_t* -floatToMantExp_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* floatToMantExp_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using floatFromMantExp_proto = int32_t(int64_t, int32_t, uint8_t*, int32_t, int32_t); -wasm_trap_t* -floatFromMantExp_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* floatFromMantExp_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using floatCompare_proto = int32_t(uint8_t const*, int32_t, uint8_t const*, int32_t); -wasm_trap_t* -floatCompare_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* floatCompare_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using floatAdd_proto = int32_t(uint8_t const*, int32_t, uint8_t const*, int32_t, uint8_t*, int32_t, int32_t); -wasm_trap_t* -floatAdd_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* floatAdd_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using floatSubtract_proto = int32_t(uint8_t const*, int32_t, uint8_t const*, int32_t, uint8_t*, int32_t, int32_t); -wasm_trap_t* -floatSubtract_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* floatSubtract_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using floatMultiply_proto = int32_t(uint8_t const*, int32_t, uint8_t const*, int32_t, uint8_t*, int32_t, int32_t); -wasm_trap_t* -floatMultiply_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* floatMultiply_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using floatDivide_proto = int32_t(uint8_t const*, int32_t, uint8_t const*, int32_t, uint8_t*, int32_t, int32_t); -wasm_trap_t* -floatDivide_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* floatDivide_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using floatRoot_proto = int32_t(uint8_t const*, int32_t, int32_t, uint8_t*, int32_t, int32_t); -wasm_trap_t* -floatRoot_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* floatRoot_wrap(WASM_SECONDARY_CB_PARAMS_LIST); using floatPower_proto = int32_t(uint8_t const*, int32_t, int32_t, uint8_t*, int32_t, int32_t); -wasm_trap_t* -floatPower_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); +wasm_trap_t* floatPower_wrap(WASM_SECONDARY_CB_PARAMS_LIST); } // namespace xrpl diff --git a/include/xrpl/tx/wasm/WasmCommon.h b/include/xrpl/tx/wasm/WasmCommon.h index 5e1b47b982..ed03a4aaf4 100644 --- a/include/xrpl/tx/wasm/WasmCommon.h +++ b/include/xrpl/tx/wasm/WasmCommon.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -60,6 +61,56 @@ struct WasmResult }; using EscrowResult = WasmResult; +class FieldLocator +{ + int32_t const* ptr_ = nullptr; + uint32_t size_ = 0; + std::vector buf_; + +public: + FieldLocator(std::vector&& buf) + : ptr_(&buf[0]), size_(buf.size()), buf_(std::move(buf)) + { + } + + FieldLocator(int32_t const* ptr, uint32_t const size) : ptr_(ptr), size_(size) + { + } + + FieldLocator(FieldLocator const&) = delete; + FieldLocator& + operator=(FieldLocator const&) = delete; + FieldLocator(FieldLocator&&) = default; + FieldLocator& + operator=(FieldLocator&&) = default; + + int32_t + operator[](unsigned i) const + { + if (i >= size_) + Throw("index out of bounds"); + return ptr_[i]; + } + + [[nodiscard]] uint32_t + size() const + { + return size_; + } + + [[nodiscard]] int32_t const* + data() const + { + return ptr_; + } + + [[nodiscard]] bool + empty() const + { + return size_ == 0; + } +}; + class WasmRuntimeWrapper { public: diff --git a/include/xrpl/tx/wasm/WasmImportsHelper.h b/include/xrpl/tx/wasm/WasmImportsHelper.h index 18ceb52973..a0bf74a089 100644 --- a/include/xrpl/tx/wasm/WasmImportsHelper.h +++ b/include/xrpl/tx/wasm/WasmImportsHelper.h @@ -14,13 +14,16 @@ namespace bft = boost::function_types; namespace xrpl { +using wasmSecondaryCbFuncType = + wasm_trap_t*(HostFunctions&, wasm_val_vec_t const*, wasm_val_vec_t*); + struct WasmImportFunc { std::string_view name; std::optional result; std::vector params; - // wasm_func_callback_with_env_t - void* wrap = nullptr; + + wasmSecondaryCbFuncType* wrap = nullptr; uint32_t gas = 0; }; @@ -105,7 +108,7 @@ void WasmImpFunc( ImportVec& v, std::string_view impName, - void* fWrap, + wasmSecondaryCbFuncType* fWrap, HostFunctions& hf, uint32_t gas = 0) { @@ -117,11 +120,9 @@ WasmImpFunc( v.emplace(impName, std::make_pair(HFRef(hf), std::move(e))); } -#define WASM_IMPORT_FUNC(v, f, ...) \ - WasmImpFunc(v, #f, reinterpret_cast(&f##_wrap), ##__VA_ARGS__) +#define WASM_IMPORT_FUNC(v, f, ...) WasmImpFunc(v, #f, &f##_wrap, ##__VA_ARGS__) // n - string literal name, must have static lifetime -#define WASM_IMPORT_FUNC2(v, f, n, ...) \ - WasmImpFunc(v, n, reinterpret_cast(&f##_wrap), ##__VA_ARGS__) +#define WASM_IMPORT_FUNC2(v, f, n, ...) WasmImpFunc(v, n, &f##_wrap, ##__VA_ARGS__) } // namespace xrpl diff --git a/src/libxrpl/tx/wasm/HostFuncImplGetter.cpp b/src/libxrpl/tx/wasm/HostFuncImplGetter.cpp index 3f94587dc4..f86bc5741e 100644 --- a/src/libxrpl/tx/wasm/HostFuncImplGetter.cpp +++ b/src/libxrpl/tx/wasm/HostFuncImplGetter.cpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include @@ -14,7 +13,6 @@ #include #include -#include #include #include @@ -134,33 +132,13 @@ noField(STBase const* field) } static Expected -locateField(STObject const& obj, Slice const& locator) +locateField(STObject const& obj, FieldLocator const& locator) { - if (locator.empty() || ((locator.size() & 3) != 0u)) // must be multiple of 4 - return Unexpected(HostFunctionError::LocatorMalformed); - - static_assert(kMaxWasmParamLength % sizeof(int32_t) == 0); - int32_t locBuf[kMaxWasmParamLength / sizeof(int32_t)]; - int32_t const* locPtr = &locBuf[0]; - int32_t const locSize = locator.size() / sizeof(int32_t); - - { - uintptr_t const p = reinterpret_cast(locator.data()); - if ((p & (alignof(int32_t) - 1)) != 0u) - { // unaligned - memcpy(&locBuf[0], locator.data(), locator.size()); - } - else - { - locPtr = reinterpret_cast(locator.data()); - } - } - STBase const* field = nullptr; auto const& knownSFields = SField::getKnownCodeToField(); { - int32_t const sfieldCode = adjustWasmEndianess(locPtr[0]); + int32_t const sfieldCode = adjustWasmEndianess(locator[0]); auto const it = knownSFields.find(sfieldCode); if (it == knownSFields.end()) return Unexpected(HostFunctionError::InvalidField); @@ -171,9 +149,9 @@ locateField(STObject const& obj, Slice const& locator) return Unexpected(HostFunctionError::FieldNotFound); } - for (int i = 1; i < locSize; ++i) + for (unsigned i = 1; i < locator.size(); ++i) { - int32_t const sfieldCode = adjustWasmEndianess(locPtr[i]); + int32_t const sfieldCode = adjustWasmEndianess(locator[i]); if (STI_ARRAY == field->getSType()) { @@ -285,7 +263,7 @@ WasmHostFunctionsImpl::getLedgerObjField(int32_t cacheIdx, SField const& fname) // Subsection: nested getters Expected -WasmHostFunctionsImpl::getTxNestedField(Slice const& locator) const +WasmHostFunctionsImpl::getTxNestedField(FieldLocator const& locator) const { auto const r = locateField(ctx_.tx, locator); if (!r) @@ -295,7 +273,7 @@ WasmHostFunctionsImpl::getTxNestedField(Slice const& locator) const } Expected -WasmHostFunctionsImpl::getCurrentLedgerObjNestedField(Slice const& locator) const +WasmHostFunctionsImpl::getCurrentLedgerObjNestedField(FieldLocator const& locator) const { auto const sle = getCurrentLedgerObj(); if (!sle.has_value()) @@ -309,7 +287,7 @@ WasmHostFunctionsImpl::getCurrentLedgerObjNestedField(Slice const& locator) cons } Expected -WasmHostFunctionsImpl::getLedgerObjNestedField(int32_t cacheIdx, Slice const& locator) const +WasmHostFunctionsImpl::getLedgerObjNestedField(int32_t cacheIdx, FieldLocator const& locator) const { auto const normalizedIdx = normalizeCacheIndex(cacheIdx); if (!normalizedIdx.has_value()) @@ -374,7 +352,7 @@ WasmHostFunctionsImpl::getLedgerObjArrayLen(int32_t cacheIdx, SField const& fnam // Subsection: nested array length getters Expected -WasmHostFunctionsImpl::getTxNestedArrayLen(Slice const& locator) const +WasmHostFunctionsImpl::getTxNestedArrayLen(FieldLocator const& locator) const { auto const r = locateField(ctx_.tx, locator); if (!r) @@ -385,7 +363,7 @@ WasmHostFunctionsImpl::getTxNestedArrayLen(Slice const& locator) const } Expected -WasmHostFunctionsImpl::getCurrentLedgerObjNestedArrayLen(Slice const& locator) const +WasmHostFunctionsImpl::getCurrentLedgerObjNestedArrayLen(FieldLocator const& locator) const { auto const sle = getCurrentLedgerObj(); if (!sle.has_value()) @@ -399,7 +377,8 @@ WasmHostFunctionsImpl::getCurrentLedgerObjNestedArrayLen(Slice const& locator) c } Expected -WasmHostFunctionsImpl::getLedgerObjNestedArrayLen(int32_t cacheIdx, Slice const& locator) const +WasmHostFunctionsImpl::getLedgerObjNestedArrayLen(int32_t cacheIdx, FieldLocator const& locator) + const { auto const normalizedIdx = normalizeCacheIndex(cacheIdx); if (!normalizedIdx.has_value()) diff --git a/src/libxrpl/tx/wasm/HostFuncWrapper.cpp b/src/libxrpl/tx/wasm/HostFuncWrapper.cpp index a8a35fb8d7..9939407034 100644 --- a/src/libxrpl/tx/wasm/HostFuncWrapper.cpp +++ b/src/libxrpl/tx/wasm/HostFuncWrapper.cpp @@ -32,61 +32,95 @@ #include #include #include +#include #include #include +#include namespace xrpl { using SFieldCRef = std::reference_wrapper; -static inline HostFunctions* -getHF(void* env) +static inline Expected +checkGas(WasmRuntimeWrapper& rt, int64_t delta) { - auto const* udata = reinterpret_cast(env); - HostFunctions* hf = &udata->first.get(); // NOLINT - return hf; + int64_t const gas = rt.getGas(); + if (delta == 0) + return gas; + + int64_t const x = gas >= delta ? gas - delta : 0; + + if (rt.setGas(x) < 0) + return Unexpected(HostFunctionError::Internal); // LCOV_EXCL_LINE + + if (gas < delta) + return Unexpected(HostFunctionError::OutOfGas); + + return x; } static inline Expected -checkGas(void* env) +checkGas(WasmRuntimeWrapper& rt, WasmImportFunc const& impFunc) { - auto const* udata = reinterpret_cast(env); - HostFunctions const* hf = &udata->first.get(); - auto* rt = hf->getRT(); + auto g = checkGas(rt, impFunc.gas); - if (rt == nullptr) + if (!g) { - wasm_trap_t* trap = reinterpret_cast( // NOLINT - WasmEngine::instance().newTrap("hf no runtime")); // LCOV_EXCL_LINE - return Unexpected(trap); // LCOV_EXCL_LINE - } + if (g.error() == HostFunctionError::OutOfGas) + { + wasm_trap_t* const trap = // NOLINT + reinterpret_cast(WasmEngine::instance().newTrap("hf out of gas")); + return Unexpected(trap); + } - int64_t const gas = rt->getGas(); - WasmImportFunc const& impFunc = udata->second; - int64_t const x = gas >= impFunc.gas ? gas - impFunc.gas : 0; - - if (rt->setGas(x) < 0) - { wasm_trap_t* trap = reinterpret_cast( // NOLINT WasmEngine::instance().newTrap("can't set gas")); // LCOV_EXCL_LINE return Unexpected(trap); // LCOV_EXCL_LINE } - if (gas < impFunc.gas) + return *g; +} + +static Expected, wasm_trap_t*> +mainCheck(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +{ + if (env == nullptr) { - wasm_trap_t* const trap = // NOLINT - reinterpret_cast(WasmEngine::instance().newTrap("hf out of gas")); - return Unexpected(trap); + wasm_trap_t* trap = reinterpret_cast( // NOLINT + WasmEngine::instance().newTrap("no environment")); // LCOV_EXCL_LINE + return Unexpected(trap); // LCOV_EXCL_LINE } - return x; + if (params == nullptr) + { + wasm_trap_t* trap = reinterpret_cast( // NOLINT + WasmEngine::instance().newTrap("no params")); // LCOV_EXCL_LINE + return Unexpected(trap); // LCOV_EXCL_LINE + } + + if (results == nullptr) + { + wasm_trap_t* trap = reinterpret_cast( // NOLINT + WasmEngine::instance().newTrap("no results")); // LCOV_EXCL_LINE + return Unexpected(trap); // LCOV_EXCL_LINE + } + + WasmUserData const* udata = reinterpret_cast(env); + HostFunctions& hf = udata->first; + WasmRuntimeWrapper& rt = hf.getRT(); + WasmImportFunc const& impFunc = udata->second; + + if (auto g = checkGas(rt, impFunc); !g) + return Unexpected(g.error()); // LCOV_EXCL_LINE + + return std::tie(hf, impFunc); } //---------------------------------------------------------------------------------------------------------------------- static int32_t setData( - WasmRuntimeWrapper* runtime, + WasmRuntimeWrapper& runtime, int32_t dst, int32_t dstSize, uint8_t const* src, @@ -101,7 +135,7 @@ setData( if (srcSize > kMaxWasmDataLength) return hfErrorToInt(HostFunctionError::DataFieldTooLarge); - auto const memory = (runtime != nullptr) ? runtime->getMem() : Wmem(); + auto const memory = runtime.getMem(); // LCOV_EXCL_START if (memory.s == 0u) @@ -118,11 +152,7 @@ setData( } static Expected -getDataSlice( - WasmRuntimeWrapper* runtime, - wasm_val_vec_t const* params, - int32_t& i, - bool isUpdate = false) +getDataSlice(WasmRuntimeWrapper& runtime, wasm_val_vec_t const* params, int32_t& i) { int64_t const ptr = params->data[i].of.i32; int64_t const size = params->data[i + 1].of.i32; @@ -133,10 +163,10 @@ getDataSlice( if (size == 0) return Slice(); - if (size > (isUpdate ? kMaxWasmDataLength : kMaxWasmParamLength)) + if (size > kMaxWasmDataLength) return Unexpected(HostFunctionError::DataFieldTooLarge); - auto const memory = runtime != nullptr ? runtime->getMem() : Wmem(); + auto const memory = runtime.getMem(); // LCOV_EXCL_START if (memory.s == 0u) return Unexpected(HostFunctionError::NoMemExported); @@ -150,7 +180,7 @@ getDataSlice( } static Expected -getDataInt32(WasmRuntimeWrapper const*, wasm_val_vec_t const* params, int32_t& i) +getDataInt32(WasmRuntimeWrapper const&, wasm_val_vec_t const* params, int32_t& i) { auto const result = params->data[i].of.i32; i++; @@ -158,7 +188,7 @@ getDataInt32(WasmRuntimeWrapper const*, wasm_val_vec_t const* params, int32_t& i } static Expected -getDataInt64(WasmRuntimeWrapper const*, wasm_val_vec_t const* params, int32_t& i) +getDataInt64(WasmRuntimeWrapper const&, wasm_val_vec_t const* params, int32_t& i) { auto const result = params->data[i].of.i64; i++; @@ -167,7 +197,7 @@ getDataInt64(WasmRuntimeWrapper const*, wasm_val_vec_t const* params, int32_t& i template static Expected -getDataUnsigned(WasmRuntimeWrapper* runtime, wasm_val_vec_t const* params, int32_t& i) +getDataUnsigned(WasmRuntimeWrapper& runtime, wasm_val_vec_t const* params, int32_t& i) { static_assert(std::is_unsigned_v); auto const r = getDataSlice(runtime, params, i); @@ -192,19 +222,19 @@ getDataUnsigned(WasmRuntimeWrapper* runtime, wasm_val_vec_t const* params, int32 } static Expected -getDataUInt32(WasmRuntimeWrapper* runtime, wasm_val_vec_t const* params, int32_t& i) +getDataUInt32(WasmRuntimeWrapper& runtime, wasm_val_vec_t const* params, int32_t& i) { return getDataUnsigned(runtime, params, i); } static Expected -getDataUInt64(WasmRuntimeWrapper* runtime, wasm_val_vec_t const* params, int32_t& i) +getDataUInt64(WasmRuntimeWrapper& runtime, wasm_val_vec_t const* params, int32_t& i) { return getDataUnsigned(runtime, params, i); } static Expected -getDataSField(WasmRuntimeWrapper* runtime, wasm_val_vec_t const* params, int32_t& i) +getDataSField(WasmRuntimeWrapper& runtime, wasm_val_vec_t const* params, int32_t& i) { auto const& m = SField::getKnownCodeToField(); auto const it = m.find(params->data[i].of.i32); @@ -216,7 +246,7 @@ getDataSField(WasmRuntimeWrapper* runtime, wasm_val_vec_t const* params, int32_t } static Expected -getDataUInt256(WasmRuntimeWrapper* runtime, wasm_val_vec_t const* params, int32_t& i) +getDataUInt256(WasmRuntimeWrapper& runtime, wasm_val_vec_t const* params, int32_t& i) { auto const slice = getDataSlice(runtime, params, i); if (!slice) @@ -229,7 +259,7 @@ getDataUInt256(WasmRuntimeWrapper* runtime, wasm_val_vec_t const* params, int32_ } static Expected -getDataAccountID(WasmRuntimeWrapper* runtime, wasm_val_vec_t const* params, int32_t& i) +getDataAccountID(WasmRuntimeWrapper& runtime, wasm_val_vec_t const* params, int32_t& i) { auto const slice = getDataSlice(runtime, params, i); if (!slice) @@ -242,7 +272,7 @@ getDataAccountID(WasmRuntimeWrapper* runtime, wasm_val_vec_t const* params, int3 } static Expected -getDataCurrency(WasmRuntimeWrapper* runtime, wasm_val_vec_t const* params, int32_t& i) +getDataCurrency(WasmRuntimeWrapper& runtime, wasm_val_vec_t const* params, int32_t& i) { auto const slice = getDataSlice(runtime, params, i); if (!slice) @@ -255,7 +285,7 @@ getDataCurrency(WasmRuntimeWrapper* runtime, wasm_val_vec_t const* params, int32 } static Expected -getDataAsset(WasmRuntimeWrapper* runtime, wasm_val_vec_t const* params, int32_t& i) +getDataAsset(WasmRuntimeWrapper& runtime, wasm_val_vec_t const* params, int32_t& i) { auto const slice = getDataSlice(runtime, params, i); if (!slice) @@ -293,7 +323,7 @@ getDataAsset(WasmRuntimeWrapper* runtime, wasm_val_vec_t const* params, int32_t& } static Expected -getDataString(WasmRuntimeWrapper* runtime, wasm_val_vec_t const* params, int32_t& i) +getDataString(WasmRuntimeWrapper& runtime, wasm_val_vec_t const* params, int32_t& i) { auto const slice = getDataSlice(runtime, params, i); if (!slice) @@ -302,6 +332,34 @@ getDataString(WasmRuntimeWrapper* runtime, wasm_val_vec_t const* params, int32_t return std::string_view(reinterpret_cast(slice->data()), slice->size()); } +static Expected +getDataLocator(WasmRuntimeWrapper& runtime, wasm_val_vec_t const* params, int32_t& i) +{ + static_assert(kMaxWasmDataLength % sizeof(int32_t) == 0); + + auto const slice = getDataSlice(runtime, params, i); + if (!slice) + return Unexpected(slice.error()); + if (slice->empty() || ((slice->size() & 3) != 0u)) // must be multiple of 4 + return Unexpected(HostFunctionError::LocatorMalformed); + + uint32_t const locSize = slice->size() / sizeof(int32_t); + uintptr_t const p = reinterpret_cast(slice->data()); + + if ((p & (alignof(int32_t) - 1)) != 0u) + { // unaligned + + std::vector locBuf(locSize); + memcpy(&locBuf[0], slice->data(), slice->size()); + FieldLocator locator(std::move(locBuf)); + + return locator; + } + + int32_t const* locPtr = reinterpret_cast(slice->data()); + return FieldLocator(locPtr, locSize); +} + static inline std::nullptr_t hfResult(wasm_val_vec_t* results, int32_t value) { @@ -321,7 +379,7 @@ hfResult(wasm_val_vec_t* results, HostFunctionError value) template static std::nullptr_t returnResult( - WasmRuntimeWrapper* runtime, + WasmRuntimeWrapper& runtime, wasm_val_vec_t const* params, wasm_val_vec_t* results, Expected const& res, @@ -424,61 +482,85 @@ returnResult( //---------------------------------------------------------------------------------------------------------------------- wasm_trap_t* -getLedgerSqn_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +HostFuncMain_wrap(WASM_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); - int const index = 0; + [[maybe_unused]] std::string_view hfName; - return returnResult(runtime, params, results, hf->getLedgerSqn(), index); + try + { + auto const mc = mainCheck(env, params, results); + if (!mc) + return mc.error(); // LCOV_EXCL_LINE + auto& [hf, impFunc] = *mc; + + hfName = impFunc.name; + auto* fWrap = reinterpret_cast(impFunc.wrap); + return fWrap(hf, params, results); + } + catch (std::exception const& e) + { +#ifdef DEBUG_OUTPUT + std::cerr << "Hostfunction " << hfName << " exception: " << e.what() << std::endl; +#endif + wasm_trap_t* trap = reinterpret_cast( // NOLINT + WasmEngine::instance().newTrap(e.what())); // LCOV_EXCL_LINE + return trap; + } + catch (...) + { +#ifdef DEBUG_OUTPUT + std::cerr << "Hostfunction " << hfName << " unknown exception." << std::endl; +#endif + wasm_trap_t* trap = reinterpret_cast( // NOLINT + WasmEngine::instance().newTrap("Unknown exception")); // LCOV_EXCL_LINE + return trap; + } + + return nullptr; +} + +//---------------------------------------------------------------------------------------------------------------------- +wasm_trap_t* +getLedgerSqn_wrap(WASM_SECONDARY_CB_PARAMS_LIST) +{ + int const index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); + + return returnResult(runtime, params, results, hf.getLedgerSqn(), index); } wasm_trap_t* -getParentLedgerTime_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +getParentLedgerTime_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int const index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); - return returnResult(runtime, params, results, hf->getParentLedgerTime(), index); + return returnResult(runtime, params, results, hf.getParentLedgerTime(), index); } wasm_trap_t* -getParentLedgerHash_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +getParentLedgerHash_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int const index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); - return returnResult(runtime, params, results, hf->getParentLedgerHash(), index); + return returnResult(runtime, params, results, hf.getParentLedgerHash(), index); } wasm_trap_t* -getBaseFee_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +getBaseFee_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int const index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); - return returnResult(runtime, params, results, hf->getBaseFee(), index); + return returnResult(runtime, params, results, hf.getBaseFee(), index); } wasm_trap_t* -isAmendmentEnabled_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +isAmendmentEnabled_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const slice = getDataSlice(runtime, params, index); if (!slice) @@ -486,7 +568,7 @@ isAmendmentEnabled_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* if (slice->size() == uint256::size()) { - if (auto const ret = hf->isAmendmentEnabled(uint256::fromVoid(slice->data())); + if (auto const ret = hf.isAmendmentEnabled(uint256::fromVoid(slice->data())); ret && *ret == 1) return returnResult(runtime, params, results, ret, index); // Fall through to string lookup — the 32 bytes may be an amendment name @@ -496,17 +578,14 @@ isAmendmentEnabled_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* return hfResult(results, HostFunctionError::DataFieldTooLarge); auto const str = std::string_view(reinterpret_cast(slice->data()), slice->size()); - return returnResult(runtime, params, results, hf->isAmendmentEnabled(str), index); + return returnResult(runtime, params, results, hf.isAmendmentEnabled(str), index); } wasm_trap_t* -cacheLedgerObj_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +cacheLedgerObj_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const id = getDataUInt256(runtime, params, index); if (!id) @@ -516,49 +595,40 @@ cacheLedgerObj_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* res if (!cache) return hfResult(results, cache.error()); // LCOV_EXCL_LINE - return returnResult(runtime, params, results, hf->cacheLedgerObj(*id, *cache), index); + return returnResult(runtime, params, results, hf.cacheLedgerObj(*id, *cache), index); } wasm_trap_t* -getTxField_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +getTxField_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const fname = getDataSField(runtime, params, index); if (!fname) return hfResult(results, fname.error()); - return returnResult(runtime, params, results, hf->getTxField(*fname), index); + return returnResult(runtime, params, results, hf.getTxField(*fname), index); } wasm_trap_t* -getCurrentLedgerObjField_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +getCurrentLedgerObjField_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const fname = getDataSField(runtime, params, index); if (!fname) return hfResult(results, fname.error()); - return returnResult(runtime, params, results, hf->getCurrentLedgerObjField(*fname), index); + return returnResult(runtime, params, results, hf.getCurrentLedgerObjField(*fname), index); } wasm_trap_t* -getLedgerObjField_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +getLedgerObjField_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const cache = getDataInt32(runtime, params, index); if (!cache) @@ -568,106 +638,85 @@ getLedgerObjField_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* if (!fname) return hfResult(results, fname.error()); - return returnResult(runtime, params, results, hf->getLedgerObjField(*cache, *fname), index); + return returnResult(runtime, params, results, hf.getLedgerObjField(*cache, *fname), index); } wasm_trap_t* -getTxNestedField_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +getTxNestedField_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); - auto const bytes = getDataSlice(runtime, params, index); - if (!bytes) - return hfResult(results, bytes.error()); + auto const locator = getDataLocator(runtime, params, index); + if (!locator) + return hfResult(results, locator.error()); - return returnResult(runtime, params, results, hf->getTxNestedField(*bytes), index); + return returnResult(runtime, params, results, hf.getTxNestedField(*locator), index); } wasm_trap_t* -getCurrentLedgerObjNestedField_wrap( - void* env, - wasm_val_vec_t const* params, - wasm_val_vec_t* results) +getCurrentLedgerObjNestedField_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); - auto const bytes = getDataSlice(runtime, params, index); - if (!bytes) - return hfResult(results, bytes.error()); + auto const locator = getDataLocator(runtime, params, index); + if (!locator) + return hfResult(results, locator.error()); return returnResult( - runtime, params, results, hf->getCurrentLedgerObjNestedField(*bytes), index); + runtime, params, results, hf.getCurrentLedgerObjNestedField(*locator), index); } wasm_trap_t* -getLedgerObjNestedField_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +getLedgerObjNestedField_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const cache = getDataInt32(runtime, params, index); if (!cache) return hfResult(results, cache.error()); // LCOV_EXCL_LINE - auto const bytes = getDataSlice(runtime, params, index); - if (!bytes) - return hfResult(results, bytes.error()); + auto const locator = getDataLocator(runtime, params, index); + if (!locator) + return hfResult(results, locator.error()); return returnResult( - runtime, params, results, hf->getLedgerObjNestedField(*cache, *bytes), index); + runtime, params, results, hf.getLedgerObjNestedField(*cache, *locator), index); } wasm_trap_t* -getTxArrayLen_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +getTxArrayLen_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const fname = getDataSField(runtime, params, index); if (!fname) return hfResult(results, fname.error()); - return returnResult(runtime, params, results, hf->getTxArrayLen(*fname), index); + return returnResult(runtime, params, results, hf.getTxArrayLen(*fname), index); } wasm_trap_t* -getCurrentLedgerObjArrayLen_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +getCurrentLedgerObjArrayLen_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const fname = getDataSField(runtime, params, index); if (!fname) return hfResult(results, fname.error()); - return returnResult(runtime, params, results, hf->getCurrentLedgerObjArrayLen(*fname), index); + return returnResult(runtime, params, results, hf.getCurrentLedgerObjArrayLen(*fname), index); } wasm_trap_t* -getLedgerObjArrayLen_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +getLedgerObjArrayLen_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const cache = getDataInt32(runtime, params, index); if (!cache) @@ -677,89 +726,71 @@ getLedgerObjArrayLen_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_ if (!fname) return hfResult(results, fname.error()); - return returnResult(runtime, params, results, hf->getLedgerObjArrayLen(*cache, *fname), index); + return returnResult(runtime, params, results, hf.getLedgerObjArrayLen(*cache, *fname), index); } wasm_trap_t* -getTxNestedArrayLen_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +getTxNestedArrayLen_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); - auto const bytes = getDataSlice(runtime, params, index); - if (!bytes) - return hfResult(results, bytes.error()); + auto const locator = getDataLocator(runtime, params, index); + if (!locator) + return hfResult(results, locator.error()); - return returnResult(runtime, params, results, hf->getTxNestedArrayLen(*bytes), index); + return returnResult(runtime, params, results, hf.getTxNestedArrayLen(*locator), index); } wasm_trap_t* -getCurrentLedgerObjNestedArrayLen_wrap( - void* env, - wasm_val_vec_t const* params, - wasm_val_vec_t* results) +getCurrentLedgerObjNestedArrayLen_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); - auto const bytes = getDataSlice(runtime, params, index); - if (!bytes) - return hfResult(results, bytes.error()); + auto const locator = getDataLocator(runtime, params, index); + if (!locator) + return hfResult(results, locator.error()); return returnResult( - runtime, params, results, hf->getCurrentLedgerObjNestedArrayLen(*bytes), index); + runtime, params, results, hf.getCurrentLedgerObjNestedArrayLen(*locator), index); } wasm_trap_t* -getLedgerObjNestedArrayLen_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +getLedgerObjNestedArrayLen_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const cache = getDataInt32(runtime, params, index); if (!cache) return hfResult(results, cache.error()); // LCOV_EXCL_LINE + auto const locator = getDataLocator(runtime, params, index); + if (!locator) + return hfResult(results, locator.error()); + + return returnResult( + runtime, params, results, hf.getLedgerObjNestedArrayLen(*cache, *locator), index); +} + +wasm_trap_t* +updateData_wrap(WASM_SECONDARY_CB_PARAMS_LIST) +{ + int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); + auto const bytes = getDataSlice(runtime, params, index); if (!bytes) return hfResult(results, bytes.error()); - return returnResult( - runtime, params, results, hf->getLedgerObjNestedArrayLen(*cache, *bytes), index); + return returnResult(runtime, params, results, hf.updateData(*bytes), index); } wasm_trap_t* -updateData_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +checkSignature_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); - int index = 0; - - auto const bytes = getDataSlice(runtime, params, index, true); - if (!bytes) - return hfResult(results, bytes.error()); - - return returnResult(runtime, params, results, hf->updateData(*bytes), index); -} - -wasm_trap_t* -checkSignature_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) -{ - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const message = getDataSlice(runtime, params, index); if (!message) @@ -774,49 +805,40 @@ checkSignature_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* res return hfResult(results, pubkey.error()); return returnResult( - runtime, params, results, hf->checkSignature(*message, *signature, *pubkey), index); + runtime, params, results, hf.checkSignature(*message, *signature, *pubkey), index); } wasm_trap_t* -computeSha512HalfHash_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +computeSha512HalfHash_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const bytes = getDataSlice(runtime, params, index); if (!bytes) return hfResult(results, bytes.error()); - return returnResult(runtime, params, results, hf->computeSha512HalfHash(*bytes), index); + return returnResult(runtime, params, results, hf.computeSha512HalfHash(*bytes), index); } wasm_trap_t* -accountKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +accountKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const acc = getDataAccountID(runtime, params, index); if (!acc) return hfResult(results, acc.error()); - return returnResult(runtime, params, results, hf->accountKeylet(*acc), index); + return returnResult(runtime, params, results, hf.accountKeylet(*acc), index); } wasm_trap_t* -ammKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +ammKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const issue1 = getDataAsset(runtime, params, index); if (!issue1) @@ -827,17 +849,14 @@ ammKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) return hfResult(results, issue2.error()); return returnResult( - runtime, params, results, hf->ammKeylet(issue1.value(), issue2.value()), index); + runtime, params, results, hf.ammKeylet(issue1.value(), issue2.value()), index); } wasm_trap_t* -checkKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +checkKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const acc = getDataAccountID(runtime, params, index); if (!acc) @@ -847,17 +866,14 @@ checkKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* result if (!seq) return hfResult(results, seq.error()); - return returnResult(runtime, params, results, hf->checkKeylet(acc.value(), *seq), index); + return returnResult(runtime, params, results, hf.checkKeylet(acc.value(), *seq), index); } wasm_trap_t* -credentialKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +credentialKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const subj = getDataAccountID(runtime, params, index); if (!subj) @@ -872,17 +888,14 @@ credentialKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* r return hfResult(results, credType.error()); return returnResult( - runtime, params, results, hf->credentialKeylet(*subj, *iss, *credType), index); + runtime, params, results, hf.credentialKeylet(*subj, *iss, *credType), index); } wasm_trap_t* -delegateKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +delegateKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const acc = getDataAccountID(runtime, params, index); if (!acc) @@ -893,17 +906,14 @@ delegateKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* res return hfResult(results, authorize.error()); return returnResult( - runtime, params, results, hf->delegateKeylet(acc.value(), authorize.value()), index); + runtime, params, results, hf.delegateKeylet(acc.value(), authorize.value()), index); } wasm_trap_t* -depositPreauthKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +depositPreauthKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const acc = getDataAccountID(runtime, params, index); if (!acc) @@ -914,33 +924,27 @@ depositPreauthKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_ return hfResult(results, authorize.error()); return returnResult( - runtime, params, results, hf->depositPreauthKeylet(acc.value(), authorize.value()), index); + runtime, params, results, hf.depositPreauthKeylet(acc.value(), authorize.value()), index); } wasm_trap_t* -didKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +didKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const acc = getDataAccountID(runtime, params, index); if (!acc) return hfResult(results, acc.error()); - return returnResult(runtime, params, results, hf->didKeylet(acc.value()), index); + return returnResult(runtime, params, results, hf.didKeylet(acc.value()), index); } wasm_trap_t* -escrowKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +escrowKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const acc = getDataAccountID(runtime, params, index); if (!acc) @@ -950,17 +954,14 @@ escrowKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* resul if (!seq) return hfResult(results, seq.error()); - return returnResult(runtime, params, results, hf->escrowKeylet(*acc, *seq), index); + return returnResult(runtime, params, results, hf.escrowKeylet(*acc, *seq), index); } wasm_trap_t* -lineKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +lineKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const acc1 = getDataAccountID(runtime, params, index); if (!acc1) @@ -978,18 +979,15 @@ lineKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results runtime, params, results, - hf->lineKeylet(acc1.value(), acc2.value(), currency.value()), + hf.lineKeylet(acc1.value(), acc2.value(), currency.value()), index); } wasm_trap_t* -mptIssuanceKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +mptIssuanceKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const acc = getDataAccountID(runtime, params, index); if (!acc) @@ -1000,17 +998,14 @@ mptIssuanceKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* return hfResult(results, seq.error()); return returnResult( - runtime, params, results, hf->mptIssuanceKeylet(acc.value(), seq.value()), index); + runtime, params, results, hf.mptIssuanceKeylet(acc.value(), seq.value()), index); } wasm_trap_t* -mptokenKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +mptokenKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const slice = getDataSlice(runtime, params, index); if (!slice) @@ -1024,17 +1019,14 @@ mptokenKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* resu if (!holder) return hfResult(results, holder.error()); - return returnResult(runtime, params, results, hf->mptokenKeylet(mptid, holder.value()), index); + return returnResult(runtime, params, results, hf.mptokenKeylet(mptid, holder.value()), index); } wasm_trap_t* -nftOfferKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +nftOfferKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const acc = getDataAccountID(runtime, params, index); if (!acc) @@ -1045,17 +1037,14 @@ nftOfferKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* res return hfResult(results, seq.error()); return returnResult( - runtime, params, results, hf->nftOfferKeylet(acc.value(), seq.value()), index); + runtime, params, results, hf.nftOfferKeylet(acc.value(), seq.value()), index); } wasm_trap_t* -offerKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +offerKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const acc = getDataAccountID(runtime, params, index); if (!acc) @@ -1065,17 +1054,14 @@ offerKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* result if (!seq) return hfResult(results, seq.error()); - return returnResult(runtime, params, results, hf->offerKeylet(acc.value(), seq.value()), index); + return returnResult(runtime, params, results, hf.offerKeylet(acc.value(), seq.value()), index); } wasm_trap_t* -oracleKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +oracleKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const acc = getDataAccountID(runtime, params, index); if (!acc) @@ -1085,17 +1071,14 @@ oracleKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* resul if (!documentId) return hfResult(results, documentId.error()); - return returnResult(runtime, params, results, hf->oracleKeylet(*acc, *documentId), index); + return returnResult(runtime, params, results, hf.oracleKeylet(*acc, *documentId), index); } wasm_trap_t* -paychanKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +paychanKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const acc = getDataAccountID(runtime, params, index); if (!acc) @@ -1110,17 +1093,14 @@ paychanKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* resu return hfResult(results, seq.error()); return returnResult( - runtime, params, results, hf->paychanKeylet(acc.value(), dest.value(), seq.value()), index); + runtime, params, results, hf.paychanKeylet(acc.value(), dest.value(), seq.value()), index); } wasm_trap_t* -permissionedDomainKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +permissionedDomainKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const acc = getDataAccountID(runtime, params, index); if (!acc) @@ -1131,33 +1111,27 @@ permissionedDomainKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_ return hfResult(results, seq.error()); return returnResult( - runtime, params, results, hf->permissionedDomainKeylet(acc.value(), seq.value()), index); + runtime, params, results, hf.permissionedDomainKeylet(acc.value(), seq.value()), index); } wasm_trap_t* -signersKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +signersKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const acc = getDataAccountID(runtime, params, index); if (!acc) return hfResult(results, acc.error()); - return returnResult(runtime, params, results, hf->signersKeylet(acc.value()), index); + return returnResult(runtime, params, results, hf.signersKeylet(acc.value()), index); } wasm_trap_t* -ticketKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +ticketKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const acc = getDataAccountID(runtime, params, index); if (!acc) @@ -1167,18 +1141,14 @@ ticketKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* resul if (!seq) return hfResult(results, seq.error()); - return returnResult( - runtime, params, results, hf->ticketKeylet(acc.value(), seq.value()), index); + return returnResult(runtime, params, results, hf.ticketKeylet(acc.value(), seq.value()), index); } wasm_trap_t* -vaultKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +vaultKeylet_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const acc = getDataAccountID(runtime, params, index); if (!acc) @@ -1188,17 +1158,14 @@ vaultKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* result if (!seq) return hfResult(results, seq.error()); - return returnResult(runtime, params, results, hf->vaultKeylet(acc.value(), seq.value()), index); + return returnResult(runtime, params, results, hf.vaultKeylet(acc.value(), seq.value()), index); } wasm_trap_t* -getNFT_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +getNFT_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const acc = getDataAccountID(runtime, params, index); if (!acc) @@ -1208,104 +1175,79 @@ getNFT_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) if (!nftId) return hfResult(results, nftId.error()); - return returnResult(runtime, params, results, hf->getNFT(*acc, *nftId), index); + return returnResult(runtime, params, results, hf.getNFT(*acc, *nftId), index); } wasm_trap_t* -getNFTIssuer_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +getNFTIssuer_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const nftId = getDataUInt256(runtime, params, index); if (!nftId) return hfResult(results, nftId.error()); - return returnResult(runtime, params, results, hf->getNFTIssuer(*nftId), index); + return returnResult(runtime, params, results, hf.getNFTIssuer(*nftId), index); } wasm_trap_t* -getNFTTaxon_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +getNFTTaxon_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const nftId = getDataUInt256(runtime, params, index); if (!nftId) return hfResult(results, nftId.error()); - return returnResult(runtime, params, results, hf->getNFTTaxon(*nftId), index); + return returnResult(runtime, params, results, hf.getNFTTaxon(*nftId), index); } wasm_trap_t* -getNFTFlags_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +getNFTFlags_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const nftId = getDataUInt256(runtime, params, index); if (!nftId) return hfResult(results, nftId.error()); - return returnResult(runtime, params, results, hf->getNFTFlags(*nftId), index); + return returnResult(runtime, params, results, hf.getNFTFlags(*nftId), index); } wasm_trap_t* -getNFTTransferFee_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +getNFTTransferFee_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const nftId = getDataUInt256(runtime, params, index); if (!nftId) return hfResult(results, nftId.error()); - return returnResult(runtime, params, results, hf->getNFTTransferFee(*nftId), index); + return returnResult(runtime, params, results, hf.getNFTTransferFee(*nftId), index); } wasm_trap_t* -getNFTSerial_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +getNFTSerial_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const nftId = getDataUInt256(runtime, params, index); if (!nftId) return hfResult(results, nftId.error()); - return returnResult(runtime, params, results, hf->getNFTSerial(*nftId), index); + return returnResult(runtime, params, results, hf.getNFTSerial(*nftId), index); } wasm_trap_t* -trace_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +trace_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; - - int64_t const len = (int64_t)params->data[1].of.i32 + params->data[3].of.i32; - if (len < 0) - return hfResult(results, HostFunctionError::InvalidParams); - - if (std::cmp_greater(len, kMaxWasmParamLength)) - return hfResult(results, HostFunctionError::DataFieldTooLarge); + WasmRuntimeWrapper& runtime = hf.getRT(); auto const msg = getDataString(runtime, params, index); if (!msg) @@ -1315,6 +1257,9 @@ trace_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) if (!data) return hfResult(results, data.error()); + if (msg->size() + data->size() > kMaxWasmDataLength) + return hfResult(results, HostFunctionError::DataFieldTooLarge); + auto const asHex = getDataInt32(runtime, params, index); if (!asHex) return hfResult(results, asHex.error()); // LCOV_EXCL_LINE @@ -1322,24 +1267,14 @@ trace_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) if (*asHex != 0 && *asHex != 1) return hfResult(results, HostFunctionError::InvalidParams); - return returnResult(runtime, params, results, hf->trace(*msg, *data, *asHex != 0), index); + return returnResult(runtime, params, results, hf.trace(*msg, *data, *asHex != 0), index); } wasm_trap_t* -traceNum_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +traceNum_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); int index = 0; - - int32_t const len = params->data[1].of.i32; - if (len < 0) - return hfResult(results, HostFunctionError::InvalidParams); - - if (std::cmp_greater(len, kMaxWasmParamLength)) - return hfResult(results, HostFunctionError::DataFieldTooLarge); + WasmRuntimeWrapper& runtime = hf.getRT(); auto const msg = getDataString(runtime, params, index); if (!msg) @@ -1349,25 +1284,15 @@ traceNum_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) if (!number) return hfResult(results, number.error()); // LCOV_EXCL_LINE - return returnResult(runtime, params, results, hf->traceNum(*msg, *number), index); + return returnResult(runtime, params, results, hf.traceNum(*msg, *number), index); } wasm_trap_t* -traceAccount_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +traceAccount_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); - - int32_t const len = params->data[1].of.i32; - if (len < 0) - return hfResult(results, HostFunctionError::InvalidParams); - - if (std::cmp_greater(len, kMaxWasmParamLength)) - return hfResult(results, HostFunctionError::DataFieldTooLarge); - int i = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); + auto const msg = getDataString(runtime, params, i); if (!msg) return hfResult(results, msg.error()); @@ -1376,25 +1301,15 @@ traceAccount_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* resul if (!account) return hfResult(results, account.error()); - return returnResult(runtime, params, results, hf->traceAccount(*msg, *account), i); + return returnResult(runtime, params, results, hf.traceAccount(*msg, *account), i); } wasm_trap_t* -traceFloat_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +traceFloat_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); - - int32_t const len = params->data[1].of.i32; - if (len < 0) - return hfResult(results, HostFunctionError::InvalidParams); - - if (std::cmp_greater(len, kMaxWasmParamLength)) - return hfResult(results, HostFunctionError::DataFieldTooLarge); - int i = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); + auto const msg = getDataString(runtime, params, i); if (!msg) return hfResult(results, msg.error()); @@ -1403,25 +1318,15 @@ traceFloat_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results if (!number) return hfResult(results, number.error()); - return returnResult(runtime, params, results, hf->traceFloat(*msg, *number), i); + return returnResult(runtime, params, results, hf.traceFloat(*msg, *number), i); } wasm_trap_t* -traceAmount_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +traceAmount_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); - - int32_t const len = params->data[1].of.i32; - if (len < 0) - return hfResult(results, HostFunctionError::InvalidParams); - - if (std::cmp_greater(len, kMaxWasmParamLength)) - return hfResult(results, HostFunctionError::DataFieldTooLarge); - int i = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); + auto const msg = getDataString(runtime, params, i); if (!msg) return hfResult(results, msg.error()); @@ -1448,18 +1353,15 @@ traceAmount_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* result return hfResult(results, HostFunctionError::InvalidParams); } - return returnResult(runtime, params, results, hf->traceAmount(*msg, *amount), i); + return returnResult(runtime, params, results, hf.traceAmount(*msg, *amount), i); } wasm_trap_t* -floatFromInt_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +floatFromInt_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); - int i = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); + auto const x = getDataInt64(runtime, params, i); if (!x) return hfResult(results, x.error()); // LCOV_EXCL_LINE @@ -1470,18 +1372,15 @@ floatFromInt_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* resul return hfResult(results, rounding.error()); // LCOV_EXCL_LINE i = 1; - return returnResult(runtime, params, results, hf->floatFromInt(*x, *rounding), i); + return returnResult(runtime, params, results, hf.floatFromInt(*x, *rounding), i); } wasm_trap_t* -floatFromUint_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +floatFromUint_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); - int i = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); + auto const x = getDataUInt64(runtime, params, i); if (!x) return hfResult(results, x.error()); @@ -1492,18 +1391,15 @@ floatFromUint_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* resu return hfResult(results, rounding.error()); // LCOV_EXCL_LINE i = 2; - return returnResult(runtime, params, results, hf->floatFromUint(*x, *rounding), i); + return returnResult(runtime, params, results, hf.floatFromUint(*x, *rounding), i); } wasm_trap_t* -floatFromSTAmount_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +floatFromSTAmount_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); - int i = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); + auto const x = getDataSlice(runtime, params, i); if (!x) return hfResult(results, x.error()); @@ -1527,18 +1423,15 @@ floatFromSTAmount_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* return hfResult(results, rounding.error()); // LCOV_EXCL_LINE i = 2; - return returnResult(runtime, params, results, hf->floatFromSTAmount(*amount, *rounding), i); + return returnResult(runtime, params, results, hf.floatFromSTAmount(*amount, *rounding), i); } wasm_trap_t* -floatFromSTNumber_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +floatFromSTNumber_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); - int i = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); + auto const x = getDataSlice(runtime, params, i); if (!x) return hfResult(results, x.error()); @@ -1562,18 +1455,15 @@ floatFromSTNumber_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* return hfResult(results, rounding.error()); // LCOV_EXCL_LINE i = 2; - return returnResult(runtime, params, results, hf->floatFromSTNumber(*num, *rounding), i); + return returnResult(runtime, params, results, hf.floatFromSTNumber(*num, *rounding), i); } wasm_trap_t* -floatToInt_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +floatToInt_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); - int i = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); + auto const x = getDataSlice(runtime, params, i); if (!x) return hfResult(results, x.error()); @@ -1584,35 +1474,28 @@ floatToInt_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results return hfResult(results, rounding.error()); // LCOV_EXCL_LINE i = 2; - return returnResult(runtime, params, results, hf->floatToInt(*x, *rounding), i); + return returnResult(runtime, params, results, hf.floatToInt(*x, *rounding), i); } wasm_trap_t* -floatToMantExp_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +floatToMantExp_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); - int i = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); + auto const x = getDataSlice(runtime, params, i); if (!x) return hfResult(results, x.error()); i = 2; - return returnResult(runtime, params, results, hf->floatToMantExp(*x), i); + return returnResult(runtime, params, results, hf.floatToMantExp(*x), i); } wasm_trap_t* -floatFromMantExp_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +floatFromMantExp_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); - int i = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); auto const mant = getDataInt64(runtime, params, i); if (!mant) @@ -1628,18 +1511,15 @@ floatFromMantExp_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* r return hfResult(results, rounding.error()); // LCOV_EXCL_LINE i = 2; - return returnResult(runtime, params, results, hf->floatFromMantExp(*mant, *exp, *rounding), i); + return returnResult(runtime, params, results, hf.floatFromMantExp(*mant, *exp, *rounding), i); } wasm_trap_t* -floatCompare_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +floatCompare_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); - int i = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); + auto const x = getDataSlice(runtime, params, i); if (!x) return hfResult(results, x.error()); @@ -1648,18 +1528,15 @@ floatCompare_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* resul if (!y) return hfResult(results, y.error()); - return returnResult(runtime, params, results, hf->floatCompare(*x, *y), i); + return returnResult(runtime, params, results, hf.floatCompare(*x, *y), i); } wasm_trap_t* -floatAdd_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +floatAdd_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); - int i = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); + auto const x = getDataSlice(runtime, params, i); if (!x) return hfResult(results, x.error()); @@ -1674,18 +1551,15 @@ floatAdd_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) return hfResult(results, rounding.error()); // LCOV_EXCL_LINE i = 4; - return returnResult(runtime, params, results, hf->floatAdd(*x, *y, *rounding), i); + return returnResult(runtime, params, results, hf.floatAdd(*x, *y, *rounding), i); } wasm_trap_t* -floatSubtract_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +floatSubtract_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); - int i = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); + auto const x = getDataSlice(runtime, params, i); if (!x) return hfResult(results, x.error()); @@ -1700,18 +1574,15 @@ floatSubtract_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* resu return hfResult(results, rounding.error()); // LCOV_EXCL_LINE i = 4; - return returnResult(runtime, params, results, hf->floatSubtract(*x, *y, *rounding), i); + return returnResult(runtime, params, results, hf.floatSubtract(*x, *y, *rounding), i); } wasm_trap_t* -floatMultiply_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +floatMultiply_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); - int i = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); + auto const x = getDataSlice(runtime, params, i); if (!x) return hfResult(results, x.error()); @@ -1726,18 +1597,15 @@ floatMultiply_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* resu return hfResult(results, rounding.error()); // LCOV_EXCL_LINE i = 4; - return returnResult(runtime, params, results, hf->floatMultiply(*x, *y, *rounding), i); + return returnResult(runtime, params, results, hf.floatMultiply(*x, *y, *rounding), i); } wasm_trap_t* -floatDivide_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +floatDivide_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); - int i = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); + auto const x = getDataSlice(runtime, params, i); if (!x) return hfResult(results, x.error()); @@ -1752,18 +1620,15 @@ floatDivide_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* result return hfResult(results, rounding.error()); // LCOV_EXCL_LINE i = 4; - return returnResult(runtime, params, results, hf->floatDivide(*x, *y, *rounding), i); + return returnResult(runtime, params, results, hf.floatDivide(*x, *y, *rounding), i); } wasm_trap_t* -floatRoot_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +floatRoot_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); - int i = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); + auto const x = getDataSlice(runtime, params, i); if (!x) return hfResult(results, x.error()); @@ -1778,18 +1643,15 @@ floatRoot_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) return hfResult(results, rounding.error()); // LCOV_EXCL_LINE i = 3; - return returnResult(runtime, params, results, hf->floatRoot(*x, *n, *rounding), i); + return returnResult(runtime, params, results, hf.floatRoot(*x, *n, *rounding), i); } wasm_trap_t* -floatPower_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +floatPower_wrap(WASM_SECONDARY_CB_PARAMS_LIST) { - if (auto g = checkGas(env); !g) - return g.error(); // LCOV_EXCL_LINE - auto* hf = getHF(env); - auto* runtime = hf->getRT(); - int i = 0; + WasmRuntimeWrapper& runtime = hf.getRT(); + auto const x = getDataSlice(runtime, params, i); if (!x) return hfResult(results, x.error()); @@ -1804,7 +1666,7 @@ floatPower_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results return hfResult(results, rounding.error()); // LCOV_EXCL_LINE i = 3; - return returnResult(runtime, params, results, hf->floatPower(*x, *n, *rounding), i); + return returnResult(runtime, params, results, hf.floatPower(*x, *n, *rounding), i); } // LCOV_EXCL_START @@ -1857,7 +1719,7 @@ testGetDataIncrement() values[0] = WASM_I32_VAL(42); int index = 0; - auto const result = getDataInt32(&runtime, ¶ms, index); + auto const result = getDataInt32(runtime, ¶ms, index); if (!result || result.value() != 42 || index != 1) return false; } @@ -1869,7 +1731,7 @@ testGetDataIncrement() values[0] = WASM_I64_VAL(1234); int index = 0; - auto const result = getDataInt64(&runtime, ¶ms, index); + auto const result = getDataInt64(runtime, ¶ms, index); if (!result || result.value() != 1234 || index != 1) return false; } @@ -1881,7 +1743,7 @@ testGetDataIncrement() values[0] = WASM_I32_VAL(sfAccount.getCode()); int index = 0; - auto const result = getDataSField(&runtime, ¶ms, index); + auto const result = getDataSField(runtime, ¶ms, index); if (!result || result.value().get() != sfAccount || index != 1) return false; } @@ -1894,7 +1756,7 @@ testGetDataIncrement() values[1] = WASM_I32_VAL(3); int index = 0; - auto const result = getDataSlice(&runtime, ¶ms, index); + auto const result = getDataSlice(runtime, ¶ms, index); if (!result || result.value() != Slice(buffer.data(), 3) || index != 2) return false; } @@ -1907,7 +1769,7 @@ testGetDataIncrement() values[1] = WASM_I32_VAL(5); int index = 0; - auto const result = getDataString(&runtime, ¶ms, index); + auto const result = getDataString(runtime, ¶ms, index); if (!result || result.value() != std::string_view(reinterpret_cast(buffer.data()), 5) || index != 2) @@ -1926,7 +1788,7 @@ testGetDataIncrement() memcpy(&buffer[0], id.data(), AccountID::size()); int index = 0; - auto const result = getDataAccountID(&runtime, ¶ms, index); + auto const result = getDataAccountID(runtime, ¶ms, index); if (!result || result.value() != id || index != 2) return false; } @@ -1942,7 +1804,7 @@ testGetDataIncrement() memcpy(&buffer[0], h1.data(), Hash::size()); int index = 0; - auto const result = getDataUInt256(&runtime, ¶ms, index); + auto const result = getDataUInt256(runtime, ¶ms, index); if (!result || result.value() != h1 || index != 2) return false; } @@ -1958,7 +1820,7 @@ testGetDataIncrement() memcpy(&buffer[0], c.data(), Currency::size()); int index = 0; - auto const result = getDataCurrency(&runtime, ¶ms, index); + auto const result = getDataCurrency(runtime, ¶ms, index); if (!result || result.value() != c || index != 2) return false; } diff --git a/src/libxrpl/tx/wasm/WasmiVM.cpp b/src/libxrpl/tx/wasm/WasmiVM.cpp index 007610fee2..018b97e22b 100644 --- a/src/libxrpl/tx/wasm/WasmiVM.cpp +++ b/src/libxrpl/tx/wasm/WasmiVM.cpp @@ -35,6 +35,9 @@ namespace xrpl { +wasm_trap_t* +HostFuncMain_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results); + namespace { void @@ -395,12 +398,8 @@ ModuleWrapper::buildImports(StorePtr& s, ImportVec const& imports) const params.release(); results.release(); - wasm_func_t* func = wasm_func_new_with_env( - s.get(), - ftype.get(), - reinterpret_cast(imp.wrap), - (void*)&obj, - nullptr); + wasm_func_t* func = + wasm_func_new_with_env(s.get(), ftype.get(), HostFuncMain_wrap, (void*)&obj, nullptr); if (func == nullptr) { Throw( diff --git a/src/test/app/HostFuncImpl_test.cpp b/src/test/app/HostFuncImpl_test.cpp index ab925cb432..f77cbe8a87 100644 --- a/src/test/app/HostFuncImpl_test.cpp +++ b/src/test/app/HostFuncImpl_test.cpp @@ -294,7 +294,7 @@ ww_hlp(size_t& idx, E&& e, P&& params, Arg&& arg) { auto const* udata = reinterpret_cast(e); HostFunctions const& hf = udata->first; - auto& vrt = *reinterpret_cast(hf.getRT()); + auto& vrt = reinterpret_cast(hf.getRT()); auto const data = toBytes(std::forward(arg)); @@ -307,7 +307,7 @@ ww_hlp(size_t& idx, E&& e, P&& params, Arg&& arg) { auto const* udata = reinterpret_cast(e); HostFunctions const& hf = udata->first; - auto& vrt = *reinterpret_cast(hf.getRT()); + auto& vrt = reinterpret_cast(hf.getRT()); size_t const ptr = (idx << 10); vrt.setBytes(ptr, arg.data(), arg.size()); @@ -317,13 +317,13 @@ ww_hlp(size_t& idx, E&& e, P&& params, Arg&& arg) } // Helper wrapper to call WASM wrapper functions with automatic parameter packing -template +template wasm_trap_t* -ww(F&& f, E&& e, P&& params, P&& result, Args... args) +ww(E&& e, P&& params, P&& result, Args... args) { size_t idx = 0; - (ww_hlp(idx, e, params, std::forward(args)), ...); - return f(std::forward(e), params.get(), result.get()); + (ww_hlp(idx, e, params, std::forward(args)), ...); // NOLINT + return HostFuncMain_wrap(std::forward(e), params.get(), result.get()); // NOLINT } constexpr int64_t min64 = std::numeric_limits::min(); @@ -351,13 +351,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { // hfs.getLedgerSqn(); WasmValVec params(2), result(1); - auto* trap = - ww(getLedgerSqn_wrap, - &import.at("get_ledger_sqn"), - params, - result, - 0, - sizeof(std::uint32_t)); + auto* trap = ww(&import.at("get_ledger_sqn"), params, result, 0, sizeof(std::uint32_t)); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == sizeof(std::uint32_t)) && @@ -385,12 +379,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.getParentLedgerTime(); WasmValVec params(2), result(1); auto* trap = - ww(getParentLedgerTime_wrap, - &import.at("get_parent_ledger_time"), - params, - result, - 0, - sizeof(std::uint32_t)); + ww(&import.at("get_parent_ledger_time"), params, result, 0, sizeof(std::uint32_t)); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == sizeof(std::uint32_t)) && @@ -420,12 +409,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.getParentLedgerHash(); WasmValVec params(2), result(1); auto* trap = - ww(getParentLedgerHash_wrap, - &import.at("get_parent_ledger_hash"), - params, - result, - 0, - uint256::size()); + ww(&import.at("get_parent_ledger_hash"), params, result, 0, uint256::size()); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == uint256::size()); @@ -456,13 +440,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.getBaseFee(); { WasmValVec params(2), result(1); - auto* trap = - ww(getBaseFee_wrap, - &import.at("get_base_fee"), - params, - result, - 0, - sizeof(std::uint32_t)); + auto* trap = ww(&import.at("get_base_fee"), params, result, 0, sizeof(std::uint32_t)); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == sizeof(std::uint32_t)) && @@ -493,13 +471,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { WasmValVec params(2), result(1); vrt.setBytes(0, amendmentId.data(), uint256::size()); - auto* trap = - ww(isAmendmentEnabled_wrap, - &import.at("amendment_enabled"), - params, - result, - 0, - uint256::size()); + auto* trap = ww(&import.at("amendment_enabled"), params, result, 0, uint256::size()); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == 1); @@ -511,12 +483,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite WasmValVec params(2), result(1); vrt.setBytes(0, amendmentName.data(), amendmentName.size()); auto* trap = - ww(isAmendmentEnabled_wrap, - &import.at("amendment_enabled"), - params, - result, - 0, - amendmentName.size()); + ww(&import.at("amendment_enabled"), params, result, 0, amendmentName.size()); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == 1); @@ -527,13 +494,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { WasmValVec params(2), result(1); vrt.setBytes(0, fakeId.data(), uint256::size()); - auto* trap = - ww(isAmendmentEnabled_wrap, - &import.at("amendment_enabled"), - params, - result, - 0, - uint256::size()); + auto* trap = ww(&import.at("amendment_enabled"), params, result, 0, uint256::size()); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == 0); @@ -544,13 +505,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { WasmValVec params(2), result(1); vrt.setBytes(0, fakeName.data(), fakeName.size()); - auto* trap = - ww(isAmendmentEnabled_wrap, - &import.at("amendment_enabled"), - params, - result, - 0, - fakeName.size()); + auto* trap = ww(&import.at("amendment_enabled"), params, result, 0, fakeName.size()); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == 0); @@ -580,13 +535,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite WasmValVec params(3), result(1); vrt.setBytes(0, accountKeylet.key.data(), uint256::size()); auto* trap = - ww(cacheLedgerObj_wrap, - &import.at("cache_ledger_obj"), - params, - result, - 0, - uint256::size(), - -1); + ww(&import.at("cache_ledger_obj"), params, result, 0, uint256::size(), -1); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -598,13 +547,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite WasmValVec params(3), result(1); vrt.setBytes(0, accountKeylet.key.data(), uint256::size()); auto* trap = - ww(cacheLedgerObj_wrap, - &import.at("cache_ledger_obj"), - params, - result, - 0, - uint256::size(), - 257); + ww(&import.at("cache_ledger_obj"), params, result, 0, uint256::size(), 257); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -616,13 +559,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite WasmValVec params(3), result(1); vrt.setBytes(0, dummyEscrow.key.data(), uint256::size()); auto* trap = - ww(cacheLedgerObj_wrap, - &import.at("cache_ledger_obj"), - params, - result, - 0, - uint256::size(), - 0); + ww(&import.at("cache_ledger_obj"), params, result, 0, uint256::size(), 0); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -635,13 +572,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite WasmValVec params(3), result(1); vrt.setBytes(0, accountKeylet.key.data(), uint256::size()); auto* trap = - ww(cacheLedgerObj_wrap, - &import.at("cache_ledger_obj"), - params, - result, - 0, - uint256::size(), - 0); + ww(&import.at("cache_ledger_obj"), params, result, 0, uint256::size(), 0); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == 1); @@ -654,13 +585,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite WasmValVec params(3), result(1); vrt.setBytes(0, accountKeylet.key.data(), uint256::size()); auto* trap = - ww(cacheLedgerObj_wrap, - &import.at("cache_ledger_obj"), - params, - result, - 0, - uint256::size(), - i); + ww(&import.at("cache_ledger_obj"), params, result, 0, uint256::size(), i); if (!(BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECTS( @@ -675,13 +600,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite WasmValVec params(3), result(1); vrt.setBytes(0, accountKeylet.key.data(), uint256::size()); auto* trap = - ww(cacheLedgerObj_wrap, - &import.at("cache_ledger_obj"), - params, - result, - 0, - uint256::size(), - 0); + ww(&import.at("cache_ledger_obj"), params, result, 0, uint256::size(), 0); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -703,13 +622,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite WasmValVec params(3), result(1); vrt.setBytes(0, accountKeylet.key.data(), uint256::size()); auto* trap = - ww(cacheLedgerObj_wrap, - &import.at("cache_ledger_obj"), - params, - result, - 0, - uint256::size(), - 0); + ww(&import.at("cache_ledger_obj"), params, result, 0, uint256::size(), 0); if (!(BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECTS( @@ -724,13 +637,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite WasmValVec params(3), result(1); vrt.setBytes(0, accountKeylet.key.data(), uint256::size()); auto* trap = - ww(cacheLedgerObj_wrap, - &import.at("cache_ledger_obj"), - params, - result, - 0, - uint256::size(), - 0); + ww(&import.at("cache_ledger_obj"), params, result, 0, uint256::size(), 0); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -775,8 +682,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { WasmValVec params(3), result(1); auto* trap = - ww(getTxField_wrap, - &import.at("get_tx_field"), + ww(&import.at("get_tx_field"), params, result, sfAccount.getCode(), @@ -793,8 +699,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { WasmValVec params(3), result(1); auto* trap = - ww(getTxField_wrap, - &import.at("get_tx_field"), + ww(&import.at("get_tx_field"), params, result, sfOwner.getCode(), @@ -811,8 +716,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { WasmValVec params(3), result(1); auto* trap = - ww(getTxField_wrap, - &import.at("get_tx_field"), + ww(&import.at("get_tx_field"), params, result, sfTransactionType.getCode(), @@ -829,14 +733,8 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.getTxField(sfOfferSequence); { WasmValVec params(3), result(1); - auto* trap = - ww(getTxField_wrap, - &import.at("get_tx_field"), - params, - result, - sfOfferSequence.getCode(), - 0, - 256); + auto* trap = ww( + &import.at("get_tx_field"), params, result, sfOfferSequence.getCode(), 0, 256); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 > 0); @@ -849,13 +747,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { WasmValVec params(3), result(1); auto* trap = - ww(getTxField_wrap, - &import.at("get_tx_field"), - params, - result, - sfDestination.getCode(), - 0, - 256); + ww(&import.at("get_tx_field"), params, result, sfDestination.getCode(), 0, 256); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -866,13 +758,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { WasmValVec params(3), result(1); auto* trap = - ww(getTxField_wrap, - &import.at("get_tx_field"), - params, - result, - sfMemos.getCode(), - 0, - 256); + ww(&import.at("get_tx_field"), params, result, sfMemos.getCode(), 0, 256); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -882,14 +768,8 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.getTxField(sfCredentialIDs); { WasmValVec params(3), result(1); - auto* trap = - ww(getTxField_wrap, - &import.at("get_tx_field"), - params, - result, - sfCredentialIDs.getCode(), - 0, - 256); + auto* trap = ww( + &import.at("get_tx_field"), params, result, sfCredentialIDs.getCode(), 0, 256); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32); BEAST_EXPECTS( @@ -901,13 +781,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { WasmValVec params(3), result(1); auto* trap = - ww(getTxField_wrap, - &import.at("get_tx_field"), - params, - result, - kSfInvalid.getCode(), - 0, - 256); + ww(&import.at("get_tx_field"), params, result, kSfInvalid.getCode(), 0, 256); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -918,13 +792,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { WasmValVec params(3), result(1); auto* trap = - ww(getTxField_wrap, - &import.at("get_tx_field"), - params, - result, - kSfGeneric.getCode(), - 0, - 256); + ww(&import.at("get_tx_field"), params, result, kSfGeneric.getCode(), 0, 256); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -950,13 +818,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { WasmValVec params(3), result(1); auto* trap = - ww(getTxField_wrap, - &import.at("get_tx_field"), - params, - result, - sfAsset.getCode(), - 0, - 256); + ww(&import.at("get_tx_field"), params, result, sfAsset.getCode(), 0, 256); std::vector const expectedAsset(20, 0); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && @@ -970,13 +832,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { WasmValVec params(3), result(1); auto* trap = - ww(getTxField_wrap, - &import.at("get_tx_field"), - params, - result, - sfAsset2.getCode(), - 0, - 256); + ww(&import.at("get_tx_field"), params, result, sfAsset2.getCode(), 0, 256); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 > 0); @@ -1005,13 +861,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { WasmValVec params(3), result(1); auto* trap = - ww(getTxField_wrap, - &import.at("get_tx_field"), - params, - result, - sfAsset.getCode(), - 0, - 256); + ww(&import.at("get_tx_field"), params, result, sfAsset.getCode(), 0, 256); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32); if (BEAST_EXPECT(result[0].of.i32 > 0)) @@ -1026,13 +876,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { WasmValVec params(3), result(1); auto* trap = - ww(getTxField_wrap, - &import.at("get_tx_field"), - params, - result, - sfAsset2.getCode(), - 0, - 256); + ww(&import.at("get_tx_field"), params, result, sfAsset2.getCode(), 0, 256); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32); if (BEAST_EXPECT(result[0].of.i32 > 0)) @@ -1061,13 +905,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { WasmValVec params(3), result(1); auto* trap = - ww(getTxField_wrap, - &import.at("get_tx_field"), - params, - result, - sfAssetScale.getCode(), - 0, - 256); + ww(&import.at("get_tx_field"), params, result, sfAssetScale.getCode(), 0, 256); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32); if (BEAST_EXPECT(result[0].of.i32 > 0)) @@ -1110,8 +948,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { WasmValVec params(3), result(1); auto* trap = - ww(getCurrentLedgerObjField_wrap, - &import.at("get_current_ledger_obj_field"), + ww(&import.at("get_current_ledger_obj_field"), params, result, sfAccount.getCode(), @@ -1131,8 +968,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { WasmValVec params(3), result(1); auto* trap = - ww(getCurrentLedgerObjField_wrap, - &import.at("get_current_ledger_obj_field"), + ww(&import.at("get_current_ledger_obj_field"), params, result, sfAmount.getCode(), @@ -1152,8 +988,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { WasmValVec params(3), result(1); auto* trap = - ww(getCurrentLedgerObjField_wrap, - &import.at("get_current_ledger_obj_field"), + ww(&import.at("get_current_ledger_obj_field"), params, result, sfPreviousTxnID.getCode(), @@ -1173,8 +1008,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { WasmValVec params(3), result(1); auto* trap = - ww(getCurrentLedgerObjField_wrap, - &import.at("get_current_ledger_obj_field"), + ww(&import.at("get_current_ledger_obj_field"), params, result, sfOwner.getCode(), @@ -1198,8 +1032,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { WasmValVec params(3), result(1); auto* trap = - ww(getCurrentLedgerObjField_wrap, - &import2.at("get_current_ledger_obj_field"), + ww(&import2.at("get_current_ledger_obj_field"), params, result, sfAccount.getCode(), @@ -1241,14 +1074,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { WasmValVec params(3), result(1); vrt.setBytes(0, accountKeylet.key.data(), uint256::size()); - auto* trap = - ww(cacheLedgerObj_wrap, - &import.at("cache_ledger_obj"), - params, - result, - 0, - uint256::size(), - 1); + auto* trap = ww(&import.at("cache_ledger_obj"), params, result, 0, uint256::size(), 1); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == 1); @@ -1257,15 +1083,8 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.getLedgerObjField(1, sfAccount); { WasmValVec params(4), result(1); - auto* trap = - ww(getLedgerObjField_wrap, - &import.at("get_ledger_obj_field"), - params, - result, - 1, - sfAccount.getCode(), - 0, - 256); + auto* trap = ww( + &import.at("get_ledger_obj_field"), params, result, 1, sfAccount.getCode(), 0, 256); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32); if (BEAST_EXPECTS(result[0].of.i32 > 0, std::to_string(result[0].of.i32))) @@ -1279,15 +1098,8 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.getLedgerObjField(1, sfBalance); { WasmValVec params(4), result(1); - auto* trap = - ww(getLedgerObjField_wrap, - &import.at("get_ledger_obj_field"), - params, - result, - 1, - sfBalance.getCode(), - 0, - 256); + auto* trap = ww( + &import.at("get_ledger_obj_field"), params, result, 1, sfBalance.getCode(), 0, 256); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32); if (BEAST_EXPECT(result[0].of.i32 > 0)) @@ -1301,15 +1113,8 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.getLedgerObjField(0, sfAccount); { WasmValVec params(4), result(1); - auto* trap = - ww(getLedgerObjField_wrap, - &import.at("get_ledger_obj_field"), - params, - result, - 0, - sfAccount.getCode(), - 0, - 256); + auto* trap = ww( + &import.at("get_ledger_obj_field"), params, result, 0, sfAccount.getCode(), 0, 256); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -1320,8 +1125,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { WasmValVec params(4), result(1); auto* trap = - ww(getLedgerObjField_wrap, - &import.at("get_ledger_obj_field"), + ww(&import.at("get_ledger_obj_field"), params, result, 257, @@ -1337,15 +1141,8 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.getLedgerObjField(2, sfAccount); { WasmValVec params(4), result(1); - auto* trap = - ww(getLedgerObjField_wrap, - &import.at("get_ledger_obj_field"), - params, - result, - 2, - sfAccount.getCode(), - 0, - 256); + auto* trap = ww( + &import.at("get_ledger_obj_field"), params, result, 2, sfAccount.getCode(), 0, 256); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -1355,15 +1152,8 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.getLedgerObjField(1, sfOwner); { WasmValVec params(4), result(1); - auto* trap = - ww(getLedgerObjField_wrap, - &import.at("get_ledger_obj_field"), - params, - result, - 1, - sfOwner.getCode(), - 0, - 256); + auto* trap = ww( + &import.at("get_ledger_obj_field"), params, result, 1, sfOwner.getCode(), 0, 256); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -1416,8 +1206,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite WasmValVec params(4), result(1); auto* trap = - ww(getTxNestedField_wrap, - &import.at("get_tx_nested_field"), + ww(&import.at("get_tx_nested_field"), params, result, 0, @@ -1446,8 +1235,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite WasmValVec params(4), result(1); auto* trap = - ww(getTxNestedField_wrap, - &import.at("get_tx_nested_field"), + ww(&import.at("get_tx_nested_field"), params, result, 0, @@ -1473,8 +1261,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite WasmValVec params(4), result(1); auto* trap = - ww(getTxNestedField_wrap, - &import.at("get_tx_nested_field"), + ww(&import.at("get_tx_nested_field"), params, result, 0, @@ -1497,18 +1284,11 @@ struct HostFuncImpl_test : public beast::unit_test::Suite std::vector locatorVec(sizeof(int32_t) + 1); auto const accountFieldCode = sfAccount.getCode(); memcpy(locatorVec.data() + 1, &accountFieldCode, sizeof(int32_t)); - vrt.setBytes(0, locatorVec.data() + 1, sizeof(int32_t)); + vrt.setBytes(0, locatorVec.data(), sizeof(int32_t) + 1); WasmValVec params(4), result(1); auto* trap = - ww(getTxNestedField_wrap, - &import.at("get_tx_nested_field"), - params, - result, - 0, - sizeof(int32_t), - 256, - 256); + ww(&import.at("get_tx_nested_field"), params, result, 1, sizeof(int32_t), 256, 256); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32); if (BEAST_EXPECTS(result[0].of.i32 > 0, std::to_string(result[0].of.i32))) @@ -1526,8 +1306,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite WasmValVec params(4), result(1); // hfs.getTxNestedField(locator); auto* trap = - ww(getTxNestedField_wrap, - &import.at("get_tx_nested_field"), + ww(&import.at("get_tx_nested_field"), params, result, 0, @@ -1654,15 +1433,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, locatorVec.data(), 3); WasmValVec params(4), result(1); - auto* trap = - ww(getTxNestedField_wrap, - &import.at("get_tx_nested_field"), - params, - result, - 0, - 3, - 256, - 256); + auto* trap = ww(&import.at("get_tx_nested_field"), params, result, 0, 3, 256, 256); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -1703,8 +1474,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite WasmValVec params(4), result(1); auto* trap = - ww(getCurrentLedgerObjNestedField_wrap, - &import.at("get_current_ledger_obj_nested_field"), + ww(&import.at("get_current_ledger_obj_nested_field"), params, result, 0, @@ -1728,8 +1498,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite WasmValVec params(4), result(1); // hfs.getCurrentLedgerObjNestedField(locator); auto* trap = - ww(getCurrentLedgerObjNestedField_wrap, - &import.at("get_current_ledger_obj_nested_field"), + ww(&import.at("get_current_ledger_obj_nested_field"), params, result, 0, @@ -1761,15 +1530,8 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // Locator for empty locator { WasmValVec params(4), result(1); - auto* trap = - ww(getCurrentLedgerObjNestedField_wrap, - &import.at("get_current_ledger_obj_nested_field"), - params, - result, - 0, - 0, - 256, - 256); + auto* trap = ww( + &import.at("get_current_ledger_obj_nested_field"), params, result, 0, 0, 256, 256); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -1783,15 +1545,8 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, malformedLocatorVec.data(), 3); WasmValVec params(4), result(1); - auto* trap = - ww(getCurrentLedgerObjNestedField_wrap, - &import.at("get_current_ledger_obj_nested_field"), - params, - result, - 0, - 3, - 256, - 256); + auto* trap = ww( + &import.at("get_current_ledger_obj_nested_field"), params, result, 0, 3, 256, 256); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -1812,8 +1567,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite WasmValVec params(4), result(1); auto* trap = - ww(getCurrentLedgerObjNestedField_wrap, - &import2.at("get_current_ledger_obj_nested_field"), + ww(&import2.at("get_current_ledger_obj_nested_field"), params, result, 0, @@ -1857,14 +1611,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { WasmValVec params(3), result(1); vrt.setBytes(0, signerListKeylet.key.data(), uint256::size()); - auto* trap = - ww(cacheLedgerObj_wrap, - &import.at("cache_ledger_obj"), - params, - result, - 0, - uint256::size(), - 1); + auto* trap = ww(&import.at("cache_ledger_obj"), params, result, 0, uint256::size(), 1); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == 1); } @@ -1877,8 +1624,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, locatorVec.data(), locatorVec.size() * sizeof(int32_t)); WasmValVec params(5), result(1); auto* trap = - ww(getLedgerObjNestedField_wrap, - &import.at("get_ledger_obj_nested_field"), + ww(&import.at("get_ledger_obj_nested_field"), params, result, 1, @@ -1904,8 +1650,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, locatorVec.data(), locatorVec.size() * sizeof(int32_t)); WasmValVec params(5), result(1); auto* trap = - ww(getLedgerObjNestedField_wrap, - &import.at("get_ledger_obj_nested_field"), + ww(&import.at("get_ledger_obj_nested_field"), params, result, 1, @@ -1931,8 +1676,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, locatorVec.data(), locatorVec.size() * sizeof(int32_t)); WasmValVec params(5), result(1); auto* trap = - ww(getLedgerObjNestedField_wrap, - &import.at("get_ledger_obj_nested_field"), + ww(&import.at("get_ledger_obj_nested_field"), params, result, 1, @@ -1959,8 +1703,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, locatorVec.data(), locatorVec.size() * sizeof(int32_t)); WasmValVec params(5), result(1); auto* trap = - ww(getLedgerObjNestedField_wrap, - &import.at("get_ledger_obj_nested_field"), + ww(&import.at("get_ledger_obj_nested_field"), params, result, 1, @@ -1987,8 +1730,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, locatorVec.data(), locatorVec.size() * sizeof(int32_t)); WasmValVec params(5), result(1); auto* trap = - ww(getLedgerObjNestedField_wrap, - &import.at("get_ledger_obj_nested_field"), + ww(&import.at("get_ledger_obj_nested_field"), params, result, slot, @@ -2058,15 +1800,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, locatorVec.data(), 3); WasmValVec params(5), result(1); auto* trap = - ww(getLedgerObjNestedField_wrap, - &import.at("get_ledger_obj_nested_field"), - params, - result, - 1, - 0, - 3, - 256, - 256); + ww(&import.at("get_ledger_obj_nested_field"), params, result, 1, 0, 3, 256, 256); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -2120,12 +1854,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.getTxArrayLen(sfMemos); { WasmValVec params(1), result(1); - auto* trap = - ww(getTxArrayLen_wrap, - &import.at("get_tx_array_len"), - params, - result, - sfMemos.getCode()); + auto* trap = ww(&import.at("get_tx_array_len"), params, result, sfMemos.getCode()); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32); if (BEAST_EXPECT(result[0].of.i32 > 0)) @@ -2136,12 +1865,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.getTxArrayLen(sfAccount); { WasmValVec params(1), result(1); - auto* trap = - ww(getTxArrayLen_wrap, - &import.at("get_tx_array_len"), - params, - result, - sfAccount.getCode()); + auto* trap = ww(&import.at("get_tx_array_len"), params, result, sfAccount.getCode()); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32); BEAST_EXPECT(result[0].of.i32 == static_cast(HostFunctionError::NoArray)); @@ -2151,12 +1875,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.getTxArrayLen(sfSigners); { WasmValVec params(1), result(1); - auto* trap = - ww(getTxArrayLen_wrap, - &import.at("get_tx_array_len"), - params, - result, - sfSigners.getCode()); + auto* trap = ww(&import.at("get_tx_array_len"), params, result, sfSigners.getCode()); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32); BEAST_EXPECT( @@ -2168,11 +1887,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { WasmValVec params(1), result(1); auto* trap = - ww(getTxArrayLen_wrap, - &import.at("get_tx_array_len"), - params, - result, - sfCredentialIDs.getCode()); + ww(&import.at("get_tx_array_len"), params, result, sfCredentialIDs.getCode()); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32); if (BEAST_EXPECT(result[0].of.i32 > 0)) @@ -2207,8 +1922,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { WasmValVec params(1), result(1); auto* trap = - ww(getCurrentLedgerObjArrayLen_wrap, - &import.at("get_current_ledger_obj_array_len"), + ww(&import.at("get_current_ledger_obj_array_len"), params, result, sfSignerEntries.getCode()); @@ -2221,12 +1935,8 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.getCurrentLedgerObjArrayLen(sfMemos); { WasmValVec params(1), result(1); - auto* trap = - ww(getCurrentLedgerObjArrayLen_wrap, - &import.at("get_current_ledger_obj_array_len"), - params, - result, - sfMemos.getCode()); + auto* trap = ww( + &import.at("get_current_ledger_obj_array_len"), params, result, sfMemos.getCode()); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32); BEAST_EXPECT( @@ -2238,8 +1948,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { WasmValVec params(1), result(1); auto* trap = - ww(getCurrentLedgerObjArrayLen_wrap, - &import.at("get_current_ledger_obj_array_len"), + ww(&import.at("get_current_ledger_obj_array_len"), params, result, sfAccount.getCode()); @@ -2258,12 +1967,8 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // auto const len = dummyHfs.getCurrentLedgerObjArrayLen(sfMemos); WasmValVec params(1), result(1); - auto* trap = - ww(getCurrentLedgerObjArrayLen_wrap, - &import2.at("get_current_ledger_obj_array_len"), - params, - result, - sfMemos.getCode()); + auto* trap = ww( + &import2.at("get_current_ledger_obj_array_len"), params, result, sfMemos.getCode()); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32); BEAST_EXPECT( @@ -2299,14 +2004,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { WasmValVec params(3), result(1); vrt.setBytes(0, signerListKeylet.key.data(), uint256::size()); - auto* trap = - ww(cacheLedgerObj_wrap, - &import.at("cache_ledger_obj"), - params, - result, - 0, - uint256::size(), - 1); + auto* trap = ww(&import.at("cache_ledger_obj"), params, result, 0, uint256::size(), 1); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == 1); } @@ -2315,8 +2013,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.getLedgerObjArrayLen(1, sfSignerEntries); WasmValVec params(2), result(1); auto* trap = - ww(getLedgerObjArrayLen_wrap, - &import.at("get_ledger_obj_array_len"), + ww(&import.at("get_ledger_obj_array_len"), params, result, 1, @@ -2333,8 +2030,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.getLedgerObjArrayLen(0, sfSignerEntries); WasmValVec params(2), result(1); auto* trap = - ww(getLedgerObjArrayLen_wrap, - &import.at("get_ledger_obj_array_len"), + ww(&import.at("get_ledger_obj_array_len"), params, result, 0, @@ -2349,12 +2045,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.getLedgerObjArrayLen(1, sfAccount); WasmValVec params(2), result(1); auto* trap = - ww(getLedgerObjArrayLen_wrap, - &import.at("get_ledger_obj_array_len"), - params, - result, - 1, - sfAccount.getCode()); + ww(&import.at("get_ledger_obj_array_len"), params, result, 1, sfAccount.getCode()); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32); BEAST_EXPECT(result[0].of.i32 == static_cast(HostFunctionError::NoArray)); @@ -2365,8 +2056,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.getLedgerObjArrayLen(2, sfSignerEntries); WasmValVec params(2), result(1); auto* trap = - ww(getLedgerObjArrayLen_wrap, - &import.at("get_ledger_obj_array_len"), + ww(&import.at("get_ledger_obj_array_len"), params, result, 2, @@ -2381,12 +2071,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.getLedgerObjArrayLen(1, sfMemos); WasmValVec params(2), result(1); auto* trap = - ww(getLedgerObjArrayLen_wrap, - &import.at("get_ledger_obj_array_len"), - params, - result, - 1, - sfMemos.getCode()); + ww(&import.at("get_ledger_obj_array_len"), params, result, 1, sfMemos.getCode()); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32); BEAST_EXPECT( @@ -2426,8 +2111,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, locatorVec.data(), locatorVec.size() * sizeof(int32_t)); WasmValVec params(2), result(1); auto* trap = - ww(getTxNestedArrayLen_wrap, - &import.at("get_tx_nested_array_len"), + ww(&import.at("get_tx_nested_array_len"), params, result, 0, @@ -2445,8 +2129,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, locatorVec.data(), locatorVec.size() * sizeof(int32_t)); WasmValVec params(2), result(1); auto* trap = - ww(getTxNestedArrayLen_wrap, - &import.at("get_tx_nested_array_len"), + ww(&import.at("get_tx_nested_array_len"), params, result, 0, @@ -2493,8 +2176,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, locatorVec.data(), locatorVec.size() * sizeof(int32_t)); WasmValVec params(2), result(1); auto* trap = - ww(getCurrentLedgerObjNestedArrayLen_wrap, - &import.at("get_current_ledger_obj_nested_array_len"), + ww(&import.at("get_current_ledger_obj_nested_array_len"), params, result, 0, @@ -2512,8 +2194,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, locatorVec.data(), locatorVec.size() * sizeof(int32_t)); WasmValVec params(2), result(1); auto* trap = - ww(getCurrentLedgerObjNestedArrayLen_wrap, - &import.at("get_current_ledger_obj_nested_array_len"), + ww(&import.at("get_current_ledger_obj_nested_array_len"), params, result, 0, @@ -2542,8 +2223,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt2.setBytes(0, locatorVec.data(), locatorVec.size() * sizeof(int32_t)); WasmValVec params(2), result(1); auto* trap = - ww(getCurrentLedgerObjNestedArrayLen_wrap, - &import2.at("get_current_ledger_obj_nested_array_len"), + ww(&import2.at("get_current_ledger_obj_nested_array_len"), params, result, 0, @@ -2583,14 +2263,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { WasmValVec params(3), result(1); vrt.setBytes(0, signerListKeylet.key.data(), uint256::size()); - auto* trap = - ww(cacheLedgerObj_wrap, - &import.at("cache_ledger_obj"), - params, - result, - 0, - uint256::size(), - 1); + auto* trap = ww(&import.at("cache_ledger_obj"), params, result, 0, uint256::size(), 1); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == 1); } @@ -2602,8 +2275,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, locatorVec.data(), locatorVec.size() * sizeof(int32_t)); WasmValVec params(3), result(1); auto* trap = - ww(getLedgerObjNestedArrayLen_wrap, - &import.at("get_ledger_obj_nested_array_len"), + ww(&import.at("get_ledger_obj_nested_array_len"), params, result, 1, @@ -2623,8 +2295,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, locatorVec.data(), locatorVec.size() * sizeof(int32_t)); WasmValVec params(3), result(1); auto* trap = - ww(getLedgerObjNestedArrayLen_wrap, - &import.at("get_ledger_obj_nested_array_len"), + ww(&import.at("get_ledger_obj_nested_array_len"), params, result, slot, @@ -2657,14 +2328,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.getLedgerObjNestedArrayLen(1, malformedLocator); vrt.setBytes(0, locatorVec.data(), 3); WasmValVec params(3), result(1); - auto* trap = - ww(getLedgerObjNestedArrayLen_wrap, - &import.at("get_ledger_obj_nested_array_len"), - params, - result, - 1, - 0, - 3); + auto* trap = ww(&import.at("get_ledger_obj_nested_array_len"), params, result, 1, 0, 3); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -2704,8 +2368,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { vrt.setBytes(0, data.data(), data.size()); WasmValVec params(2), result(1); - auto* trap = - ww(updateData_wrap, &import.at("update_data"), params, result, 0, data.size()); + auto* trap = ww(&import.at("update_data"), params, result, 0, data.size()); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == data.size()); @@ -2718,8 +2381,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { vrt.setBytes(0, bigData.data(), bigData.size()); WasmValVec params(2), result(1); - auto* trap = - ww(updateData_wrap, &import.at("update_data"), params, result, 0, bigData.size()); + auto* trap = ww(&import.at("update_data"), params, result, 0, bigData.size()); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -2762,8 +2424,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(512, pk.data(), pk.size()); WasmValVec params(6), result(1); auto* trap = - ww(checkSignature_wrap, - &import.at("check_sig"), + ww(&import.at("check_sig"), params, result, 0, @@ -2789,8 +2450,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(512, pk.data(), pk.size()); WasmValVec params(6), result(1); auto* trap = - ww(checkSignature_wrap, - &import.at("check_sig"), + ww(&import.at("check_sig"), params, result, 0, @@ -2816,8 +2476,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(512, badPk.data(), badPk.size()); WasmValVec params(6), result(1); auto* trap = - ww(checkSignature_wrap, - &import.at("check_sig"), + ww(&import.at("check_sig"), params, result, 0, @@ -2841,8 +2500,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(256, sig.data(), sig.size()); WasmValVec params(6), result(1); auto* trap = - ww(checkSignature_wrap, - &import.at("check_sig"), + ww(&import.at("check_sig"), params, result, 0, @@ -2865,17 +2523,8 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, message.data(), message.size()); vrt.setBytes(512, pk.data(), pk.size()); WasmValVec params(6), result(1); - auto* trap = - ww(checkSignature_wrap, - &import.at("check_sig"), - params, - result, - 0, - message.size(), - 256, - 0, - 512, - pk.size()); + auto* trap = ww( + &import.at("check_sig"), params, result, 0, message.size(), 256, 0, 512, pk.size()); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == 0); @@ -2889,16 +2538,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(512, pk.data(), pk.size()); WasmValVec params(6), result(1); auto* trap = - ww(checkSignature_wrap, - &import.at("check_sig"), - params, - result, - 0, - 0, - 256, - sig.size(), - 512, - pk.size()); + ww(&import.at("check_sig"), params, result, 0, 0, 256, sig.size(), 512, pk.size()); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == 0); @@ -2928,8 +2568,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, data.data(), data.size()); WasmValVec params(4), result(1); auto* trap = - ww(computeSha512HalfHash_wrap, - &import.at("compute_sha512_half"), + ww(&import.at("compute_sha512_half"), params, result, 0, @@ -2976,22 +2615,14 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { auto const expected = keylet::account(masterID); WasmValVec params(4), result(1); - auto* trap = ww( - accountKeylet_wrap, &imp.at("account_keylet"), params, result, masterID, 1024, 32); + auto* trap = ww(&imp.at("account_keylet"), params, result, masterID, 1024, 32); if (BEAST_EXPECT(!trap && result[0].kind == WASM_I32 && result[0].of.i32 == 32)) { auto const actual = vrt.getBytes(params, 2); BEAST_EXPECT(compareKeylet(actual, expected)); } - auto* trap2 = - ww(accountKeylet_wrap, - &imp.at("account_keylet"), - params, - result, - xrpAccount(), - 1024, - 32); + auto* trap2 = ww(&imp.at("account_keylet"), params, result, xrpAccount(), 1024, 32); BEAST_EXPECT( !trap2 && result[0].kind == WASM_I32 && result[0].of.i32 == static_cast(HostFunctionError::InvalidAccount)); @@ -3001,15 +2632,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite auto const expected = keylet::amm(xrpIssue(), usdIssue); WasmValVec params(6), result(1); - auto* trap = - ww(ammKeylet_wrap, - &imp.at("amm_keylet"), - params, - result, - xrpIssue(), - usdIssue, - 1024, - 32); + auto* trap = ww(&imp.at("amm_keylet"), params, result, xrpIssue(), usdIssue, 1024, 32); if (BEAST_EXPECT(!trap && result[0].kind == WASM_I32 && result[0].of.i32 == 32)) { auto const actual = vrt.getBytes(params, 4); @@ -3017,27 +2640,12 @@ struct HostFuncImpl_test : public beast::unit_test::Suite } auto* trap2 = - ww(ammKeylet_wrap, - &imp.at("amm_keylet"), - params, - result, - xrpIssue(), - xrpIssue(), - 1024, - 32); + ww(&imp.at("amm_keylet"), params, result, xrpIssue(), xrpIssue(), 1024, 32); BEAST_EXPECT( !trap2 && result[0].kind == WASM_I32 && result[0].of.i32 == static_cast(HostFunctionError::InvalidParams)); - auto* trap3 = - ww(ammKeylet_wrap, - &imp.at("amm_keylet"), - params, - result, - baseMpt, - xrpIssue(), - 1024, - 32); + auto* trap3 = ww(&imp.at("amm_keylet"), params, result, baseMpt, xrpIssue(), 1024, 32); BEAST_EXPECT( !trap3 && result[0].kind == WASM_I32 && result[0].of.i32 == static_cast(HostFunctionError::InvalidParams)); @@ -3047,14 +2655,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite auto const expected = keylet::check(masterID, 1u); WasmValVec params(6), result(1); auto* trap = - ww(checkKeylet_wrap, - &imp.at("check_keylet"), - params, - result, - masterID, - toBytes(1u), - 1024, - 32); + ww(&imp.at("check_keylet"), params, result, masterID, toBytes(1u), 1024, 32); if (BEAST_EXPECT(!trap && result[0].kind == WASM_I32 && result[0].of.i32 == 32)) { auto const actual = vrt.getBytes(params, 4); @@ -3062,14 +2663,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite } auto* trap2 = - ww(checkKeylet_wrap, - &imp.at("check_keylet"), - params, - result, - xrpAccount(), - toBytes(1u), - 1024, - 32); + ww(&imp.at("check_keylet"), params, result, xrpAccount(), toBytes(1u), 1024, 32); BEAST_EXPECT( !trap2 && result[0].kind == WASM_I32 && result[0].of.i32 == static_cast(HostFunctionError::InvalidAccount)); @@ -3082,8 +2676,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite auto const expected = keylet::credential(masterID, masterID, credType); WasmValVec params(8), result(1); auto* trap = - ww(credentialKeylet_wrap, - &imp.at("credential_keylet"), + ww(&imp.at("credential_keylet"), params, result, masterID, @@ -3103,8 +2696,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite Slice const longCredType(longCredTypeStr.data(), longCredTypeStr.size()); static_assert(longCredTypeStr.size() > kMaxCredentialTypeLength); auto* trap2 = - ww(credentialKeylet_wrap, - &imp.at("credential_keylet"), + ww(&imp.at("credential_keylet"), params, result, masterID, @@ -3117,8 +2709,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite result[0].of.i32 == static_cast(HostFunctionError::InvalidParams)); auto* trap3 = - ww(credentialKeylet_wrap, - &imp.at("credential_keylet"), + ww(&imp.at("credential_keylet"), params, result, xrpAccount(), @@ -3131,8 +2722,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite result[0].of.i32 == static_cast(HostFunctionError::InvalidAccount)); auto* trap4 = - ww(credentialKeylet_wrap, - &imp.at("credential_keylet"), + ww(&imp.at("credential_keylet"), params, result, masterID, @@ -3148,16 +2738,14 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { auto const expected = keylet::did(masterID); WasmValVec params(4), result(1); - auto* trap = - ww(didKeylet_wrap, &imp.at("did_keylet"), params, result, masterID, 1024, 32); + auto* trap = ww(&imp.at("did_keylet"), params, result, masterID, 1024, 32); if (BEAST_EXPECT(!trap && result[0].kind == WASM_I32 && result[0].of.i32 == 32)) { auto const actual = vrt.getBytes(params, 2); BEAST_EXPECT(compareKeylet(actual, expected)); } - auto* trap2 = - ww(didKeylet_wrap, &imp.at("did_keylet"), params, result, xrpAccount(), 1024, 32); + auto* trap2 = ww(&imp.at("did_keylet"), params, result, xrpAccount(), 1024, 32); BEAST_EXPECT( !trap2 && result[0].kind == WASM_I32 && result[0].of.i32 == static_cast(HostFunctionError::InvalidAccount)); @@ -3167,14 +2755,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite auto const expected = keylet::delegate(masterID, alice.id()); WasmValVec params(6), result(1); auto* trap = - ww(delegateKeylet_wrap, - &imp.at("delegate_keylet"), - params, - result, - masterID, - alice.id(), - 1024, - 32); + ww(&imp.at("delegate_keylet"), params, result, masterID, alice.id(), 1024, 32); if (BEAST_EXPECT(!trap && result[0].kind == WASM_I32 && result[0].of.i32 == 32)) { auto const actual = vrt.getBytes(params, 4); @@ -3182,40 +2763,19 @@ struct HostFuncImpl_test : public beast::unit_test::Suite } auto* trap2 = - ww(delegateKeylet_wrap, - &imp.at("delegate_keylet"), - params, - result, - masterID, - masterID, - 1024, - 32); + ww(&imp.at("delegate_keylet"), params, result, masterID, masterID, 1024, 32); BEAST_EXPECT( !trap2 && result[0].kind == WASM_I32 && result[0].of.i32 == static_cast(HostFunctionError::InvalidParams)); auto* trap3 = - ww(delegateKeylet_wrap, - &imp.at("delegate_keylet"), - params, - result, - masterID, - xrpAccount(), - 1024, - 32); + ww(&imp.at("delegate_keylet"), params, result, masterID, xrpAccount(), 1024, 32); BEAST_EXPECT( !trap3 && result[0].kind == WASM_I32 && result[0].of.i32 == static_cast(HostFunctionError::InvalidAccount)); auto* trap4 = - ww(delegateKeylet_wrap, - &imp.at("delegate_keylet"), - params, - result, - xrpAccount(), - masterID, - 1024, - 32); + ww(&imp.at("delegate_keylet"), params, result, xrpAccount(), masterID, 1024, 32); BEAST_EXPECT( !trap4 && result[0].kind == WASM_I32 && result[0].of.i32 == static_cast(HostFunctionError::InvalidAccount)); @@ -3224,15 +2784,8 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { auto const expected = keylet::depositPreauth(masterID, alice.id()); WasmValVec params(6), result(1); - auto* trap = - ww(depositPreauthKeylet_wrap, - &imp.at("deposit_preauth_keylet"), - params, - result, - masterID, - alice.id(), - 1024, - 32); + auto* trap = ww( + &imp.at("deposit_preauth_keylet"), params, result, masterID, alice.id(), 1024, 32); if (BEAST_EXPECT(!trap && result[0].kind == WASM_I32 && result[0].of.i32 == 32)) { auto const actual = vrt.getBytes(params, 4); @@ -3240,21 +2793,13 @@ struct HostFuncImpl_test : public beast::unit_test::Suite } auto* trap2 = - ww(depositPreauthKeylet_wrap, - &imp.at("deposit_preauth_keylet"), - params, - result, - masterID, - masterID, - 1024, - 32); + ww(&imp.at("deposit_preauth_keylet"), params, result, masterID, masterID, 1024, 32); BEAST_EXPECT( !trap2 && result[0].kind == WASM_I32 && result[0].of.i32 == static_cast(HostFunctionError::InvalidParams)); auto* trap3 = - ww(depositPreauthKeylet_wrap, - &imp.at("deposit_preauth_keylet"), + ww(&imp.at("deposit_preauth_keylet"), params, result, masterID, @@ -3266,8 +2811,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite result[0].of.i32 == static_cast(HostFunctionError::InvalidAccount)); auto* trap4 = - ww(depositPreauthKeylet_wrap, - &imp.at("deposit_preauth_keylet"), + ww(&imp.at("deposit_preauth_keylet"), params, result, xrpAccount(), @@ -3283,14 +2827,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite auto const expected = keylet::escrow(masterID, 1u); WasmValVec params(6), result(1); auto* trap = - ww(escrowKeylet_wrap, - &imp.at("escrow_keylet"), - params, - result, - masterID, - toBytes(1u), - 1024, - 32); + ww(&imp.at("escrow_keylet"), params, result, masterID, toBytes(1u), 1024, 32); if (BEAST_EXPECT(!trap && result[0].kind == WASM_I32 && result[0].of.i32 == 32)) { auto const actual = vrt.getBytes(params, 4); @@ -3298,14 +2835,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite } auto* trap2 = - ww(escrowKeylet_wrap, - &imp.at("escrow_keylet"), - params, - result, - xrpAccount(), - toBytes(1u), - 1024, - 32); + ww(&imp.at("escrow_keylet"), params, result, xrpAccount(), toBytes(1u), 1024, 32); BEAST_EXPECT( !trap2 && result[0].kind == WASM_I32 && result[0].of.i32 == static_cast(HostFunctionError::InvalidAccount)); @@ -3316,15 +2846,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite auto const expected = keylet::line(masterID, alice.id(), usd); WasmValVec params(8), result(1); auto* trap = - ww(lineKeylet_wrap, - &imp.at("line_keylet"), - params, - result, - masterID, - alice.id(), - usd, - 1024, - 32); + ww(&imp.at("line_keylet"), params, result, masterID, alice.id(), usd, 1024, 32); if (BEAST_EXPECT(!trap && result[0].kind == WASM_I32 && result[0].of.i32 == 32)) { auto const actual = vrt.getBytes(params, 6); @@ -3332,50 +2854,25 @@ struct HostFuncImpl_test : public beast::unit_test::Suite } auto* trap2 = - ww(lineKeylet_wrap, - &imp.at("line_keylet"), - params, - result, - masterID, - masterID, - usd, - 1024, - 32); + ww(&imp.at("line_keylet"), params, result, masterID, masterID, usd, 1024, 32); BEAST_EXPECT( !trap2 && result[0].kind == WASM_I32 && result[0].of.i32 == static_cast(HostFunctionError::InvalidParams)); auto* trap3 = - ww(lineKeylet_wrap, - &imp.at("line_keylet"), - params, - result, - masterID, - xrpAccount(), - usd, - 1024, - 32); + ww(&imp.at("line_keylet"), params, result, masterID, xrpAccount(), usd, 1024, 32); BEAST_EXPECT( !trap3 && result[0].kind == WASM_I32 && result[0].of.i32 == static_cast(HostFunctionError::InvalidAccount)); auto* trap4 = - ww(lineKeylet_wrap, - &imp.at("line_keylet"), - params, - result, - xrpAccount(), - masterID, - usd, - 1024, - 32); + ww(&imp.at("line_keylet"), params, result, xrpAccount(), masterID, usd, 1024, 32); BEAST_EXPECT( !trap4 && result[0].kind == WASM_I32 && result[0].of.i32 == static_cast(HostFunctionError::InvalidAccount)); auto* trap5 = - ww(lineKeylet_wrap, - &imp.at("line_keylet"), + ww(&imp.at("line_keylet"), params, result, masterID, @@ -3392,14 +2889,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite auto const expected = keylet::mptIssuance(1u, masterID); WasmValVec params(6), result(1); auto* trap = - ww(mptIssuanceKeylet_wrap, - &imp.at("mpt_issuance_keylet"), - params, - result, - masterID, - toBytes(1u), - 1024, - 32); + ww(&imp.at("mpt_issuance_keylet"), params, result, masterID, toBytes(1u), 1024, 32); if (BEAST_EXPECT(!trap && result[0].kind == WASM_I32 && result[0].of.i32 == 32)) { auto const actual = vrt.getBytes(params, 4); @@ -3407,8 +2897,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite } auto* trap2 = - ww(mptIssuanceKeylet_wrap, - &imp.at("mpt_issuance_keylet"), + ww(&imp.at("mpt_issuance_keylet"), params, result, xrpAccount(), @@ -3424,14 +2913,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite auto const expected = keylet::mptoken(baseMpt, alice.id()); WasmValVec params(6), result(1); auto* trap = - ww(mptokenKeylet_wrap, - &imp.at("mptoken_keylet"), - params, - result, - baseMpt, - alice.id(), - 1024, - 32); + ww(&imp.at("mptoken_keylet"), params, result, baseMpt, alice.id(), 1024, 32); if (BEAST_EXPECT(!trap && result[0].kind == WASM_I32 && result[0].of.i32 == 32)) { auto const actual = vrt.getBytes(params, 4); @@ -3439,27 +2921,13 @@ struct HostFuncImpl_test : public beast::unit_test::Suite } auto* trap2 = - ww(mptokenKeylet_wrap, - &imp.at("mptoken_keylet"), - params, - result, - MPTID{}, - alice.id(), - 1024, - 32); + ww(&imp.at("mptoken_keylet"), params, result, MPTID{}, alice.id(), 1024, 32); BEAST_EXPECT( !trap2 && result[0].kind == WASM_I32 && result[0].of.i32 == static_cast(HostFunctionError::InvalidParams)); auto* trap3 = - ww(mptokenKeylet_wrap, - &imp.at("mptoken_keylet"), - params, - result, - baseMpt, - xrpAccount(), - 1024, - 32); + ww(&imp.at("mptoken_keylet"), params, result, baseMpt, xrpAccount(), 1024, 32); BEAST_EXPECT( !trap3 && result[0].kind == WASM_I32 && result[0].of.i32 == static_cast(HostFunctionError::InvalidAccount)); @@ -3469,29 +2937,15 @@ struct HostFuncImpl_test : public beast::unit_test::Suite auto const expected = keylet::nftoffer(masterID, 1u); WasmValVec params(6), result(1); auto* trap = - ww(nftOfferKeylet_wrap, - &imp.at("nft_offer_keylet"), - params, - result, - masterID, - toBytes(1u), - 1024, - 32); + ww(&imp.at("nft_offer_keylet"), params, result, masterID, toBytes(1u), 1024, 32); if (BEAST_EXPECT(!trap && result[0].kind == WASM_I32 && result[0].of.i32 == 32)) { auto const actual = vrt.getBytes(params, 4); BEAST_EXPECT(compareKeylet(actual, expected)); } - auto* trap2 = - ww(nftOfferKeylet_wrap, - &imp.at("nft_offer_keylet"), - params, - result, - xrpAccount(), - toBytes(1u), - 1024, - 32); + auto* trap2 = ww( + &imp.at("nft_offer_keylet"), params, result, xrpAccount(), toBytes(1u), 1024, 32); BEAST_EXPECT( !trap2 && result[0].kind == WASM_I32 && result[0].of.i32 == static_cast(HostFunctionError::InvalidAccount)); @@ -3501,14 +2955,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite auto const expected = keylet::offer(masterID, 1u); WasmValVec params(6), result(1); auto* trap = - ww(offerKeylet_wrap, - &imp.at("offer_keylet"), - params, - result, - masterID, - toBytes(1u), - 1024, - 32); + ww(&imp.at("offer_keylet"), params, result, masterID, toBytes(1u), 1024, 32); if (BEAST_EXPECT(!trap && result[0].kind == WASM_I32 && result[0].of.i32 == 32)) { auto const actual = vrt.getBytes(params, 4); @@ -3516,14 +2963,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite } auto* trap2 = - ww(offerKeylet_wrap, - &imp.at("offer_keylet"), - params, - result, - xrpAccount(), - toBytes(1u), - 1024, - 32); + ww(&imp.at("offer_keylet"), params, result, xrpAccount(), toBytes(1u), 1024, 32); BEAST_EXPECT( !trap2 && result[0].kind == WASM_I32 && result[0].of.i32 == static_cast(HostFunctionError::InvalidAccount)); @@ -3533,14 +2973,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite auto const expected = keylet::oracle(masterID, 1u); WasmValVec params(6), result(1); auto* trap = - ww(oracleKeylet_wrap, - &imp.at("oracle_keylet"), - params, - result, - masterID, - toBytes(1u), - 1024, - 32); + ww(&imp.at("oracle_keylet"), params, result, masterID, toBytes(1u), 1024, 32); if (BEAST_EXPECT(!trap && result[0].kind == WASM_I32 && result[0].of.i32 == 32)) { auto const actual = vrt.getBytes(params, 4); @@ -3548,14 +2981,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite } auto* trap2 = - ww(oracleKeylet_wrap, - &imp.at("oracle_keylet"), - params, - result, - xrpAccount(), - toBytes(1u), - 1024, - 32); + ww(&imp.at("oracle_keylet"), params, result, xrpAccount(), toBytes(1u), 1024, 32); BEAST_EXPECT( !trap2 && result[0].kind == WASM_I32 && result[0].of.i32 == static_cast(HostFunctionError::InvalidAccount)); @@ -3565,8 +2991,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite auto const expected = keylet::payChan(masterID, alice.id(), 1u); WasmValVec params(8), result(1); auto* trap = - ww(paychanKeylet_wrap, - &imp.at("paychan_keylet"), + ww(&imp.at("paychan_keylet"), params, result, masterID, @@ -3581,8 +3006,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite } auto* trap2 = - ww(paychanKeylet_wrap, - &imp.at("paychan_keylet"), + ww(&imp.at("paychan_keylet"), params, result, masterID, @@ -3595,8 +3019,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite result[0].of.i32 == static_cast(HostFunctionError::InvalidParams)); auto* trap3 = - ww(paychanKeylet_wrap, - &imp.at("paychan_keylet"), + ww(&imp.at("paychan_keylet"), params, result, masterID, @@ -3609,8 +3032,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite result[0].of.i32 == static_cast(HostFunctionError::InvalidAccount)); auto* trap4 = - ww(paychanKeylet_wrap, - &imp.at("paychan_keylet"), + ww(&imp.at("paychan_keylet"), params, result, xrpAccount(), @@ -3627,8 +3049,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite auto const expected = keylet::permissionedDomain(masterID, 1u); WasmValVec params(6), result(1); auto* trap = - ww(permissionedDomainKeylet_wrap, - &imp.at("permissioned_domain_keylet"), + ww(&imp.at("permissioned_domain_keylet"), params, result, masterID, @@ -3642,8 +3063,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite } auto* trap2 = - ww(permissionedDomainKeylet_wrap, - &imp.at("permissioned_domain_keylet"), + ww(&imp.at("permissioned_domain_keylet"), params, result, xrpAccount(), @@ -3658,22 +3078,14 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { auto const expected = keylet::signers(masterID); WasmValVec params(4), result(1); - auto* trap = ww( - signersKeylet_wrap, &imp.at("signers_keylet"), params, result, masterID, 1024, 32); + auto* trap = ww(&imp.at("signers_keylet"), params, result, masterID, 1024, 32); if (BEAST_EXPECT(!trap && result[0].kind == WASM_I32 && result[0].of.i32 == 32)) { auto const actual = vrt.getBytes(params, 2); BEAST_EXPECT(compareKeylet(actual, expected)); } - auto* trap2 = - ww(signersKeylet_wrap, - &imp.at("signers_keylet"), - params, - result, - xrpAccount(), - 1024, - 32); + auto* trap2 = ww(&imp.at("signers_keylet"), params, result, xrpAccount(), 1024, 32); BEAST_EXPECT( !trap2 && result[0].kind == WASM_I32 && result[0].of.i32 == static_cast(HostFunctionError::InvalidAccount)); @@ -3683,14 +3095,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite auto const expected = keylet::kTicket(masterID, 1u); WasmValVec params(6), result(1); auto* trap = - ww(ticketKeylet_wrap, - &imp.at("ticket_keylet"), - params, - result, - masterID, - toBytes(1u), - 1024, - 32); + ww(&imp.at("ticket_keylet"), params, result, masterID, toBytes(1u), 1024, 32); if (BEAST_EXPECT(!trap && result[0].kind == WASM_I32 && result[0].of.i32 == 32)) { auto const actual = vrt.getBytes(params, 4); @@ -3698,14 +3103,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite } auto* trap2 = - ww(ticketKeylet_wrap, - &imp.at("ticket_keylet"), - params, - result, - xrpAccount(), - toBytes(1u), - 1024, - 32); + ww(&imp.at("ticket_keylet"), params, result, xrpAccount(), toBytes(1u), 1024, 32); BEAST_EXPECT( !trap2 && result[0].kind == WASM_I32 && result[0].of.i32 == static_cast(HostFunctionError::InvalidAccount)); @@ -3715,14 +3113,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite auto const expected = keylet::vault(masterID, 1u); WasmValVec params(6), result(1); auto* trap = - ww(vaultKeylet_wrap, - &imp.at("vault_keylet"), - params, - result, - masterID, - toBytes(1u), - 1024, - 32); + ww(&imp.at("vault_keylet"), params, result, masterID, toBytes(1u), 1024, 32); if (BEAST_EXPECT(!trap && result[0].kind == WASM_I32 && result[0].of.i32 == 32)) { auto const actual = vrt.getBytes(params, 4); @@ -3730,14 +3121,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite } auto* trap2 = - ww(vaultKeylet_wrap, - &imp.at("vault_keylet"), - params, - result, - xrpAccount(), - toBytes(1u), - 1024, - 32); + ww(&imp.at("vault_keylet"), params, result, xrpAccount(), toBytes(1u), 1024, 32); BEAST_EXPECT( !trap2 && result[0].kind == WASM_I32 && result[0].of.i32 == static_cast(HostFunctionError::InvalidAccount)); @@ -3781,8 +3165,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(256, nftId.data(), uint256::size()); WasmValVec params(6), result(1); auto* trap = - ww(getNFT_wrap, - &import.at("get_nft"), + ww(&import.at("get_nft"), params, result, 0, @@ -3808,8 +3191,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(256, nftId.data(), uint256::size()); WasmValVec params(6), result(1); auto* trap = - ww(getNFT_wrap, - &import.at("get_nft"), + ww(&import.at("get_nft"), params, result, 0, @@ -3831,8 +3213,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(256, zeroId.data(), uint256::size()); WasmValVec params(6), result(1); auto* trap = - ww(getNFT_wrap, - &import.at("get_nft"), + ww(&import.at("get_nft"), params, result, 0, @@ -3854,8 +3235,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(256, badId.data(), uint256::size()); WasmValVec params(6), result(1); auto* trap = - ww(getNFT_wrap, - &import.at("get_nft"), + ww(&import.at("get_nft"), params, result, 0, @@ -3876,8 +3256,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(256, nftId2.data(), uint256::size()); WasmValVec params(6), result(1); auto* trap = - ww(getNFT_wrap, - &import.at("get_nft"), + ww(&import.at("get_nft"), params, result, 0, @@ -3921,8 +3300,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, nftId.data(), uint256::size()); WasmValVec params(4), result(1); auto* trap = - ww(getNFTIssuer_wrap, - &import.at("get_nft_issuer"), + ww(&import.at("get_nft_issuer"), params, result, 0, @@ -3945,8 +3323,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, zeroId.data(), uint256::size()); WasmValVec params(4), result(1); auto* trap = - ww(getNFTIssuer_wrap, - &import.at("get_nft_issuer"), + ww(&import.at("get_nft_issuer"), params, result, 0, @@ -3985,15 +3362,8 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.getNFTTaxon(nftId); vrt.setBytes(0, nftId.data(), uint256::size()); WasmValVec params(4), result(1); - auto* trap = - ww(getNFTTaxon_wrap, - &import.at("get_nft_taxon"), - params, - result, - 0, - uint256::size(), - 256, - sizeof(uint32_t)); + auto* trap = ww( + &import.at("get_nft_taxon"), params, result, 0, uint256::size(), 256, sizeof(uint32_t)); if (BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == sizeof(uint32_t))) @@ -4029,8 +3399,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.getNFTFlags(nftId); vrt.setBytes(0, nftId.data(), uint256::size()); WasmValVec params(2), result(1); - auto* trap = ww( - getNFTFlags_wrap, &import.at("get_nft_flags"), params, result, 0, uint256::size()); + auto* trap = ww(&import.at("get_nft_flags"), params, result, 0, uint256::size()); if (BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32)) BEAST_EXPECT(result[0].of.i32 == tfTransferable); @@ -4042,8 +3411,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite uint256 zeroId; vrt.setBytes(0, zeroId.data(), uint256::size()); WasmValVec params(2), result(1); - auto* trap = ww( - getNFTFlags_wrap, &import.at("get_nft_flags"), params, result, 0, uint256::size()); + auto* trap = ww(&import.at("get_nft_flags"), params, result, 0, uint256::size()); if (BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32)) BEAST_EXPECT(result[0].of.i32 == 0); @@ -4077,13 +3445,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.getNFTTransferFee(nftId); vrt.setBytes(0, nftId.data(), uint256::size()); WasmValVec params(2), result(1); - auto* trap = - ww(getNFTTransferFee_wrap, - &import.at("get_nft_transfer_fee"), - params, - result, - 0, - uint256::size()); + auto* trap = ww(&import.at("get_nft_transfer_fee"), params, result, 0, uint256::size()); if (BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32)) BEAST_EXPECT(result[0].of.i32 == transferFee); @@ -4095,13 +3457,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite uint256 zeroId; vrt.setBytes(0, zeroId.data(), uint256::size()); WasmValVec params(2), result(1); - auto* trap = - ww(getNFTTransferFee_wrap, - &import.at("get_nft_transfer_fee"), - params, - result, - 0, - uint256::size()); + auto* trap = ww(&import.at("get_nft_transfer_fee"), params, result, 0, uint256::size()); if (BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32)) BEAST_EXPECT(result[0].of.i32 == 0); @@ -4137,8 +3493,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, nftId.data(), uint256::size()); WasmValVec params(4), result(1); auto* trap = - ww(getNFTSerial_wrap, - &import.at("get_nft_serial"), + ww(&import.at("get_nft_serial"), params, result, 0, @@ -4160,8 +3515,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, zeroId.data(), uint256::size()); WasmValVec params(4), result(1); auto* trap = - ww(getNFTSerial_wrap, - &import.at("get_nft_serial"), + ww(&import.at("get_nft_serial"), params, result, 0, @@ -4207,15 +3561,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(256, slice.data(), slice.size()); WasmValVec params(5), result(1); auto* trap = - ww(trace_wrap, - &import.at("trace"), - params, - result, - 0, - msg.size(), - 256, - slice.size(), - 0); + ww(&import.at("trace"), params, result, 0, msg.size(), 256, slice.size(), 0); if (BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == 0)) @@ -4231,15 +3577,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(256, slice.data(), slice.size()); WasmValVec params(5), result(1); auto* trap = - ww(trace_wrap, - &import.at("trace"), - params, - result, - 0, - msg.size(), - 256, - slice.size(), - 1); + ww(&import.at("trace"), params, result, 0, msg.size(), 256, slice.size(), 1); if (BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == 0)) @@ -4278,15 +3616,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(256, slice.data(), slice.size()); WasmValVec params(5), result(1); auto* trap = - ww(trace_wrap, - &import.at("trace"), - params, - result, - 0, - msg.size(), - 256, - slice.size(), - 0); + ww(&import.at("trace"), params, result, 0, msg.size(), 256, slice.size(), 0); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == 0); @@ -4321,8 +3651,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.traceNum(msg, num); vrt.setBytes(0, reinterpret_cast(msg.data()), msg.size()); WasmValVec params(3), result(1); - auto* trap = - ww(traceNum_wrap, &import.at("trace_num"), params, result, 0, msg.size(), num); + auto* trap = ww(&import.at("trace_num"), params, result, 0, msg.size(), num); if (BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == 0)) @@ -4354,8 +3683,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.traceNum(msg, num); vrt.setBytes(0, reinterpret_cast(msg.data()), msg.size()); WasmValVec params(3), result(1); - auto* trap = - ww(traceNum_wrap, &import.at("trace_num"), params, result, 0, msg.size(), num); + auto* trap = ww(&import.at("trace_num"), params, result, 0, msg.size(), num); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == 0); @@ -4391,15 +3719,8 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, reinterpret_cast(msg.data()), msg.size()); vrt.setBytes(256, accountId.data(), accountId.size()); WasmValVec params(4), result(1); - auto* trap = - ww(traceAccount_wrap, - &import.at("trace_account"), - params, - result, - 0, - msg.size(), - 256, - accountId.size()); + auto* trap = ww( + &import.at("trace_account"), params, result, 0, msg.size(), 256, accountId.size()); if (BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == 0)) @@ -4432,15 +3753,8 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, reinterpret_cast(msg.data()), msg.size()); vrt.setBytes(256, accountId.data(), accountId.size()); WasmValVec params(4), result(1); - auto* trap = - ww(traceAccount_wrap, - &import.at("trace_account"), - params, - result, - 0, - msg.size(), - 256, - accountId.size()); + auto* trap = ww( + &import.at("trace_account"), params, result, 0, msg.size(), 256, accountId.size()); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == 0); @@ -4478,8 +3792,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(256, amountBytes.data(), amountBytes.size()); WasmValVec params(4), result(1); auto* trap = - ww(traceAmount_wrap, - &import.at("trace_amount"), + ww(&import.at("trace_amount"), params, result, 0, @@ -4508,8 +3821,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(256, amountBytes.data(), amountBytes.size()); WasmValVec params(4), result(1); auto* trap = - ww(traceAmount_wrap, - &import.at("trace_amount"), + ww(&import.at("trace_amount"), params, result, 0, @@ -4533,8 +3845,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(256, amountBytes.data(), amountBytes.size()); WasmValVec params(4), result(1); auto* trap = - ww(traceAmount_wrap, - &import.at("trace_amount"), + ww(&import.at("trace_amount"), params, result, 0, @@ -4570,15 +3881,8 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, reinterpret_cast(msg.data()), msg.size()); vrt.setBytes(256, amountBytes.data(), amountBytes.size()); WasmValVec params(4), result(1); - auto* trap = - ww(traceAmount_wrap, - &import.at("trace_amount"), - params, - result, - 0, - msg.size(), - 256, - amountBytes.size()); + auto* trap = ww( + &import.at("trace_amount"), params, result, 0, msg.size(), 256, amountBytes.size()); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == 0); @@ -4699,8 +4003,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(256, reinterpret_cast(invalid.data()), invalid.size()); WasmValVec params(4), result(1); auto* trap = - ww(traceFloat_wrap, - &import.at("trace_opaque_float"), + ww(&import.at("trace_opaque_float"), params, result, 0, @@ -4718,8 +4021,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(256, floatMaxExp.data(), floatMaxExp.size()); WasmValVec params(4), result(1); auto* trap = - ww(traceFloat_wrap, - &import.at("trace_opaque_float"), + ww(&import.at("trace_opaque_float"), params, result, 0, @@ -4754,8 +4056,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(256, reinterpret_cast(invalid.data()), invalid.size()); WasmValVec params(4), result(1); auto* trap = - ww(traceFloat_wrap, - &import.at("trace_opaque_float"), + ww(&import.at("trace_opaque_float"), params, result, 0, @@ -4789,15 +4090,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { // hfs.floatFromInt(min64, -1); WasmValVec params(4), result(1); - auto* trap = - ww(floatFromInt_wrap, - &import.at("float_from_int"), - params, - result, - min64, - 0, - floatSize, - -1); + auto* trap = ww(&import.at("float_from_int"), params, result, min64, 0, floatSize, -1); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -4808,15 +4101,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { // hfs.floatFromInt(min64, 4); WasmValVec params(4), result(1); - auto* trap = - ww(floatFromInt_wrap, - &import.at("float_from_int"), - params, - result, - min64, - 0, - floatSize, - 4); + auto* trap = ww(&import.at("float_from_int"), params, result, min64, 0, floatSize, 4); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -4827,15 +4112,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { // hfs.floatFromInt(min64, 0); WasmValVec params(4), result(1); - auto* trap = - ww(floatFromInt_wrap, - &import.at("float_from_int"), - params, - result, - min64, - 0, - floatSize, - 0); + auto* trap = ww(&import.at("float_from_int"), params, result, min64, 0, floatSize, 0); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == floatSize); @@ -4846,15 +4123,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { // hfs.floatFromInt(0, 0); WasmValVec params(4), result(1); - auto* trap = - ww(floatFromInt_wrap, - &import.at("float_from_int"), - params, - result, - 0ll, - 0, - floatSize, - 0); + auto* trap = ww(&import.at("float_from_int"), params, result, 0ll, 0, floatSize, 0); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == floatSize); @@ -4865,15 +4134,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { // hfs.floatFromInt(max64, 0); WasmValVec params(4), result(1); - auto* trap = - ww(floatFromInt_wrap, - &import.at("float_from_int"), - params, - result, - max64, - 0, - floatSize, - 0); + auto* trap = ww(&import.at("float_from_int"), params, result, max64, 0, floatSize, 0); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == floatSize); @@ -4903,16 +4164,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite WasmValVec params(5), result(1); uint64_t val = std::numeric_limits::min(); vrt.setBytes(0, &val, sizeof(val)); - auto* trap = - ww(floatFromUint_wrap, - &import.at("float_from_uint"), - params, - result, - 0, - 8, - 16, - floatSize, - -1); + auto* trap = ww(&import.at("float_from_uint"), params, result, 0, 8, 16, floatSize, -1); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -4925,16 +4177,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite WasmValVec params(5), result(1); uint64_t val = std::numeric_limits::min(); vrt.setBytes(0, &val, sizeof(val)); - auto* trap = - ww(floatFromUint_wrap, - &import.at("float_from_uint"), - params, - result, - 0, - 8, - 16, - floatSize, - 4); + auto* trap = ww(&import.at("float_from_uint"), params, result, 0, 8, 16, floatSize, 4); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -4947,16 +4190,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite WasmValVec params(5), result(1); uint64_t val = 0; vrt.setBytes(0, &val, sizeof(val)); - auto* trap = - ww(floatFromUint_wrap, - &import.at("float_from_uint"), - params, - result, - 0, - 8, - 16, - floatSize, - 0); + auto* trap = ww(&import.at("float_from_uint"), params, result, 0, 8, 16, floatSize, 0); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == floatSize); @@ -4969,16 +4203,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite WasmValVec params(5), result(1); uint64_t val = std::numeric_limits::max(); vrt.setBytes(0, &val, sizeof(val)); - auto* trap = - ww(floatFromUint_wrap, - &import.at("float_from_uint"), - params, - result, - 0, - 8, - 16, - floatSize, - 0); + auto* trap = ww(&import.at("float_from_uint"), params, result, 0, 8, 16, floatSize, 0); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == floatSize); @@ -5008,15 +4233,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.floatFromMantExp(1, 0, -1); WasmValVec params(5), result(1); auto* trap = - ww(floatFromMantExp_wrap, - &import.at("float_from_mant_exp"), - params, - result, - 1ll, - 0, - 0, - floatSize, - -1); + ww(&import.at("float_from_mant_exp"), params, result, 1ll, 0, 0, floatSize, -1); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -5028,15 +4245,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.floatFromMantExp(1, 0, 4); WasmValVec params(5), result(1); auto* trap = - ww(floatFromMantExp_wrap, - &import.at("float_from_mant_exp"), - params, - result, - 1ll, - 0, - 0, - floatSize, - 4); + ww(&import.at("float_from_mant_exp"), params, result, 1ll, 0, 0, floatSize, 4); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -5048,8 +4257,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.floatFromMantExp(1, Number::kMaxExponent + normalExp + 1, 0); WasmValVec params(5), result(1); auto* trap = - ww(floatFromMantExp_wrap, - &import.at("float_from_mant_exp"), + ww(&import.at("float_from_mant_exp"), params, result, 1ll, @@ -5068,8 +4276,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.floatFromMantExp(1, Number::kMinExponent + normalExp - 1, 0); WasmValVec params(5), result(1); auto* trap = - ww(floatFromMantExp_wrap, - &import.at("float_from_mant_exp"), + ww(&import.at("float_from_mant_exp"), params, result, 1ll, @@ -5088,8 +4295,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.floatFromMantExp(1, Number::kMaxExponent + normalExp, 0); WasmValVec params(5), result(1); auto* trap = - ww(floatFromMantExp_wrap, - &import.at("float_from_mant_exp"), + ww(&import.at("float_from_mant_exp"), params, result, 1ll, @@ -5108,8 +4314,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.floatFromMantExp(-1, Number::kMaxExponent + normalExp, 0); WasmValVec params(5), result(1); auto* trap = - ww(floatFromMantExp_wrap, - &import.at("float_from_mant_exp"), + ww(&import.at("float_from_mant_exp"), params, result, -1ll, @@ -5128,8 +4333,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.floatFromMantExp(1, Number::kMaxExponent + normalExp - 1, 0); WasmValVec params(5), result(1); auto* trap = - ww(floatFromMantExp_wrap, - &import.at("float_from_mant_exp"), + ww(&import.at("float_from_mant_exp"), params, result, 1ll, @@ -5148,8 +4352,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.floatFromMantExp(STAmount::kMaxValue, STAmount::kMaxOffset, 0); WasmValVec params(5), result(1); auto* trap = - ww(floatFromMantExp_wrap, - &import.at("float_from_mant_exp"), + ww(&import.at("float_from_mant_exp"), params, result, static_cast(STAmount::kMaxValue), @@ -5168,8 +4371,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.floatFromMantExp(1, Number::kMinExponent + normalExp, 0); WasmValVec params(5), result(1); auto* trap = - ww(floatFromMantExp_wrap, - &import.at("float_from_mant_exp"), + ww(&import.at("float_from_mant_exp"), params, result, 1ll, @@ -5188,15 +4390,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.floatFromMantExp(10, -1, 0); WasmValVec params(5), result(1); auto* trap = - ww(floatFromMantExp_wrap, - &import.at("float_from_mant_exp"), - params, - result, - 10ll, - -1, - 0, - floatSize, - 0); + ww(&import.at("float_from_mant_exp"), params, result, 10ll, -1, 0, floatSize, 0); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == floatSize); @@ -5208,8 +4402,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.floatFromMantExp(1, Number::kMaxExponent + normalExp + 1, 0); WasmValVec params(5), result(1); auto* trap = - ww(floatFromMantExp_wrap, - &import.at("float_from_mant_exp"), + ww(&import.at("float_from_mant_exp"), params, result, 1ll, @@ -5244,8 +4437,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { // hfs.floatCompare(Slice(), Slice()); WasmValVec params(4), result(1); - auto* trap = - ww(floatCompare_wrap, &import.at("float_compare"), params, result, 0, 0, 0, 0); + auto* trap = ww(&import.at("float_compare"), params, result, 0, 0, 0, 0); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -5257,8 +4449,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.floatCompare(makeSlice(floatInvalidZero), Slice()); WasmValVec params(4), result(1); vrt.setBytes(0, floatInvalidZero.data(), floatInvalidZero.size()); - auto* trap = ww( - floatCompare_wrap, &import.at("float_compare"), params, result, 0, floatSize, 0, 0); + auto* trap = ww(&import.at("float_compare"), params, result, 0, floatSize, 0, 0); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -5272,8 +4463,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, float1.data(), float1.size()); vrt.setBytes(floatSize, invalid.data(), invalid.size()); auto* trap = - ww(floatCompare_wrap, - &import.at("float_compare"), + ww(&import.at("float_compare"), params, result, 0, @@ -5293,14 +4483,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, floatIntMin.data(), floatIntMin.size()); vrt.setBytes(floatSize, floatIntZero.data(), floatIntZero.size()); auto* trap = - ww(floatCompare_wrap, - &import.at("float_compare"), - params, - result, - 0, - floatSize, - floatSize, - floatSize); + ww(&import.at("float_compare"), params, result, 0, floatSize, floatSize, floatSize); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == 2); @@ -5312,14 +4495,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, floatIntMax.data(), floatIntMax.size()); vrt.setBytes(floatSize, floatIntZero.data(), floatIntZero.size()); auto* trap = - ww(floatCompare_wrap, - &import.at("float_compare"), - params, - result, - 0, - floatSize, - floatSize, - floatSize); + ww(&import.at("float_compare"), params, result, 0, floatSize, floatSize, floatSize); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == 1); @@ -5331,14 +4507,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, float1.data(), float1.size()); vrt.setBytes(floatSize, float1.data(), float1.size()); auto* trap = - ww(floatCompare_wrap, - &import.at("float_compare"), - params, - result, - 0, - floatSize, - floatSize, - floatSize); + ww(&import.at("float_compare"), params, result, 0, floatSize, floatSize, floatSize); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == 0); @@ -5364,18 +4533,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { // hfs.floatAdd(Slice(), Slice(), -1); WasmValVec params(7), result(1); - auto* trap = - ww(floatAdd_wrap, - &import.at("float_add"), - params, - result, - 0, - 0, - 0, - 0, - 0, - floatSize, - -1); + auto* trap = ww(&import.at("float_add"), params, result, 0, 0, 0, 0, 0, floatSize, -1); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -5386,18 +4544,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { // hfs.floatAdd(Slice(), Slice(), 0); WasmValVec params(7), result(1); - auto* trap = - ww(floatAdd_wrap, - &import.at("float_add"), - params, - result, - 0, - 0, - 0, - 0, - 0, - floatSize, - 0); + auto* trap = ww(&import.at("float_add"), params, result, 0, 0, 0, 0, 0, floatSize, 0); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -5411,8 +4558,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, float1.data(), float1.size()); vrt.setBytes(floatSize, invalid.data(), invalid.size()); auto* trap = - ww(floatAdd_wrap, - &import.at("float_add"), + ww(&import.at("float_add"), params, result, 0, @@ -5436,8 +4582,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, floatMaxIOU.data(), floatMaxIOU.size()); vrt.setBytes(floatSize, floatMaxExp.data(), floatMaxExp.size()); auto* trap = - ww(floatAdd_wrap, - &import.at("float_add"), + ww(&import.at("float_add"), params, result, 0, @@ -5460,8 +4605,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, floatIntMin.data(), floatIntMin.size()); vrt.setBytes(floatSize, floatIntZero.data(), floatIntZero.size()); auto* trap = - ww(floatAdd_wrap, - &import.at("float_add"), + ww(&import.at("float_add"), params, result, 0, @@ -5485,8 +4629,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, floatIntMax.data(), floatIntMax.size()); vrt.setBytes(floatSize, floatIntMin.data(), floatIntMin.size()); auto* trap = - ww(floatAdd_wrap, - &import.at("float_add"), + ww(&import.at("float_add"), params, result, 0, @@ -5524,17 +4667,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.floatSubtract(Slice(), Slice(), -1); WasmValVec params(7), result(1); auto* trap = - ww(floatSubtract_wrap, - &import.at("float_subtract"), - params, - result, - 0, - 0, - 0, - 0, - 0, - floatSize, - -1); + ww(&import.at("float_subtract"), params, result, 0, 0, 0, 0, 0, floatSize, -1); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -5546,17 +4679,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.floatSubtract(Slice(), Slice(), 0); WasmValVec params(7), result(1); auto* trap = - ww(floatSubtract_wrap, - &import.at("float_subtract"), - params, - result, - 0, - 0, - 0, - 0, - 0, - floatSize, - 0); + ww(&import.at("float_subtract"), params, result, 0, 0, 0, 0, 0, floatSize, 0); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -5570,8 +4693,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, float1.data(), float1.size()); vrt.setBytes(floatSize, invalid.data(), invalid.size()); auto* trap = - ww(floatSubtract_wrap, - &import.at("float_subtract"), + ww(&import.at("float_subtract"), params, result, 0, @@ -5594,8 +4716,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, floatMinusMaxExp.data(), floatMinusMaxExp.size()); vrt.setBytes(floatSize, floatMaxIOU.data(), floatMaxIOU.size()); auto* trap = - ww(floatSubtract_wrap, - &import.at("float_subtract"), + ww(&import.at("float_subtract"), params, result, 0, @@ -5618,8 +4739,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, floatIntMin.data(), floatIntMin.size()); vrt.setBytes(floatSize, floatIntZero.data(), floatIntZero.size()); auto* trap = - ww(floatSubtract_wrap, - &import.at("float_subtract"), + ww(&import.at("float_subtract"), params, result, 0, @@ -5642,8 +4762,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, floatIntZero.data(), floatIntZero.size()); vrt.setBytes(floatSize, float1.data(), float1.size()); auto* trap = - ww(floatSubtract_wrap, - &import.at("float_subtract"), + ww(&import.at("float_subtract"), params, result, 0, @@ -5681,17 +4800,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.floatMultiply(Slice(), Slice(), -1); WasmValVec params(7), result(1); auto* trap = - ww(floatMultiply_wrap, - &import.at("float_multiply"), - params, - result, - 0, - 0, - 0, - 0, - 0, - floatSize, - -1); + ww(&import.at("float_multiply"), params, result, 0, 0, 0, 0, 0, floatSize, -1); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -5703,17 +4812,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.floatMultiply(Slice(), Slice(), 0); WasmValVec params(7), result(1); auto* trap = - ww(floatMultiply_wrap, - &import.at("float_multiply"), - params, - result, - 0, - 0, - 0, - 0, - 0, - floatSize, - 0); + ww(&import.at("float_multiply"), params, result, 0, 0, 0, 0, 0, floatSize, 0); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -5727,8 +4826,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, float1.data(), float1.size()); vrt.setBytes(floatSize, invalid.data(), invalid.size()); auto* trap = - ww(floatMultiply_wrap, - &import.at("float_multiply"), + ww(&import.at("float_multiply"), params, result, 0, @@ -5751,8 +4849,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, floatMax.data(), floatMax.size()); vrt.setBytes(floatSize, float1More.data(), float1More.size()); auto* trap = - ww(floatMultiply_wrap, - &import.at("float_multiply"), + ww(&import.at("float_multiply"), params, result, 0, @@ -5775,8 +4872,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, float1.data(), float1.size()); vrt.setBytes(floatSize, float1.data(), float1.size()); auto* trap = - ww(floatMultiply_wrap, - &import.at("float_multiply"), + ww(&import.at("float_multiply"), params, result, 0, @@ -5799,8 +4895,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, floatIntZero.data(), floatIntZero.size()); vrt.setBytes(floatSize, floatMaxIOU.data(), floatMaxIOU.size()); auto* trap = - ww(floatMultiply_wrap, - &import.at("float_multiply"), + ww(&import.at("float_multiply"), params, result, 0, @@ -5823,8 +4918,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, float10.data(), float10.size()); vrt.setBytes(floatSize, floatPreMaxExp.data(), floatPreMaxExp.size()); auto* trap = - ww(floatMultiply_wrap, - &import.at("float_multiply"), + ww(&import.at("float_multiply"), params, result, 0, @@ -5862,17 +4956,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.floatDivide(Slice(), Slice(), -1); WasmValVec params(7), result(1); auto* trap = - ww(floatDivide_wrap, - &import.at("float_divide"), - params, - result, - 0, - 0, - 0, - 0, - 0, - floatSize, - -1); + ww(&import.at("float_divide"), params, result, 0, 0, 0, 0, 0, floatSize, -1); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -5884,17 +4968,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.floatDivide(Slice(), Slice(), 0); WasmValVec params(7), result(1); auto* trap = - ww(floatDivide_wrap, - &import.at("float_divide"), - params, - result, - 0, - 0, - 0, - 0, - 0, - floatSize, - 0); + ww(&import.at("float_divide"), params, result, 0, 0, 0, 0, 0, floatSize, 0); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -5907,8 +4981,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, float1.data(), float1.size()); vrt.setBytes(floatSize, invalid.data(), invalid.size()); auto* trap = - ww(floatDivide_wrap, - &import.at("float_divide"), + ww(&import.at("float_divide"), params, result, 0, @@ -5930,8 +5003,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, float1.data(), float1.size()); vrt.setBytes(floatSize, floatIntZero.data(), floatIntZero.size()); auto* trap = - ww(floatDivide_wrap, - &import.at("float_divide"), + ww(&import.at("float_divide"), params, result, 0, @@ -5957,8 +5029,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, floatMax.data(), floatMax.size()); vrt.setBytes(floatSize, y->data(), y->size()); auto* trap = - ww(floatDivide_wrap, - &import.at("float_divide"), + ww(&import.at("float_divide"), params, result, 0, @@ -5981,8 +5052,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, floatIntZero.data(), floatIntZero.size()); vrt.setBytes(floatSize, float1.data(), float1.size()); auto* trap = - ww(floatDivide_wrap, - &import.at("float_divide"), + ww(&import.at("float_divide"), params, result, 0, @@ -6004,8 +5074,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, floatMaxExp.data(), floatMaxExp.size()); vrt.setBytes(floatSize, float10.data(), float10.size()); auto* trap = - ww(floatDivide_wrap, - &import.at("float_divide"), + ww(&import.at("float_divide"), params, result, 0, @@ -6041,17 +5110,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { // hfs.floatRoot(Slice(), 2, -1); WasmValVec params(6), result(1); - auto* trap = - ww(floatRoot_wrap, - &import.at("float_root"), - params, - result, - 0, - 0, - 2, - 0, - floatSize, - -1); + auto* trap = ww(&import.at("float_root"), params, result, 0, 0, 2, 0, floatSize, -1); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -6063,8 +5122,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite WasmValVec params(6), result(1); vrt.setBytes(0, invalid.data(), invalid.size()); auto* trap = - ww(floatRoot_wrap, - &import.at("float_root"), + ww(&import.at("float_root"), params, result, 0, @@ -6084,8 +5142,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite WasmValVec params(6), result(1); vrt.setBytes(0, float1.data(), float1.size()); auto* trap = - ww(floatRoot_wrap, - &import.at("float_root"), + ww(&import.at("float_root"), params, result, 0, @@ -6105,8 +5162,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite WasmValVec params(6), result(1); vrt.setBytes(0, floatIntZero.data(), floatIntZero.size()); auto* trap = - ww(floatRoot_wrap, - &import.at("float_root"), + ww(&import.at("float_root"), params, result, 0, @@ -6126,8 +5182,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite WasmValVec params(6), result(1); vrt.setBytes(0, floatMaxIOU.data(), floatMaxIOU.size()); auto* trap = - ww(floatRoot_wrap, - &import.at("float_root"), + ww(&import.at("float_root"), params, result, 0, @@ -6151,8 +5206,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite WasmValVec params(6), result(1); vrt.setBytes(0, x->data(), x->size()); auto* trap = - ww(floatRoot_wrap, - &import.at("float_root"), + ww(&import.at("float_root"), params, result, 0, @@ -6177,8 +5231,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite WasmValVec params(6), result(1); vrt.setBytes(0, x->data(), x->size()); auto* trap = - ww(floatRoot_wrap, - &import.at("float_root"), + ww(&import.at("float_root"), params, result, 0, @@ -6204,8 +5257,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite WasmValVec params(6), result(1); vrt.setBytes(0, x->data(), x->size()); auto* trap = - ww(floatRoot_wrap, - &import.at("float_root"), + ww(&import.at("float_root"), params, result, 0, @@ -6241,17 +5293,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { // hfs.floatPower(Slice(), 2, -1); WasmValVec params(6), result(1); - auto* trap = - ww(floatPower_wrap, - &import.at("float_pow"), - params, - result, - 0, - 0, - 2, - 0, - floatSize, - -1); + auto* trap = ww(&import.at("float_pow"), params, result, 0, 0, 2, 0, floatSize, -1); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -6263,8 +5305,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite WasmValVec params(6), result(1); vrt.setBytes(0, invalid.data(), invalid.size()); auto* trap = - ww(floatPower_wrap, - &import.at("float_pow"), + ww(&import.at("float_pow"), params, result, 0, @@ -6284,8 +5325,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite WasmValVec params(6), result(1); vrt.setBytes(0, float1.data(), float1.size()); auto* trap = - ww(floatPower_wrap, - &import.at("float_pow"), + ww(&import.at("float_pow"), params, result, 0, @@ -6305,17 +5345,8 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.floatPower(makeSlice(floatMax), 2, 0); WasmValVec params(6), result(1); vrt.setBytes(0, floatMax.data(), floatMax.size()); - auto* trap = - ww(floatPower_wrap, - &import.at("float_pow"), - params, - result, - 0, - floatSize, - 2, - floatSize, - floatSize, - 0); + auto* trap = ww( + &import.at("float_pow"), params, result, 0, floatSize, 2, floatSize, floatSize, 0); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -6328,8 +5359,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite WasmValVec params(6), result(1); vrt.setBytes(0, floatMax.data(), floatMax.size()); auto* trap = - ww(floatPower_wrap, - &import.at("float_pow"), + ww(&import.at("float_pow"), params, result, 0, @@ -6349,17 +5379,8 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.floatPower(makeSlice(floatMaxIOU), 0, 0); WasmValVec params(6), result(1); vrt.setBytes(0, floatMaxIOU.data(), floatMaxIOU.size()); - auto* trap = - ww(floatPower_wrap, - &import.at("float_pow"), - params, - result, - 0, - floatSize, - 0, - floatSize, - floatSize, - 0); + auto* trap = ww( + &import.at("float_pow"), params, result, 0, floatSize, 0, floatSize, floatSize, 0); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == floatSize); @@ -6370,17 +5391,8 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { // hfs.floatPower(makeSlice(floatMaxIOU), 1, 0); WasmValVec params(6), result(1); vrt.setBytes(0, floatMaxIOU.data(), floatMaxIOU.size()); - auto* trap = - ww(floatPower_wrap, - &import.at("float_pow"), - params, - result, - 0, - floatSize, - 1, - floatSize, - floatSize, - 0); + auto* trap = ww( + &import.at("float_pow"), params, result, 0, floatSize, 1, floatSize, floatSize, 0); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == floatSize); @@ -6396,8 +5408,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite WasmValVec params(6), result(1); vrt.setBytes(0, float10.data(), float10.size()); auto* trap = - ww(floatPower_wrap, - &import.at("float_pow"), + ww(&import.at("float_pow"), params, result, 0, @@ -6423,8 +5434,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite WasmValVec params(6), result(1); vrt.setBytes(0, x->data(), x->size()); auto* trap = - ww(floatPower_wrap, - &import.at("float_pow"), + ww(&import.at("float_pow"), params, result, 0, @@ -6486,8 +5496,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, amountBytes.data(), amountBytes.size()); WasmValVec params(5), result(1); auto* trap = - ww(floatFromSTAmount_wrap, - &import.at("float_from_stamount"), + ww(&import.at("float_from_stamount"), params, result, 0, @@ -6509,8 +5518,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, amountBytes.data(), amountBytes.size()); WasmValVec params(5), result(1); auto* trap = - ww(floatFromSTAmount_wrap, - &import.at("float_from_stamount"), + ww(&import.at("float_from_stamount"), params, result, 0, @@ -6532,8 +5540,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, amountBytes.data(), amountBytes.size()); WasmValVec params(5), result(1); auto* trap = - ww(floatFromSTAmount_wrap, - &import.at("float_from_stamount"), + ww(&import.at("float_from_stamount"), params, result, 0, @@ -6558,8 +5565,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, amountBytes.data(), amountBytes.size()); WasmValVec params(5), result(1); auto* trap = - ww(floatFromSTAmount_wrap, - &import.at("float_from_stamount"), + ww(&import.at("float_from_stamount"), params, result, 0, @@ -6583,8 +5589,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, amountBytes.data(), amountBytes.size()); WasmValVec params(5), result(1); auto* trap = - ww(floatFromSTAmount_wrap, - &import.at("float_from_stamount"), + ww(&import.at("float_from_stamount"), params, result, 0, @@ -6623,8 +5628,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, amountBytes.data(), amountBytes.size()); WasmValVec params(5), result(1); auto* trap = - ww(floatFromSTAmount_wrap, - &import.at("float_from_stamount"), + ww(&import.at("float_from_stamount"), params, result, 0, @@ -6647,8 +5651,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, amountBytes.data(), amountBytes.size()); WasmValVec params(5), result(1); auto* trap = - ww(floatFromSTAmount_wrap, - &import.at("float_from_stamount"), + ww(&import.at("float_from_stamount"), params, result, 0, @@ -6688,8 +5691,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, numBytes.data(), numBytes.size()); WasmValVec params(5), result(1); auto* trap = - ww(floatFromSTNumber_wrap, - &import.at("float_from_stnumber"), + ww(&import.at("float_from_stnumber"), params, result, 0, @@ -6711,8 +5713,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, numBytes.data(), numBytes.size()); WasmValVec params(5), result(1); auto* trap = - ww(floatFromSTNumber_wrap, - &import.at("float_from_stnumber"), + ww(&import.at("float_from_stnumber"), params, result, 0, @@ -6735,8 +5736,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, numBytes.data(), numBytes.size()); WasmValVec params(5), result(1); auto* trap = - ww(floatFromSTNumber_wrap, - &import.at("float_from_stnumber"), + ww(&import.at("float_from_stnumber"), params, result, 0, @@ -6758,8 +5758,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, numBytes.data(), numBytes.size()); WasmValVec params(5), result(1); auto* trap = - ww(floatFromSTNumber_wrap, - &import.at("float_from_stnumber"), + ww(&import.at("float_from_stnumber"), params, result, 0, @@ -6795,16 +5794,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.floatToInt(makeSlice(float1), -1); vrt.setBytes(0, float1.data(), float1.size()); WasmValVec params(5), result(1); - auto* trap = - ww(floatToInt_wrap, - &import.at("float_to_int"), - params, - result, - 0, - floatSize, - 256, - 8, - -1); + auto* trap = ww(&import.at("float_to_int"), params, result, 0, floatSize, 256, 8, -1); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -6816,16 +5806,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.floatToInt(makeSlice(float1), 4); vrt.setBytes(0, float1.data(), float1.size()); WasmValVec params(5), result(1); - auto* trap = - ww(floatToInt_wrap, - &import.at("float_to_int"), - params, - result, - 0, - floatSize, - 256, - 8, - 4); + auto* trap = ww(&import.at("float_to_int"), params, result, 0, floatSize, 256, 8, 4); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -6836,8 +5817,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite { // hfs.floatToInt(Slice(), 0); WasmValVec params(5), result(1); - auto* trap = - ww(floatToInt_wrap, &import.at("float_to_int"), params, result, 0, 0, 256, 8, 0); + auto* trap = ww(&import.at("float_to_int"), params, result, 0, 0, 256, 8, 0); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -6849,16 +5829,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.floatToInt(makeSlice(invalid), 0); vrt.setBytes(0, invalid.data(), invalid.size()); WasmValVec params(5), result(1); - auto* trap = - ww(floatToInt_wrap, - &import.at("float_to_int"), - params, - result, - 0, - floatSize, - 256, - 8, - 0); + auto* trap = ww(&import.at("float_to_int"), params, result, 0, floatSize, 256, 8, 0); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -6870,16 +5841,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.floatToInt(makeSlice(floatIntZero), 0); vrt.setBytes(0, floatIntZero.data(), floatIntZero.size()); WasmValVec params(5), result(1); - auto* trap = - ww(floatToInt_wrap, - &import.at("float_to_int"), - params, - result, - 0, - floatSize, - 256, - 8, - 0); + auto* trap = ww(&import.at("float_to_int"), params, result, 0, floatSize, 256, 8, 0); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == 8); @@ -6895,16 +5857,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.floatToInt(makeSlice(float1), 0); vrt.setBytes(0, float1.data(), float1.size()); WasmValVec params(5), result(1); - auto* trap = - ww(floatToInt_wrap, - &import.at("float_to_int"), - params, - result, - 0, - floatSize, - 256, - 8, - 0); + auto* trap = ww(&import.at("float_to_int"), params, result, 0, floatSize, 256, 8, 0); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == 8); @@ -6920,16 +5873,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.floatToInt(makeSlice(floatMinus1), 0); vrt.setBytes(0, floatMinus1.data(), floatMinus1.size()); WasmValVec params(5), result(1); - auto* trap = - ww(floatToInt_wrap, - &import.at("float_to_int"), - params, - result, - 0, - floatSize, - 256, - 8, - 0); + auto* trap = ww(&import.at("float_to_int"), params, result, 0, floatSize, 256, 8, 0); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == 8); @@ -6945,16 +5889,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.floatToInt(makeSlice(floatIntMax), 0); vrt.setBytes(0, floatIntMax.data(), floatIntMax.size()); WasmValVec params(5), result(1); - auto* trap = - ww(floatToInt_wrap, - &import.at("float_to_int"), - params, - result, - 0, - floatSize, - 256, - 8, - 0); + auto* trap = ww(&import.at("float_to_int"), params, result, 0, floatSize, 256, 8, 0); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == 8); @@ -6972,16 +5907,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.floatToInt(makeSlice(floatIntMin), 0); vrt.setBytes(0, floatIntMin.data(), floatIntMin.size()); WasmValVec params(5), result(1); - auto* trap = - ww(floatToInt_wrap, - &import.at("float_to_int"), - params, - result, - 0, - floatSize, - 256, - 8, - 0); + auto* trap = ww(&import.at("float_to_int"), params, result, 0, floatSize, 256, 8, 0); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -6993,16 +5919,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.floatToInt(makeSlice(floatUIntMax), 0); vrt.setBytes(0, floatUIntMax.data(), floatUIntMax.size()); WasmValVec params(5), result(1); - auto* trap = - ww(floatToInt_wrap, - &import.at("float_to_int"), - params, - result, - 0, - floatSize, - 256, - 8, - 0); + auto* trap = ww(&import.at("float_to_int"), params, result, 0, floatSize, 256, 8, 0); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -7016,16 +5933,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.floatToInt(makeSlice(floatPi), 0); vrt.setBytes(0, floatPi.data(), floatPi.size()); WasmValVec params(5), result(1); - auto* trap = - ww(floatToInt_wrap, - &import.at("float_to_int"), - params, - result, - 0, - floatSize, - 256, - 8, - 0); + auto* trap = ww(&import.at("float_to_int"), params, result, 0, floatSize, 256, 8, 0); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == 8); @@ -7038,16 +5946,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.floatToInt(makeSlice(floatPi), 1); vrt.setBytes(0, floatPi.data(), floatPi.size()); WasmValVec params(5), result(1); - auto* trap = - ww(floatToInt_wrap, - &import.at("float_to_int"), - params, - result, - 0, - floatSize, - 256, - 8, - 1); + auto* trap = ww(&import.at("float_to_int"), params, result, 0, floatSize, 256, 8, 1); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == 8); @@ -7060,16 +5959,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.floatToInt(makeSlice(floatPi), 2); vrt.setBytes(0, floatPi.data(), floatPi.size()); WasmValVec params(5), result(1); - auto* trap = - ww(floatToInt_wrap, - &import.at("float_to_int"), - params, - result, - 0, - floatSize, - 256, - 8, - 2); + auto* trap = ww(&import.at("float_to_int"), params, result, 0, floatSize, 256, 8, 2); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == 8); @@ -7082,16 +5972,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite // hfs.floatToInt(makeSlice(floatPi), 3); vrt.setBytes(0, floatPi.data(), floatPi.size()); WasmValVec params(5), result(1); - auto* trap = - ww(floatToInt_wrap, - &import.at("float_to_int"), - params, - result, - 0, - floatSize, - 256, - 8, - 3); + auto* trap = ww(&import.at("float_to_int"), params, result, 0, floatSize, 256, 8, 3); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == 8); @@ -7121,16 +6002,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, invalid.data(), invalid.size()); WasmValVec params(6), result(1); auto* trap = - ww(floatToMantExp_wrap, - &import.at("float_to_mant_exp"), - params, - result, - 0, - floatSize, - 256, - 8, - 512, - 4); + ww(&import.at("float_to_mant_exp"), params, result, 0, floatSize, 256, 8, 512, 4); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT( @@ -7143,16 +6015,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, floatIntZero.data(), floatIntZero.size()); WasmValVec params(6), result(1); auto* trap = - ww(floatToMantExp_wrap, - &import.at("float_to_mant_exp"), - params, - result, - 0, - floatSize, - 256, - 8, - 512, - 4); + ww(&import.at("float_to_mant_exp"), params, result, 0, floatSize, 256, 8, 512, 4); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == floatSize); @@ -7171,16 +6034,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, float1.data(), float1.size()); WasmValVec params(6), result(1); auto* trap = - ww(floatToMantExp_wrap, - &import.at("float_to_mant_exp"), - params, - result, - 0, - floatSize, - 256, - 8, - 512, - 4); + ww(&import.at("float_to_mant_exp"), params, result, 0, floatSize, 256, 8, 512, 4); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == floatSize); @@ -7198,16 +6052,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, floatMinus1.data(), floatMinus1.size()); WasmValVec params(6), result(1); auto* trap = - ww(floatToMantExp_wrap, - &import.at("float_to_mant_exp"), - params, - result, - 0, - floatSize, - 256, - 8, - 512, - 4); + ww(&import.at("float_to_mant_exp"), params, result, 0, floatSize, 256, 8, 512, 4); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == floatSize); @@ -7225,16 +6070,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, float10.data(), float10.size()); WasmValVec params(6), result(1); auto* trap = - ww(floatToMantExp_wrap, - &import.at("float_to_mant_exp"), - params, - result, - 0, - floatSize, - 256, - 8, - 512, - 4); + ww(&import.at("float_to_mant_exp"), params, result, 0, floatSize, 256, 8, 512, 4); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == floatSize); @@ -7253,16 +6089,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, floatPi.data(), floatPi.size()); WasmValVec params(6), result(1); auto* trap = - ww(floatToMantExp_wrap, - &import.at("float_to_mant_exp"), - params, - result, - 0, - floatSize, - 256, - 8, - 512, - 4); + ww(&import.at("float_to_mant_exp"), params, result, 0, floatSize, 256, 8, 512, 4); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == floatSize); @@ -7280,16 +6107,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, floatIntMax.data(), floatIntMax.size()); WasmValVec params(6), result(1); auto* trap = - ww(floatToMantExp_wrap, - &import.at("float_to_mant_exp"), - params, - result, - 0, - floatSize, - 256, - 8, - 512, - 4); + ww(&import.at("float_to_mant_exp"), params, result, 0, floatSize, 256, 8, 512, 4); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == floatSize); @@ -7308,16 +6126,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, floatIntMin.data(), floatIntMin.size()); WasmValVec params(6), result(1); auto* trap = - ww(floatToMantExp_wrap, - &import.at("float_to_mant_exp"), - params, - result, - 0, - floatSize, - 256, - 8, - 512, - 4); + ww(&import.at("float_to_mant_exp"), params, result, 0, floatSize, 256, 8, 512, 4); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == floatSize); @@ -7336,16 +6145,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite vrt.setBytes(0, floatMax.data(), floatMax.size()); WasmValVec params(6), result(1); auto* trap = - ww(floatToMantExp_wrap, - &import.at("float_to_mant_exp"), - params, - result, - 0, - floatSize, - 256, - 8, - 512, - 4); + ww(&import.at("float_to_mant_exp"), params, result, 0, floatSize, 256, 8, 512, 4); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == floatSize); @@ -7407,13 +6207,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite WasmValVec params(2), result(1); // 3 parameters instead of 2 auto* trap = - ww(getLedgerSqn_wrap, - &import.at("get_ledger_sqn"), - params, - result, - 0, - sizeof(std::uint32_t), - 1); + ww(&import.at("get_ledger_sqn"), params, result, 0, sizeof(std::uint32_t), 1); BEAST_EXPECT(!trap) && BEAST_EXPECT(result[0].kind == WASM_I32) && BEAST_EXPECT(result[0].of.i32 == sizeof(std::uint32_t)) && diff --git a/src/test/app/TestHostFunctions.h b/src/test/app/TestHostFunctions.h index d0dc19d52d..13bc18e09c 100644 --- a/src/test/app/TestHostFunctions.h +++ b/src/test/app/TestHostFunctions.h @@ -155,15 +155,16 @@ public: } Expected - getTxNestedField(Slice const& locator) const override + getTxNestedField(FieldLocator const& locator) const override { - if (locator.size() == 4) + if (locator.size() == 1) { - int32_t const* l = reinterpret_cast(locator.data()); + int32_t const* l = locator.data(); int32_t const sfield = l[0]; if (sfield == sfAccount.getCode()) return Bytes(accountID_.begin(), accountID_.end()); } + uint8_t const a[] = {0x2b, 0x6a, 0x23, 0x2a, 0xa4, 0xc4, 0xbe, 0x41, 0xbf, 0x49, 0xd2, 0x45, 0x9f, 0xa4, 0xa0, 0x34, 0x7e, 0x1b, 0x54, 0x3a, 0x4c, 0x92, 0xfc, 0xee, 0x08, 0x21, 0xc0, 0x20, 0x1e, 0x2e, 0x9a, 0x00}; @@ -171,15 +172,16 @@ public: } Expected - getCurrentLedgerObjNestedField(Slice const& locator) const override + getCurrentLedgerObjNestedField(FieldLocator const& locator) const override { - if (locator.size() == 4) + if (locator.size() == 1) { - int32_t const* l = reinterpret_cast(locator.data()); + int32_t const* l = locator.data(); int32_t const sfield = l[0]; if (sfield == sfAccount.getCode()) return Bytes(accountID_.begin(), accountID_.end()); } + uint8_t const a[] = {0x2b, 0x6a, 0x23, 0x2a, 0xa4, 0xc4, 0xbe, 0x41, 0xbf, 0x49, 0xd2, 0x45, 0x9f, 0xa4, 0xa0, 0x34, 0x7e, 0x1b, 0x54, 0x3a, 0x4c, 0x92, 0xfc, 0xee, 0x08, 0x21, 0xc0, 0x20, 0x1e, 0x2e, 0x9a, 0x00}; @@ -187,15 +189,16 @@ public: } Expected - getLedgerObjNestedField(int32_t cacheIdx, Slice const& locator) const override + getLedgerObjNestedField(int32_t cacheIdx, FieldLocator const& locator) const override { - if (locator.size() == 4) + if (locator.size() == 1) { - int32_t const* l = reinterpret_cast(locator.data()); + int32_t const* l = locator.data(); int32_t const sfield = l[0]; if (sfield == sfAccount.getCode()) return Bytes(accountID_.begin(), accountID_.end()); } + uint8_t const a[] = {0x2b, 0x6a, 0x23, 0x2a, 0xa4, 0xc4, 0xbe, 0x41, 0xbf, 0x49, 0xd2, 0x45, 0x9f, 0xa4, 0xa0, 0x34, 0x7e, 0x1b, 0x54, 0x3a, 0x4c, 0x92, 0xfc, 0xee, 0x08, 0x21, 0xc0, 0x20, 0x1e, 0x2e, 0x9a, 0x00}; @@ -221,19 +224,19 @@ public: } Expected - getTxNestedArrayLen(Slice const& locator) const override + getTxNestedArrayLen(FieldLocator const& locator) const override { return 32; } Expected - getCurrentLedgerObjNestedArrayLen(Slice const& locator) const override + getCurrentLedgerObjNestedArrayLen(FieldLocator const& locator) const override { return 32; } Expected - getLedgerObjNestedArrayLen(int32_t cacheIdx, Slice const& locator) const override + getLedgerObjNestedArrayLen(int32_t cacheIdx, FieldLocator const& locator) const override { return 32; } diff --git a/src/test/app/Wasm_test.cpp b/src/test/app/Wasm_test.cpp index 49a29f1563..fd64976f1e 100644 --- a/src/test/app/Wasm_test.cpp +++ b/src/test/app/Wasm_test.cpp @@ -1,3 +1,8 @@ +#ifdef _DEBUG +// #define DEBUG_OUTPUT 1 +#endif + +#include #include #include @@ -17,21 +22,14 @@ #include #include -#include #include #include #include #include +#include #include #include #include -#ifdef _DEBUG -// #define DEBUG_OUTPUT 1 -#endif - -#include - -#include namespace xrpl::test { @@ -40,7 +38,7 @@ testGetDataIncrement(); using Add_proto = int32_t(int32_t, int32_t); static wasm_trap_t* -add(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) +add(HostFunctions&, wasm_val_vec_t const* params, wasm_val_vec_t* results) { int32_t const val1 = params->data[0].of.i32; int32_t const val2 = params->data[1].of.i32; @@ -219,7 +217,7 @@ struct Wasm_test : public beast::unit_test::Suite HostFunctions hfs; ImportVec imports; - WasmImpFunc(imports, "func-add", reinterpret_cast(&add), hfs); + WasmImpFunc(imports, "func-add", add, hfs); auto re = vm.run(wasm, hfs, 10'000'000, "addTwo", wasmParams(1234, 5678), imports); @@ -405,7 +403,7 @@ struct Wasm_test : public beast::unit_test::Suite auto re = engine.run( allHostFuncWasm, hfs, 1'000'000, escrowFunctionName, {}, imp, env.journal); - checkResult(re, 1, 27'080); + checkResult(re, 1, 27'617); env.close(); } @@ -427,7 +425,7 @@ struct Wasm_test : public beast::unit_test::Suite auto re = engine.run( allHostFuncWasm, hfs, 1'000'000, escrowFunctionName, {}, imp, env.journal); - checkResult(re, 1, 70'340); + checkResult(re, 1, 70'877); env.close(); } @@ -466,7 +464,7 @@ struct Wasm_test : public beast::unit_test::Suite { TestHostFunctions hfs(env); auto re = runEscrowWasm(allHFWasm, hfs, 100'000, escrowFunctionName, {}); - checkResult(re, 1, 70'340); + checkResult(re, 1, 70'877); } { @@ -490,7 +488,7 @@ struct Wasm_test : public beast::unit_test::Suite TestHostFunctions hfs(env); auto re = runEscrowWasm( allHFWasm, hfs, std::numeric_limits::max(), escrowFunctionName, {}); - checkResult(re, 1, 70'340); + checkResult(re, 1, 70'877); } { // fail because trying to access nonexistent field @@ -508,7 +506,7 @@ struct Wasm_test : public beast::unit_test::Suite FieldNotFoundHostFunctions hfs(env); auto re = runEscrowWasm(allHFWasm, hfs, 100'000, escrowFunctionName, {}); - checkResult(re, -201, 28'965); + checkResult(re, -201, 29'502); } { // fail because trying to allocate more than MAX_PAGES memory @@ -526,7 +524,7 @@ struct Wasm_test : public beast::unit_test::Suite OversizedFieldHostFunctions hfs(env); auto re = runEscrowWasm(allHFWasm, hfs, 100'000, escrowFunctionName, {}); - checkResult(re, -201, 28'965); + checkResult(re, -201, 29'502); } // This test use log output, so DEBUG_OUTPUT must be disabled. @@ -642,7 +640,7 @@ struct Wasm_test : public beast::unit_test::Suite TestHostFunctions hfs(env); auto re = runEscrowWasm(float0Wasm, hfs, 100'000, funcName, {}); - checkResult(re, 1, 4'309); + checkResult(re, 1, 2'819); env.close(); } } diff --git a/src/test/app/wasm_fixtures/all_host_functions/src/lib.rs b/src/test/app/wasm_fixtures/all_host_functions/src/lib.rs index 444fcaddfa..a0bf4c0dcf 100644 --- a/src/test/app/wasm_fixtures/all_host_functions/src/lib.rs +++ b/src/test/app/wasm_fixtures/all_host_functions/src/lib.rs @@ -200,7 +200,7 @@ fn test_transaction_data_functions() -> i32 { // Use get_tx_field() with appropriate parameters for all transaction field access. // Test 2.2: get_tx_nested_field() - Nested field access with locator - let locator = [0x01, 0x00]; // Simple locator for first element + let locator = [0x01_u8, 0x00_u8, 0x00_u8, 0x00_u8, 0x00_u8, 0x00_u8, 0x00_u8, 0x00_u8]; // Two int32s in little-endian: [1, 0] let mut nested_buffer = [0u8; 32]; let nested_result = unsafe { host::get_tx_nested_field( @@ -314,7 +314,7 @@ fn test_current_ledger_object_functions() -> i32 { } // Test 3.2: get_current_ledger_obj_nested_field() - Nested field access - let locator = [0x01, 0x00]; // Simple locator + let locator = [0x01_u8, 0x00_u8, 0x00_u8, 0x00_u8, 0x00_u8, 0x00_u8, 0x00_u8, 0x00_u8]; // Two int32s in little-endian: [1, 0] let mut current_nested_buffer = [0u8; 32]; let current_nested_result = unsafe { host::get_current_ledger_obj_nested_field( @@ -426,7 +426,7 @@ fn test_any_ledger_object_functions() -> i32 { } // Test get_ledger_obj_nested_field with invalid slot - let locator = [0x01, 0x00]; + let locator = [0x01_u8, 0x00_u8, 0x00_u8, 0x00_u8, 0x00_u8, 0x00_u8, 0x00_u8, 0x00_u8]; // Two int32s in little-endian: [1, 0] let nested_result = unsafe { host::get_ledger_obj_nested_field( 1, @@ -509,7 +509,7 @@ fn test_any_ledger_object_functions() -> i32 { } // Test 4.3: get_ledger_obj_nested_field() - Nested field from cached object - let locator = [0x01, 0x00]; + let locator = [0x01_u8, 0x00_u8, 0x00_u8, 0x00_u8, 0x00_u8, 0x00_u8, 0x00_u8, 0x00_u8]; // Two int32s in little-endian: [1, 0] let mut cached_nested_buffer = [0u8; 32]; let cached_nested_result = unsafe { host::get_ledger_obj_nested_field( diff --git a/src/test/app/wasm_fixtures/fixtures.cpp b/src/test/app/wasm_fixtures/fixtures.cpp index cf8e3fe2c0..cfe531639d 100644 --- a/src/test/app/wasm_fixtures/fixtures.cpp +++ b/src/test/app/wasm_fixtures/fixtures.cpp @@ -45,13 +45,13 @@ extern std::string const kAllHostFunctionsWasmHex = "65645f61727261795f6c656e000108686f73745f6c69620e6163636f756e745f6b65796c6574000208686f73745f6c" "69620d74726163655f6163636f756e740002030c0b090a05050b05000101030005030100110619037f01418080c000" "0b7f0041af99c0000b7f0041b099c0000b072e04066d656d6f727902000666696e697368001e0a5f5f646174615f65" - "6e6403010b5f5f686561705f6261736503020ac61d0b990101027f230041306b220124002000027f41818020200141" + "6e6403010b5f5f686561705f6261736503020a911e0b990101027f230041306b220124002000027f41818020200141" "1c6a4114100022024114470440417f20022002417f4e1b210241010c010b200020012f001c3b0001200041036a2001" "411e6a2d00003a0000200120012900233703082001200141286a29000037000d200128001f21022000410d6a200129" "000d3700002000200129030837020841000b3a000020002002360204200141306a24000b460020012d000041014604" "40418080c000410b20013402041001000b20002001290001370000200041106a200141116a28000036000020004108" - "6a200141096a2900003700000b1900200241214f0440000b20002002360204200020013602000b1900200241094f04" - "40000b20002002360204200020013602000bde1a01097f230041b0036b22002400418b80c000411b41014100410010" + "6a200141096a2900003700000b1900200241094f0440000b20002002360204200020013602000b1900200241214f04" + "40000b20002002360204200020013602000ba91b01097f230041b0036b22002400418b80c000411b41014100410010" "021a41a680c000411941014100410010021a41e780c000412b41014100410010021a20004100360270024002400240" "02400240024002400240200041f0006a220741041003220141004a0440419281c00041172000280270220141187420" "014180fe03714108747220014108764180fe037120014118767272ad10011a200041003602900120004190016a2203" @@ -60,144 +60,146 @@ extern std::string const kAllHostFunctionsWasmHex = "044200370300200042003703b001200041b0016a22064120100522014120470d0241bc81c000411320064120410110" "021a41cf81c000412041014100410010021a41dc82c000412e41014100410010021a200041a0016a41003602002000" "4198016a420037030020004200370390014181802020034114100022014114470d03418a83c00041142003101f2000" - "42003703704188801820074108100022014108470d04419e83c0004117420810011a41b583c0004128200741084101" - "10021a2000410036024841848008200041c8006a22034104100022014104470d0541dd83c000411520034104410110" - "021a200041013b0034200242003703002005420037030020044200370300200042003703b0010240200041346a4102" - "200641201006220141004e044041f283c00041142001ad10011a200041286a20062001101c418684c000410d200028" - "0228200028022c410110021a0c010b419384c00041292001ac10011a0b41bc84c00041154183803c1007ac10011a41" - "d184c00041134189803c1007ac10011a0240200041346a41021008220141004e044041e484c00041142001ad10011a" - "0c010b41f884c000412d2001ac10011a0b41a585c000412341014100410010021a41de86c000413341014100410010" - "021a2000420037037041828018200041f0006a220141081009220341004c0d0620034108460440419187c000412b42" - "0810011a41bc87c000412f20014108410110021a0c080b41eb87c000412f2003ad10011a200041206a200041f0006a" - "2003101d419a88c000411720002802202000280224410110021a0c070b41bf82c000411d2001ac10011a419b7f2102" - "0c070b419a82c00041252001ac10011a419a7f21020c060b41ef81c000412b2001ac10011a41997f21020c050b41b4" - "86c000412a2001ac10011a41b77e21020c040b41f385c00041c1002001ac10011a41b67e21020c030b41c885c00041" - "2b2001ac10011a41b57e21020c020b41b188c00041c5002003ac10011a0b200041a0016a410036020020004198016a" - "4200370300200042003703900102404181802020004190016a220341141009220141004a044041f688c000411e2003" - "101f0c010b419489c00041332001ac10011a0b200041013b0048200041c8016a4200370300200041c0016a42003703" - "00200041b8016a4200370300200042003703b0010240200041c8006a4102200041b0016a22014120100a220341004e" - "044041c789c000411c2003ad10011a200041186a20012003101c41e389c00041152000280218200028021c41011002" - "1a0c010b41f889c00041392003ac10011a0b41b18ac00041244183803c100bac10011a0240200041c8006a4102100c" - "220141004e044041d58ac000411c2001ad10011a0c010b41f18ac000413d2001ac10011a0b41ae8bc0004128410141" - "00410010021a41d68bc000412f41014100410010021a200041b0016a2203101a200041f0006a22012003101b200041" - "a8016a4200370300200041a0016a420037030020004198016a42003703002000420037039001024002400240024002" - "40200120004190016a2203102022014120460440200341204100100d220441004a044041858cc00041232004ad1001" - "1a200042003703482004200041c8006a220141081021220341004c0d022003410846044041a88cc000412a42081001" - "1a41d28cc000412e20014108410110021a0c060b41808dc000412e2003ad10011a200041106a200041c8006a200310" - "1d41ae8dc000411620002802102000280214410110021a0c050b41e68fc000413c2004ac10011a200041c8016a4200" - "370300200041c0016a4200370300200041b8016a4200370300200042003703b0014101200041b0016a412010212201" - "4100480d020c030b41ba92c000412e2001ac10011a41ef7c21020c050b41c48dc000412b2003ac10011a0c020b41a2" - "90c00041c1002001ac10011a0b200041013b00484101200041c8006a200041b0016a10222201410048044041e390c0" - "0041352001ac10011a0b4101102322014100480440419891c00041322001ac10011a0b4101200041c8006a10242201" - "410048044041ca91c00041392001ac10011a0b418392c000413741014100410010021a0c010b200041013b00342000" - "41c8016a4200370300200041c0016a4200370300200041b8016a4200370300200042003703b0010240200420004134" - "6a200041b0016a22011022220341004e044041ef8dc000411b2003ad10011a200041086a20012003101c418a8ec000" - "41142000280208200028020c410110021a0c010b419e8ec00041312003ac10011a0b41cf8ec000412320041023ac10" - "011a02402004200041346a1024220141004e044041f28ec000411b2001ad10011a0c010b418d8fc00041352001ac10" - "011a0b41c28fc000412441014100410010021a0b41e892c000412f41014100410010021a200041b0016a2201101a20" - "0041346a22042001101b200041e0006a4200370300200041d8006a4200370300200041d0006a420037030020004200" - "370348024002400240024002402004200041c8006a2203102022014120460440419793c000410f2003412041011002" - "1a20004188016a420037030020004180016a4200370300200041f8006a420037030020004200370370024020044114" - "2004411441a693c0004109200041f0006a22014120100e220341004a0440200020012003101c41ae93c00041122000" - "2802002000280204410110021a0c010b41c093c000413c2003ac10011a0b200041a8016a22064200370300200041a0" - "016a2202420037030020004198016a22054200370300200042003703900120004180808cc07e360268200041346a22" - "034114200041e8006a410420004190016a22084120100f22014120470d0141fc93c000410e20084120410110021a20" - "0041c8016a4200370300200041c0016a4200370300200041b8016a4200370300200042003703b001200041808080d0" - "0236026c20034114200041ec006a4104200041b0016a22044120101022014120470d02418a94c000410e2004412041" - "0110021a419894c000412441014100410010021a419195c000412541014100410010021a20004188016a4200370300" - "20004180016a4200370300200041f8006a42003703002000420037037041b695c0004117200041f0006a2203412010" - "1122014120470d0341cd95c000410b41b695c0004117410110021a41d895c000411120034120410110021a2004101a" - "200041c8006a22072004101b2006420037030020024200370300200542003703002000420037039001024041002004" - "22026b410371220320026a220520024d0d0020030440200321010340200241003a0000200241016a2102200141016b" - "22010d000b0b200341016b4107490d000340200241003a0000200241076a41003a0000200241066a41003a00002002" - "41056a41003a0000200241046a41003a0000200241036a41003a0000200241026a41003a0000200241016a41003a00" - "00200241086a22022005470d000b0b200541800220036b2201417c716a220220054b04400340200541003602002005" - "41046a22052002490d000b0b024020022001410371220120026a22034f0d002001220504400340200241003a000020" - "0241016a2102200541016b22050d000b0b200141016b4107490d000340200241003a0000200241076a41003a000020" - "0241066a41003a0000200241056a41003a0000200241046a41003a0000200241036a41003a0000200241026a41003a" - "0000200241016a41003a0000200241086a22022003470d000b0b024020074114200841202004418002101222014100" - "4a044041e995c00041102001ad10011a20014181024f0d0641f995c000410920042001410110021a0c010b418296c0" - "00412e2001ac10011a0b41b096c000411241c296c00041074101100222014100480d0541c996c000411d2001ad1001" - "1a41e696c0004111422a1001410048044041ad97c000411a42a47b10011a41a47b21020c070b41f796c000411c4200" - "10011a41012102419397c000411a41014100410010021a41ff97c000412941014100410010021a41a898c000412810" - "132201412846044041d098c000412741a898c0004128410110021a41f798c000411e41014100410010021a41bf80c0" - "00412841014100410010021a0c070b419599c000411a2001ac10011a41c37a21020c060b41f494c000411d2001ac10" - "011a418b7c21020c050b41d894c000411c2001ac10011a41897c21020c040b41bc94c000411c2001ac10011a41887c" - "21020c030b41dd97c00041222001ac10011a41a77b21020c020b000b41c797c00041162001ac10011a41a57b21020b" - "200041b0036a240020020b0d00200020012002411410191a0b0c00200041142001412010180b0e0020004182801820" - "01200210140b0e002000200141022002412010150b0a0020004183803c10160b0a0020002001410210170b0bb91901" - "00418080c0000baf196572726f725f636f64653d3d3d3d20484f53542046554e4354494f4e532054455354203d3d3d" - "54657374696e6720323620686f73742066756e6374696f6e73535543434553533a20416c6c20686f73742066756e63" - "74696f6e20746573747320706173736564212d2d2d2043617465676f727920313a204c656467657220486561646572" - "2046756e6374696f6e73202d2d2d4c65646765722073657175656e6365206e756d6265723a506172656e74206c6564" - "6765722074696d653a506172656e74206c656467657220686173683a535543434553533a204c656467657220686561" - "6465722066756e6374696f6e734552524f523a206765745f706172656e745f6c65646765725f686173682077726f6e" - "67206c656e6774683a4552524f523a206765745f706172656e745f6c65646765725f74696d65206661696c65643a45" - "52524f523a206765745f6c65646765725f73716e206661696c65643a2d2d2d2043617465676f727920323a20547261" - "6e73616374696f6e20446174612046756e6374696f6e73202d2d2d5472616e73616374696f6e204163636f756e743a" - "5472616e73616374696f6e20466565206c656e6774683a5472616e73616374696f6e20466565202873657269616c69" - "7a65642058525020616d6f756e74293a5472616e73616374696f6e2053657175656e63653a4e657374656420666965" - "6c64206c656e6774683a4e6573746564206669656c643a494e464f3a206765745f74785f6e65737465645f6669656c" - "64206e6f74206170706c696361626c653a5369676e657273206172726179206c656e6774683a4d656d6f7320617272" - "6179206c656e6774683a4e6573746564206172726179206c656e6774683a494e464f3a206765745f74785f6e657374" - "65645f61727261795f6c656e206e6f74206170706c696361626c653a535543434553533a205472616e73616374696f" - "6e20646174612066756e6374696f6e734552524f523a206765745f74785f6669656c642853657175656e6365292077" - "726f6e67206c656e6774683a4552524f523a206765745f74785f6669656c6428466565292077726f6e67206c656e67" - "746820286578706563746564203820627974657320666f7220585250293a4552524f523a206765745f74785f666965" - "6c64284163636f756e74292077726f6e67206c656e6774683a2d2d2d2043617465676f727920333a2043757272656e" - "74204c6564676572204f626a6563742046756e6374696f6e73202d2d2d43757272656e74206f626a6563742062616c" - "616e6365206c656e677468202858525020616d6f756e74293a43757272656e74206f626a6563742062616c616e6365" - "202873657269616c697a65642058525020616d6f756e74293a43757272656e74206f626a6563742062616c616e6365" - "206c656e67746820286e6f6e2d58525020616d6f756e74293a43757272656e74206f626a6563742062616c616e6365" - "3a494e464f3a206765745f63757272656e745f6c65646765725f6f626a5f6669656c642842616c616e636529206661" - "696c656420286d6179206265206578706563746564293a43757272656e74206c6564676572206f626a656374206163" - "636f756e743a494e464f3a206765745f63757272656e745f6c65646765725f6f626a5f6669656c64284163636f756e" - "7429206661696c65643a43757272656e74206e6573746564206669656c64206c656e6774683a43757272656e74206e" - "6573746564206669656c643a494e464f3a206765745f63757272656e745f6c65646765725f6f626a5f6e6573746564" - "5f6669656c64206e6f74206170706c696361626c653a43757272656e74206f626a656374205369676e657273206172" - "726179206c656e6774683a43757272656e74206e6573746564206172726179206c656e6774683a494e464f3a206765" - "745f63757272656e745f6c65646765725f6f626a5f6e65737465645f61727261795f6c656e206e6f74206170706c69" - "6361626c653a535543434553533a2043757272656e74206c6564676572206f626a6563742066756e6374696f6e732d" - "2d2d2043617465676f727920343a20416e79204c6564676572204f626a6563742046756e6374696f6e73202d2d2d53" - "75636365737366756c6c7920636163686564206f626a65637420696e20736c6f743a436163686564206f626a656374" - "2062616c616e6365206c656e677468202858525020616d6f756e74293a436163686564206f626a6563742062616c61" - "6e6365202873657269616c697a65642058525020616d6f756e74293a436163686564206f626a6563742062616c616e" - "6365206c656e67746820286e6f6e2d58525020616d6f756e74293a436163686564206f626a6563742062616c616e63" - "653a494e464f3a206765745f6c65646765725f6f626a5f6669656c642842616c616e636529206661696c65643a4361" - "63686564206e6573746564206669656c64206c656e6774683a436163686564206e6573746564206669656c643a494e" - "464f3a206765745f6c65646765725f6f626a5f6e65737465645f6669656c64206e6f74206170706c696361626c653a" - "436163686564206f626a656374205369676e657273206172726179206c656e6774683a436163686564206e65737465" - "64206172726179206c656e6774683a494e464f3a206765745f6c65646765725f6f626a5f6e65737465645f61727261" - "795f6c656e206e6f74206170706c696361626c653a535543434553533a20416e79206c6564676572206f626a656374" - "2066756e6374696f6e73494e464f3a2063616368655f6c65646765725f6f626a206661696c65642028657870656374" - "656420776974682074657374206669787475726573293a494e464f3a206765745f6c65646765725f6f626a5f666965" - "6c64206661696c656420617320657870656374656420286e6f20636163686564206f626a656374293a494e464f3a20" - "6765745f6c65646765725f6f626a5f6e65737465645f6669656c64206661696c65642061732065787065637465643a" - "494e464f3a206765745f6c65646765725f6f626a5f61727261795f6c656e206661696c656420617320657870656374" - "65643a494e464f3a206765745f6c65646765725f6f626a5f6e65737465645f61727261795f6c656e206661696c6564" - "2061732065787065637465643a535543434553533a20416e79206c6564676572206f626a6563742066756e6374696f" - "6e732028696e7465726661636520746573746564294552524f523a206163636f756e745f6b65796c6574206661696c" - "656420666f722063616368696e6720746573743a2d2d2d2043617465676f727920353a204b65796c65742047656e65" - "726174696f6e2046756e6374696f6e73202d2d2d4163636f756e74206b65796c65743a546573745479706543726564" - "656e7469616c206b65796c65743a494e464f3a2063726564656e7469616c5f6b65796c6574206661696c6564202865" - "78706563746564202d20696e74657266616365206973737565293a457363726f77206b65796c65743a4f7261636c65" - "206b65796c65743a535543434553533a204b65796c65742067656e65726174696f6e2066756e6374696f6e73455252" - "4f523a206f7261636c655f6b65796c6574206661696c65643a4552524f523a20657363726f775f6b65796c65742066" - "61696c65643a4552524f523a206163636f756e745f6b65796c6574206661696c65643a2d2d2d2043617465676f7279" - "20363a205574696c6974792046756e6374696f6e73202d2d2d48656c6c6f2c205852504c205741534d20776f726c64" - "21496e70757420646174613a5348413531322068616c6620686173683a4e46542064617461206c656e6774683a4e46" - "5420646174613a494e464f3a206765745f6e6674206661696c656420286578706563746564202d206e6f2073756368" - "204e4654293a54657374207472616365206d6573736167657061796c6f616454726163652066756e6374696f6e2062" - "79746573207772697474656e3a54657374206e756d62657220747261636554726163655f6e756d2066756e6374696f" - "6e20737563636565646564535543434553533a205574696c6974792066756e6374696f6e734552524f523a20747261" - "63655f6e756d2829206661696c65643a4552524f523a2074726163652829206661696c65643a4552524f523a20636f" - "6d707574655f7368613531325f68616c66206661696c65643a2d2d2d2043617465676f727920373a20446174612055" - "70646174652046756e6374696f6e73202d2d2d55706461746564206c656467657220656e7472792064617461206672" - "6f6d205741534d20746573745375636365737366756c6c792075706461746564206c656467657220656e7472792077" - "6974683a535543434553533a2044617461207570646174652066756e6374696f6e734552524f523a20757064617465" - "5f64617461206661696c65643a004d0970726f64756365727302086c616e6775616765010452757374000c70726f63" - "65737365642d6279010572757374631d312e38372e30202831373036376539616320323032352d30352d303929002c" - "0f7461726765745f6665617475726573022b0f6d757461626c652d676c6f62616c732b087369676e2d657874"; + "420037034841888018200041c8006a22034108100022014108470d04419e83c0004117420810011a41b583c0004128" + "20034108410110021a2000410036023041848008200041306a22034104100022014104470d0541dd83c00041152003" + "4104410110021a200041f4006a410036000020004100360071200041013a0070200242003703002005420037030020" + "044200370300200042003703b001024020074108200641201006220141004e044041f283c00041142001ad10011a20" + "0041286a20062001101d418684c000410d2000280228200028022c410110021a0c010b419384c00041292001ac1001" + "1a0b41bc84c00041154183803c1007ac10011a41d184c00041134189803c1007ac10011a0240200041f0006a410810" + "08220141004e044041e484c00041142001ad10011a0c010b41f884c000412d2001ac10011a0b41a585c00041234101" + "4100410010021a41de86c000413341014100410010021a2000420037034841828018200041c8006a22014108100922" + "0341004c0d0620034108460440419187c000412b420810011a41bc87c000412f20014108410110021a0c080b41eb87" + "c000412f2003ad10011a200041206a200041c8006a2003101c419a88c000411720002802202000280224410110021a" + "0c070b41bf82c000411d2001ac10011a419b7f21020c070b419a82c00041252001ac10011a419a7f21020c060b41ef" + "81c000412b2001ac10011a41997f21020c050b41b486c000412a2001ac10011a41b77e21020c040b41f385c00041c1" + "002001ac10011a41b67e21020c030b41c885c000412b2001ac10011a41b57e21020c020b41b188c00041c5002003ac" + "10011a0b200041a0016a410036020020004198016a4200370300200042003703900102404181802020004190016a22" + "0341141009220141004a044041f688c000411e2003101f0c010b419489c00041332001ac10011a0b200041f4006a41" + "0036000020004100360071200041013a0070200041c8016a4200370300200041c0016a4200370300200041b8016a42" + "00370300200042003703b0010240200041f0006a4108200041b0016a22014120100a220341004e044041c789c00041" + "1c2003ad10011a200041186a20012003101d41e389c00041152000280218200028021c410110021a0c010b41f889c0" + "0041392003ac10011a0b41b18ac00041244183803c100bac10011a0240200041f0006a4108100c220141004e044041" + "d58ac000411c2001ad10011a0c010b41f18ac000413d2001ac10011a0b41ae8bc000412841014100410010021a41d6" + "8bc000412f41014100410010021a200041b0016a2203101a200041f0006a22012003101b200041a8016a4200370300" + "200041a0016a420037030020004198016a420037030020004200370390010240024002400240024020012000419001" + "6a2203102022014120460440200341204100100d220441004a044041858cc00041232004ad10011a20004200370330" + "2004200041306a220141081021220341004c0d022003410846044041a88cc000412a420810011a41d28cc000412e20" + "014108410110021a0c060b41808dc000412e2003ad10011a200041106a200041306a2003101c41ae8dc00041162000" + "2802102000280214410110021a0c050b41e68fc000413c2004ac10011a200041c8016a4200370300200041c0016a42" + "00370300200041b8016a4200370300200042003703b0014101200041b0016a4120102122014100480d020c030b41ba" + "92c000412e2001ac10011a41ef7c21020c050b41c48dc000412b2003ac10011a0c020b41a290c00041c1002001ac10" + "011a0b200041cc006a410036000020004100360049200041013a00484101200041c8006a200041b0016a1022220141" + "0048044041e390c00041352001ac10011a0b4101102322014100480440419891c00041322001ac10011a0b41012000" + "41c8006a10242201410048044041ca91c00041392001ac10011a0b418392c000413741014100410010021a0c010b20" + "0041cc006a410036000020004100360049200041013a0048200041c8016a4200370300200041c0016a420037030020" + "0041b8016a4200370300200042003703b00102402004200041c8006a200041b0016a22011022220341004e044041ef" + "8dc000411b2003ad10011a200041086a20012003101d418a8ec00041142000280208200028020c410110021a0c010b" + "419e8ec00041312003ac10011a0b41cf8ec000412320041023ac10011a02402004200041c8006a1024220141004e04" + "4041f28ec000411b2001ad10011a0c010b418d8fc00041352001ac10011a0b41c28fc000412441014100410010021a" + "0b41e892c000412f41014100410010021a200041b0016a2201101a200041306a22042001101b200041e0006a420037" + "0300200041d8006a4200370300200041d0006a420037030020004200370348024002400240024002402004200041c8" + "006a2203102022014120460440419793c000410f20034120410110021a20004188016a420037030020004180016a42" + "00370300200041f8006a4200370300200042003703700240200441142004411441a693c0004109200041f0006a2201" + "4120100e220341004a0440200020012003101d41ae93c000411220002802002000280204410110021a0c010b41c093" + "c000413c2003ac10011a0b200041a8016a22064200370300200041a0016a2202420037030020004198016a22054200" + "370300200042003703900120004180808cc07e360268200041306a22034114200041e8006a410420004190016a2208" + "4120100f22014120470d0141fc93c000410e20084120410110021a200041c8016a4200370300200041c0016a420037" + "0300200041b8016a4200370300200042003703b001200041808080d00236026c20034114200041ec006a4104200041" + "b0016a22044120101022014120470d02418a94c000410e20044120410110021a419894c00041244101410041001002" + "1a419195c000412541014100410010021a20004188016a420037030020004180016a4200370300200041f8006a4200" + "3703002000420037037041b695c0004117200041f0006a22034120101122014120470d0341cd95c000410b41b695c0" + "004117410110021a41d895c000411120034120410110021a2004101a200041c8006a22072004101b20064200370300" + "2002420037030020054200370300200042003703900102404100200422026b410371220320026a220520024d0d0020" + "030440200321010340200241003a0000200241016a2102200141016b22010d000b0b200341016b4107490d00034020" + "0241003a0000200241076a41003a0000200241066a41003a0000200241056a41003a0000200241046a41003a000020" + "0241036a41003a0000200241026a41003a0000200241016a41003a0000200241086a22022005470d000b0b20054180" + "0220036b2201417c716a220220054b0440034020054100360200200541046a22052002490d000b0b02402002200141" + "0371220120026a22034f0d002001220504400340200241003a0000200241016a2102200541016b22050d000b0b2001" + "41016b4107490d000340200241003a0000200241076a41003a0000200241066a41003a0000200241056a41003a0000" + "200241046a41003a0000200241036a41003a0000200241026a41003a0000200241016a41003a0000200241086a2202" + "2003470d000b0b0240200741142008412020044180021012220141004a044041e995c00041102001ad10011a200141" + "81024f0d0641f995c000410920042001410110021a0c010b418296c000412e2001ac10011a0b41b096c000411241c2" + "96c00041074101100222014100480d0541c996c000411d2001ad10011a41e696c0004111422a1001410048044041ad" + "97c000411a42a47b10011a41a47b21020c070b41f796c000411c420010011a41012102419397c000411a4101410041" + "0010021a41ff97c000412941014100410010021a41a898c000412810132201412846044041d098c000412741a898c0" + "004128410110021a41f798c000411e41014100410010021a41bf80c000412841014100410010021a0c070b419599c0" + "00411a2001ac10011a41c37a21020c060b41f494c000411d2001ac10011a418b7c21020c050b41d894c000411c2001" + "ac10011a41897c21020c040b41bc94c000411c2001ac10011a41887c21020c030b41dd97c00041222001ac10011a41" + "a77b21020c020b000b41c797c00041162001ac10011a41a57b21020b200041b0036a240020020b0d00200020012002" + "411410191a0b0c00200041142001412010180b0e002000418280182001200210140b0e002000200141082002412010" + "150b0a0020004183803c10160b0a0020002001410810170b0bb9190100418080c0000baf196572726f725f636f6465" + "3d3d3d3d20484f53542046554e4354494f4e532054455354203d3d3d54657374696e6720323620686f73742066756e" + "6374696f6e73535543434553533a20416c6c20686f73742066756e6374696f6e20746573747320706173736564212d" + "2d2d2043617465676f727920313a204c6564676572204865616465722046756e6374696f6e73202d2d2d4c65646765" + "722073657175656e6365206e756d6265723a506172656e74206c65646765722074696d653a506172656e74206c6564" + "67657220686173683a535543434553533a204c6564676572206865616465722066756e6374696f6e734552524f523a" + "206765745f706172656e745f6c65646765725f686173682077726f6e67206c656e6774683a4552524f523a20676574" + "5f706172656e745f6c65646765725f74696d65206661696c65643a4552524f523a206765745f6c65646765725f7371" + "6e206661696c65643a2d2d2d2043617465676f727920323a205472616e73616374696f6e20446174612046756e6374" + "696f6e73202d2d2d5472616e73616374696f6e204163636f756e743a5472616e73616374696f6e20466565206c656e" + "6774683a5472616e73616374696f6e20466565202873657269616c697a65642058525020616d6f756e74293a547261" + "6e73616374696f6e2053657175656e63653a4e6573746564206669656c64206c656e6774683a4e6573746564206669" + "656c643a494e464f3a206765745f74785f6e65737465645f6669656c64206e6f74206170706c696361626c653a5369" + "676e657273206172726179206c656e6774683a4d656d6f73206172726179206c656e6774683a4e6573746564206172" + "726179206c656e6774683a494e464f3a206765745f74785f6e65737465645f61727261795f6c656e206e6f74206170" + "706c696361626c653a535543434553533a205472616e73616374696f6e20646174612066756e6374696f6e73455252" + "4f523a206765745f74785f6669656c642853657175656e6365292077726f6e67206c656e6774683a4552524f523a20" + "6765745f74785f6669656c6428466565292077726f6e67206c656e6774682028657870656374656420382062797465" + "7320666f7220585250293a4552524f523a206765745f74785f6669656c64284163636f756e74292077726f6e67206c" + "656e6774683a2d2d2d2043617465676f727920333a2043757272656e74204c6564676572204f626a6563742046756e" + "6374696f6e73202d2d2d43757272656e74206f626a6563742062616c616e6365206c656e677468202858525020616d" + "6f756e74293a43757272656e74206f626a6563742062616c616e6365202873657269616c697a65642058525020616d" + "6f756e74293a43757272656e74206f626a6563742062616c616e6365206c656e67746820286e6f6e2d58525020616d" + "6f756e74293a43757272656e74206f626a6563742062616c616e63653a494e464f3a206765745f63757272656e745f" + "6c65646765725f6f626a5f6669656c642842616c616e636529206661696c656420286d617920626520657870656374" + "6564293a43757272656e74206c6564676572206f626a656374206163636f756e743a494e464f3a206765745f637572" + "72656e745f6c65646765725f6f626a5f6669656c64284163636f756e7429206661696c65643a43757272656e74206e" + "6573746564206669656c64206c656e6774683a43757272656e74206e6573746564206669656c643a494e464f3a2067" + "65745f63757272656e745f6c65646765725f6f626a5f6e65737465645f6669656c64206e6f74206170706c69636162" + "6c653a43757272656e74206f626a656374205369676e657273206172726179206c656e6774683a43757272656e7420" + "6e6573746564206172726179206c656e6774683a494e464f3a206765745f63757272656e745f6c65646765725f6f62" + "6a5f6e65737465645f61727261795f6c656e206e6f74206170706c696361626c653a535543434553533a2043757272" + "656e74206c6564676572206f626a6563742066756e6374696f6e732d2d2d2043617465676f727920343a20416e7920" + "4c6564676572204f626a6563742046756e6374696f6e73202d2d2d5375636365737366756c6c792063616368656420" + "6f626a65637420696e20736c6f743a436163686564206f626a6563742062616c616e6365206c656e67746820285852" + "5020616d6f756e74293a436163686564206f626a6563742062616c616e6365202873657269616c697a656420585250" + "20616d6f756e74293a436163686564206f626a6563742062616c616e6365206c656e67746820286e6f6e2d58525020" + "616d6f756e74293a436163686564206f626a6563742062616c616e63653a494e464f3a206765745f6c65646765725f" + "6f626a5f6669656c642842616c616e636529206661696c65643a436163686564206e6573746564206669656c64206c" + "656e6774683a436163686564206e6573746564206669656c643a494e464f3a206765745f6c65646765725f6f626a5f" + "6e65737465645f6669656c64206e6f74206170706c696361626c653a436163686564206f626a656374205369676e65" + "7273206172726179206c656e6774683a436163686564206e6573746564206172726179206c656e6774683a494e464f" + "3a206765745f6c65646765725f6f626a5f6e65737465645f61727261795f6c656e206e6f74206170706c696361626c" + "653a535543434553533a20416e79206c6564676572206f626a6563742066756e6374696f6e73494e464f3a20636163" + "68655f6c65646765725f6f626a206661696c6564202865787065637465642077697468207465737420666978747572" + "6573293a494e464f3a206765745f6c65646765725f6f626a5f6669656c64206661696c656420617320657870656374" + "656420286e6f20636163686564206f626a656374293a494e464f3a206765745f6c65646765725f6f626a5f6e657374" + "65645f6669656c64206661696c65642061732065787065637465643a494e464f3a206765745f6c65646765725f6f62" + "6a5f61727261795f6c656e206661696c65642061732065787065637465643a494e464f3a206765745f6c6564676572" + "5f6f626a5f6e65737465645f61727261795f6c656e206661696c65642061732065787065637465643a535543434553" + "533a20416e79206c6564676572206f626a6563742066756e6374696f6e732028696e74657266616365207465737465" + "64294552524f523a206163636f756e745f6b65796c6574206661696c656420666f722063616368696e672074657374" + "3a2d2d2d2043617465676f727920353a204b65796c65742047656e65726174696f6e2046756e6374696f6e73202d2d" + "2d4163636f756e74206b65796c65743a546573745479706543726564656e7469616c206b65796c65743a494e464f3a" + "2063726564656e7469616c5f6b65796c6574206661696c656420286578706563746564202d20696e74657266616365" + "206973737565293a457363726f77206b65796c65743a4f7261636c65206b65796c65743a535543434553533a204b65" + "796c65742067656e65726174696f6e2066756e6374696f6e734552524f523a206f7261636c655f6b65796c65742066" + "61696c65643a4552524f523a20657363726f775f6b65796c6574206661696c65643a4552524f523a206163636f756e" + "745f6b65796c6574206661696c65643a2d2d2d2043617465676f727920363a205574696c6974792046756e6374696f" + "6e73202d2d2d48656c6c6f2c205852504c205741534d20776f726c6421496e70757420646174613a53484135313220" + "68616c6620686173683a4e46542064617461206c656e6774683a4e465420646174613a494e464f3a206765745f6e66" + "74206661696c656420286578706563746564202d206e6f2073756368204e4654293a54657374207472616365206d65" + "73736167657061796c6f616454726163652066756e6374696f6e206279746573207772697474656e3a54657374206e" + "756d62657220747261636554726163655f6e756d2066756e6374696f6e20737563636565646564535543434553533a" + "205574696c6974792066756e6374696f6e734552524f523a2074726163655f6e756d2829206661696c65643a455252" + "4f523a2074726163652829206661696c65643a4552524f523a20636f6d707574655f7368613531325f68616c662066" + "61696c65643a2d2d2d2043617465676f727920373a2044617461205570646174652046756e6374696f6e73202d2d2d" + "55706461746564206c656467657220656e74727920646174612066726f6d205741534d207465737453756363657373" + "66756c6c792075706461746564206c656467657220656e74727920776974683a535543434553533a20446174612075" + "70646174652066756e6374696f6e734552524f523a207570646174655f64617461206661696c65643a004d0970726f" + "64756365727302086c616e6775616765010452757374000c70726f6365737365642d6279010572757374631d312e38" + "392e30202832393438333838336520323032352d30382d303429002c0f7461726765745f6665617475726573022b0f" + "6d757461626c652d676c6f62616c732b087369676e2d657874"; extern std::string const kDeepRecursionHex = "0061736d010000000105016000017f030201000608017f0141c0843d0b070a010666696e69736800000a1601140023" @@ -1008,33 +1010,18 @@ extern std::string const kFloat0Hex = "0061736d0100000001290560057f7f7f7f7f017f60047e7f7f7f017f60077f7f7f7f7f7f7f017f60047f7f7f7f017f" "6000017f025f0408686f73745f6c6962057472616365000008686f73745f6c69620e666c6f61745f66726f6d5f696e" "74000108686f73745f6c69620e666c6f61745f7375627472616374000208686f73745f6c69620d666c6f61745f636f" - "6d7061726500030302010405030100110619037f01418080c0000b7f00419681c0000b7f0041a081c0000b072e0406" - "6d656d6f727902000666696e69736800040a5f5f646174615f656e6403010b5f5f686561705f6261736503020ad302" - "01d00201017f23808080800041206b2200248080808000418080c0800041154101410041001080808080001a200041" - "086a410036020020004200370300200041106a41086a410036020020004200370310024002400240420a2000410c41" - "00108180808000410c470d002000410c2000410c200041106a410c4100108280808000410c470d0102400240200041" - "106a410c200041106a410c1083808080000d00419580c0800041174101410041001080808080001a0c010b41ac80c0" - "800041164101410041001080808080001a0b0240200041106a410c41c280c08000410c1083808080000d0041ce80c0" - "8000411a4101410041001080808080001a0c030b41e880c0800041194101410041001080808080001a0c020b418181" - "c0800041154101410041001080808080001a0c010b418181c0800041154101410041001080808080001a0b20004120" - "6a24808080800041010b0ba0010100418080c0000b96010a24242420746573745f666c6f61745f3020242424202066" - "6c6f6174203020636f6d706172653a20676f6f642020666c6f6174203020636f6d706172653a206261640000000000" - "000000800000002020464c4f41545f5a45524f20636f6d706172653a20676f6f642020464c4f41745f5a45524f2063" - "6f6d706172653a206261642020666c6f61742031302d31303a206661696c6564009503046e616d65000d0c666c6f61" - "745f302e7761736d01de0205004c5f5a4e31367872706c5f7761736d5f7374646c696234686f73743232686f73745f" - "646566696e65645f66756e6374696f6e73357472616365313768653738323066313637383330383338364501565f5a" - "4e31367872706c5f7761736d5f7374646c696234686f73743232686f73745f646566696e65645f66756e6374696f6e" - "733134666c6f61745f66726f6d5f696e74313768646463636262643266613366663431634502565f5a4e3136787270" - "6c5f7761736d5f7374646c696234686f73743232686f73745f646566696e65645f66756e6374696f6e733134666c6f" - "61745f7375627472616374313768313765643838343131303333663437624503555f5a4e31367872706c5f7761736d" - "5f7374646c696234686f73743232686f73745f646566696e65645f66756e6374696f6e733133666c6f61745f636f6d" - "706172653137683835393637633834333363613334623045040666696e697368071201000f5f5f737461636b5f706f" - "696e746572090a0100072e726f64617461004d0970726f64756365727302086c616e6775616765010452757374000c" - "70726f6365737365642d6279010572757374631d312e38392e30202832393438333838336520323032352d30382d30" - "34290094010f7461726765745f6665617475726573082b0b62756c6b2d6d656d6f72792b0f62756c6b2d6d656d6f72" - "792d6f70742b1663616c6c2d696e6469726563742d6f7665726c6f6e672b0a6d756c746976616c75652b0f6d757461" - "626c652d676c6f62616c732b136e6f6e7472617070696e672d6670746f696e742b0f7265666572656e63652d747970" - "65732b087369676e2d657874"; + "6d7061726500030302010405030100110619037f01418080c0000b7f0041e980c0000b7f0041f080c0000b072e0406" + "6d656d6f727902000666696e69736800040a5f5f646174615f656e6403010b5f5f686561705f6261736503020ad201" + "01cf0101027f230041206b22002400418080c000411541014100410010001a200041086a4100360200200042003703" + "00200041186a41003602002000420037031002400240420a2000410c41001001410c4604402000410c2000410c2000" + "41106a2201410c41001002410c470d012001410c419580c000410c100345044041a180c000411a4101410041001000" + "1a0c030b41bb80c000411941014100410010001a0c020b41d480c000411541014100410010001a0c010b41d480c000" + "411541014100410010001a0b200041206a240041010b0b720100418080c0000b690a24242420746573745f666c6f61" + "745f30202424240000000000000000800000002020464c4f41545f5a45524f20636f6d706172653a20676f6f642020" + "464c4f41545f5a45524f20636f6d706172653a206261642020666c6f61742031302d31303a206661696c6564004d09" + "70726f64756365727302086c616e6775616765010452757374000c70726f6365737365642d6279010572757374631d" + "312e38392e30202832393438333838336520323032352d30382d303429002c0f7461726765745f6665617475726573" + "022b0f6d757461626c652d676c6f62616c732b087369676e2d657874"; extern std::string const kDisabledFloatHex = "0061736d010000000108026000006000017f03030200010503010002063e0a7f004180080b7f004180080b7f004180" diff --git a/src/test/app/wasm_fixtures/float_0/src/lib.rs b/src/test/app/wasm_fixtures/float_0/src/lib.rs index 2c1e2dd5c3..babcc1bf54 100644 --- a/src/test/app/wasm_fixtures/float_0/src/lib.rs +++ b/src/test/app/wasm_fixtures/float_0/src/lib.rs @@ -39,13 +39,6 @@ pub extern "C" fn finish() -> i32 { return 1; } - // Compare result with zero - if 0 == unsafe { float_compare(f_result.as_ptr(), FLOAT_SIZE, f_result.as_ptr(), FLOAT_SIZE) } { - let _ = trace(" float 0 compare: good"); - } else { - let _ = trace(" float 0 compare: bad"); - } - // Compare result with FLOAT_ZERO constant if 0 == unsafe { float_compare(f_result.as_ptr(), FLOAT_SIZE, FLOAT_ZERO.as_ptr(), FLOAT_SIZE) } { let _ = trace(" FLOAT_ZERO compare: good");