Support new STIs for sto_* HookAPI (#657)

This commit is contained in:
tequ
2026-02-18 10:48:13 +09:00
committed by GitHub
parent 445f28ed30
commit e06b48d144
29 changed files with 2708 additions and 574 deletions

View File

@@ -14,6 +14,7 @@
// Override uint256, Feature and Rules for guard checker build
#define uint256 std::string
#define featureHooksUpdate1 "1"
#define featureHooksUpdate2 "1"
#define fix20250131 "1"
namespace hook_api {
struct Rules

View File

@@ -58,6 +58,9 @@ public:
// sto_erase(): same as sto_emplace with field_object = nullopt
/// etxn APIs
Expected<Bytes, HookReturnCode>
prepare(Slice const& txBlob) const;
Expected<std::shared_ptr<Transaction>, HookReturnCode>
emit(Slice const& txBlob) const;
@@ -329,14 +332,15 @@ private:
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
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
Rules const& rules,
int recursion_depth = 0) // used internally
const;
};

View File

@@ -367,3 +367,8 @@ HOOK_API_DEFINITION(
HOOK_API_DEFINITION(
int64_t, xpop_slot, (uint32_t, uint32_t),
featureHooksUpdate1)
// int64_t prepare(uint32_t write_ptr, uint32_t write_len, uint32_t read_ptr, uint32_t read_len);
HOOK_API_DEFINITION(
int64_t, prepare, (uint32_t, uint32_t, uint32_t, uint32_t),
featureHooksUpdate2)

View File

@@ -80,7 +80,7 @@ namespace detail {
// Feature.cpp. Because it's only used to reserve storage, and determine how
// large to make the FeatureBitset, it MAY be larger. It MUST NOT be less than
// the actual number of amendments. A LogicError on startup will verify this.
static constexpr std::size_t numFeatures = 110;
static constexpr std::size_t numFeatures = 113;
/** Amendments that this server supports and the default voting behavior.
Whether they are enabled depends on the Rules defined in the validated

View File

@@ -24,11 +24,14 @@
#error "undefined macro: XRPL_FIX"
#endif
// clang-format off
// Add new amendments to the top of this list.
// Keep it sorted in reverse chronological order.
// If you add an amendment here, then do not forget to increment `numFeatures`
// in include/xrpl/protocol/Feature.h.
XRPL_FEATURE(HookAPISerializedType240, Supported::yes, VoteBehavior::DefaultNo)
XRPL_FEATURE(PermissionedDomains, Supported::no, VoteBehavior::DefaultNo)
XRPL_FEATURE(DynamicNFT, Supported::no, VoteBehavior::DefaultNo)
XRPL_FEATURE(Credentials, Supported::no, VoteBehavior::DefaultNo)
@@ -50,6 +53,8 @@ XRPL_FEATURE(DID, Supported::no, VoteBehavior::DefaultNo
XRPL_FIX (DisallowIncomingV1, Supported::yes, VoteBehavior::DefaultYes)
XRPL_FEATURE(XChainBridge, Supported::no, VoteBehavior::DefaultNo)
XRPL_FEATURE(AMM, Supported::yes, VoteBehavior::DefaultNo)
XRPL_FEATURE(HookOnV2, Supported::yes, VoteBehavior::DefaultNo)
XRPL_FEATURE(HooksUpdate2, Supported::yes, VoteBehavior::DefaultNo)
XRPL_FIX (HookAPI20251128, Supported::yes, VoteBehavior::DefaultYes)
XRPL_FIX (CronStacking, Supported::yes, VoteBehavior::DefaultYes)
XRPL_FEATURE(ExtendedHookState, Supported::yes, VoteBehavior::DefaultNo)
@@ -142,3 +147,4 @@ XRPL_FIX (NFTokenDirV1, Supported::yes, VoteBehavior::Obsolete)
XRPL_FEATURE(NonFungibleTokensV1, Supported::yes, VoteBehavior::Obsolete)
XRPL_FEATURE(CryptoConditionsSuite, Supported::yes, VoteBehavior::Obsolete)
// clang-format on

View File

@@ -93,7 +93,9 @@ LEDGER_ENTRY(ltCHECK, 0x0043, Check, check, ({
*/
LEDGER_ENTRY(ltHOOK_DEFINITION, 'D', HookDefinition, hook_definition, ({
{sfHookHash, soeREQUIRED},
{sfHookOn, soeREQUIRED},
{sfHookOn, soeOPTIONAL},
{sfHookOnIncoming, soeOPTIONAL},
{sfHookOnOutgoing, soeOPTIONAL},
{sfHookCanEmit, soeOPTIONAL},
{sfHookNamespace, soeREQUIRED},
{sfHookParameters, soeREQUIRED},

View File

@@ -215,6 +215,8 @@ TYPED_SFIELD(sfGovernanceMarks, UINT256, 98)
TYPED_SFIELD(sfEmittedTxnID, UINT256, 97)
TYPED_SFIELD(sfHookCanEmit, UINT256, 96)
TYPED_SFIELD(sfCron, UINT256, 95)
TYPED_SFIELD(sfHookOnIncoming, UINT256, 94)
TYPED_SFIELD(sfHookOnOutgoing, UINT256, 93)
// number (common)
TYPED_SFIELD(sfNumber, NUMBER, 1)

View File

@@ -78,6 +78,8 @@ JSS(HookCanEmit); // field
JSS(HookHash); // field
JSS(HookNamespace); // field
JSS(HookOn); // field
JSS(HookOnIncoming); // field
JSS(HookOnOutgoing); // field
JSS(Hooks); // field
JSS(HookGrants); // field
JSS(HookParameters); // field
@@ -96,6 +98,7 @@ JSS(Issuer); // in: Credential transactions
JSS(InvoiceID); // field
JSS(LastLedgerSequence); // in: TransactionSign; field
JSS(LastUpdateTime); // field.
JSS(FirstLedgerSequence); // in: TransactionSign; field
JSS(LimitAmount); // field.
JSS(NetworkID); // field.
JSS(LPTokenOut); // in: AMM Liquidity Provider deposit tokens
@@ -119,6 +122,7 @@ JSS(Signer); // field.
JSS(Signers); // field.
JSS(HookStateData); // field.
JSS(HookStateKey); // field.
JSS(EmitDetails); // field.
JSS(SigningPubKey); // field.
JSS(Subject); // in: Credential transactions
JSS(TakerGets); // field.