0037 XLS-37d: Improved Concise Transaction Identifier (CTID) #91
Replies: 13 comments 22 replies
-
Can you give an example of how you see an explorer, a developer and a user using this standard? How would we use this? Just some examples might help. |
Beta Was this translation helpful? Give feedback.
-
What does the |
Beta Was this translation helpful? Give feedback.
-
Updated the name from |
Beta Was this translation helpful? Give feedback.
-
All other artifacts (r-address, hashes, ledger index etc) in XRPL are network agnostic. Should CTIDs be network aware? |
Beta Was this translation helpful? Give feedback.
-
Hey, what about putting the network id at the first position? It would allow for indexing in databases (performance) and even fit the acronym, now being "CanonicalTransaction Identifier" - hehehe |
Beta Was this translation helpful? Give feedback.
-
Why not just add a chain id to the transaction itself, which would cause transactions on different chains to always have different hashes? This is what the various EVM chains do to prevent replaying transactions on different chains and to keep hashes unique. |
Beta Was this translation helpful? Give feedback.
-
Stupid question perhaps, but how to I transfer a NetworkId like "testnet" to a int/hex value? |
Beta Was this translation helpful? Give feedback.
-
Here, X represents, Y represents and Z represents is the ledger sequence number, Y is the transaction ID and Z is the network ID. I'd recommend changing the format to either |
Beta Was this translation helpful? Give feedback.
-
CanonicalTransactionIDentifier :) |
Beta Was this translation helpful? Give feedback.
-
@RichardAH Do you mind pushing this spec along through new CONTRIBUTING process that was recently merged? One intention with the new process is that all specs would move through the process in a more overt fashion before code is merged into rippled Of course, this is a somewhat new process, so feedback welcome as we try it out in this repo (possibly as a PR to the CONTRIBUTING.md if you want). Just today, I initiated this process for the CFT spec -- see it in action here. |
Beta Was this translation helpful? Give feedback.
-
Hello group: per the new XLS Contributing process, it is my opinion that we have reach a "well-refined standard." As such, I propose that we move this discussion to a file (via #111) and work on final changes using additional PRs, for better change-tracking. Please comment here if you would like to object to moving this spec/discussion forward in the process into a DRAFT spec. The official PR in the rippled repository is XRPLF/rippled#4418. (Note that per the Contributing guidelines, moving a spec into the DRAFT state does not mean any kind of endorsement, nor does it mean that this specification will become adopted. It is solely meant as a mechanism to enable better change tracking using PRs.) |
Beta Was this translation helpful? Give feedback.
-
Closing this discussion in order to direct future comments to these PRs:
|
Beta Was this translation helpful? Give feedback.
-
This spec has been moved to Pull Request #111.
Quickstart
If you are a developer and want to get started quickly with integrating CTID, please visit the quickstart repo.
Abstract
This standard provides a way to locate a validated transaction on any XRP Ledger Protocol Chain using its ledger sequence number, transaction index, and network ID rather than its transaction hash.
This identifier is only applicable for validated transactions. Non-validated or unsubmitted transactions cannot be identified using a CTID.
Specification
Format
CTIDs are composed of 16 uppercase hex nibbles, and always begin with a
C
.The identifier is divided into three fields and a single lead-in nibble:
Fields
1. Background
1.1 Existing Transaction Identifiers
The XRP Ledger historically identifies ledgers and transactions (and other objects) using a namespace-biased 'SHA-512Half' hashing function, which results in a 64 hex nibble unique identifier.[1]
Since these hashes are derived from the contents of the data, each identifier is completely independent of consensus.
Example Transaction Hash (ID):
1.2 An Alternative: Indexing
Ledgers and transactions can be identified by their sequenced position.
As new ledgers are validated on XRP Ledger Protocol Chains, they are assigned a sequence number, which is always the previous ledger sequence plus one. The first ledger sequence is the genesis ledger with a value of one.
Ledgers can therefore be uniquely identified by a
ledger_index
(sequence). [2] [3] The only limitation is that the ledger needs to be closed before a sequence number can be used for identification.Example Ledger Hash:
Example Ledger Index:
During consensus, all nodes on an XRP Ledger Chain will agree on the order of transactions within a given ledger. This unique sequence of transactions is referred to as the canonical order. [4] This means that transactions, like ledgers, can also be identified by their index. This index is present in the transaction metadata as
TransactionIndex
.[5]Example:
1.3 Motivation
The XRP Ledger is poised to become (or depending on the time of reading: has already become) an ecosystem of cooperatively interconnected XRPL Protocol Chains. It is imperative that users of these chains can efficiently locate a specific transaction on a specific chain. Therefore a network-aware transaction identifier is necessary.
2. Considerations
2.1 Bit Allocations
To future-proof CTID identifiers, the parameters and their sizes and lifespans are considered:
2.2 Extensible
A leading
C
provides easy human identification of the format, but also room for growth. If the number of closed ledgers on a particular chain exceeds 268,435,455, the leadingC
may be incremented toD
,E
andF
allowing for an additional 100 years of use. It is not expected this will be necessary as another standard will likely replace it by this time. As of 2023, all CTIDs always start with aC
and this will almost certainly be the case for at least the next 20 years.2.3 Space Reduction and Savings
Improved Concise Transaction Identifiers use a quarter of the space when compared to transaction hashes. This can save considerable space in databases containing references to millions of transactions.
3. Specification
This section is enclosed in the header of the proposal.
4. Implementations
Diverse implementations (in multiple languages) with test cases and explanations are available at the quickstart repo.
Two different implementations for the Improved Concise Transaction Identifier (CTID) are presented in this XLS.
The first is a simplified method which is intended for easier self-implementation and adoption. The second is a more robust version with type checking and error handling.
4.1 Simple
An example encoding routine in javascript follows:
4.2 Advanced
See here for the source code.
Reference documentation is available here.
4.2.1 Getting Started
In an existing project (with package.json), install xls-37d with:
or with yarn:
4.2.2 Encoding
An example encoding routine in typescript follows:
4.2.3 Decoding
An example decoding routine in typescript follows:
References
[1] https://xrpl.org/basic-data-types.html#hashes
[2] https://xrpl.org/basic-data-types.html#ledger-index
[3] https://xrpl.org/ledger-header.html
[4] https://xrpl.org/consensus.html
[5] https://xrpl.org/transaction-metadata.html
Changelog
Beta Was this translation helpful? Give feedback.
All reactions