Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XLS-78d: Subscriptions #5136

Draft
wants to merge 10 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/xrpl/protocol/Feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 79;
static constexpr std::size_t numFeatures = 80;

/** Amendments that this server supports and the default voting behavior.
Whether they are enabled depends on the Rules defined in the validated
Expand Down Expand Up @@ -372,6 +372,7 @@ extern uint256 const fixEnforceNFTokenTrustline;
extern uint256 const fixInnerObjTemplate2;
extern uint256 const featureInvariantsV1_1;
extern uint256 const fixNFTokenPageLinks;
extern uint256 const featureSubscription;

} // namespace ripple

Expand Down
12 changes: 12 additions & 0 deletions include/xrpl/protocol/Indexes.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,18 @@ did(AccountID const& account) noexcept;
Keylet
oracle(AccountID const& account, std::uint32_t const& documentID) noexcept;

Keylet
subscription(
AccountID const& account,
AccountID const& dest,
std::uint32_t const& seq) noexcept;

inline Keylet
subscription(uint256 const& key) noexcept
{
return {ltSUBSCRIPTION, key};
}

} // namespace keylet

// Everything below is deprecated and should be removed in favor of keylets:
Expand Down
5 changes: 5 additions & 0 deletions include/xrpl/protocol/LedgerFormats.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ enum LedgerEntryType : std::uint16_t
*/
ltORACLE = 0x0080,

/** A ledger object which tracks Subscription
\sa keylet::subscription
*/
ltSUBSCRIPTION = 0x0055,

//---------------------------------------------------------------------------
/** A special type, matching any ledger entry type.

Expand Down
4 changes: 4 additions & 0 deletions include/xrpl/protocol/SField.h
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,9 @@ extern SF_UINT32 const sfEmitGeneration;
extern SF_UINT32 const sfVoteWeight;
extern SF_UINT32 const sfFirstNFTokenSequence;
extern SF_UINT32 const sfOracleDocumentID;
extern SF_UINT32 const sfFrequency;
extern SF_UINT32 const sfStartTime;
extern SF_UINT32 const sfNextPaymentTime;

// 64-bit integers (common)
extern SF_UINT64 const sfIndexNext;
Expand Down Expand Up @@ -511,6 +514,7 @@ extern SF_UINT256 const sfHookStateKey;
extern SF_UINT256 const sfHookHash;
extern SF_UINT256 const sfHookNamespace;
extern SF_UINT256 const sfHookSetTxnID;
extern SF_UINT256 const sfSubscriptionID;

// currency amount (common)
extern SF_AMOUNT const sfAmount;
Expand Down
9 changes: 9 additions & 0 deletions include/xrpl/protocol/TxFormats.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,15 @@ enum TxType : std::uint16_t
/** This transaction type fixes a problem in the ledger state */
ttLEDGER_STATE_FIX = 53,

/** This transaction type creates an Subscription instance */
ttSUBSCRIPTION_SET = 54,

/** This transaction type cancels an Subscription instance */
ttSUBSCRIPTION_CANCEL = 55,

/** This transaction type claims an Subscription instance */
ttSUBSCRIPTION_CLAIM = 56,


/** This system-generated transaction type is used to update the status of the various amendments.

Expand Down
7 changes: 7 additions & 0 deletions include/xrpl/protocol/jss.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ JSS(EscrowFinish); // transaction type.
JSS(Fee); // in/out: TransactionSign; field.
JSS(FeeSettings); // ledger type.
JSS(Flags); // in/out: TransactionSign; field.
JSS(Frequency); // field.
JSS(Invalid); //
JSS(LastLedgerSequence); // in: TransactionSign; field
JSS(LastUpdateTime); // field.
Expand Down Expand Up @@ -140,6 +141,11 @@ JSS(SetRegularKey); // transaction type.
JSS(SignerList); // ledger type.
JSS(SignerListSet); // transaction type.
JSS(SigningPubKey); // field.
JSS(Subscription); // ledger type.
JSS(SubscriptionCancel); // transaction type.
JSS(SubscriptionClaim); // transaction type.
JSS(SubscriptionID); // field.
JSS(SubscriptionSet); // transaction type.
JSS(TakerGets); // field.
JSS(TakerPays); // field.
JSS(Ticket); // ledger type.
Expand Down Expand Up @@ -651,6 +657,7 @@ JSS(streams); // in: Subscribe, Unsubscribe
JSS(strict); // in: AccountCurrencies, AccountInfo
JSS(sub_index); // in: LedgerEntry
JSS(subcommand); // in: PathFind
JSS(subscription); // in: LedgerEntry
JSS(success); // rpc
JSS(supported); // out: AmendmentTableImpl
JSS(sync_mode); // in: Submit
Expand Down
2 changes: 2 additions & 0 deletions src/libxrpl/protocol/Feature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,8 @@ REGISTER_FIX (fixReducedOffersV2, Supported::yes, VoteBehavior::De
REGISTER_FIX (fixEnforceNFTokenTrustline, Supported::yes, VoteBehavior::DefaultNo);
REGISTER_FIX (fixInnerObjTemplate2, Supported::yes, VoteBehavior::DefaultNo);
REGISTER_FIX (fixNFTokenPageLinks, Supported::yes, VoteBehavior::DefaultNo);
REGISTER_FEATURE(Subscription, Supported::yes, VoteBehavior::DefaultNo);

// InvariantsV1_1 will be changes to Supported::yes when all the
// invariants expected to be included under it are complete.
REGISTER_FEATURE(InvariantsV1_1, Supported::no, VoteBehavior::DefaultNo);
Expand Down
12 changes: 12 additions & 0 deletions src/libxrpl/protocol/Indexes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ enum class LedgerNameSpace : std::uint16_t {
XCHAIN_CREATE_ACCOUNT_CLAIM_ID = 'K',
DID = 'I',
ORACLE = 'R',
SUBSCRIPTION = 'U',

// No longer used or supported. Left here to reserve the space
// to avoid accidental reuse.
Expand Down Expand Up @@ -451,6 +452,17 @@ oracle(AccountID const& account, std::uint32_t const& documentID) noexcept
return {ltORACLE, indexHash(LedgerNameSpace::ORACLE, account, documentID)};
}

Keylet
subscription(
AccountID const& account,
AccountID const& dest,
std::uint32_t const& seq) noexcept
{
return {
ltSUBSCRIPTION,
indexHash(LedgerNameSpace::SUBSCRIPTION, account, dest, seq)};
}

} // namespace keylet

} // namespace ripple
17 changes: 17 additions & 0 deletions src/libxrpl/protocol/LedgerFormats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,23 @@ LedgerFormats::LedgerFormats()
{sfPreviousTxnLgrSeq, soeREQUIRED}
},
commonFields);

add(jss::Subscription,
ltSUBSCRIPTION,
{
{sfAccount, soeREQUIRED},
{sfDestination, soeREQUIRED},
{sfDestinationTag, soeOPTIONAL},
{sfAmount, soeREQUIRED},
{sfFrequency, soeREQUIRED},
{sfNextPaymentTime, soeREQUIRED},
{sfExpiration, soeOPTIONAL},
{sfOwnerNode, soeREQUIRED},
{sfPreviousTxnID, soeREQUIRED},
{sfPreviousTxnLgrSeq, soeREQUIRED},
{sfDestinationNode, soeREQUIRED},
},
commonFields);

// clang-format on
}
Expand Down
4 changes: 4 additions & 0 deletions src/libxrpl/protocol/SField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ CONSTRUCT_TYPED_SFIELD(sfEmitGeneration, "EmitGeneration", UINT32,
CONSTRUCT_TYPED_SFIELD(sfVoteWeight, "VoteWeight", UINT32, 48);
CONSTRUCT_TYPED_SFIELD(sfFirstNFTokenSequence, "FirstNFTokenSequence", UINT32, 50);
CONSTRUCT_TYPED_SFIELD(sfOracleDocumentID, "OracleDocumentID", UINT32, 51);
CONSTRUCT_TYPED_SFIELD(sfFrequency, "Frequency", UINT32, 52);
CONSTRUCT_TYPED_SFIELD(sfStartTime, "StartTime", UINT32, 53);
CONSTRUCT_TYPED_SFIELD(sfNextPaymentTime, "NextPaymentTime", UINT32, 54);

// 64-bit integers (common)
CONSTRUCT_TYPED_SFIELD(sfIndexNext, "IndexNext", UINT64, 1);
Expand Down Expand Up @@ -238,6 +241,7 @@ CONSTRUCT_TYPED_SFIELD(sfHookStateKey, "HookStateKey", UINT256,
CONSTRUCT_TYPED_SFIELD(sfHookHash, "HookHash", UINT256, 31);
CONSTRUCT_TYPED_SFIELD(sfHookNamespace, "HookNamespace", UINT256, 32);
CONSTRUCT_TYPED_SFIELD(sfHookSetTxnID, "HookSetTxnID", UINT256, 33);
CONSTRUCT_TYPED_SFIELD(sfSubscriptionID, "SubscriptionID", UINT256, 34);

// currency amount (common)
CONSTRUCT_TYPED_SFIELD(sfAmount, "Amount", AMOUNT, 1);
Expand Down
28 changes: 28 additions & 0 deletions src/libxrpl/protocol/TxFormats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,34 @@ TxFormats::TxFormats()
{sfOwner, soeOPTIONAL},
},
commonFields);

add(jss::SubscriptionSet,
ttSUBSCRIPTION_SET,
{
{sfDestination, soeOPTIONAL},
{sfDestinationTag, soeOPTIONAL},
{sfAmount, soeREQUIRED},
{sfFrequency, soeOPTIONAL},
{sfStartTime, soeOPTIONAL},
{sfExpiration, soeOPTIONAL},
{sfSubscriptionID, soeOPTIONAL},
},
commonFields);

add(jss::SubscriptionCancel,
ttSUBSCRIPTION_CANCEL,
{
{sfSubscriptionID, soeREQUIRED},
},
commonFields);

add(jss::SubscriptionClaim,
ttSUBSCRIPTION_CLAIM,
{
{sfSubscriptionID, soeREQUIRED},
{sfAmount, soeREQUIRED},
},
commonFields);
}

TxFormats const&
Expand Down
Loading
Loading