Tickets & Ticket Batching
Tickets allow selected transactions on a single account to be processed out of order, which could benefit some multisigning situations.
- Author
- Nik Bougalis
- Created
- 2020-09-01
- Updated
- 2026-11-30
- Discussion
- XRPLF/XRPL-Standards/discussions/18
Tickets¶
1. Abstract¶
Tickets are a change to the XRP Ledger protocol. They allow selected transactions on a single account to be processed out of order, which could benefit some multisigning situations.
An account creates one or more Tickets with a TicketCreate transaction. Any transaction on that account can then use a TicketSequence in place of a Sequence number. Transactions that use Tickets may be submitted to the network in any order; they are not order constrained like transactions with Sequence numbers. Each Ticket takes one owner reserve, and an account can hold at most 250 Tickets.
2. Motivation¶
Multisigning on the XRP Ledger. Cool, huh? And it's actually getting used. In March of 2018 approximately 4.4% of all payment transactions on the XRP ledger were multisigned. That's over 33,000 payments in that single month. That's not a large percentage, but when you consider the total number of multisigned payments, it's significant.
As long as multisigning is being used in automated situations, it's great. But for non-automated situations there's at least one downside.
2.1. Sequence Numbers¶
The trick is that in the XRP Ledger...
- Every account has an incrementing sequence number.
- Every transaction on that account must contain that sequence number.
- Transactions on that account must be applied to the ledger in order by sequence number.
For example, somebody just created an account for Zoe by sending her some XRP. Zoe's brand new account has a starting sequence number. The very first transaction that Zoe applies to her new account must contain that sequence number. If her first transaction omits the sequence number then the transaction fails. If her first transaction uses a sequence number other than the one in her account, then the transaction fails.
Once Zoe submits that first successful transaction then the sequence number on the account increments. So Zoe's next transaction must contain a sequence number one greater than the sequence number in her previous transaction. The story proceeds from there.
What does this have to do with multisigning? It impacts two possible multisigning scenarios.
2.2. Multiple Independent Signers on One Account¶
With multisigning, it's possible to have multiple independent signers on a single account. Suppose Bonnie and Claudine meet at a Mixed Martial Arts club and decide to start a business together: C-Body Guards. They create an account for the business and set it up for multisigning. Bonnie and Claudine trust each other a great deal. They set up the account multisigning so Claudine can sign or Bonnie can sign for any transaction. (For the detail oriented, Bonnie has a signer weight of 1, Claudine has a signer weight of 1, and the signer list has a quorum of 1.)
Everything was going along just fine until one day when Claudine and Bonnie created independent transactions at about the same time. They both looked at the business account at about the same time and saw the same sequence number. They independently used that same sequence number to create two independent transactions. They submitted their transactions at about the same time. Just by chance Bonnie's transaction made it into the ledger first, so Claudine's transaction failed with tefPAST_SEQ. Claudine was puzzled by the error but re-submitted her transaction, with an updated sequence number, and the second one went through just fine.
Eventually Bonnie and Claudine figured out what had happened.
If Bonnie and Claudine started creating transactions frequently, then the rate of collisions would go up. Eventually it would become a problem.
2.3. Multiple Required Human Signers¶
Prince, Elvis, and Moby decide to go into business together selling tree house kits. However Prince, Elvis, and Moby don't trust each other very much. So when they create their business account they decide that all three of them must sign for any transaction. (For the detail oriented, Prince, Elvis, and Moby each have a signer weight of 1, and the signer list has a quorum of 3).
Elvis decides to throw a party in honor of creating the business and creates a transaction to buy supplies for 2000 peanut butter, banana, and bacon sandwiches. Elvis signs the transaction, using the current account sequence number, and then sends it to Prince and Moby to sign. Moby sits on the transaction because he's not convinced that peanut butter, banana, and bacon sandwiches are the best party food.
In the mean time Prince decides that they should get down to business and buy some lumber for their tree house kits. But Prince has a conundrum. If he creates his transaction with the sequence number one greater than the account sequence, then he must wait until Moby has signed Elvis's transaction and Elvis's transaction has been submitted to and validated by the network. If Prince creates his transaction with the current account sequence number, and if it is validated by the network before Elvis's transaction, then Elvis's transaction could never be validated since it would have a sequence number that is already used. As a consequence Moby and Elvis might need to renegotiate; that would be a pain.
It would be great if there were a way to create transactions so acceptance of a later transaction would not be blocked by acceptance of an earlier transaction.
2.4. Enter Tickets¶
The proposed solution to this problem (one transaction blocking another due to sequence number ordering) is a new ledger type called a Ticket. Fundamentally, a Ticket can be created on an account, then later that Ticket may be used in place of a sequence number. The order in which Tickets are used is not constrained by sequence number ordering.
So Bonnie, Claudine, Prince, Elvis, and Moby could all solve their problems by creating a bunch of Tickets on their accounts first. Those Tickets would then be assigned to individuals. The individuals can then create their transactions, using Tickets instead of sequence numbers, without having to worry about the sequence number ordering of their own, or anybody else's, transactions.
3. Specification¶
The TicketBatch amendment enables the features in this specification.
3.1. Ledger Entry: Ticket¶
A Ticket holds a TicketSequence that a future transaction on the owning account can use in place of a Sequence number. A unique Ticket can be identified in the ledger with only two pieces of information: the ID of the account that owns the Ticket and the TicketSequence number of that Ticket.
3.1.1. Object Identifier¶
Key Space: 0x0054 ('T')
ID Calculation Algorithm: The ID is the SHA512-Half of the following values, concatenated in order:
- The
Ticketkey space (0x0054) - The
AccountIDof the account that owns theTicket - The
TicketSequenceof theTicket
3.1.2. Fields¶
| Field Name | Constant | Required | Internal Type | Default Value | Description |
|---|---|---|---|---|---|
| LedgerEntryType | Yes | Yes | UINT16 | 0x0054 |
Identifies this as a Ticket object. |
| Account | Yes | Yes | ACCOUNT | N/A | The ID of the account that owns the Ticket. |
| TicketSequence | Yes | Yes | UINT32 | N/A | The TicketSequence, an unsigned 32-bit integer. |
| OwnerNode | No | Yes | UINT64 | N/A | The page number for this Ticket in the Ticket owner's directory. |
| PreviousTxnID | No | Yes | HASH256 | N/A | Transaction threading support. |
| PreviousTxnLgrSeq | No | Yes | UINT32 | N/A | Transaction threading support. |
3.1.3. Ownership¶
Owner: Account
Directory Registration: A successful TicketCreate transaction adds a Ticket in the directory of the owning account. The Ticket is removed from the account directory when it is consumed.
3.1.4. Reserves¶
Reserve Requirement: Standard
Adding a Ticket to the account takes one standard reserve increment on that account. The more Tickets held by the account, proportionally more reserve is required on the account. The reserve is returned to the account when the Ticket is consumed.
3.1.5. Deletion¶
Deletion Transactions: Any transaction on the owning account that uses the Ticket's TicketSequence (see Transaction: Common Fields).
Deletion Conditions:
- When a transaction with a
TicketSequenceis applied to the ledger, with either atesSUCCESSor ateccode, thatTicketis removed from the ledger.
Tickets cannot be canceled; they must be consumed to be removed.
Account Deletion Blocker: TODO: content pass.
3.1.6. Invariants¶
- There is no overlap between valid
Sequencevalues and validTicketSequencevalues for a given account:<Ticket>.TicketSequence < <AccountRoot>.Sequencefor the owning account. - Only the account that created the
Ticketcan use theTicketin a valid transaction.
3.1.7. RPC Name¶
RPC Type Name: ticket
3.1.8. Example JSON¶
TODO: content pass.
3.2. Ledger Entry: AccountRoot¶
3.2.1. Object Identifier¶
The object identifier of this ledger entry does not change.
3.2.2. Fields¶
| Field Name | Constant | Required | Internal Type | Default Value | Description |
|---|---|---|---|---|---|
| TicketCount | No | Conditional | UINT32 | 0 |
The number of Tickets the account owns. Present when the account owns one or more Tickets. |
3.2.2.1. TicketCount¶
To track the number of Tickets an account owns, a new unsigned 32-bit optional TicketCount field is added to the AccountRoot. If an account has one or more Tickets the TicketCount is maintained to reflect the total owned. If the number of owned Tickets ever drops to zero, then the (optional) field is removed from the AccountRoot.
3.2.3. Ownership¶
The ownership of this ledger entry does not change.
3.2.4. Reserves¶
The reserves of this ledger entry do not change.
3.2.5. Deletion¶
The deletion rules of this ledger entry do not change.
3.2.6. Invariants¶
<AccountRoot>.TicketCountequals the number ofTicketentries the account owns.<AccountRoot>.TicketCount, if present, is not zero.<AccountRoot>.TicketCountis at most 250.
3.2.7. RPC Name¶
The RPC name of this ledger entry does not change.
3.2.8. Example JSON¶
TODO: content pass.
3.3. Transaction: Common Fields¶
All transactions associated with an account (i.e., not pseudo-transactions) can use a TicketSequence in place of the Sequence. Doing this allows the transaction to be submitted to the network in any order and not be blocked by unvalidated transactions with earlier (or later) TicketSequence or Sequence numbers.
3.3.1. Fields¶
| Field Name | Required | JSON Type | Internal Type | Default Value | Description |
|---|---|---|---|---|---|
| Sequence | Yes | number | UINT32 | N/A | The Sequence number of the transaction, or zero if the transaction uses a TicketSequence. |
| TicketSequence | Conditional | number | UINT32 | N/A | The TicketSequence value of a Ticket that is currently owned by the Account. Required when Sequence is zero. |
3.3.1.1. Sequence¶
The Sequence field is always required, but if a TicketSequence is present the Sequence field must be zero. When an account root is created it always gets a Sequence greater than zero, and since the account root Sequence field is incremented, it can never validly have a value of zero. If the Sequence is zero in a transaction, then there must be a TicketSequence.
3.3.1.2. TicketSequence¶
In order to allow Tickets to be consumed by transactions, all transactions associated with an account allow an optional TicketSequence field.
If the Sequence is zero then, in order to be a valid transaction, the presence of the Ticket in the ledger must be verified before the transaction is applied. If the Ticket is not found in the local ledger then the transaction is not forwarded to the network. Instead, the transaction is queued locally to be retried on the next ledger. The transaction will not be forwarded to the network until the appropriate Ticket is found in the local ledger.
Tickets are created in Sequence order, but with potential gaps. So by looking at the Sequence field of the account root we can determine if a transaction with a Ticket can never succeed:
- If a transaction uses a
Ticketand - The transaction's account root
Sequenceis past theTicketSequencenumber, and - The
Ticketis not in the ledger, then- The
Ticketwas created and already consumed or - The
Ticketnever was (and can never be) created.
- The
- At any rate, that
Ticketcan never become available for this transaction, so the transaction can never succeed.
Similarly, if a transaction uses a TicketSequence with a number that is equal to or higher than the account root Sequence field, then it is a transaction from the future. It is retried a few times (on upcoming ledgers) to see if that Ticket ever gets created. But the retry is local to the machine where the transaction was submitted. The transaction will not be forwarded to the network unless the Ticket is actually seen in the local ledger.
Canonical order. Transactions are applied to a final ledger in a canonical order. Every node on the network must use this same ordering so the nodes agree on the ledgers they construct. The sorting must allow for the possibility of two transactions having the same Sequence number or the same TicketSequence; if that occurs then only one transaction with a given Sequence number or TicketSequence is actually accepted into the ledger. Transactions with Tickets are sorted behind all transactions with Sequence numbers for a given account. Two transactions are compared this way:
- The smaller account ID goes in front. If the account IDs are equal, then...
- The smaller non-zero
Sequencenumber goes in front. ZeroSequencenumbers go to the back. If theSequencenumbers are equal, then... - If both transactions have
TicketSequences then theTicketSequencewith the smaller number goes to the front. If either transaction has noTicketSequenceor if theTicketSequencenumbers are the same, then... - The smaller transaction ID goes in front. There should never be equal transaction IDs.
3.3.2. Transaction Fee¶
The fee for transactions does not change.
3.3.3. Failure Conditions¶
3.3.3.1. Data Verification¶
- The
Sequencefield is omitted. The transaction is malformed. (TODO: content pass — result code.) - The transaction includes both a non-zero
Sequencenumber and aTicketSequencefield. The transaction is malformed and returns atemcode. (TODO: content pass — exact result code.) - The transaction uses a
TicketSequenceand also includes anAccountTxnIDfield (temINVALID).
3.3.3.2. Protocol-Level Failures¶
- The transaction uses a
TicketSequence, theTicketis not in the ledger, and the account rootSequenceis past theTicketSequence. The transaction can never succeed; it fails with atefcode and is never forwarded to the network. (TODO: content pass — exact result code.) - The transaction uses a
TicketSequencethat is equal to or higher than the account rootSequence, and theTicketis not in the local ledger. The transaction is retried locally and is not forwarded to the network. (TODO: content pass — result code.)
3.3.4. State Changes¶
Every transaction that operates on an Account leaves some kind of artifact in the ledger. Without Tickets, at a minimum, every transaction on an Account causes the Sequence of that account root to increment. With Tickets we lose that guarantee of the Sequence increment, but there are still guaranteed changes to the ledger, including to the account root.
When a transaction that uses a TicketSequence is applied to the ledger, with either a tesSUCCESS or a tec code:
- The consumed
Ticketis removed from the ledger. - The
Ticketis removed from the account's directory. - Consuming the
Ticketdoes not advance the account rootSequence. This also applies to a transaction that generates ateccode: instead of advancing the account rootSequence, theTicketthat was in the transaction is removed from the ledger. ATicketCreatethat uses aTicketstill sets the account rootSequenceas TicketCreate State Changes describes. - The
PreviousTxnIDfield in the account root is modified to contain the hash of the transaction that consumed theTicket. - The account root
TicketCountis decremented, and removed if it reaches zero. - Typically the
OwnerCountfield in the account root decreases, but that is not required. If the transaction adds one entry to the account's directory, then the removedTicketis counter-balanced by the added directory entry (say anOffer) which could cause theOwnerCountfield to be left unchanged. - Typically the account root
Balancefield changes due to the fee, but this too is not required. If the transaction does not require a fee (for example, a Key Reset Transaction) then no fee is consumed. Or, say with aCheckCashtransaction, the transaction could bring just enough XRP into the account to counterbalance the fee. If this were to occur, then theBalancewould not change. - Ledger objects that use the transaction's
Sequencein their ledger index use theTicketSequencein its place.OfferandCheckstore theTicketSequencein theirSequencefield and use it to build their ledger index.EscrowandPayChanneluse it to build their ledger index but do not store it.
3.3.5. Example JSON¶
A transaction using a Ticket with TicketSequence 12:
{
"Account" : "rDg53Haik2475DJx8bjMDSDPj4VX7htaMd",
"Fee" : "40",
"Flags" : 2147483648,
"Sequence" : 0,
"SetFlag" : 4,
"Signers" : [
{
"Signer" : {
"Account" : "rwSqb8mM4hd7oKTiNWVzvjArgUnF2qYuhW",
"SigningPubKey" : "EDD5DCA7954DAB...49225E107A15781",
"TxnSignature" : "E4E23FC9FE7E7D8...B849B250651EB05"
}
}
],
"SigningPubKey" : "",
"TicketSequence" : 12,
"TransactionType" : "AccountSet"
}
3.4. Transaction: TicketCreate¶
A TicketCreate transaction adds one or more Tickets to the account that sends it. Any signature that's valid for the account creating the Ticket(s) is acceptable.
3.4.1. Fields¶
| Field Name | Required | JSON Type | Internal Type | Default Value | Description |
|---|---|---|---|---|---|
| TransactionType | Yes | string | UINT16 | TicketCreate |
Identifies this as a TicketCreate transaction. |
| TicketCount | Yes | number | UINT32 | N/A | The number of Tickets to add to the account, from 1 to 250. |
A TicketCreate transaction may itself use a Sequence or a TicketSequence (see Transaction: Common Fields).
3.4.2. Flags¶
TODO: content pass.
3.4.3. Transaction Fee¶
Fee Structure: Standard
The fee for the transaction that creates one or more Tickets is the same fee as for other standard transactions.
3.4.4. Failure Conditions¶
3.4.4.1. Data Verification¶
TicketCountis less than 1 or greater than 250. (TODO: content pass — result code.)
3.4.4.2. Protocol-Level Failures¶
- The Account would end up with more than 250
Tickets in ledger as a consequence of thisTicketCreate(tecDIR_FULL). - The Account does not have sufficient funds to meet the reserve for all requested
Tickets (tecINSUFFICIENT_RESERVE).
3.4.5. State Changes¶
Either all of the requested Tickets are created or none of them are. If successful, this transaction:
- Creates
TicketCountTicketobjects. - Inserts tracking entries in the owner directory of the
Accountfor each of the createdTickets. - Increments the account's owner count by the number of
Tickets created. - Sets or increments the account root
TicketCount. - Assigns
TicketSequencevalues:- If the
TicketCreatetransaction uses aSequence, then the first createdTicketholds as itsTicketSequencefield a value one greater than theSequencenumber of the transaction. - If the
TicketCreatetransaction uses aTicketSequence, then the first createdTicketholds as itsTicketSequencefield the value of the account rootSequence. - Each subsequent
Ticketcreated by the transaction holds as itsTicketSequencefield a value one greater than the previously createdTicket. All of theTickets created in the same batch have contiguous integral values.
- If the
- Sets the account root
Sequenceto one greater than theTicketSequencevalue of the lastTicketcreated.
For example, Alice sends a TicketCreate transaction with Sequence 7 and TicketCount 1. The Ticket it creates has TicketSequence 8, and Alice's account root Sequence moves to 9. So if Alice then tries to send a transaction with Sequence 8 she'll get a tefPAST_SEQ error. Alice then does a TicketCreate with TicketSequence 8. Since Alice's account root Sequence is 9, the new Ticket gets TicketSequence 9, and Alice's account root Sequence moves to 10. If she then sends a TicketCreate with a TicketCount of 100 and Sequence 10, it creates Tickets with TicketSequence values 11 through 110, and her account root Sequence has the value 111 when the transaction completes.
3.4.6. Example JSON¶
The following example is a TicketCreate transaction that creates 250 Tickets and includes 4 multisigners.
{
"Account" : "rDg53Haik2475DJx8bjMDSDPj4VX7htaMd",
"TicketCount" : 250,
"Fee" : "70",
"Flags" : 2147483648,
"Sequence" : 5143,
"Signers" : [
{
"Signer" : {
"Account" : "rwSqb8mM4hd7oKTiNWVzvjArgUnF2qYuhW",
"SigningPubKey" : "EDD5DCA7954DAB...49225E107A15781",
"TxnSignature" : "E4E23FC9FE7E7D8...B849B250651EB05"
}
},
{
"Signer" : {
"Account" : "rBfCNiAc4rvrhLEm71j9kwLoScAStMpbf3",
"SigningPubKey" : "EDE71DB591D0A5...DE26745A47DCC7C",
"TxnSignature" : "A118FFCB7335BCA...524F075E8BEEB0A"
}
},
{
"Signer" : {
"Account" : "rLHuMZjp7BeRJu2t8U39y5DemiJuYKo6zV",
"SigningPubKey" : "03A9A1C13BEE02...0AF8832B1579AB9",
"TxnSignature" : "3045022100FA0E7...3E293D372418478"
}
},
{
"Signer" : {
"Account" : "rPstfVBNeskmior1fDET8429fJYBhRMJNh",
"SigningPubKey" : "034932968FF101...E696F11314B56F2",
"TxnSignature" : "3045022100F44F0...4F4F7EC062E55F7"
}
}
],
"SigningPubKey" : "",
"TransactionType" : "TicketCreate",
}
3.5. RPC: account_objects¶
The account_objects RPC command is modified to accept "type": "ticket" in its arguments.
3.5.1. Request Fields¶
| Field Name | Required | JSON Type | Description |
|---|---|---|---|
| type | No | string | "ticket" causes the command to return all of the Ticket objects on the account. |
3.5.2. Response Fields¶
TODO: content pass.
3.5.3. Failure Conditions¶
TODO: content pass.
3.5.4. Example Request¶
TODO: content pass.
3.5.5. Example Response¶
TODO: content pass.
3.6. RPC: ledger_data¶
The ledger_data RPC command accepts an argument "type". The command is augmented to support "type": "ticket".
3.6.1. Request Fields¶
| Field Name | Required | JSON Type | Description |
|---|---|---|---|
| type | No | string | "ticket" returns only Ticket ledger objects. |
3.6.2. Response Fields¶
TODO: content pass.
3.6.3. Failure Conditions¶
TODO: content pass.
3.6.4. Example Request¶
TODO: content pass.
3.6.5. Example Response¶
TODO: content pass.
3.7. RPC: ledger_entry¶
The ledger_entry command is modified to return a Ticket object.
3.7.1. Request Fields¶
| Field Name | Required | JSON Type | Description |
|---|---|---|---|
| ticket | No | string or object | The Ticket to return, specified either as a string containing the Ticket index as hexadecimal, or as a JSON object containing an "owner" and a "ticket_sequence" field. |
3.7.2. Response Fields¶
TODO: content pass.
3.7.3. Failure Conditions¶
TODO: content pass.
3.7.4. Example Request¶
TODO: content pass.
3.7.5. Example Response¶
TODO: content pass.
4. Rationale¶
Creating a replacement for something as fundamental as sequence numbers in transactions is delicate work. The design is as simple as possible. But even with that, there are a lot of details to attend to.
4.1. Why Sequence Numbers?¶
We need to start by understanding why each account has a sequence number in the first place.
The most important role of the Sequence number is that it makes each transaction on an account unique. Consider if Zoe created a transaction to pay 10,000 XRP to Brent. Once that transaction is validated in the ledger what prevents that transaction from being arbitrarily replayed time and again? All of the data in the transaction is correct and the transaction is correctly signed. Otherwise the transaction would not have been validated in the first place. If a transaction is valid, what is it that makes that transaction only valid one time?
The rule that a Sequence number may not be re-used in two or more transactions is what keeps Zoe's transaction from being reused. So, because of that Sequence number, Zoe can have confidence that her transaction will only be validated once.
Additionally, the Sequence number plays a role in guaranteeing that each validated transaction in the ledger has a unique hash. The uniqueness of the hash of each validated transaction is important because all transactions are located in the ledger by their hashes. The ledger is not set up to handle hash collisions because hash collisions are not expected to ever occur. The hash of each transaction is, in part, guaranteed to be unique because the serialized data in each transaction (which includes the Sequence number) is guaranteed to be unique.
What matters for both of these considerations is that the Sequence number must be unique for each transaction on the account. They don't really need to be sequential. But there's a lot of complexity that is reduced by requiring each Sequence number to be consecutive. If they are consecutive then they will automatically be unique (until the integer overflows). And consecutively produced and consumed Sequence numbers are easy to think about and compute.
So whatever we do with Tickets needs to carefully:
- reproduce the uniqueness that
Sequencenumbers provide while - removing the requirement for consecutiveness.
Sequence numbers are heavily used throughout the XRP Ledger for several different purposes. There are four primary ways in which Sequence numbers affect the ledger and transaction processing:
- All transactions use the
Sequencenumber to verify that the transaction is unique in the ledger and that the hash of the validated transaction is unique. - Some transactions use the
Sequencenumber as a persistent identifier in a ledger object. This happens both...- Explicitly (
Offers andChecks) and - Implicitly (
EscrowandPayChan).
- Explicitly (
- The
Sequencenumber of a transaction is used to sort transactions. This is important because- Transactions are actually applied to a final ledger one-at-a-time in that sorted order and
- The Transaction Queue (
TxQ) stores queued transactions in that order.
- The account ID and
Sequencenumber of a transaction can be used to identify all of the validated transactions associated with an account, as well as the order of those transactions.
All of these behaviors are affected by the presence of Tickets in transactions.
4.2. Unique Transaction Hash¶
A transaction that uses a Ticket has a different hash from the same transaction using a Sequence number. Compare the Example JSON in Transaction: Common Fields with the same transaction using a Sequence number:
{
"Account" : "rDg53Haik2475DJx8bjMDSDPj4VX7htaMd",
"Fee" : "40",
"Flags" : 2147483648,
"Sequence" : 12,
"SetFlag" : 4,
"Signers" : [
{
"Signer" : {
"Account" : "rwSqb8mM4hd7oKTiNWVzvjArgUnF2qYuhW",
"SigningPubKey" : "EDD5DCA7954DAB...49225E107A15781",
"TxnSignature" : "E4E23FC9FE7E7D8...B849B250651EB05"
}
}
],
"SigningPubKey" : "",
"TransactionType" : "AccountSet"
}
By examining the differences between these two transactions you can see that they will generate different hashes:
- The
Sequencefield is present in both transactions, but in one transaction it's non-zero, in the other it's zero. - The
TicketSequencefield is new in the transaction that uses theTicket.
(Sequence field rollover could be a possibility a few years out from now. Before it becomes an issue there will be a different ledger feature to prevent Sequence rollover from happening before the Sun goes Red Giant.)
4.3. TicketSequence Values¶
What is the integer value of the TicketSequence associated with each Ticket? Uniqueness is an important consideration here. There's really one rule, but exactly how that rule is applied depends on how the Ticket is created.
Rule: Each created
Ticketuses as itsTicketSequencethe next value that would be appropriate for the account root'sSequencefield. It then modifies the account rootSequencefield to be one greater than the largest createdTicketSequence.
By moving the account root Sequence past every created TicketSequence, we make sure that the account will not have any valid transactions where the Sequence and the TicketSequence values are the same. One valid way to think of this is that creating a Ticket reserves the corresponding Sequence number value so it can be used later. We'll be using it out of order, so we're calling it a TicketSequence, but the value is reserved.
4.4. Ledger Objects That Use the Sequence Number¶
Offers are the classic ledger type that incorporates a Sequence field. The Sequence of the transaction is also used to build the index of the Offer in the ledger. If we create an Offer using a Ticket instead of a Sequence, we certainly can't use the Sequence to build the Offer; the Sequence is zero. We'll need to use the TicketSequence number.
If we do this will we need to be concerned about creating Offers in the ledger with duplicate ledger indexes? Fortunately no. Because of how TicketSequence values are computed, there is no overlap between valid Sequence values and valid TicketSequence values for a given account.
Is there any way that an XRP Ledger user can receive an advantage by creating an Offer with a Sequence number that is earlier than an Offer they created before? First, how could that happen?
- Anne creates a
TicketwithTicketSequence3. - Anne creates an
OfferwithSequence4. - Anne creates an
Offerusing theTicketshe previously created. ThatTickethasTicketSequence3. So this newestOfferhas aSequenceof 3, which came from theTicket.
In this example Anne's most recently created Offer has a Sequence of 3, which precedes an older Offer with Sequence 4.
Now that we understand how it can happen, is there any advantage to be gained from it? As far as I can tell, no. An Offer has value based on where it is located in its Book. Each Book for a currency pair is separated into sections. Each section of that Book contains Offers of exactly the same quality. When a new Offer is added to the Book, that Offer is appended to the other Offers in that section. So, even though the Offer has an earlier Sequence number, the position of the Offer in the Book is unaffected.
The same thought process applies to Checks with Tickets. Building a Check using a TicketSequence number in place of a Sequence number cannot lead to duplicate ledger indices for Checks. And there is absolutely no advantage to be gained by creating Checks out of Sequence order.
Escrow and PayChannel use the Sequence when constructing their ledger indices, but they do not store the Sequence number in the ledger object. These two ledger types have the same concerns as Offers in terms of uniqueness, and the answer is also the same. Since there is no overlap between an account's Sequence and TicketSequence values, the transaction's TicketSequence could not have been used to previously create an Escrow or a PayChannel.
4.5. Creating Lots of Tickets¶
There are problems with creating only one Ticket at a time on an account with multiple required human signers. For example, it doubles the work. You must create a transaction to create a Ticket. Then you must create the originally intended transaction and apply the Ticket. And all of those transactions must be signed by all of the required signers. If that were the state of the art, then Tickets would not be worth the effort.
So we allow one TicketCreate transaction to create a whole bunch of Tickets in one fell swoop. There is still the hassle of making a transaction and getting it signed by all of the multisigners. But only one transaction needs to be signed and submitted to create up to 250 Tickets. This seriously reduces, but does not eliminate, the hassle factor.
The XRP Ledger sets a limit on the amount of metadata one transaction is allowed to create. The question came up, how close is a transaction that creates 250 Tickets to that limit? Given an initial implementation of Tickets, it was found that 5,041 Tickets could be created in a single transaction without excessive metadata. So setting the limit at 250 leaves us over an order of magnitude away from the boundary. That seems like enough safety margin.
4.6. Transaction Ordering¶
There are two places where unfinished transactions are sorted: transaction processing, where transactions are applied to a final ledger in canonical order, and transaction queuing, where the transaction queue (TxQ) sorts queued transactions by fee, account, and Sequence number. If someone can game that ordering there's the potential for someone to make money by gaming the system.
The previous canonical order compared account ID, then Sequence, then transaction ID. This comparison methodology is insufficient once we can submit a transaction using a Ticket. For one thing, since the Sequence for a transaction with a Ticket is zero, transactions with Tickets would always be sorted to the front and then sorted by transaction ID.
There are a variety of sort orders which take TicketSequence into account that could be used. The one we ended up with sorts transactions with Tickets behind all transactions with Sequence numbers for a given account. How we ended up with this sort order is mostly a historical accident. But it's an easy sort order to understand and it is working well. So there's no motivation to change the sort order at this point.
4.7. Tickets and tec Errors¶
Usually a transaction that generates a tec has small but important interactions with the ledger: the transaction's fee is removed from the account root, and the account root's Sequence number is advanced by 1. There is one tec code (tecOVERSIZE) that has more impact on the ledger; it also removes a collection of unfunded and expired offers. But, under ordinary circumstances, a transaction that generates a tec code does not change the ledger very much.
If the transaction generating the tec is also consuming a Ticket we can't advance the account root Sequence. Instead the Ticket is removed from the ledger. This is not a big change, but it's worth drawing people's attention to the change so they can think about it.
4.8. Tickets and the AccountTxnID Field¶
The AccountTxnID field allows you to chain your transactions together. A transaction that specifies an AccountTxnID field is only valid if the specified transaction ID matches the transaction that was last sent by the account. Tickets on the other hand are intended to remove restrictions on transaction ordering. Combining these two features makes it very difficult for the TxQ to predict whether a transaction is likely to succeed. If we find a crying need for such a feature in the future, then we can figure out how to implement it well.
4.9. A New Amendment¶
The Tickets amendment has been in rippled for as long as there have been amendments. However this proposal introduces significant changes from the partial Tickets implementation that has been in place for the past years. In similar situations in the past we have chosen to use a new amendment, rather than use the old amendment name, to introduce the heavily modified feature.
The motivation for using a new amendment name is as follows:
- The old amendment exists in old versions of the rippled software.
- Therefore an old version of the software could enable the new amendment and yet not be compatible with the latest version of the feature.
Whereas if we change the amendment name then an old version of the software would not be able to enable the amendment; even partial support is not present in the old version of the software. In this case the old version of the software would become amendment blocked, which is exactly what we want.
4.10. Roads Not Taken¶
The Tickets proposal has been around for a while. Here are some additional features that have been considered and are not part of the current implementation.
4.10.1. Ticket Targets¶
The original Tickets proposal allowed an account to create a Ticket with a Target. The Target would be an account ID that is different from the account creating the Ticket. A Ticket with a Target could be consumed by either the account that created the Ticket or by the Target account.
The goal was to have one account that would only be used to produce Tickets for an organization. Then those Tickets could be assigned, using Target, to whatever accounts needed them.
However consider this scenario:
- Bucky creates a
Ticketwith Cap's account as theTarget. Bucky's account is atSequence5, so theTicketis assigned 5. - In the mean time, Cap's account is also at
Sequence5. Cap creates an Offer on his account usingSequence5. Cap's offer goes in the ledger. - Bucky tells his pal Cap that the
Ticketis available. - Cap uses that
Ticketto create anotherOffer. This newOfferalso hasSequence5, since that is the number on theTicket. - If we take this to its logical conclusion, then Cap has two different
Offers in the ledger with identical ledger indices: theOfferhe made with theSequenceand theOfferhe made with theTicket.
If including the Target were really important there would probably be ways of working around this difficulty. But any solution would impact the way that Offer, Check, Escrow, and PayChan ledger indices are calculated. That would be a very invasive change. We should think very hard before deciding to make that kind of change to the ledger.
4.10.2. Ticket Expiration¶
When Tickets had Targets, it was thought that it might be useful to give a Ticket an optional Expiration, similar to Offers. However, at the moment, a Ticket can only be used by the account owning that particular Ticket. So there seems to be very little value in giving an Expiration to a Ticket.
4.10.3. Ticket Cancel Transactions¶
When Tickets had an Expiration field it was thought that a TicketCancel transaction would be necessary. Otherwise how could an expired Ticket be removed from the ledger? However since Tickets, in this proposal, do not expire then TicketCancel transactions no longer fill a useful role. So TicketCancel is no longer proposed. If a Ticket needs to be removed from the ledger it can be consumed by any transaction on its account like, for example, a noop. See https://xrpl.org/about-canceling-a-transaction.html.
4.10.4. Special Handling for Account Root Sequence Jumps¶
One of the features of the XRP Ledger is that the full transaction history of an account can be reconstructed. Prior to Tickets if you found the transactions for every Sequence number on an account, then you know you have every transaction and you also know the order in which those transactions were applied to the ledger. With Tickets things get more complicated.
The transaction metadata still contains the full story. But you can't simply look at the Sequence number.
- If the account root
Sequencenumber does not change between two transactions, then the metadata will show aTicketnode being deleted. - If the account root
Sequencenumber leaps between transactions, then the metadata will show as manyTickets being created as the size of theSequencenumber leap.
If folks decide that digging around in metadata looking for Tickets being created or deleted is too messy we could choose to add artifacts to the account root to annotate the change. Such account root additions would be purely to help external tools understand chains of transactions.
For a straw man, let's propose that we add two new optional fields in the account root:
SubSequence, andJumpSequence.
SubSequence would work as follows:
- We'd add a new optional account root entry called
SubSequence, it would be 32-bit unsigned. - When we execute a transaction with a normal
Sequencenumber, we remove theSubSequencefield, if present. - When we execute a transaction with a
Ticket:- If no
SubSequencefield exists in the account root, we create one and set it to 1. - If a
SubSequencefield exists in the account root, we increment it.
- If no
This will cause the metadata in the account root of the transaction to indicate whether the prior transaction was a ticketed one or not. And it doesn't (in general) tend to make the ledger larger since the SubSequence field is removed once we're done with it.
The SubSequence field would be sufficient to deal with the presence of Tickets in transactions. But it would not be sufficient to cover batch creation of Tickets. We would need yet another account root field to indicate that the Sequence number had taken a leap. For that we could consider adding an optional JumpSeq field to the account root. Its rules would be:
- We'd add a new optional account root entry called
JumpSequence, it would be 32-bit unsigned. - When we execute any transaction other than
TicketCreatethen we remove theJumpSequencefield if it is present. - When we execute a
TicketCreatetransaction:- If no
JumpSequencefield exists in the account root, we create one and set it to the count. - If a
JumpSequencefield already exists in the account root, set it to the count.
- If no
We have seen no evidence that tools outside the XRP Ledger need this kind of information. So the additional fields are not being added.
4.10.5. TicketSignerQuorum¶
It requires the full complement of multisigners to construct a valid TicketCreate transaction. It has been suggested that this pain could be reduced by adding an optional TicketSignerQuorum field to the SignerList.
For those unfamiliar with multisigning in the XRP Ledger, an account is made multisigning by adding a SignerList to that account using the SignerListSet transaction. Each SignerList consists of one to eight signers, where each signer has a SignerWeight and the entire list has a SignerQuorum. For a transaction to be validly multisigned it does not need all signers, it only needs enough signers so that the sum of their SignerWeights meets or exceeds the SignerQuorum.
By providing a TicketSignerQuorum, and having that value be smaller than the regular SignerQuorum, the creator of the SignerList would allow a TicketCreate transaction to require fewer signers. In fact, they could meet the Ticket creation quorum with a single (multisigned) signature if they set the TicketSignerQuorum to one. A SignerListSet transaction which set the TicketSignerQuorum larger than the SignerQuorum would be malformed.
The TicketSignerQuorum value would be a one-trick pony. The only time the TicketSignerQuorum would be checked would be on TicketCreate transactions. In all other cases the regular SignerQuorum would be checked.
This feature has not been added. Once Tickets are in active use on the network we may find that this would be a desirable feature. If so, we can add it at that later time.
5. Backwards Compatibility¶
The preexisting Tickets amendment is removed, and the new TicketBatch amendment enables the features in this specification. Even though the Tickets amendment has been available for a long time it has never been enabled. Since it was never enabled, removing the amendment will not leave any servers amendment blocked.
The account_tx RPC command has been tested with Tickets. No modifications to that command are required in order to support Tickets.
6. Security Considerations¶
The point of Tickets is to allow execution of transactions out of order. That, in turn opens up some vulnerabilities in the ledger. Here's what has been identified so far:
6.1. Submit Order is not Canonical¶
Prior to Tickets all transactions on a single account had to be submitted to the ledger in canonical order. With Tickets you can submit a transaction with TicketSequence 5 followed by TicketSequence 4. If they are submitted quickly enough they will probably both go into the same ledger. They will be applied to the ledger in canonical order (4 followed by 5). Suppose that Tickets 4 and 5 are already in the ledger and the following transactions are submitted:
Submit Order:
AccountSet signed with current Regular Key and uses Ticket 5
SetRegularKey replaces Regular Key and uses Ticket 4
Applied To Ledger (Canonical Order):
SetRegularKey replaces Regular Key and uses Ticket 4
AccountSet signed with replaced Regular Key and uses Ticket 5
So the transactions work in submit order. The local rippled tries them in that order when the transactions are initially submitted to the network. Since the transactions both succeed in submit order, the transactions are forwarded to the full network.
The validators apply the transactions in canonical order. In canonical order the SetRegularKey is applied to the ledger first. So the AccountSet transaction fails; it has the wrong signature. Since the signature is wrong we cannot charge the fee. So the entire network has processed a transaction that is guaranteed to fail and a fee is not charged.
This is really a new version of a preexisting attack. A similar attack can be made by submitting two different transactions on the same account, and using the same Sequence number, but to two different rippled client handlers. Both of the transactions are valid, so the two client handlers will individually forward both transactions to the full network. One transaction will win and the other will fail with a tefPAST_SEQ. The one that fails is wasted work by the entire network.
6.2. Reordering Before Validation¶
Both the TxQ and the canonical sort orders leave open the possibility that games could be played by doing a late insertion of a transaction in front of a transaction that was already posted (but is not yet in a validated ledger).
Here are two different ways this reordering could happen:
- Inserting in front by selective use of
Tickets:- Abril creates a wad of
Tickets on her account. - She submits a transaction using a high numbered
TicketSequence. - She submits a second transaction with a lower numbered
TicketSequence. - As long as neither transaction has been validated, the second transaction she submitted will be sorted in front of the earlier transaction.
- Abril creates a wad of
- Inserting in front by selective use of
Sequencenumbers andTickets:- Vita creates a few
Tickets on her account. - She submits a transaction using a
TicketSequence. - She submits a second transaction using a (plain)
Sequencenumber. - As long as neither transaction has been validated, the second transaction she submitted (the one with the
Sequencenumber) will be sorted in front of the earlier transaction (with theTicketSequence).
- Vita creates a few
I'm not convinced that we need to worry about this kind of reordering.
- Any reordering that does happen is limited to the account that owns the
Ticket(s). - The
TxQalready allows the account owner to replace one transaction with another by re-issuing a transaction with the same sequence but a higher fee. To the best of our current knowledge this is not being used to manipulate the ledger.
Someone who's more clever with possible ledger manipulations may have ideas for how this kind of reordering could be abused. If so I'm all ears.
6.3. Tickets as Ledger Spam¶
There are two different kinds of ledger spam:
- One form of spam is transactions that use up bandwidth and compute power but accomplish very little. The transaction fee is intended to combat this form of spam.
- The other form of spam is excessive in-ledger storage by an account. The account reserve is intended to combat this form of spam. As an account keeps more objects in ledger, the reserve on that account increases. The account is motivated to reduce the in-ledger storage because they get the reserve back when an object they own is removed.
It is possible to argue that the account reserve is not always effective as a deterrent. Anyone who has a large amount of XRP that doesn't need to be liquid can tie up that liquidity in their reserve. They are not motivated to reduce that reserve until they need the liquidity. In effect they can view their reserve simply as a form of escrow.
This means a hostile or un-caring user with lots of XRP could create millions of Tickets on their account. The entire network must pay the price for such volume in the ledger. So it makes sense to take preemptive steps to avoid this problem.
6.3.1. Approaches to Managing Ticket Ledger Spam¶
Four different approaches to managing this possible ledger spam were explored:
- We could change the
Ticketstorage format so multipleTickets occupy less space in the ledger. - We can reduce the number of
Tickets that a singleTicketCreatetransaction can produce. - We can make it more costly (increase the fee) for adding
Tickets. - We can limit the number of
Tickets an account is allowed to keep in-ledger.
An extended discussion occurred. The conclusion was to choose limiting the number of Tickets any individual account root can hold.
6.3.2. Limiting the Number of Tickets an Account Can Keep In Ledger¶
For ticket count limiting to be effective, we need to make the number of Tickets an account holds easy to discover. So we added an optional 32-bit TicketCount field to the account root. That optional TicketCount must be maintained with every Ticket-based operation. With this field the account's TicketCount can easily be found by looking in a single central location.
Once we have this TicketCount it becomes easy to set an arbitrary cap for the number of Tickets an account can keep in ledger. The cap only needs to be enforced for TicketCreate transactions.
The only remaining question is the behavior when a TicketCreate would exceed the maximum threshold. The behavior we picked was to start with a threshold of 250 Tickets. If a TicketCreate transaction would cause the number of Tickets held by an account to exceed that threshold, then the TicketCreate fails with a tecDIR_FULL error. If the resulting TicketCount is at or below the threshold, then all of the requested Tickets are created. This means, since the maximum number of Tickets one TicketCreate can produce is 250, that maximum number can only be created if the account in question has no Tickets.
Appendix¶
Appendix A: FAQ¶
A.1: Are Tickets required for using the XRP Ledger?¶
No. Tickets address a specific use case where submitting transactions in a pre-determined order is inconvenient. If you don't have that use case you do not need to know about Tickets.
A.2: How much does a Ticket cost?¶
The fee for the transaction that creates one or more Tickets is the same fee as for other standard transactions. So, for example, multisigning the transaction makes it more expensive than signing with the master key or a regular key. But there are no special or unusual costs associated with the transaction.
In addition to the fee for the transaction, each Ticket held by an account increases that account's reserve. That reserve is correspondingly reduced when each Ticket is consumed.
A.3: How many Tickets can I create in a single transaction?¶
From 1 to 250. The compute time required for a CreateTicket transaction to add 250 Tickets to the ledger is slightly less that the compute time required by a single complicated (3 path) payment. So the compute time to create 250 Tickets has a reasonable bound.
A.4: How many Tickets can I keep in my account?¶
Up to 250. There has been minor concern about the possibility of (virtually) unlimited Tickets owned by an account as being a form of ledger spam. We are preemptively removing that possibility. If the 250 limit is found to be too restrictive in practical situations then the limit is easy to increase (albeit with an amendment).
A.5: Can I create a Ticket on one account and use it in a different account?¶
No. The TicketSequence number that each Ticket captures must be one that is associated with the account that creates the Ticket. See the Ticket Targets discussion.
A.6: How do I cancel a Ticket?¶
Tickets cannot be canceled, they must be consumed to be removed. One way to do that would be to associate a Ticket with a NOOP transaction (an AccountSet that changes nothing). Another way to do it would be to use a Ticket in a transaction that will generate a tec error code.
Since Tickets don't expire we don't foresee a need for an account to remove large numbers of Tickets.
A.7: How can I get a list of the Tickets on my account?¶
The account_objects RPC command can be used to list all objects held by an account. Specify "type": "ticket" to get only the un-consumed Tickets.
A.8: What happens if I use the same Ticket in two different transactions?¶
Assuming that the Ticket is valid, at most one of those two transactions will be accepted into a validated ledger. When the first transaction is validated its Ticket is consumed. When the server sees the second transaction, it will note that the transaction is using a Ticket that is not in the ledger (since the first transaction consumed it) and could never be created. So the second transaction will fail with a tef code and never be forwarded to the network.
A.9: How do I know which Tickets I can use?¶
The account_objects RPC command answers only part of this question. It tells you which Tickets are available, in ledger, for use.
However if you have several transactions simultaneously getting signed outside of the ledger, then you must personally take steps to not use the same Ticket in two or more of those transactions. If you have responsibility for only one account then tracking is easy; just note the integer value of each TicketSequence you use. If you are responsible for several accounts, then you must keep separate lists for each of the accounts.
If several transaction creators are sharing one account, then they need to create a policy for which user can use which Tickets. Fixed schemes (e.g., Alice gets even TicketSequences and Bob gets the odd ones) can get out of balance over time. Consider what happens with this policy if Alice writes a lot more transactions than Bob for a prolonged period.
A more sustainable approach for multiple transaction creators is that each party gets an initial set of assigned Tickets. From that point on each party creates Tickets when they need them and uses only Tickets they created. A bit of stewardship is still required in this model. For example, if Bob acquires 230 Tickets, then Alice can create at most 20 Tickets until Bob burns down his supply. People still need to be considerate of their cosigners.
Appendix B: rippled Implementation Notes¶
The following elements are all internal to the rippled software, but are added or changed due to the addition of Tickets.
B.1. Object Identifier¶
/** A ticket */
struct ticket_t
{
Keylet operator()(
AccountID const& owner,
std::uint32_t ticketSeq) const
{
return { ltTICKET, sha512Half(std::uint16_t(spaceTicket), owner, sequence) };
}
Keylet operator()(uint256 const& key) const
{
return { ltTICKET, key };
}
};
B.2. SeqProxy¶
Both the CanonicalTXSet and TxQ need to solve the problem of putting transactions in order, and the rules are changing with the addition of Tickets. It was beneficial to add a new class that captures both the Sequence number and the optional TicketSequence value and provides an ordering.
B.3. CanonicalTXSet¶
The CanonicalTxSet sorts transactions before they are applied to the ledger. The mSeq member of the CanonicalTXSet::Key type is replaced with a SeqProxy. That new member is taken into account in the Key comparison operators. That change has spread out to affect users of the CanonicalTXSet.
B.4. TxQ¶
The TxQ keeps two distinct kinds of ordered lists. One list is of all transactions by FeeLevel. (FeeLevel is similar to the ratio of the actual fee paid to the minimum fee that would allow the transaction into a non-busy ledger.) This particular list ignores account IDs and Sequence numbers. So Tickets will have very little impact in this list. For every AccountID stored in the TxQ there's also a sorted list of the transactions queued for that account. These lists were sorted by Sequence. With Tickets these lists need the same sort order as the CanonicalTxSet.
The TxQ contains a few std::maps that use the transaction's Sequence number as the key. Those keys are replaced with a SeqProxy object. That change has spread out and affected users of the TxQ. Considerable effor was put into making the TxQ and CanonicalTXSet behave as similarly as possible.
The TxQ has the concept of blocker transactions for an account. The TxQ considers a transaction to be a blocker if the transaction changes how later transactions on that account can be signed. So, for instance, a SetRegularKey transaction is a blocker. The introduction of Tickets affects blocker handling by the TxQ.
Prior to the introduction of Tickets the TxQ allowed a blocker to follow other transactions in the account's queue. But once the blocker was in place no more transactions could be added for that account. This rule worked well because without Tickets transactions for a single account were always applied in a well known order: each Sequence had to immediately follow the preceding Sequence. With Tickets that expectation is no longer valid; transactions with Tickets can go into the ledger in any order.
So the rules for how the TxQ handles blockers has changed. A blocker can only be added to the queue for an account if:
- The queue for that account is empty, or
- The blocking transaction replaces the only transaction in the account's queue.
These rules have the effect that a blocker must always be alone in the account's queue. Then, once the blocker has flushed through to the ledger, that account's queue is again open for general use.
B.5. Transactor¶
The Transactor::checkSeq() method needed to take the presence of Tickets into account. That method has been adjusted and renamed to checkSeqProxy(). This method is called during preclaim, so it accomplishes many of the requirements noted in TicketSequence.
B.6. The Transaction Database and Indices¶
One of the SQLite databases that rippled keeps is called the Transaction database. As you might expect, that database stores transactions in a table. It also keeps several indices that make it easier to locate transactions in that database. The Transaction database looks like this:
TABLE Transactions (
TransID CHARACTER(64) PRIMARY KEY,
TransType CHARACTER(24),
FromAcct CHARACTER(35),
FromSeq BIGINT UNSIGNED,
LedgerSeq BIGINT UNSIGNED,
Status CHARACTER(1),
RawTxn BLOB,
TxnMeta BLOB
);
INDEX TxLgrIndex ON
Transactions(LedgerSeq);",
TABLE AccountTransactions (
TransID CHARACTER(64),
Account CHARACTER(64),
LedgerSeq BIGINT UNSIGNED,
TxnSeq INTEGER
);
INDEX AcctTxIDIndex ON
AccountTransactions(TransID);
INDEX AcctTxIndex ON
AccountTransactions(Account, LedgerSeq, TxnSeq, TransID);
INDEX AcctLgrIndex ON
AccountTransactions(LedgerSeq, Account, TransID);
The transaction's Sequence number shows up in the top-most Transactions table as the FromSeq field. But it makes no additional showing in any of the other tables or indexes. Note that it's easy to get confused by the TxnSeq fields in the other tables and indices. But the TxnSeq field is not the Sequence number that is embedded in the transaction. TxnSeq carries the order of transaction application within one ledger – a much different thing.
We spent some time examining these tables and came to the conclusion that they do not need any modifications to take Tickets into account.
The strongest evidence that the Ticket would need to be present in the tables or indices would be if the transaction Sequence field (FromSeq) had a strong present there. Although FromSeq is present at the top-most level of the Transactions table, none of the other indices reference FromSeq.
There are currently two standard methodologies to extract the transactions associated with an account from the Transactions database table. Neither of those methodologies rely on the transaction Sequence. The methodologies are:
- The account_tx rpc command. This command uses the
AccountTransactionstable. The technique is to examine consecutive ledgers byLedgerSeqlooking forAccountand saving the correspondingTransID. Those results are then placed in order first byLedgerSeqand then byTxnSeq.TxnSeqis the order in which transactions were placed in the ledger, not theSequencenumber in the transaction. The order in which all transactions were applied to a ledger must also be the order in which any given account's transactions were applied. - Account threading using the
PreviousTxnIDfield of the account root. By using thePreviousTxnIDfield and walking backwards through transactions using thetxRPC command you can request the last transaction that modified the account. By looking in the metadata of that transaction you can locate the previous value of thePreviousTxnIDfield. You can follow this chain until you run out of history or the account root is created.
Since neither of these methodologies rely on the transaction's Sequence number, they won't be made more efficient by adding Ticket information to the database. We have also worked with the Data team to see if they have any dependency on the FromSeq field (which might indicate a need for TicketSequence information in the table). No dependencies on FromSeq were identified by the Data team. Tests were added to increase confidence.
B.7. RPC Tests¶
Tests for Tickets in account_objects, ledger_data, and ledger_entry are added. ledger_data support for "type": "ticket" occurred as a side effect of the fix for account_objects.