mirror of
https://github.com/Xahau/xahaud.git
synced 2025-11-04 18:55:49 +00:00
Compare commits
26 Commits
release
...
hook-api-u
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
11d0c3486c | ||
|
|
bf7ea28b3d | ||
|
|
010951e8d7 | ||
|
|
19032e5a2b | ||
|
|
c83bfe1987 | ||
|
|
bc7a28f6af | ||
|
|
3db217058b | ||
|
|
bf9765753f | ||
|
|
cf59180660 | ||
|
|
4ff8d688e2 | ||
|
|
e3c4644151 | ||
|
|
a62bac3fcd | ||
|
|
27e4e4b510 | ||
|
|
962fdbceb6 | ||
|
|
2466289a1e | ||
|
|
7b79e7d390 | ||
|
|
4d33603f39 | ||
|
|
3f65b57997 | ||
|
|
22c71a9801 | ||
|
|
0290b73a9e | ||
|
|
cf9eef03e5 | ||
|
|
dfd93e9ab2 | ||
|
|
ed68a53f6c | ||
|
|
6e49f7d1b1 | ||
|
|
4a36ca527e | ||
|
|
c732609f46 |
@@ -488,6 +488,7 @@ target_sources (rippled PRIVATE
|
||||
src/ripple/app/tx/impl/apply.cpp
|
||||
src/ripple/app/tx/impl/applySteps.cpp
|
||||
src/ripple/app/hook/impl/applyHook.cpp
|
||||
src/ripple/app/hook/impl/HookAPI.cpp
|
||||
src/ripple/app/tx/impl/details/NFTokenUtils.cpp
|
||||
#[===============================[
|
||||
main sources:
|
||||
|
||||
350
src/ripple/app/hook/HookAPI.h
Normal file
350
src/ripple/app/hook/HookAPI.h
Normal file
@@ -0,0 +1,350 @@
|
||||
#include <ripple/app/hook/Enum.h>
|
||||
#include <ripple/app/tx/impl/ApplyContext.h>
|
||||
#include <ripple/basics/Blob.h>
|
||||
#include <ripple/basics/Expected.h>
|
||||
#include <ripple/basics/Slice.h>
|
||||
#include <ripple/protocol/STTx.h>
|
||||
|
||||
#include <ripple/app/misc/Transaction.h>
|
||||
#include <ripple/basics/base_uint.h>
|
||||
#include <ripple/protocol/TxFormats.h>
|
||||
#include <cstdint>
|
||||
|
||||
namespace hook {
|
||||
using namespace ripple;
|
||||
using HookReturnCode = hook_api::hook_return_code;
|
||||
|
||||
using Bytes = std::vector<std::uint8_t>;
|
||||
|
||||
struct HookContext; // defined in applyHook.h
|
||||
|
||||
class HookAPI
|
||||
{
|
||||
public:
|
||||
explicit HookAPI(HookContext& ctx) : hookCtx(ctx)
|
||||
{
|
||||
}
|
||||
|
||||
/// control APIs
|
||||
// _g
|
||||
// accept
|
||||
// rollback
|
||||
|
||||
/// util APIs
|
||||
Expected<std::string, HookReturnCode>
|
||||
util_raddr(Bytes const& accountID) const;
|
||||
|
||||
Expected<Bytes, HookReturnCode>
|
||||
util_accid(std::string raddress) const;
|
||||
|
||||
Expected<bool, HookReturnCode>
|
||||
util_verify(Slice const& data, Slice const& sig, Slice const& key) const;
|
||||
|
||||
uint256
|
||||
util_sha512h(Slice const& data) const;
|
||||
|
||||
// util_keylet()
|
||||
|
||||
/// sto APIs
|
||||
Expected<bool, HookReturnCode>
|
||||
sto_validate(Bytes const& data) const;
|
||||
|
||||
Expected<std::pair<uint32_t, uint32_t>, HookReturnCode>
|
||||
sto_subfield(Bytes const& data, uint32_t field_id) const;
|
||||
|
||||
Expected<std::pair<uint32_t, uint32_t>, HookReturnCode>
|
||||
sto_subarray(Bytes const& data, uint32_t index_id) const;
|
||||
|
||||
Expected<Bytes, HookReturnCode>
|
||||
sto_emplace(
|
||||
Bytes const& source_object,
|
||||
std::optional<Bytes> const& field_object,
|
||||
uint32_t field_id) const;
|
||||
|
||||
// sto_erase(): same as sto_emplace with field_object = nullopt
|
||||
|
||||
/// etxn APIs
|
||||
Expected<std::shared_ptr<Transaction>, HookReturnCode>
|
||||
emit(Slice const& txBlob) const;
|
||||
|
||||
Expected<uint64_t, HookReturnCode>
|
||||
etxn_burden() const;
|
||||
|
||||
Expected<uint64_t, HookReturnCode>
|
||||
etxn_fee_base(Slice const& txBlob) const;
|
||||
|
||||
Expected<uint64_t, HookReturnCode>
|
||||
etxn_details(uint8_t* out_ptr) const;
|
||||
|
||||
Expected<uint64_t, HookReturnCode>
|
||||
etxn_reserve(uint64_t count) const;
|
||||
|
||||
uint32_t
|
||||
etxn_generation() const;
|
||||
|
||||
Expected<uint256, HookReturnCode>
|
||||
etxn_nonce() const;
|
||||
|
||||
/// float APIs
|
||||
Expected<uint64_t, HookReturnCode>
|
||||
float_set(int32_t exponent, int64_t mantissa) const;
|
||||
|
||||
Expected<uint64_t, HookReturnCode>
|
||||
float_multiply(uint64_t float1, uint64_t float2) const;
|
||||
|
||||
Expected<uint64_t, HookReturnCode>
|
||||
float_mulratio(
|
||||
uint64_t float1,
|
||||
uint32_t round_up,
|
||||
uint32_t numerator,
|
||||
uint32_t denominator) const;
|
||||
|
||||
uint64_t
|
||||
float_negate(uint64_t float1) const;
|
||||
|
||||
Expected<uint64_t, HookReturnCode>
|
||||
float_compare(uint64_t float1, uint64_t float2, uint32_t mode) const;
|
||||
|
||||
Expected<uint64_t, HookReturnCode>
|
||||
float_sum(uint64_t float1, uint64_t float2) const;
|
||||
|
||||
Expected<Bytes, HookReturnCode>
|
||||
float_sto(
|
||||
std::optional<Currency> currency,
|
||||
std::optional<AccountID> issuer,
|
||||
uint64_t float1,
|
||||
uint32_t field_code,
|
||||
uint32_t write_len) const;
|
||||
|
||||
Expected<uint64_t, HookReturnCode>
|
||||
float_sto_set(Bytes const& data) const;
|
||||
|
||||
Expected<uint64_t, HookReturnCode>
|
||||
float_invert(uint64_t float1) const;
|
||||
|
||||
Expected<uint64_t, HookReturnCode>
|
||||
float_divide(uint64_t float1, uint64_t float2) const;
|
||||
|
||||
uint64_t
|
||||
float_one() const;
|
||||
|
||||
Expected<uint64_t, HookReturnCode>
|
||||
float_mantissa(uint64_t float1) const;
|
||||
|
||||
uint64_t
|
||||
float_sign(uint64_t float1) const;
|
||||
|
||||
Expected<uint64_t, HookReturnCode>
|
||||
float_int(uint64_t float1, uint32_t decimal_places, uint32_t absolute)
|
||||
const;
|
||||
|
||||
Expected<uint64_t, HookReturnCode>
|
||||
float_log(uint64_t float1) const;
|
||||
|
||||
Expected<uint64_t, HookReturnCode>
|
||||
float_root(uint64_t float1, uint32_t n) const;
|
||||
|
||||
/// otxn APIs
|
||||
uint64_t
|
||||
otxn_burden() const;
|
||||
|
||||
uint32_t
|
||||
otxn_generation() const;
|
||||
|
||||
Expected<const STBase*, HookReturnCode>
|
||||
otxn_field(uint32_t field_id) const;
|
||||
|
||||
Expected<uint256, HookReturnCode>
|
||||
otxn_id(uint32_t flags) const;
|
||||
|
||||
TxType
|
||||
otxn_type() const;
|
||||
|
||||
Expected<uint32_t, HookReturnCode>
|
||||
otxn_slot(uint32_t slot_into) const;
|
||||
|
||||
Expected<Blob, HookReturnCode>
|
||||
otxn_param(Bytes const& param_name) const;
|
||||
|
||||
/// hook APIs
|
||||
AccountID
|
||||
hook_account() const;
|
||||
|
||||
Expected<ripple::uint256, HookReturnCode>
|
||||
hook_hash(int32_t hook_no) const;
|
||||
|
||||
Expected<int64_t, HookReturnCode>
|
||||
hook_again() const;
|
||||
|
||||
Expected<Blob, HookReturnCode>
|
||||
hook_param(Bytes const& paramName) const;
|
||||
|
||||
Expected<uint64_t, HookReturnCode>
|
||||
hook_param_set(
|
||||
uint256 const& hash,
|
||||
Bytes const& paramName,
|
||||
Bytes const& paramValue) const;
|
||||
|
||||
Expected<uint64_t, HookReturnCode>
|
||||
hook_skip(uint256 const& hash, uint32_t flags) const;
|
||||
|
||||
uint8_t
|
||||
hook_pos() const;
|
||||
|
||||
/// ledger APIs
|
||||
uint64_t
|
||||
fee_base() const;
|
||||
|
||||
uint32_t
|
||||
ledger_seq() const;
|
||||
|
||||
uint256
|
||||
ledger_last_hash() const;
|
||||
|
||||
uint64_t
|
||||
ledger_last_time() const;
|
||||
|
||||
Expected<uint256, HookReturnCode>
|
||||
ledger_nonce() const;
|
||||
|
||||
Expected<Keylet, HookReturnCode>
|
||||
ledger_keylet(Keylet const& klLo, Keylet const& klHi) const;
|
||||
|
||||
/// state APIs
|
||||
|
||||
// state(): same as state_foreign with ns = 0 and account = hook_account()
|
||||
|
||||
Expected<Bytes, HookReturnCode>
|
||||
state_foreign(
|
||||
uint256 const& key,
|
||||
uint256 const& ns,
|
||||
AccountID const& account) const;
|
||||
|
||||
// state_set(): same as state_foreign_set with ns = 0 and account =
|
||||
|
||||
Expected<uint64_t, HookReturnCode>
|
||||
state_foreign_set(
|
||||
uint256 const& key,
|
||||
uint256 const& ns,
|
||||
AccountID const& account,
|
||||
Bytes& data) const;
|
||||
|
||||
/// slot APIs
|
||||
Expected<const STBase*, HookReturnCode>
|
||||
slot(uint32_t slot_no) const;
|
||||
|
||||
Expected<uint64_t, HookReturnCode>
|
||||
slot_clear(uint32_t slot_no) const;
|
||||
|
||||
Expected<uint64_t, HookReturnCode>
|
||||
slot_count(uint32_t slot_no) const;
|
||||
|
||||
Expected<uint32_t, HookReturnCode>
|
||||
slot_set(Bytes const& data, uint32_t slot_no) const;
|
||||
|
||||
Expected<uint64_t, HookReturnCode>
|
||||
slot_size(uint32_t slot_no) const;
|
||||
|
||||
Expected<uint32_t, HookReturnCode>
|
||||
slot_subarray(uint32_t parent_slot, uint32_t array_id, uint32_t new_slot)
|
||||
const;
|
||||
|
||||
Expected<uint32_t, HookReturnCode>
|
||||
slot_subfield(uint32_t parent_slot, uint32_t field_id, uint32_t new_slot)
|
||||
const;
|
||||
|
||||
Expected<std::variant<STBase, STAmount>, HookReturnCode>
|
||||
slot_type(uint32_t slot_no, uint32_t flags) const;
|
||||
|
||||
Expected<uint64_t, HookReturnCode>
|
||||
slot_float(uint32_t slot_no) const;
|
||||
|
||||
/// trace APIs
|
||||
// trace
|
||||
// trace_num
|
||||
// trace_float
|
||||
|
||||
Expected<uint32_t, HookReturnCode>
|
||||
meta_slot(uint32_t slot_into) const;
|
||||
|
||||
Expected<std::pair<uint32_t, uint32_t>, HookReturnCode>
|
||||
xpop_slot(uint32_t slot_into_tx, uint32_t slot_into_meta) const;
|
||||
|
||||
private:
|
||||
HookContext& hookCtx;
|
||||
|
||||
inline int32_t
|
||||
no_free_slots() const;
|
||||
|
||||
inline std::optional<int32_t>
|
||||
get_free_slot() const;
|
||||
|
||||
inline Expected<uint64_t, HookReturnCode>
|
||||
float_multiply_internal_parts(
|
||||
uint64_t man1,
|
||||
int32_t exp1,
|
||||
bool neg1,
|
||||
uint64_t man2,
|
||||
int32_t exp2,
|
||||
bool neg2) const;
|
||||
|
||||
inline Expected<uint64_t, HookReturnCode>
|
||||
mulratio_internal(
|
||||
int64_t& man1,
|
||||
int32_t& exp1,
|
||||
bool round_up,
|
||||
uint32_t numerator,
|
||||
uint32_t denominator) const;
|
||||
|
||||
inline Expected<uint64_t, HookReturnCode>
|
||||
float_divide_internal(uint64_t float1, uint64_t float2) const;
|
||||
|
||||
inline Expected<uint64_t, HookReturnCode>
|
||||
double_to_xfl(double x) const;
|
||||
|
||||
std::optional<ripple::Keylet>
|
||||
unserialize_keylet(Bytes const& data) const;
|
||||
|
||||
// update the state cache
|
||||
inline std::optional<
|
||||
std::reference_wrapper<std::pair<bool, ripple::Blob> const>>
|
||||
lookup_state_cache(
|
||||
AccountID const& acc,
|
||||
uint256 const& ns,
|
||||
uint256 const& key) const;
|
||||
|
||||
// check the state cache
|
||||
inline Expected<uint64_t, HookReturnCode>
|
||||
set_state_cache(
|
||||
AccountID const& acc,
|
||||
uint256 const& ns,
|
||||
uint256 const& key,
|
||||
Bytes const& data,
|
||||
bool modified) const;
|
||||
|
||||
// these are only used by get_stobject_length below
|
||||
enum parse_error {
|
||||
pe_unexpected_end = -1,
|
||||
pe_unknown_type_early = -2, // detected early
|
||||
pe_unknown_type_late = -3, // end of function
|
||||
pe_excessive_nesting = -4,
|
||||
pe_excessive_size = -5
|
||||
};
|
||||
|
||||
inline Expected<
|
||||
int32_t,
|
||||
parse_error>
|
||||
get_stobject_length(
|
||||
unsigned char* start, // in - begin iterator
|
||||
unsigned char* maxptr, // in - end iterator
|
||||
int& type, // out - populated by serialized type code
|
||||
int& field, // out - populated by serialized field code
|
||||
int& payload_start, // out - the start of actual payload data for
|
||||
// this type
|
||||
int& payload_length, // out - the length of actual payload data for
|
||||
// this type
|
||||
int recursion_depth = 0) // used internally
|
||||
const;
|
||||
};
|
||||
|
||||
} // namespace hook
|
||||
@@ -477,7 +477,6 @@ struct HookResult
|
||||
ripple::uint256 const hookHash;
|
||||
ripple::uint256 const hookCanEmit;
|
||||
ripple::Keylet const accountKeylet;
|
||||
ripple::Keylet const ownerDirKeylet;
|
||||
ripple::Keylet const hookKeylet;
|
||||
ripple::AccountID const account;
|
||||
ripple::AccountID const otxnAccount;
|
||||
@@ -799,12 +798,13 @@ public:
|
||||
ADD_HOOK_FUNCTION(util_accid, ctx);
|
||||
ADD_HOOK_FUNCTION(util_verify, ctx);
|
||||
ADD_HOOK_FUNCTION(util_sha512h, ctx);
|
||||
ADD_HOOK_FUNCTION(util_keylet, ctx);
|
||||
|
||||
ADD_HOOK_FUNCTION(sto_validate, ctx);
|
||||
ADD_HOOK_FUNCTION(sto_subfield, ctx);
|
||||
ADD_HOOK_FUNCTION(sto_subarray, ctx);
|
||||
ADD_HOOK_FUNCTION(sto_emplace, ctx);
|
||||
ADD_HOOK_FUNCTION(sto_erase, ctx);
|
||||
ADD_HOOK_FUNCTION(util_keylet, ctx);
|
||||
|
||||
ADD_HOOK_FUNCTION(emit, ctx);
|
||||
ADD_HOOK_FUNCTION(etxn_burden, ctx);
|
||||
@@ -843,6 +843,11 @@ public:
|
||||
ADD_HOOK_FUNCTION(hook_account, ctx);
|
||||
ADD_HOOK_FUNCTION(hook_hash, ctx);
|
||||
ADD_HOOK_FUNCTION(hook_again, ctx);
|
||||
ADD_HOOK_FUNCTION(hook_param, ctx);
|
||||
ADD_HOOK_FUNCTION(hook_param_set, ctx);
|
||||
ADD_HOOK_FUNCTION(hook_skip, ctx);
|
||||
ADD_HOOK_FUNCTION(hook_pos, ctx);
|
||||
|
||||
ADD_HOOK_FUNCTION(fee_base, ctx);
|
||||
ADD_HOOK_FUNCTION(ledger_seq, ctx);
|
||||
ADD_HOOK_FUNCTION(ledger_last_hash, ctx);
|
||||
@@ -850,11 +855,6 @@ public:
|
||||
ADD_HOOK_FUNCTION(ledger_nonce, ctx);
|
||||
ADD_HOOK_FUNCTION(ledger_keylet, ctx);
|
||||
|
||||
ADD_HOOK_FUNCTION(hook_param, ctx);
|
||||
ADD_HOOK_FUNCTION(hook_param_set, ctx);
|
||||
ADD_HOOK_FUNCTION(hook_skip, ctx);
|
||||
ADD_HOOK_FUNCTION(hook_pos, ctx);
|
||||
|
||||
ADD_HOOK_FUNCTION(state, ctx);
|
||||
ADD_HOOK_FUNCTION(state_foreign, ctx);
|
||||
ADD_HOOK_FUNCTION(state_set, ctx);
|
||||
|
||||
3149
src/ripple/app/hook/impl/HookAPI.cpp
Normal file
3149
src/ripple/app/hook/impl/HookAPI.cpp
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -137,14 +137,14 @@ class [[nodiscard]] Expected
|
||||
public:
|
||||
template <typename U>
|
||||
requires std::convertible_to<U, T> constexpr Expected(U && r)
|
||||
: Base(T(std::forward<U>(r)))
|
||||
: Base(boost::outcome_v2::success(T(std::forward<U>(r))))
|
||||
{
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
requires std::convertible_to<U, E> &&
|
||||
(!std::is_reference_v<U>)constexpr Expected(Unexpected<U> e)
|
||||
: Base(E(std::move(e.value())))
|
||||
: Base(boost::outcome_v2::failure(E(std::move(e.value()))))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ public:
|
||||
template <typename U>
|
||||
requires std::convertible_to<U, E> &&
|
||||
(!std::is_reference_v<U>)constexpr Expected(Unexpected<U> e)
|
||||
: Base(E(std::move(e.value())))
|
||||
: Base(boost::outcome_v2::failure(E(std::move(e.value()))))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -17,11 +17,22 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
#include <ripple/app/hook/Enum.h>
|
||||
#include <ripple/app/hook/HookAPI.h>
|
||||
#include <ripple/app/hook/Misc.h>
|
||||
#include <ripple/app/hook/applyHook.h>
|
||||
#include <ripple/app/ledger/LedgerMaster.h>
|
||||
#include <ripple/app/misc/Transaction.h>
|
||||
#include <ripple/app/tx/impl/ApplyContext.h>
|
||||
#include <ripple/app/tx/impl/SetHook.h>
|
||||
#include <ripple/basics/base_uint.h>
|
||||
#include <ripple/json/json_reader.h>
|
||||
#include <ripple/json/json_writer.h>
|
||||
#include <ripple/ledger/OpenView.h>
|
||||
#include <ripple/protocol/SField.h>
|
||||
#include <ripple/protocol/STAccount.h>
|
||||
#include <ripple/protocol/STArray.h>
|
||||
#include <ripple/protocol/TxFlags.h>
|
||||
#include <ripple/protocol/TxFormats.h>
|
||||
#include <ripple/protocol/jss.h>
|
||||
#include <test/app/Import_json.h>
|
||||
#include <test/app/SetHook_wasm.h>
|
||||
@@ -2570,15 +2581,212 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
ApplyContext
|
||||
createApplyContext(jtx::Env& env, OpenView ov, STTx const& tx)
|
||||
{
|
||||
ApplyContext applyCtx{
|
||||
env.app(),
|
||||
ov,
|
||||
tx,
|
||||
tesSUCCESS,
|
||||
env.current()->fees().base,
|
||||
tapNONE,
|
||||
env.journal};
|
||||
return applyCtx;
|
||||
}
|
||||
|
||||
// hook::HookContext
|
||||
// createHookContext(
|
||||
// AccountID const& hookAccount,
|
||||
// AccountID const& otxnAccount,
|
||||
// hook::HookContext ctx)
|
||||
// {
|
||||
// hook::HookContext hookCtx{
|
||||
// .applyCtx = ctx.applyCtx,
|
||||
// .result =
|
||||
// {
|
||||
// .hookSetTxnID = uint256(),
|
||||
// .hookHash = uint256(),
|
||||
// .hookCanEmit = uint256(),
|
||||
// .accountKeylet = keylet::account(otxnAccount),
|
||||
// .hookKeylet = keylet::hook(hookAccount),
|
||||
// .account = otxnAccount,
|
||||
// .otxnAccount = otxnAccount,
|
||||
// .hookNamespace = uint256(),
|
||||
// .stateMap = ctx.result.stateMap,
|
||||
// .hookParamOverrides = {},
|
||||
// .hookParams = {{}},
|
||||
// .hookSkips = {uint256{}},
|
||||
// },
|
||||
// .module = nullptr};
|
||||
|
||||
// return hookCtx;
|
||||
// }
|
||||
|
||||
void
|
||||
test_emit(FeatureBitset features)
|
||||
{
|
||||
testcase("Test emit");
|
||||
using namespace jtx;
|
||||
Env env{*this, features};
|
||||
|
||||
auto const alice = Account{"alice"};
|
||||
auto const bob = Account{"bob"};
|
||||
|
||||
{
|
||||
using namespace hook_api;
|
||||
Env env{*this, features};
|
||||
|
||||
STTx invokeTx = STTx(ttINVOKE, [&](STObject& obj) {});
|
||||
OpenView ov{*env.current()};
|
||||
ApplyContext applyCtx = createApplyContext(env, ov, invokeTx);
|
||||
|
||||
STTx const emitInvokeTx = STTx(ttINVOKE, [&](STObject& obj) {
|
||||
obj[sfAccount] = alice.id();
|
||||
obj[sfSequence] = 0;
|
||||
obj[sfSigningPubKey] = PublicKey();
|
||||
obj[sfFirstLedgerSequence] = env.closed()->seq() + 1;
|
||||
obj[sfLastLedgerSequence] = env.closed()->seq() + 5;
|
||||
obj[sfFee] = env.closed()->fees().base;
|
||||
|
||||
auto& emitDetails = obj.peekFieldObject(sfEmitDetails);
|
||||
emitDetails[sfEmitGeneration] = 1;
|
||||
emitDetails[sfEmitBurden] = 1;
|
||||
emitDetails[sfEmitParentTxnID] = invokeTx.getTransactionID();
|
||||
emitDetails[sfEmitNonce] = uint256();
|
||||
emitDetails[sfEmitHookHash] = uint256();
|
||||
});
|
||||
|
||||
STTx const emitSetHookTx = STTx(ttHOOK_SET, [&](STObject& obj) {
|
||||
obj[sfAccount] = alice.id();
|
||||
obj[sfSequence] = 0;
|
||||
obj[sfSigningPubKey] = PublicKey();
|
||||
obj[sfFirstLedgerSequence] = env.closed()->seq() + 1;
|
||||
obj[sfLastLedgerSequence] = env.closed()->seq() + 5;
|
||||
obj[sfFee] = env.closed()->fees().base;
|
||||
STObject hookobj(sfHook);
|
||||
auto& hooks = obj.peekFieldArray(sfHooks);
|
||||
hooks.emplace_back(std::move(hookobj));
|
||||
|
||||
auto& emitDetails = obj.peekFieldObject(sfEmitDetails);
|
||||
emitDetails[sfEmitGeneration] = 1;
|
||||
emitDetails[sfEmitBurden] = 1;
|
||||
emitDetails[sfEmitParentTxnID] = invokeTx.getTransactionID();
|
||||
emitDetails[sfEmitNonce] = uint256();
|
||||
emitDetails[sfEmitHookHash] = uint256();
|
||||
});
|
||||
|
||||
{
|
||||
// PREREQUISITE_NOT_MET
|
||||
auto hookCtx = makeStubHookContext(
|
||||
applyCtx,
|
||||
alice.id(),
|
||||
alice.id(),
|
||||
{.expected_etxn_count = -1});
|
||||
hook::HookAPI api(hookCtx);
|
||||
|
||||
Serializer s;
|
||||
emitInvokeTx.add(s);
|
||||
BEAST_EXPECT(
|
||||
api.emit(s.slice()).error() == PREREQUISITE_NOT_MET);
|
||||
}
|
||||
{
|
||||
// TOO_MANY_EMITTED_TXN
|
||||
std::string reason;
|
||||
auto tx = std::make_shared<ripple::Transaction>(
|
||||
std::make_shared<ripple::STTx const>(invokeTx),
|
||||
reason,
|
||||
env.app());
|
||||
std::queue<std::shared_ptr<ripple::Transaction>> emittedTxn;
|
||||
emittedTxn.push(tx);
|
||||
auto hookCtx = makeStubHookContext(
|
||||
applyCtx,
|
||||
alice.id(),
|
||||
alice.id(),
|
||||
{
|
||||
.expected_etxn_count = 1,
|
||||
.result = {.emittedTxn = emittedTxn},
|
||||
});
|
||||
hook::HookAPI api(hookCtx);
|
||||
|
||||
Serializer s;
|
||||
emitInvokeTx.add(s);
|
||||
BEAST_EXPECT(
|
||||
api.emit(s.slice()).error() == TOO_MANY_EMITTED_TXN);
|
||||
}
|
||||
// EMISSION_FAILURE
|
||||
{
|
||||
// Pseudo txn
|
||||
auto hookCtx = makeStubHookContext(
|
||||
applyCtx,
|
||||
alice.id(),
|
||||
alice.id(),
|
||||
{
|
||||
.expected_etxn_count = 1,
|
||||
.nonce_used = {{uint256(0), true}},
|
||||
});
|
||||
hook::HookAPI api(hookCtx);
|
||||
auto tx = emitInvokeTx;
|
||||
tx.setFieldU16(sfTransactionType, ttFEE);
|
||||
Serializer s;
|
||||
tx.add(s);
|
||||
BEAST_EXPECT(api.emit(s.slice()).error() == EMISSION_FAILURE);
|
||||
}
|
||||
{
|
||||
// HookCanEmit (non-SetHook)
|
||||
auto hookCtx = makeStubHookContext(
|
||||
applyCtx,
|
||||
alice.id(),
|
||||
alice.id(),
|
||||
{.expected_etxn_count = 1,
|
||||
.nonce_used = {{uint256(0), true}},
|
||||
.result = {
|
||||
.hookCanEmit = UINT256_BIT[ttINVOKE],
|
||||
}});
|
||||
hook::HookAPI api(hookCtx);
|
||||
auto tx = emitInvokeTx;
|
||||
Serializer s;
|
||||
tx.add(s);
|
||||
BEAST_EXPECT(api.emit(s.slice()).error() == EMISSION_FAILURE);
|
||||
}
|
||||
{
|
||||
// HookCanEmit (SetHook) Error
|
||||
auto hookCtx = makeStubHookContext(
|
||||
applyCtx,
|
||||
alice.id(),
|
||||
alice.id(),
|
||||
{
|
||||
.expected_etxn_count = 1,
|
||||
.nonce_used = {{uint256(0), true}},
|
||||
.result = {.hookCanEmit = uint256()},
|
||||
});
|
||||
hook::HookAPI api(hookCtx);
|
||||
auto tx = emitSetHookTx;
|
||||
Serializer s;
|
||||
tx.add(s);
|
||||
BEAST_EXPECT(api.emit(s.slice()).error() == EMISSION_FAILURE);
|
||||
}
|
||||
{
|
||||
// HookCanEmit (SetHook) Success
|
||||
auto hookCtx = makeStubHookContext(
|
||||
applyCtx,
|
||||
alice.id(),
|
||||
alice.id(),
|
||||
{
|
||||
.expected_etxn_count = 1,
|
||||
.nonce_used = {{uint256(0), true}},
|
||||
.result = {.hookCanEmit = UINT256_BIT[ttHOOK_SET]},
|
||||
});
|
||||
hook::HookAPI api(hookCtx);
|
||||
auto tx = emitSetHookTx;
|
||||
Serializer s;
|
||||
tx.add(s);
|
||||
auto const result = api.emit(s.slice());
|
||||
BEAST_EXPECT(result.has_value());
|
||||
}
|
||||
}
|
||||
return;
|
||||
Env env{*this, features};
|
||||
|
||||
env.fund(XRP(10000), alice);
|
||||
env.fund(XRP(10000), bob);
|
||||
|
||||
@@ -3094,6 +3302,7 @@ public:
|
||||
extern int64_t rollback (uint32_t read_ptr, uint32_t read_len, int64_t error_code);
|
||||
extern int64_t etxn_details (uint32_t, uint32_t);
|
||||
extern int64_t etxn_reserve(uint32_t);
|
||||
extern int64_t hook_hash (uint32_t, uint32_t, int32_t);
|
||||
#define TOO_SMALL -4
|
||||
#define OUT_OF_BOUNDS -1
|
||||
#define PREREQUISITE_NOT_MET -9
|
||||
@@ -3116,6 +3325,45 @@ public:
|
||||
etxn_reserve(1);
|
||||
ASSERT(etxn_details((uint32_t)det, 116) == 116);
|
||||
|
||||
uint8_t expected1[49] = {
|
||||
0xEDU, 0x20U, 0x2EU, 0x00U, 0x00U, 0x00U, 0x01U, 0x3DU, 0x00U, 0x00U,
|
||||
0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x01U, 0x5BU, 0xB8U, 0x05U, 0xD6U,
|
||||
0xC3U, 0x52U, 0xDFU, 0x7AU, 0x27U, 0x76U, 0x6DU, 0xC0U, 0x20U, 0x47U,
|
||||
0xB7U, 0x64U, 0x22U, 0x5AU, 0xB7U, 0x5DU, 0xF3U, 0xFAU, 0x0DU, 0xE3U,
|
||||
0xBDU, 0xC6U, 0x40U, 0xBAU, 0xD0U, 0x0AU, 0x66U, 0xEBU, 0x68U,
|
||||
};
|
||||
// 0x5CU
|
||||
// EmitNonce 32bytes
|
||||
uint8_t expected_emit_nonce[32] = {
|
||||
0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU,
|
||||
0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU,
|
||||
0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU,
|
||||
0xFFU, 0xFFU
|
||||
};
|
||||
// 0x5DU,
|
||||
// EmitHookHash
|
||||
uint8_t expected_hook_hash[32] = {
|
||||
0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU,
|
||||
0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU,
|
||||
0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU,
|
||||
0xFFU, 0xFFU,
|
||||
};
|
||||
// 0xE1U
|
||||
|
||||
// current hook hash
|
||||
ASSERT(hook_hash((uint32_t)expected_hook_hash, 32, -1) == 32);
|
||||
|
||||
for (int i = 0; GUARD(49), i < sizeof(expected1); ++i)
|
||||
ASSERT(det[i] == expected1[i]);
|
||||
ASSERT(det[49] == 0x5CU);
|
||||
// TODO: need to test this
|
||||
// for (int i = 0; GUARD(32), i < sizeof(expected_emit_nonce); ++i)
|
||||
// ASSERT(det[50 + i] == expected_emit_nonce[i]);
|
||||
ASSERT(det[82] == 0x5DU);
|
||||
for (int i = 0; GUARD(32), i < sizeof(expected_hook_hash); ++i)
|
||||
ASSERT(det[83 + i] == expected_hook_hash[i]);
|
||||
ASSERT(det[115] == 0xE1);
|
||||
|
||||
return accept(0,0,0);
|
||||
}
|
||||
)[test.hook]"];
|
||||
@@ -3236,6 +3484,7 @@ public:
|
||||
}
|
||||
|
||||
ASSERT(etxn_nonce((uint32_t)nonce, 116) == TOO_MANY_NONCES);
|
||||
ASSERT(etxn_nonce((uint32_t)nonce, 31) == TOO_MANY_NONCES);
|
||||
|
||||
return accept(0,0,0);
|
||||
}
|
||||
@@ -13435,7 +13684,7 @@ private:
|
||||
)[test.hook]"];
|
||||
|
||||
HASH_WASM(accept2);
|
||||
};
|
||||
}; // namespace test
|
||||
|
||||
#define SETHOOK_TEST(i, last) \
|
||||
class SetHook##i##_test : public SetHook0_test \
|
||||
|
||||
@@ -1168,6 +1168,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
extern int64_t rollback (uint32_t read_ptr, uint32_t read_len, int64_t error_code);
|
||||
extern int64_t etxn_details (uint32_t, uint32_t);
|
||||
extern int64_t etxn_reserve(uint32_t);
|
||||
extern int64_t hook_hash (uint32_t, uint32_t, int32_t);
|
||||
#define TOO_SMALL -4
|
||||
#define OUT_OF_BOUNDS -1
|
||||
#define PREREQUISITE_NOT_MET -9
|
||||
@@ -1190,78 +1191,178 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
etxn_reserve(1);
|
||||
ASSERT(etxn_details((uint32_t)det, 116) == 116);
|
||||
|
||||
uint8_t expected1[49] = {
|
||||
0xEDU, 0x20U, 0x2EU, 0x00U, 0x00U, 0x00U, 0x01U, 0x3DU, 0x00U, 0x00U,
|
||||
0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x01U, 0x5BU, 0xB8U, 0x05U, 0xD6U,
|
||||
0xC3U, 0x52U, 0xDFU, 0x7AU, 0x27U, 0x76U, 0x6DU, 0xC0U, 0x20U, 0x47U,
|
||||
0xB7U, 0x64U, 0x22U, 0x5AU, 0xB7U, 0x5DU, 0xF3U, 0xFAU, 0x0DU, 0xE3U,
|
||||
0xBDU, 0xC6U, 0x40U, 0xBAU, 0xD0U, 0x0AU, 0x66U, 0xEBU, 0x68U,
|
||||
};
|
||||
// 0x5CU
|
||||
// EmitNonce 32bytes
|
||||
uint8_t expected_emit_nonce[32] = {
|
||||
0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU,
|
||||
0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU,
|
||||
0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU,
|
||||
0xFFU, 0xFFU
|
||||
};
|
||||
// 0x5DU,
|
||||
// EmitHookHash
|
||||
uint8_t expected_hook_hash[32] = {
|
||||
0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU,
|
||||
0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU,
|
||||
0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU,
|
||||
0xFFU, 0xFFU,
|
||||
};
|
||||
// 0xE1U
|
||||
|
||||
// current hook hash
|
||||
ASSERT(hook_hash((uint32_t)expected_hook_hash, 32, -1) == 32);
|
||||
|
||||
for (int i = 0; GUARD(49), i < sizeof(expected1); ++i)
|
||||
ASSERT(det[i] == expected1[i]);
|
||||
ASSERT(det[49] == 0x5CU);
|
||||
// TODO: need to test this
|
||||
// for (int i = 0; GUARD(32), i < sizeof(expected_emit_nonce); ++i)
|
||||
// ASSERT(det[50 + i] == expected_emit_nonce[i]);
|
||||
ASSERT(det[82] == 0x5DU);
|
||||
for (int i = 0; GUARD(32), i < sizeof(expected_hook_hash); ++i)
|
||||
ASSERT(det[83 + i] == expected_hook_hash[i]);
|
||||
ASSERT(det[115] == 0xE1);
|
||||
|
||||
return accept(0,0,0);
|
||||
}
|
||||
)[test.hook]",
|
||||
{
|
||||
0x00U, 0x61U, 0x73U, 0x6DU, 0x01U, 0x00U, 0x00U, 0x00U, 0x01U, 0x19U,
|
||||
0x04U, 0x60U, 0x02U, 0x7FU, 0x7FU, 0x01U, 0x7FU, 0x60U, 0x02U, 0x7FU,
|
||||
0x00U, 0x61U, 0x73U, 0x6DU, 0x01U, 0x00U, 0x00U, 0x00U, 0x01U, 0x20U,
|
||||
0x05U, 0x60U, 0x02U, 0x7FU, 0x7FU, 0x01U, 0x7FU, 0x60U, 0x02U, 0x7FU,
|
||||
0x7FU, 0x01U, 0x7EU, 0x60U, 0x03U, 0x7FU, 0x7FU, 0x7EU, 0x01U, 0x7EU,
|
||||
0x60U, 0x01U, 0x7FU, 0x01U, 0x7EU, 0x02U, 0x4CU, 0x05U, 0x03U, 0x65U,
|
||||
0x6EU, 0x76U, 0x02U, 0x5FU, 0x67U, 0x00U, 0x00U, 0x03U, 0x65U, 0x6EU,
|
||||
0x76U, 0x0CU, 0x65U, 0x74U, 0x78U, 0x6EU, 0x5FU, 0x64U, 0x65U, 0x74U,
|
||||
0x61U, 0x69U, 0x6CU, 0x73U, 0x00U, 0x01U, 0x03U, 0x65U, 0x6EU, 0x76U,
|
||||
0x08U, 0x72U, 0x6FU, 0x6CU, 0x6CU, 0x62U, 0x61U, 0x63U, 0x6BU, 0x00U,
|
||||
0x02U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x0CU, 0x65U, 0x74U, 0x78U, 0x6EU,
|
||||
0x5FU, 0x72U, 0x65U, 0x73U, 0x65U, 0x72U, 0x76U, 0x65U, 0x00U, 0x03U,
|
||||
0x03U, 0x65U, 0x6EU, 0x76U, 0x06U, 0x61U, 0x63U, 0x63U, 0x65U, 0x70U,
|
||||
0x74U, 0x00U, 0x02U, 0x03U, 0x02U, 0x01U, 0x03U, 0x05U, 0x03U, 0x01U,
|
||||
0x00U, 0x02U, 0x06U, 0x21U, 0x05U, 0x7FU, 0x01U, 0x41U, 0xF0U, 0x89U,
|
||||
0x04U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0xE5U, 0x09U, 0x0BU, 0x7FU, 0x00U,
|
||||
0x41U, 0x80U, 0x08U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0xF0U, 0x89U, 0x04U,
|
||||
0x0BU, 0x7FU, 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU, 0x07U, 0x08U, 0x01U,
|
||||
0x04U, 0x68U, 0x6FU, 0x6FU, 0x6BU, 0x00U, 0x05U, 0x0AU, 0x84U, 0x82U,
|
||||
0x00U, 0x01U, 0x80U, 0x82U, 0x00U, 0x02U, 0x01U, 0x7FU, 0x01U, 0x7EU,
|
||||
0x23U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x41U, 0x80U, 0x01U, 0x6BU,
|
||||
0x22U, 0x01U, 0x24U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x41U, 0x01U,
|
||||
0x41U, 0x01U, 0x10U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x02U,
|
||||
0x40U, 0x41U, 0xC0U, 0x84U, 0x3DU, 0x41U, 0xF4U, 0x00U, 0x10U, 0x81U,
|
||||
0x60U, 0x01U, 0x7FU, 0x01U, 0x7EU, 0x60U, 0x03U, 0x7FU, 0x7FU, 0x7FU,
|
||||
0x01U, 0x7EU, 0x02U, 0x5CU, 0x06U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x02U,
|
||||
0x5FU, 0x67U, 0x00U, 0x00U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x0CU, 0x65U,
|
||||
0x74U, 0x78U, 0x6EU, 0x5FU, 0x64U, 0x65U, 0x74U, 0x61U, 0x69U, 0x6CU,
|
||||
0x73U, 0x00U, 0x01U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x08U, 0x72U, 0x6FU,
|
||||
0x6CU, 0x6CU, 0x62U, 0x61U, 0x63U, 0x6BU, 0x00U, 0x02U, 0x03U, 0x65U,
|
||||
0x6EU, 0x76U, 0x0CU, 0x65U, 0x74U, 0x78U, 0x6EU, 0x5FU, 0x72U, 0x65U,
|
||||
0x73U, 0x65U, 0x72U, 0x76U, 0x65U, 0x00U, 0x03U, 0x03U, 0x65U, 0x6EU,
|
||||
0x76U, 0x09U, 0x68U, 0x6FU, 0x6FU, 0x6BU, 0x5FU, 0x68U, 0x61U, 0x73U,
|
||||
0x68U, 0x00U, 0x04U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x06U, 0x61U, 0x63U,
|
||||
0x63U, 0x65U, 0x70U, 0x74U, 0x00U, 0x02U, 0x03U, 0x02U, 0x01U, 0x03U,
|
||||
0x05U, 0x03U, 0x01U, 0x00U, 0x02U, 0x06U, 0x21U, 0x05U, 0x7FU, 0x01U,
|
||||
0x41U, 0xD0U, 0x8BU, 0x04U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0xC6U, 0x0BU,
|
||||
0x0BU, 0x7FU, 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU, 0x7FU, 0x00U, 0x41U,
|
||||
0xD0U, 0x8BU, 0x04U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU,
|
||||
0x07U, 0x08U, 0x01U, 0x04U, 0x68U, 0x6FU, 0x6FU, 0x6BU, 0x00U, 0x06U,
|
||||
0x0AU, 0xF4U, 0x84U, 0x00U, 0x01U, 0xF0U, 0x84U, 0x00U, 0x02U, 0x03U,
|
||||
0x7FU, 0x01U, 0x7EU, 0x23U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x41U,
|
||||
0xA0U, 0x01U, 0x6BU, 0x22U, 0x01U, 0x24U, 0x80U, 0x80U, 0x80U, 0x80U,
|
||||
0x00U, 0x41U, 0x01U, 0x41U, 0x01U, 0x10U, 0x80U, 0x80U, 0x80U, 0x80U,
|
||||
0x00U, 0x1AU, 0x02U, 0x40U, 0x41U, 0xC0U, 0x84U, 0x3DU, 0x41U, 0xF4U,
|
||||
0x00U, 0x10U, 0x81U, 0x80U, 0x80U, 0x80U, 0x00U, 0x42U, 0x7FU, 0x51U,
|
||||
0x0DU, 0x00U, 0x41U, 0x80U, 0x88U, 0x80U, 0x80U, 0x00U, 0x41U, 0x2CU,
|
||||
0x42U, 0x16U, 0x10U, 0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU,
|
||||
0x02U, 0x40U, 0x41U, 0x00U, 0x41U, 0xC0U, 0x84U, 0x3DU, 0x10U, 0x81U,
|
||||
0x80U, 0x80U, 0x80U, 0x00U, 0x42U, 0x7FU, 0x51U, 0x0DU, 0x00U, 0x41U,
|
||||
0x80U, 0x88U, 0x80U, 0x80U, 0x00U, 0x41U, 0x2CU, 0x42U, 0x15U, 0x10U,
|
||||
0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x02U, 0x40U, 0x41U,
|
||||
0x00U, 0x41U, 0xC0U, 0x84U, 0x3DU, 0x10U, 0x81U, 0x80U, 0x80U, 0x80U,
|
||||
0x00U, 0x42U, 0x7FU, 0x51U, 0x0DU, 0x00U, 0x41U, 0xACU, 0x88U, 0x80U,
|
||||
0x80U, 0x00U, 0x41U, 0x2AU, 0x42U, 0x16U, 0x10U, 0x82U, 0x80U, 0x80U,
|
||||
0x80U, 0x00U, 0x1AU, 0x0BU, 0x02U, 0x40U, 0x20U, 0x01U, 0x41U, 0xF3U,
|
||||
0x00U, 0x10U, 0x81U, 0x80U, 0x80U, 0x80U, 0x00U, 0x42U, 0x7CU, 0x51U,
|
||||
0x0DU, 0x00U, 0x41U, 0xD6U, 0x88U, 0x80U, 0x80U, 0x00U, 0x41U, 0x2EU,
|
||||
0x42U, 0x18U, 0x10U, 0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU,
|
||||
0x02U, 0x40U, 0x20U, 0x01U, 0x41U, 0xF4U, 0x00U, 0x10U, 0x81U, 0x80U,
|
||||
0x80U, 0x80U, 0x00U, 0x42U, 0x77U, 0x51U, 0x0DU, 0x00U, 0x41U, 0x84U,
|
||||
0x89U, 0x80U, 0x80U, 0x00U, 0x41U, 0x39U, 0x42U, 0x1AU, 0x10U, 0x82U,
|
||||
0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x41U, 0x01U, 0x10U, 0x83U,
|
||||
0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x02U, 0x40U, 0x20U, 0x01U, 0x41U,
|
||||
0xF4U, 0x00U, 0x10U, 0x81U, 0x80U, 0x80U, 0x80U, 0x00U, 0x42U, 0xF4U,
|
||||
0x00U, 0x51U, 0x0DU, 0x00U, 0x41U, 0xBDU, 0x89U, 0x80U, 0x80U, 0x00U,
|
||||
0x41U, 0x28U, 0x42U, 0x1DU, 0x10U, 0x82U, 0x80U, 0x80U, 0x80U, 0x00U,
|
||||
0x1AU, 0x0BU, 0x41U, 0x00U, 0x41U, 0x00U, 0x42U, 0x00U, 0x10U, 0x84U,
|
||||
0x80U, 0x80U, 0x80U, 0x00U, 0x21U, 0x02U, 0x20U, 0x01U, 0x41U, 0x80U,
|
||||
0x01U, 0x6AU, 0x24U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x20U, 0x02U,
|
||||
0x0BU, 0x0BU, 0xEDU, 0x01U, 0x01U, 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU,
|
||||
0xE5U, 0x01U, 0x65U, 0x74U, 0x78U, 0x6EU, 0x5FU, 0x64U, 0x65U, 0x74U,
|
||||
0x61U, 0x69U, 0x6CU, 0x73U, 0x28U, 0x31U, 0x30U, 0x30U, 0x30U, 0x30U,
|
||||
0x30U, 0x30U, 0x2CU, 0x20U, 0x31U, 0x31U, 0x36U, 0x29U, 0x20U, 0x3DU,
|
||||
0x3DU, 0x20U, 0x4FU, 0x55U, 0x54U, 0x5FU, 0x4FU, 0x46U, 0x5FU, 0x42U,
|
||||
0x4FU, 0x55U, 0x4EU, 0x44U, 0x53U, 0x00U, 0x65U, 0x74U, 0x78U, 0x6EU,
|
||||
0x5FU, 0x64U, 0x65U, 0x74U, 0x61U, 0x69U, 0x6CU, 0x73U, 0x28U, 0x30U,
|
||||
0x2CU, 0x20U, 0x31U, 0x30U, 0x30U, 0x30U, 0x30U, 0x30U, 0x30U, 0x29U,
|
||||
0x20U, 0x3DU, 0x3DU, 0x20U, 0x4FU, 0x55U, 0x54U, 0x5FU, 0x4FU, 0x46U,
|
||||
0x5FU, 0x42U, 0x4FU, 0x55U, 0x4EU, 0x44U, 0x53U, 0x00U, 0x65U, 0x74U,
|
||||
0x78U, 0x6EU, 0x5FU, 0x64U, 0x65U, 0x74U, 0x61U, 0x69U, 0x6CU, 0x73U,
|
||||
0x28U, 0x28U, 0x75U, 0x69U, 0x6EU, 0x74U, 0x33U, 0x32U, 0x5FU, 0x74U,
|
||||
0x29U, 0x64U, 0x65U, 0x74U, 0x2CU, 0x20U, 0x31U, 0x31U, 0x35U, 0x29U,
|
||||
0x20U, 0x3DU, 0x3DU, 0x20U, 0x54U, 0x4FU, 0x4FU, 0x5FU, 0x53U, 0x4DU,
|
||||
0x41U, 0x4CU, 0x4CU, 0x00U, 0x65U, 0x74U, 0x78U, 0x6EU, 0x5FU, 0x64U,
|
||||
0x65U, 0x74U, 0x61U, 0x69U, 0x6CU, 0x73U, 0x28U, 0x28U, 0x75U, 0x69U,
|
||||
0x6EU, 0x74U, 0x33U, 0x32U, 0x5FU, 0x74U, 0x29U, 0x64U, 0x65U, 0x74U,
|
||||
0x2CU, 0x20U, 0x31U, 0x31U, 0x36U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U,
|
||||
0x50U, 0x52U, 0x45U, 0x52U, 0x45U, 0x51U, 0x55U, 0x49U, 0x53U, 0x49U,
|
||||
0x54U, 0x45U, 0x5FU, 0x4EU, 0x4FU, 0x54U, 0x5FU, 0x4DU, 0x45U, 0x54U,
|
||||
0x00U, 0x65U, 0x74U, 0x78U, 0x6EU, 0x5FU, 0x64U, 0x65U, 0x74U, 0x61U,
|
||||
0x69U, 0x6CU, 0x73U, 0x28U, 0x28U, 0x75U, 0x69U, 0x6EU, 0x74U, 0x33U,
|
||||
0x32U, 0x5FU, 0x74U, 0x29U, 0x64U, 0x65U, 0x74U, 0x2CU, 0x20U, 0x31U,
|
||||
0x31U, 0x36U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x31U, 0x31U, 0x36U,
|
||||
0x00U,
|
||||
0xACU, 0x88U, 0x80U, 0x80U, 0x00U, 0x41U, 0x2AU, 0x42U, 0x17U, 0x10U,
|
||||
0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x02U, 0x40U, 0x20U,
|
||||
0x01U, 0x41U, 0x20U, 0x6AU, 0x41U, 0xF3U, 0x00U, 0x10U, 0x81U, 0x80U,
|
||||
0x80U, 0x80U, 0x00U, 0x42U, 0x7CU, 0x51U, 0x0DU, 0x00U, 0x41U, 0xD6U,
|
||||
0x88U, 0x80U, 0x80U, 0x00U, 0x41U, 0x2EU, 0x42U, 0x19U, 0x10U, 0x82U,
|
||||
0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x02U, 0x40U, 0x20U, 0x01U,
|
||||
0x41U, 0x20U, 0x6AU, 0x41U, 0xF4U, 0x00U, 0x10U, 0x81U, 0x80U, 0x80U,
|
||||
0x80U, 0x00U, 0x42U, 0x77U, 0x51U, 0x0DU, 0x00U, 0x41U, 0x84U, 0x89U,
|
||||
0x80U, 0x80U, 0x00U, 0x41U, 0x39U, 0x42U, 0x1BU, 0x10U, 0x82U, 0x80U,
|
||||
0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x41U, 0x01U, 0x10U, 0x83U, 0x80U,
|
||||
0x80U, 0x80U, 0x00U, 0x1AU, 0x02U, 0x40U, 0x20U, 0x01U, 0x41U, 0x20U,
|
||||
0x6AU, 0x41U, 0xF4U, 0x00U, 0x10U, 0x81U, 0x80U, 0x80U, 0x80U, 0x00U,
|
||||
0x42U, 0xF4U, 0x00U, 0x51U, 0x0DU, 0x00U, 0x41U, 0xBDU, 0x89U, 0x80U,
|
||||
0x80U, 0x00U, 0x41U, 0x28U, 0x42U, 0x1EU, 0x10U, 0x82U, 0x80U, 0x80U,
|
||||
0x80U, 0x00U, 0x1AU, 0x0BU, 0x20U, 0x01U, 0x41U, 0x18U, 0x6AU, 0x42U,
|
||||
0x7FU, 0x37U, 0x03U, 0x00U, 0x20U, 0x01U, 0x41U, 0x10U, 0x6AU, 0x42U,
|
||||
0x7FU, 0x37U, 0x03U, 0x00U, 0x20U, 0x01U, 0x42U, 0x7FU, 0x37U, 0x03U,
|
||||
0x08U, 0x20U, 0x01U, 0x42U, 0x7FU, 0x37U, 0x03U, 0x00U, 0x02U, 0x40U,
|
||||
0x20U, 0x01U, 0x41U, 0x20U, 0x41U, 0x7FU, 0x10U, 0x84U, 0x80U, 0x80U,
|
||||
0x80U, 0x00U, 0x42U, 0x20U, 0x51U, 0x0DU, 0x00U, 0x41U, 0xA1U, 0x8AU,
|
||||
0x80U, 0x80U, 0x00U, 0x41U, 0x36U, 0x42U, 0x3AU, 0x10U, 0x82U, 0x80U,
|
||||
0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x41U, 0xBCU, 0x80U, 0x80U, 0x80U,
|
||||
0x78U, 0x41U, 0x32U, 0x10U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU,
|
||||
0x41U, 0x00U, 0x21U, 0x02U, 0x03U, 0x40U, 0x41U, 0xBCU, 0x80U, 0x80U,
|
||||
0x80U, 0x78U, 0x41U, 0x32U, 0x10U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U,
|
||||
0x1AU, 0x02U, 0x40U, 0x20U, 0x01U, 0x41U, 0x20U, 0x6AU, 0x20U, 0x02U,
|
||||
0x6AU, 0x2DU, 0x00U, 0x00U, 0x20U, 0x02U, 0x41U, 0xF0U, 0x89U, 0x80U,
|
||||
0x80U, 0x00U, 0x6AU, 0x2DU, 0x00U, 0x00U, 0x46U, 0x0DU, 0x00U, 0x41U,
|
||||
0xD7U, 0x8AU, 0x80U, 0x80U, 0x00U, 0x41U, 0x17U, 0x42U, 0x3DU, 0x10U,
|
||||
0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x20U, 0x02U, 0x41U,
|
||||
0x01U, 0x6AU, 0x22U, 0x02U, 0x41U, 0x31U, 0x47U, 0x0DU, 0x00U, 0x0BU,
|
||||
0x02U, 0x40U, 0x20U, 0x01U, 0x2DU, 0x00U, 0x51U, 0x41U, 0xDCU, 0x00U,
|
||||
0x46U, 0x0DU, 0x00U, 0x41U, 0xEEU, 0x8AU, 0x80U, 0x80U, 0x00U, 0x41U,
|
||||
0x11U, 0x42U, 0x3EU, 0x10U, 0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU,
|
||||
0x0BU, 0x02U, 0x40U, 0x20U, 0x01U, 0x2DU, 0x00U, 0x72U, 0x41U, 0xDDU,
|
||||
0x00U, 0x46U, 0x0DU, 0x00U, 0x41U, 0xFFU, 0x8AU, 0x80U, 0x80U, 0x00U,
|
||||
0x41U, 0x11U, 0x42U, 0xC2U, 0x00U, 0x10U, 0x82U, 0x80U, 0x80U, 0x80U,
|
||||
0x00U, 0x1AU, 0x0BU, 0x41U, 0xC3U, 0x80U, 0x80U, 0x80U, 0x78U, 0x41U,
|
||||
0x21U, 0x10U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x20U, 0x01U,
|
||||
0x41U, 0xF3U, 0x00U, 0x6AU, 0x21U, 0x03U, 0x41U, 0x00U, 0x21U, 0x02U,
|
||||
0x03U, 0x40U, 0x41U, 0xC3U, 0x80U, 0x80U, 0x80U, 0x78U, 0x41U, 0x21U,
|
||||
0x10U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x02U, 0x40U, 0x20U,
|
||||
0x03U, 0x20U, 0x02U, 0x6AU, 0x2DU, 0x00U, 0x00U, 0x20U, 0x01U, 0x20U,
|
||||
0x02U, 0x6AU, 0x2DU, 0x00U, 0x00U, 0x46U, 0x0DU, 0x00U, 0x41U, 0x90U,
|
||||
0x8BU, 0x80U, 0x80U, 0x00U, 0x41U, 0x25U, 0x42U, 0xC4U, 0x00U, 0x10U,
|
||||
0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x20U, 0x02U, 0x41U,
|
||||
0x01U, 0x6AU, 0x22U, 0x02U, 0x41U, 0x20U, 0x47U, 0x0DU, 0x00U, 0x0BU,
|
||||
0x02U, 0x40U, 0x20U, 0x01U, 0x2DU, 0x00U, 0x93U, 0x01U, 0x41U, 0xE1U,
|
||||
0x01U, 0x46U, 0x0DU, 0x00U, 0x41U, 0xB5U, 0x8BU, 0x80U, 0x80U, 0x00U,
|
||||
0x41U, 0x11U, 0x42U, 0xC5U, 0x00U, 0x10U, 0x82U, 0x80U, 0x80U, 0x80U,
|
||||
0x00U, 0x1AU, 0x0BU, 0x41U, 0x00U, 0x41U, 0x00U, 0x42U, 0x00U, 0x10U,
|
||||
0x85U, 0x80U, 0x80U, 0x80U, 0x00U, 0x21U, 0x04U, 0x20U, 0x01U, 0x41U,
|
||||
0xA0U, 0x01U, 0x6AU, 0x24U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x20U,
|
||||
0x04U, 0x0BU, 0x0BU, 0xCEU, 0x03U, 0x01U, 0x00U, 0x41U, 0x80U, 0x08U,
|
||||
0x0BU, 0xC6U, 0x03U, 0x65U, 0x74U, 0x78U, 0x6EU, 0x5FU, 0x64U, 0x65U,
|
||||
0x74U, 0x61U, 0x69U, 0x6CU, 0x73U, 0x28U, 0x31U, 0x30U, 0x30U, 0x30U,
|
||||
0x30U, 0x30U, 0x30U, 0x2CU, 0x20U, 0x31U, 0x31U, 0x36U, 0x29U, 0x20U,
|
||||
0x3DU, 0x3DU, 0x20U, 0x4FU, 0x55U, 0x54U, 0x5FU, 0x4FU, 0x46U, 0x5FU,
|
||||
0x42U, 0x4FU, 0x55U, 0x4EU, 0x44U, 0x53U, 0x00U, 0x65U, 0x74U, 0x78U,
|
||||
0x6EU, 0x5FU, 0x64U, 0x65U, 0x74U, 0x61U, 0x69U, 0x6CU, 0x73U, 0x28U,
|
||||
0x30U, 0x2CU, 0x20U, 0x31U, 0x30U, 0x30U, 0x30U, 0x30U, 0x30U, 0x30U,
|
||||
0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x4FU, 0x55U, 0x54U, 0x5FU, 0x4FU,
|
||||
0x46U, 0x5FU, 0x42U, 0x4FU, 0x55U, 0x4EU, 0x44U, 0x53U, 0x00U, 0x65U,
|
||||
0x74U, 0x78U, 0x6EU, 0x5FU, 0x64U, 0x65U, 0x74U, 0x61U, 0x69U, 0x6CU,
|
||||
0x73U, 0x28U, 0x28U, 0x75U, 0x69U, 0x6EU, 0x74U, 0x33U, 0x32U, 0x5FU,
|
||||
0x74U, 0x29U, 0x64U, 0x65U, 0x74U, 0x2CU, 0x20U, 0x31U, 0x31U, 0x35U,
|
||||
0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x54U, 0x4FU, 0x4FU, 0x5FU, 0x53U,
|
||||
0x4DU, 0x41U, 0x4CU, 0x4CU, 0x00U, 0x65U, 0x74U, 0x78U, 0x6EU, 0x5FU,
|
||||
0x64U, 0x65U, 0x74U, 0x61U, 0x69U, 0x6CU, 0x73U, 0x28U, 0x28U, 0x75U,
|
||||
0x69U, 0x6EU, 0x74U, 0x33U, 0x32U, 0x5FU, 0x74U, 0x29U, 0x64U, 0x65U,
|
||||
0x74U, 0x2CU, 0x20U, 0x31U, 0x31U, 0x36U, 0x29U, 0x20U, 0x3DU, 0x3DU,
|
||||
0x20U, 0x50U, 0x52U, 0x45U, 0x52U, 0x45U, 0x51U, 0x55U, 0x49U, 0x53U,
|
||||
0x49U, 0x54U, 0x45U, 0x5FU, 0x4EU, 0x4FU, 0x54U, 0x5FU, 0x4DU, 0x45U,
|
||||
0x54U, 0x00U, 0x65U, 0x74U, 0x78U, 0x6EU, 0x5FU, 0x64U, 0x65U, 0x74U,
|
||||
0x61U, 0x69U, 0x6CU, 0x73U, 0x28U, 0x28U, 0x75U, 0x69U, 0x6EU, 0x74U,
|
||||
0x33U, 0x32U, 0x5FU, 0x74U, 0x29U, 0x64U, 0x65U, 0x74U, 0x2CU, 0x20U,
|
||||
0x31U, 0x31U, 0x36U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x31U, 0x31U,
|
||||
0x36U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U,
|
||||
0x00U, 0x00U, 0x00U, 0xEDU, 0x20U, 0x2EU, 0x00U, 0x00U, 0x00U, 0x01U,
|
||||
0x3DU, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x01U, 0x5BU,
|
||||
0xB8U, 0x05U, 0xD6U, 0xC3U, 0x52U, 0xDFU, 0x7AU, 0x27U, 0x76U, 0x6DU,
|
||||
0xC0U, 0x20U, 0x47U, 0xB7U, 0x64U, 0x22U, 0x5AU, 0xB7U, 0x5DU, 0xF3U,
|
||||
0xFAU, 0x0DU, 0xE3U, 0xBDU, 0xC6U, 0x40U, 0xBAU, 0xD0U, 0x0AU, 0x66U,
|
||||
0xEBU, 0x68U, 0x68U, 0x6FU, 0x6FU, 0x6BU, 0x5FU, 0x68U, 0x61U, 0x73U,
|
||||
0x68U, 0x28U, 0x28U, 0x75U, 0x69U, 0x6EU, 0x74U, 0x33U, 0x32U, 0x5FU,
|
||||
0x74U, 0x29U, 0x65U, 0x78U, 0x70U, 0x65U, 0x63U, 0x74U, 0x65U, 0x64U,
|
||||
0x5FU, 0x68U, 0x6FU, 0x6FU, 0x6BU, 0x5FU, 0x68U, 0x61U, 0x73U, 0x68U,
|
||||
0x2CU, 0x20U, 0x33U, 0x32U, 0x2CU, 0x20U, 0x2DU, 0x31U, 0x29U, 0x20U,
|
||||
0x3DU, 0x3DU, 0x20U, 0x33U, 0x32U, 0x00U, 0x64U, 0x65U, 0x74U, 0x5BU,
|
||||
0x69U, 0x5DU, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x65U, 0x78U, 0x70U, 0x65U,
|
||||
0x63U, 0x74U, 0x65U, 0x64U, 0x31U, 0x5BU, 0x69U, 0x5DU, 0x00U, 0x64U,
|
||||
0x65U, 0x74U, 0x5BU, 0x34U, 0x39U, 0x5DU, 0x20U, 0x3DU, 0x3DU, 0x20U,
|
||||
0x30U, 0x78U, 0x35U, 0x43U, 0x55U, 0x00U, 0x64U, 0x65U, 0x74U, 0x5BU,
|
||||
0x38U, 0x32U, 0x5DU, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x30U, 0x78U, 0x35U,
|
||||
0x44U, 0x55U, 0x00U, 0x64U, 0x65U, 0x74U, 0x5BU, 0x38U, 0x33U, 0x20U,
|
||||
0x2BU, 0x20U, 0x69U, 0x5DU, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x65U, 0x78U,
|
||||
0x70U, 0x65U, 0x63U, 0x74U, 0x65U, 0x64U, 0x5FU, 0x68U, 0x6FU, 0x6FU,
|
||||
0x6BU, 0x5FU, 0x68U, 0x61U, 0x73U, 0x68U, 0x5BU, 0x69U, 0x5DU, 0x00U,
|
||||
0x64U, 0x65U, 0x74U, 0x5BU, 0x31U, 0x31U, 0x35U, 0x5DU, 0x20U, 0x3DU,
|
||||
0x3DU, 0x20U, 0x30U, 0x78U, 0x45U, 0x31U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 8 ==== */
|
||||
@@ -1397,6 +1498,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
}
|
||||
|
||||
ASSERT(etxn_nonce((uint32_t)nonce, 116) == TOO_MANY_NONCES);
|
||||
ASSERT(etxn_nonce((uint32_t)nonce, 31) == TOO_MANY_NONCES);
|
||||
|
||||
return accept(0,0,0);
|
||||
}
|
||||
@@ -1412,12 +1514,12 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x6FU, 0x6CU, 0x6CU, 0x62U, 0x61U, 0x63U, 0x6BU, 0x00U, 0x02U, 0x03U,
|
||||
0x65U, 0x6EU, 0x76U, 0x06U, 0x61U, 0x63U, 0x63U, 0x65U, 0x70U, 0x74U,
|
||||
0x00U, 0x02U, 0x03U, 0x02U, 0x01U, 0x03U, 0x05U, 0x03U, 0x01U, 0x00U,
|
||||
0x02U, 0x06U, 0x21U, 0x05U, 0x7FU, 0x01U, 0x41U, 0xA0U, 0x8AU, 0x04U,
|
||||
0x0BU, 0x7FU, 0x00U, 0x41U, 0x9EU, 0x0AU, 0x0BU, 0x7FU, 0x00U, 0x41U,
|
||||
0x80U, 0x08U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0xA0U, 0x8AU, 0x04U, 0x0BU,
|
||||
0x02U, 0x06U, 0x21U, 0x05U, 0x7FU, 0x01U, 0x41U, 0xE0U, 0x8AU, 0x04U,
|
||||
0x0BU, 0x7FU, 0x00U, 0x41U, 0xD1U, 0x0AU, 0x0BU, 0x7FU, 0x00U, 0x41U,
|
||||
0x80U, 0x08U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0xE0U, 0x8AU, 0x04U, 0x0BU,
|
||||
0x7FU, 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU, 0x07U, 0x08U, 0x01U, 0x04U,
|
||||
0x68U, 0x6FU, 0x6FU, 0x6BU, 0x00U, 0x04U, 0x0AU, 0xE1U, 0x82U, 0x00U,
|
||||
0x01U, 0xDDU, 0x82U, 0x00U, 0x02U, 0x02U, 0x7FU, 0x01U, 0x7EU, 0x23U,
|
||||
0x68U, 0x6FU, 0x6FU, 0x6BU, 0x00U, 0x04U, 0x0AU, 0x84U, 0x83U, 0x00U,
|
||||
0x01U, 0x80U, 0x83U, 0x00U, 0x02U, 0x02U, 0x7FU, 0x01U, 0x7EU, 0x23U,
|
||||
0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x41U, 0xC0U, 0x00U, 0x6BU, 0x22U,
|
||||
0x01U, 0x24U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x41U, 0x01U, 0x41U,
|
||||
0x01U, 0x10U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x02U, 0x40U,
|
||||
@@ -1449,39 +1551,48 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
|
||||
0x20U, 0x01U, 0x41U, 0xF4U, 0x00U, 0x10U, 0x81U, 0x80U, 0x80U, 0x80U,
|
||||
0x00U, 0x42U, 0x74U, 0x51U, 0x0DU, 0x00U, 0x41U, 0xEAU, 0x89U, 0x80U,
|
||||
0x80U, 0x00U, 0x41U, 0x34U, 0x42U, 0x23U, 0x10U, 0x82U, 0x80U, 0x80U,
|
||||
0x80U, 0x00U, 0x1AU, 0x0BU, 0x41U, 0x00U, 0x41U, 0x00U, 0x42U, 0x00U,
|
||||
0x10U, 0x83U, 0x80U, 0x80U, 0x80U, 0x00U, 0x21U, 0x03U, 0x20U, 0x01U,
|
||||
0x41U, 0xC0U, 0x00U, 0x6AU, 0x24U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U,
|
||||
0x20U, 0x03U, 0x0BU, 0x0BU, 0xA6U, 0x02U, 0x01U, 0x00U, 0x41U, 0x80U,
|
||||
0x08U, 0x0BU, 0x9EU, 0x02U, 0x65U, 0x74U, 0x78U, 0x6EU, 0x5FU, 0x6EU,
|
||||
0x6FU, 0x6EU, 0x63U, 0x65U, 0x28U, 0x31U, 0x30U, 0x30U, 0x30U, 0x30U,
|
||||
0x30U, 0x30U, 0x2CU, 0x20U, 0x31U, 0x31U, 0x36U, 0x29U, 0x20U, 0x3DU,
|
||||
0x3DU, 0x20U, 0x4FU, 0x55U, 0x54U, 0x5FU, 0x4FU, 0x46U, 0x5FU, 0x42U,
|
||||
0x4FU, 0x55U, 0x4EU, 0x44U, 0x53U, 0x00U, 0x65U, 0x74U, 0x78U, 0x6EU,
|
||||
0x5FU, 0x6EU, 0x6FU, 0x6EU, 0x63U, 0x65U, 0x28U, 0x30U, 0x2CU, 0x20U,
|
||||
0x31U, 0x30U, 0x30U, 0x30U, 0x30U, 0x30U, 0x30U, 0x29U, 0x20U, 0x3DU,
|
||||
0x3DU, 0x20U, 0x4FU, 0x55U, 0x54U, 0x5FU, 0x4FU, 0x46U, 0x5FU, 0x42U,
|
||||
0x4FU, 0x55U, 0x4EU, 0x44U, 0x53U, 0x00U, 0x65U, 0x74U, 0x78U, 0x6EU,
|
||||
0x5FU, 0x6EU, 0x6FU, 0x6EU, 0x63U, 0x65U, 0x28U, 0x28U, 0x75U, 0x69U,
|
||||
0x6EU, 0x74U, 0x33U, 0x32U, 0x5FU, 0x74U, 0x29U, 0x6EU, 0x6FU, 0x6EU,
|
||||
0x63U, 0x65U, 0x2CU, 0x20U, 0x33U, 0x31U, 0x29U, 0x20U, 0x3DU, 0x3DU,
|
||||
0x20U, 0x54U, 0x4FU, 0x4FU, 0x5FU, 0x53U, 0x4DU, 0x41U, 0x4CU, 0x4CU,
|
||||
0x80U, 0x00U, 0x1AU, 0x0BU, 0x02U, 0x40U, 0x20U, 0x01U, 0x41U, 0x1FU,
|
||||
0x10U, 0x81U, 0x80U, 0x80U, 0x80U, 0x00U, 0x42U, 0x74U, 0x51U, 0x0DU,
|
||||
0x00U, 0x41U, 0x9EU, 0x8AU, 0x80U, 0x80U, 0x00U, 0x41U, 0x33U, 0x42U,
|
||||
0x24U, 0x10U, 0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x41U,
|
||||
0x00U, 0x41U, 0x00U, 0x42U, 0x00U, 0x10U, 0x83U, 0x80U, 0x80U, 0x80U,
|
||||
0x00U, 0x21U, 0x03U, 0x20U, 0x01U, 0x41U, 0xC0U, 0x00U, 0x6AU, 0x24U,
|
||||
0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x20U, 0x03U, 0x0BU, 0x0BU, 0xD9U,
|
||||
0x02U, 0x01U, 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU, 0xD1U, 0x02U, 0x65U,
|
||||
0x74U, 0x78U, 0x6EU, 0x5FU, 0x6EU, 0x6FU, 0x6EU, 0x63U, 0x65U, 0x28U,
|
||||
0x31U, 0x30U, 0x30U, 0x30U, 0x30U, 0x30U, 0x30U, 0x2CU, 0x20U, 0x31U,
|
||||
0x31U, 0x36U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x4FU, 0x55U, 0x54U,
|
||||
0x5FU, 0x4FU, 0x46U, 0x5FU, 0x42U, 0x4FU, 0x55U, 0x4EU, 0x44U, 0x53U,
|
||||
0x00U, 0x65U, 0x74U, 0x78U, 0x6EU, 0x5FU, 0x6EU, 0x6FU, 0x6EU, 0x63U,
|
||||
0x65U, 0x28U, 0x30U, 0x2CU, 0x20U, 0x31U, 0x30U, 0x30U, 0x30U, 0x30U,
|
||||
0x30U, 0x30U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x4FU, 0x55U, 0x54U,
|
||||
0x5FU, 0x4FU, 0x46U, 0x5FU, 0x42U, 0x4FU, 0x55U, 0x4EU, 0x44U, 0x53U,
|
||||
0x00U, 0x65U, 0x74U, 0x78U, 0x6EU, 0x5FU, 0x6EU, 0x6FU, 0x6EU, 0x63U,
|
||||
0x65U, 0x28U, 0x28U, 0x75U, 0x69U, 0x6EU, 0x74U, 0x33U, 0x32U, 0x5FU,
|
||||
0x74U, 0x29U, 0x6EU, 0x6FU, 0x6EU, 0x63U, 0x65U, 0x20U, 0x2BU, 0x20U,
|
||||
0x28U, 0x28U, 0x69U, 0x20U, 0x25U, 0x20U, 0x32U, 0x29U, 0x20U, 0x2AU,
|
||||
0x20U, 0x33U, 0x32U, 0x29U, 0x2CU, 0x20U, 0x33U, 0x32U, 0x29U, 0x20U,
|
||||
0x3DU, 0x3DU, 0x20U, 0x33U, 0x32U, 0x00U, 0x21U, 0x28U, 0x2AU, 0x28U,
|
||||
0x6EU, 0x31U, 0x20U, 0x2BU, 0x20U, 0x30U, 0x29U, 0x20U, 0x3DU, 0x3DU,
|
||||
0x20U, 0x2AU, 0x28U, 0x6EU, 0x32U, 0x20U, 0x2BU, 0x20U, 0x30U, 0x29U,
|
||||
0x20U, 0x26U, 0x26U, 0x20U, 0x2AU, 0x28U, 0x6EU, 0x31U, 0x20U, 0x2BU,
|
||||
0x20U, 0x31U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x2AU, 0x28U, 0x6EU,
|
||||
0x32U, 0x20U, 0x2BU, 0x20U, 0x31U, 0x29U, 0x29U, 0x00U, 0x65U, 0x74U,
|
||||
0x78U, 0x6EU, 0x5FU, 0x6EU, 0x6FU, 0x6EU, 0x63U, 0x65U, 0x28U, 0x28U,
|
||||
0x75U, 0x69U, 0x6EU, 0x74U, 0x33U, 0x32U, 0x5FU, 0x74U, 0x29U, 0x6EU,
|
||||
0x6FU, 0x6EU, 0x63U, 0x65U, 0x2CU, 0x20U, 0x31U, 0x31U, 0x36U, 0x29U,
|
||||
0x20U, 0x3DU, 0x3DU, 0x20U, 0x54U, 0x4FU, 0x4FU, 0x5FU, 0x4DU, 0x41U,
|
||||
0x4EU, 0x59U, 0x5FU, 0x4EU, 0x4FU, 0x4EU, 0x43U, 0x45U, 0x53U, 0x00U,
|
||||
0x74U, 0x29U, 0x6EU, 0x6FU, 0x6EU, 0x63U, 0x65U, 0x2CU, 0x20U, 0x33U,
|
||||
0x31U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x54U, 0x4FU, 0x4FU, 0x5FU,
|
||||
0x53U, 0x4DU, 0x41U, 0x4CU, 0x4CU, 0x00U, 0x65U, 0x74U, 0x78U, 0x6EU,
|
||||
0x5FU, 0x6EU, 0x6FU, 0x6EU, 0x63U, 0x65U, 0x28U, 0x28U, 0x75U, 0x69U,
|
||||
0x6EU, 0x74U, 0x33U, 0x32U, 0x5FU, 0x74U, 0x29U, 0x6EU, 0x6FU, 0x6EU,
|
||||
0x63U, 0x65U, 0x20U, 0x2BU, 0x20U, 0x28U, 0x28U, 0x69U, 0x20U, 0x25U,
|
||||
0x20U, 0x32U, 0x29U, 0x20U, 0x2AU, 0x20U, 0x33U, 0x32U, 0x29U, 0x2CU,
|
||||
0x20U, 0x33U, 0x32U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x33U, 0x32U,
|
||||
0x00U, 0x21U, 0x28U, 0x2AU, 0x28U, 0x6EU, 0x31U, 0x20U, 0x2BU, 0x20U,
|
||||
0x30U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x2AU, 0x28U, 0x6EU, 0x32U,
|
||||
0x20U, 0x2BU, 0x20U, 0x30U, 0x29U, 0x20U, 0x26U, 0x26U, 0x20U, 0x2AU,
|
||||
0x28U, 0x6EU, 0x31U, 0x20U, 0x2BU, 0x20U, 0x31U, 0x29U, 0x20U, 0x3DU,
|
||||
0x3DU, 0x20U, 0x2AU, 0x28U, 0x6EU, 0x32U, 0x20U, 0x2BU, 0x20U, 0x31U,
|
||||
0x29U, 0x29U, 0x00U, 0x65U, 0x74U, 0x78U, 0x6EU, 0x5FU, 0x6EU, 0x6FU,
|
||||
0x6EU, 0x63U, 0x65U, 0x28U, 0x28U, 0x75U, 0x69U, 0x6EU, 0x74U, 0x33U,
|
||||
0x32U, 0x5FU, 0x74U, 0x29U, 0x6EU, 0x6FU, 0x6EU, 0x63U, 0x65U, 0x2CU,
|
||||
0x20U, 0x31U, 0x31U, 0x36U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x54U,
|
||||
0x4FU, 0x4FU, 0x5FU, 0x4DU, 0x41U, 0x4EU, 0x59U, 0x5FU, 0x4EU, 0x4FU,
|
||||
0x4EU, 0x43U, 0x45U, 0x53U, 0x00U, 0x65U, 0x74U, 0x78U, 0x6EU, 0x5FU,
|
||||
0x6EU, 0x6FU, 0x6EU, 0x63U, 0x65U, 0x28U, 0x28U, 0x75U, 0x69U, 0x6EU,
|
||||
0x74U, 0x33U, 0x32U, 0x5FU, 0x74U, 0x29U, 0x6EU, 0x6FU, 0x6EU, 0x63U,
|
||||
0x65U, 0x2CU, 0x20U, 0x33U, 0x31U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U,
|
||||
0x54U, 0x4FU, 0x4FU, 0x5FU, 0x4DU, 0x41U, 0x4EU, 0x59U, 0x5FU, 0x4EU,
|
||||
0x4FU, 0x4EU, 0x43U, 0x45U, 0x53U, 0x00U,
|
||||
}},
|
||||
|
||||
/* ==== WASM: 10 ==== */
|
||||
|
||||
@@ -20,9 +20,13 @@
|
||||
#ifndef RIPPLE_TEST_JTX_HOOK_H_INCLUDED
|
||||
#define RIPPLE_TEST_JTX_HOOK_H_INCLUDED
|
||||
|
||||
#include <ripple/app/hook/applyHook.h>
|
||||
#include <ripple/json/json_value.h>
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <test/jtx/Account.h>
|
||||
#include <vector>
|
||||
|
||||
namespace ripple {
|
||||
namespace test {
|
||||
@@ -43,6 +47,66 @@ hso(std::string const& wasmHex, void (*f)(Json::Value& jv) = 0);
|
||||
Json::Value
|
||||
hso_delete(void (*f)(Json::Value& jv) = 0);
|
||||
|
||||
struct StubHookResult
|
||||
{
|
||||
ripple::uint256 const hookSetTxnID = ripple::uint256();
|
||||
ripple::uint256 const hookHash = ripple::uint256();
|
||||
ripple::uint256 const hookCanEmit = ripple::uint256();
|
||||
ripple::uint256 const hookNamespace = ripple::uint256();
|
||||
|
||||
std::queue<std::shared_ptr<ripple::Transaction>> emittedTxn{};
|
||||
std::optional<hook::HookStateMap> stateMap = std::nullopt;
|
||||
uint16_t changedStateCount = 0;
|
||||
std::map<
|
||||
ripple::uint256, // hook hash
|
||||
std::map<
|
||||
std::vector<uint8_t>, // hook param name
|
||||
std::vector<uint8_t> // hook param value
|
||||
>>
|
||||
hookParamOverrides = {};
|
||||
|
||||
std::optional<std::map<std::vector<uint8_t>, std::vector<uint8_t>>>
|
||||
hookParams = std::nullopt;
|
||||
std::set<ripple::uint256> hookSkips = {};
|
||||
hook_api::ExitType exitType = hook_api::ExitType::ROLLBACK;
|
||||
std::string exitReason{""};
|
||||
int64_t exitCode{-1};
|
||||
uint64_t instructionCount{0};
|
||||
bool hasCallback = false;
|
||||
bool isCallback = false;
|
||||
bool isStrong = false;
|
||||
uint32_t wasmParam = 0;
|
||||
uint32_t overrideCount = 0;
|
||||
uint8_t hookChainPosition = 0;
|
||||
bool foreignStateSetDisabled = false;
|
||||
bool executeAgainAsWeak = false;
|
||||
std::shared_ptr<STObject const> provisionalMeta = nullptr;
|
||||
};
|
||||
|
||||
struct StubHookContext
|
||||
{
|
||||
std::map<uint32_t, hook::SlotEntry> slot{};
|
||||
std::queue<uint32_t> slot_free{};
|
||||
uint32_t slot_counter{0};
|
||||
uint16_t emit_nonce_counter{0};
|
||||
uint16_t ledger_nonce_counter{0};
|
||||
int64_t expected_etxn_count{-1};
|
||||
std::map<ripple::uint256, bool> nonce_used{};
|
||||
uint32_t generation = 0;
|
||||
uint64_t burden = 0;
|
||||
std::map<uint32_t, uint32_t> guard_map{};
|
||||
StubHookResult result = {};
|
||||
std::optional<ripple::STObject> emitFailure = std::nullopt;
|
||||
const hook::HookExecutor* module = 0;
|
||||
};
|
||||
|
||||
hook::HookContext
|
||||
makeStubHookContext(
|
||||
ripple::ApplyContext& applyCtx,
|
||||
ripple::AccountID const& hookAccount,
|
||||
ripple::AccountID const& otxnAccount,
|
||||
StubHookContext const& stubHookContext);
|
||||
|
||||
} // namespace jtx
|
||||
} // namespace test
|
||||
} // namespace ripple
|
||||
|
||||
@@ -18,7 +18,9 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/app/hook/Enum.h>
|
||||
#include <ripple/app/hook/applyHook.h>
|
||||
#include <ripple/basics/contract.h>
|
||||
#include <ripple/protocol/Keylet.h>
|
||||
#include <ripple/protocol/jss.h>
|
||||
#include <stdexcept>
|
||||
#include <test/jtx/hook.h>
|
||||
@@ -102,6 +104,63 @@ hso(std::string const& wasmHex, void (*f)(Json::Value& jv))
|
||||
return jv;
|
||||
}
|
||||
|
||||
hook::HookContext
|
||||
makeStubHookContext(
|
||||
ripple::ApplyContext& applyCtx,
|
||||
ripple::AccountID const& hookAccount,
|
||||
ripple::AccountID const& otxnAccount,
|
||||
StubHookContext const& stubHookContext)
|
||||
{
|
||||
auto& result = stubHookContext.result;
|
||||
auto stateMap = result.stateMap.value_or(hook::HookStateMap{});
|
||||
auto hookParams = result.hookParams.value_or(
|
||||
std::map<std::vector<uint8_t>, std::vector<uint8_t>>{});
|
||||
return hook::HookContext{
|
||||
.applyCtx = applyCtx,
|
||||
.slot = stubHookContext.slot,
|
||||
.slot_free = stubHookContext.slot_free,
|
||||
.slot_counter = stubHookContext.slot_counter,
|
||||
.emit_nonce_counter = stubHookContext.emit_nonce_counter,
|
||||
.ledger_nonce_counter = stubHookContext.ledger_nonce_counter,
|
||||
.expected_etxn_count = stubHookContext.expected_etxn_count,
|
||||
.nonce_used = stubHookContext.nonce_used,
|
||||
.generation = stubHookContext.generation,
|
||||
.burden = stubHookContext.burden,
|
||||
.guard_map = stubHookContext.guard_map,
|
||||
.result =
|
||||
{
|
||||
.hookSetTxnID = result.hookSetTxnID,
|
||||
.hookHash = result.hookHash,
|
||||
.hookCanEmit = result.hookCanEmit,
|
||||
.accountKeylet = keylet::account(hookAccount),
|
||||
.hookKeylet = keylet::hook(hookAccount),
|
||||
.account = hookAccount,
|
||||
.otxnAccount = otxnAccount,
|
||||
.hookNamespace = result.hookNamespace,
|
||||
.emittedTxn = result.emittedTxn,
|
||||
.stateMap = stateMap,
|
||||
.changedStateCount = result.changedStateCount,
|
||||
.hookParamOverrides = result.hookParamOverrides,
|
||||
.hookParams = hookParams,
|
||||
.hookSkips = result.hookSkips,
|
||||
.exitType = result.exitType,
|
||||
.exitReason = result.exitReason,
|
||||
.exitCode = result.exitCode,
|
||||
.instructionCount = result.instructionCount,
|
||||
.hasCallback = result.hasCallback,
|
||||
.isCallback = result.isCallback,
|
||||
.isStrong = result.isStrong,
|
||||
.wasmParam = result.wasmParam,
|
||||
.overrideCount = result.overrideCount,
|
||||
.hookChainPosition = result.hookChainPosition,
|
||||
.foreignStateSetDisabled = result.foreignStateSetDisabled,
|
||||
.executeAgainAsWeak = result.executeAgainAsWeak,
|
||||
.provisionalMeta = result.provisionalMeta,
|
||||
},
|
||||
.emitFailure = stubHookContext.emitFailure,
|
||||
.module = nullptr};
|
||||
}
|
||||
|
||||
} // namespace jtx
|
||||
} // namespace test
|
||||
} // namespace ripple
|
||||
|
||||
Reference in New Issue
Block a user