From 6733689102812dc081c69b1e310670e93c97dcaa Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Thu, 18 Sep 2025 17:24:30 -0400 Subject: [PATCH] fix more issues, reduce diff --- include/xrpl/protocol/Indexes.h | 2 + include/xrpl/protocol/Protocol.h | 15 +- .../xrpl/protocol/detail/ledger_entries.macro | 8 +- include/xrpl/protocol/detail/sfields.macro | 8 +- src/test/jtx/escrow.h | 141 +----------------- 5 files changed, 27 insertions(+), 147 deletions(-) diff --git a/include/xrpl/protocol/Indexes.h b/include/xrpl/protocol/Indexes.h index 1e4bb921d7..94f60cdcd6 100644 --- a/include/xrpl/protocol/Indexes.h +++ b/include/xrpl/protocol/Indexes.h @@ -293,9 +293,11 @@ delegate(AccountID const& account, AccountID const& authorizedAccount) noexcept; Keylet bridge(STXChainBridge const& bridge, STXChainBridge::ChainType chainType); +// `seq` is stored as `sfXChainClaimID` in the object Keylet xChainClaimID(STXChainBridge const& bridge, std::uint64_t seq); +// `seq` is stored as `sfXChainAccountCreateCount` in the object Keylet xChainCreateAccountClaimID(STXChainBridge const& bridge, std::uint64_t seq); diff --git a/include/xrpl/protocol/Protocol.h b/include/xrpl/protocol/Protocol.h index d52ae2dfc1..42ae2e947b 100644 --- a/include/xrpl/protocol/Protocol.h +++ b/include/xrpl/protocol/Protocol.h @@ -22,7 +22,6 @@ #include #include -#include #include @@ -133,13 +132,6 @@ std::uint8_t constexpr vaultMaximumIOUScale = 18; * another vault; counted from 0 */ std::uint8_t constexpr maxAssetCheckDepth = 5; -/** The maximum length of a Data field in Escrow object that can be updated by - * Wasm code */ -std::size_t constexpr maxWasmDataLength = 4 * 1024; - -/** The maximum length of a parameters passed from Wasm code*/ -std::size_t constexpr maxWasmParamLength = 1024; - /** A ledger index. */ using LedgerIndex = std::uint32_t; @@ -186,6 +178,13 @@ std::size_t constexpr permissionMaxSize = 10; /** The maximum number of transactions that can be in a batch. */ std::size_t constexpr maxBatchTxCount = 8; +/** The maximum length of a Data field in Escrow object that can be updated by + * Wasm code */ +std::size_t constexpr maxWasmDataLength = 4 * 1024; + +/** The maximum length of a parameters passed from Wasm code*/ +std::size_t constexpr maxWasmParamLength = 1024; + } // namespace ripple #endif diff --git a/include/xrpl/protocol/detail/ledger_entries.macro b/include/xrpl/protocol/detail/ledger_entries.macro index 9c69b33cb8..a1bc9f9aac 100644 --- a/include/xrpl/protocol/detail/ledger_entries.macro +++ b/include/xrpl/protocol/detail/ledger_entries.macro @@ -120,6 +120,7 @@ LEDGER_ENTRY(ltNFTOKEN_PAGE, 0x0050, NFTokenPage, nft_page, ({ // All fields are soeREQUIRED because there is always a SignerEntries. // If there are no SignerEntries the node is deleted. LEDGER_ENTRY(ltSIGNER_LIST, 0x0053, SignerList, signer_list, ({ + {sfOwner, soeOPTIONAL}, {sfOwnerNode, soeREQUIRED}, {sfSignerQuorum, soeREQUIRED}, {sfSignerEntries, soeREQUIRED}, @@ -188,7 +189,7 @@ LEDGER_ENTRY(ltDIR_NODE, 0x0064, DirectoryNode, directory, ({ {sfNFTokenID, soeOPTIONAL}, {sfPreviousTxnID, soeOPTIONAL}, {sfPreviousTxnLgrSeq, soeOPTIONAL}, - {sfDomainID, soeOPTIONAL} + {sfDomainID, soeOPTIONAL} // order book directories })) /** The ledger object which lists details about amendments on the network. @@ -319,7 +320,6 @@ LEDGER_ENTRY(ltFEE_SETTINGS, 0x0073, FeeSettings, fee, ({ {sfBaseFeeDrops, soeOPTIONAL}, {sfReserveBaseDrops, soeOPTIONAL}, {sfReserveIncrementDrops, soeOPTIONAL}, - {sfPreviousTxnID, soeOPTIONAL}, {sfPreviousTxnLgrSeq, soeOPTIONAL}, })) @@ -344,6 +344,7 @@ LEDGER_ENTRY(ltXCHAIN_OWNED_CREATE_ACCOUNT_CLAIM_ID, 0x0074, XChainOwnedCreateAc */ LEDGER_ENTRY(ltESCROW, 0x0075, Escrow, escrow, ({ {sfAccount, soeREQUIRED}, + {sfSequence, soeOPTIONAL}, {sfDestination, soeREQUIRED}, {sfAmount, soeREQUIRED}, {sfCondition, soeOPTIONAL}, @@ -368,6 +369,7 @@ LEDGER_ENTRY(ltESCROW, 0x0075, Escrow, escrow, ({ LEDGER_ENTRY(ltPAYCHAN, 0x0078, PayChannel, payment_channel, ({ {sfAccount, soeREQUIRED}, {sfDestination, soeREQUIRED}, + {sfSequence, soeOPTIONAL}, {sfAmount, soeREQUIRED}, {sfBalance, soeREQUIRED}, {sfPublicKey, soeREQUIRED}, @@ -415,6 +417,7 @@ LEDGER_ENTRY(ltMPTOKEN_ISSUANCE, 0x007e, MPTokenIssuance, mpt_issuance, ({ {sfPreviousTxnID, soeREQUIRED}, {sfPreviousTxnLgrSeq, soeREQUIRED}, {sfDomainID, soeOPTIONAL}, + {sfMutableFlags, soeDEFAULT}, })) /** A ledger object which tracks MPToken @@ -435,6 +438,7 @@ LEDGER_ENTRY(ltMPTOKEN, 0x007f, MPToken, mptoken, ({ */ LEDGER_ENTRY(ltORACLE, 0x0080, Oracle, oracle, ({ {sfOwner, soeREQUIRED}, + {sfOracleDocumentID, soeOPTIONAL}, {sfProvider, soeREQUIRED}, {sfPriceDataSeries, soeREQUIRED}, {sfAssetClass, soeREQUIRED}, diff --git a/include/xrpl/protocol/detail/sfields.macro b/include/xrpl/protocol/detail/sfields.macro index 5263ed52cd..63d471b35b 100644 --- a/include/xrpl/protocol/detail/sfields.macro +++ b/include/xrpl/protocol/detail/sfields.macro @@ -179,7 +179,8 @@ TYPED_SFIELD(sfNFTokenID, UINT256, 10) TYPED_SFIELD(sfEmitParentTxnID, UINT256, 11) TYPED_SFIELD(sfEmitNonce, UINT256, 12) TYPED_SFIELD(sfEmitHookHash, UINT256, 13) -TYPED_SFIELD(sfAMMID, UINT256, 14) +TYPED_SFIELD(sfAMMID, UINT256, 14, + SField::sMD_PseudoAccount | SField::sMD_Default) // 256-bit (uncommon) TYPED_SFIELD(sfBookDirectory, UINT256, 16) @@ -201,7 +202,8 @@ TYPED_SFIELD(sfHookHash, UINT256, 31) TYPED_SFIELD(sfHookNamespace, UINT256, 32) TYPED_SFIELD(sfHookSetTxnID, UINT256, 33) TYPED_SFIELD(sfDomainID, UINT256, 34) -TYPED_SFIELD(sfVaultID, UINT256, 35) +TYPED_SFIELD(sfVaultID, UINT256, 35, + SField::sMD_PseudoAccount | SField::sMD_Default) TYPED_SFIELD(sfParentBatchID, UINT256, 36) // number (common) @@ -250,6 +252,7 @@ TYPED_SFIELD(sfPrice, AMOUNT, 28) TYPED_SFIELD(sfSignatureReward, AMOUNT, 29) TYPED_SFIELD(sfMinAccountCreateAmount, AMOUNT, 30) TYPED_SFIELD(sfLPTokenBalance, AMOUNT, 31) +TYPED_SFIELD(sfFinishFunction, VL, 32) // variable length (common) TYPED_SFIELD(sfPublicKey, VL, 1) @@ -284,7 +287,6 @@ TYPED_SFIELD(sfAssetClass, VL, 28) TYPED_SFIELD(sfProvider, VL, 29) TYPED_SFIELD(sfMPTokenMetadata, VL, 30) TYPED_SFIELD(sfCredentialType, VL, 31) -TYPED_SFIELD(sfFinishFunction, VL, 32) // account (common) TYPED_SFIELD(sfAccount, ACCOUNT, 1) diff --git a/src/test/jtx/escrow.h b/src/test/jtx/escrow.h index 8e21890d98..b4d9410b53 100644 --- a/src/test/jtx/escrow.h +++ b/src/test/jtx/escrow.h @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -93,140 +94,12 @@ std::array const cb3 = { 0x26, 0x4A, 0x2D, 0x85, 0x7B, 0xE8, 0xA0, 0x9C, 0x1D, 0xFD, 0x57, 0x0D, 0x15, 0x85, 0x8B, 0xD4, 0x81, 0x01, 0x04}}; -/** Set the "FinishAfter" time tag on a JTx */ -struct finish_time -{ -private: - NetClock::time_point value_; - -public: - explicit finish_time(NetClock::time_point const& value) : value_(value) - { - } - - void - operator()(Env&, JTx& jt) const - { - jt.jv[sfFinishAfter.jsonName] = value_.time_since_epoch().count(); - } -}; - -/** Set the "CancelAfter" time tag on a JTx */ -struct cancel_time -{ -private: - NetClock::time_point value_; - -public: - explicit cancel_time(NetClock::time_point const& value) : value_(value) - { - } - - void - operator()(jtx::Env&, jtx::JTx& jt) const - { - jt.jv[sfCancelAfter.jsonName] = value_.time_since_epoch().count(); - } -}; - -struct condition -{ -private: - std::string value_; - -public: - explicit condition(Slice const& cond) : value_(strHex(cond)) - { - } - - template - explicit condition(std::array const& c) - : condition(makeSlice(c)) - { - } - - void - operator()(Env&, JTx& jt) const - { - jt.jv[sfCondition.jsonName] = value_; - } -}; - -struct fulfillment -{ -private: - std::string value_; - -public: - explicit fulfillment(Slice condition) : value_(strHex(condition)) - { - } - - template - explicit fulfillment(std::array f) - : fulfillment(makeSlice(f)) - { - } - - void - operator()(Env&, JTx& jt) const - { - jt.jv[sfFulfillment.jsonName] = value_; - } -}; - -struct finish_function -{ -private: - std::string value_; - -public: - explicit finish_function(std::string func) : value_(func) - { - } - - explicit finish_function(Slice const& func) : value_(strHex(func)) - { - } - - template - explicit finish_function(std::array const& f) - : finish_function(makeSlice(f)) - { - } - - void - operator()(Env&, JTx& jt) const - { - jt.jv[sfFinishFunction.jsonName] = value_; - } -}; - -struct data -{ -private: - std::string value_; - -public: - explicit data(std::string func) : value_(func) - { - } - - explicit data(Slice const& func) : value_(strHex(func)) - { - } - - template - explicit data(std::array const& f) : data(makeSlice(f)) - { - } - - void - operator()(Env&, JTx& jt) const - { - jt.jv[sfData.jsonName] = value_; - } -}; +auto const finish_time = JTxFieldWrapper(sfFinishAfter); +auto const cancel_time = JTxFieldWrapper(sfCancelAfter); +auto const condition = JTxFieldWrapper(sfCondition); +auto const fulfillment = JTxFieldWrapper(sfFulfillment); +auto const finish_function = JTxFieldWrapper(sfFinishFunction); +auto const data = JTxFieldWrapper(sfData); struct comp_allowance {