System XLS: Add Formats and Flags to server_definitions #418
ckeshava
started this conversation in
Standard Proposals
Replies: 1 comment 1 reply
-
|
Looks Great. You could also add LedgerHeader hexs and if you got fancy add the indexes and arguments. But this is a step in a great direction. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
System XLS: Add Formats and Flags to
server_definitions1. Abstract
The server_definitions RPC command is an existing API endpoint that provides client applications with essential protocol information needed to properly interact with the XRPL network. Currently, it returns all the details necessary to serialize and deserialize data encoded in the custom XRPL binary format. This document proposes new additions to the
server_definitionsRPC response. Specifically, it advocates adding transaction formats, ledger object formats, transaction flags and ledger specific flags in theserver_definitionsresponse.2. Motivation
This information helps client libraries understand how to serialize/deserialize XRPL data structures, construct valid transactions, and parse valid ledger entries. Essentially, the basics of an XRPL library in any programming language could be constructed just from the details of the
server_definitionsoutput with the additions.Some of the envisioned benefits of this proposal:
server_definitionsRPC.server_definitionsRPC response3. RPC:
server_definitionsThe
server_definitionsRPC already exists. A sample output is available here. This spec proposes some additions.3.1. Request Fields
There are no changes to the request fields. The current request fields are shown below:
commandstringserver_definitions" to access this RPChashstringserver_definitionsdata. If this matches the hash the rippled server has, only the hash will be returned.3.2. Response Fields
Current response fields:
TYPEShashmatches the server’s data hashobjectLEDGER_ENTRY_TYPEShashmatches the server’s data hashobjectFIELDShashmatches the server’s data hasharrayTRANSACTION_RESULTShashmatches the server’s data hashobjectTRANSACTION_TYPEShashmatches the server’s data hashobjecthashstringserver_definitionsdata that the rippled server has.Proposed additions:
LEDGER_ENTRY_FORMATShashmatches the server’s data hashobjectAccountRoot,RippleState,Offer, etc.) - namely, the fields and their optionality.TRANSACTION_FORMATShashmatches the server’s data hashobjectPayment,OfferCreate,TrustSet, etc.) - namely, the fields and their optionality.LEDGER_ENTRY_FLAGShashmatches the server’s data hashobjectTRANSACTION_FLAGShashmatches the server’s data hashobjectACCOUNT_SET_FLAGShashmatches the server’s data hashobjectAccountSetflags (asfflags) with their hexadecimal values.3.2.1. Fields
3.2.1.1. LEDGER_ENTRY_FORMATS
The format of this field is an
object. The keys of theobjectare the ledger entry type name (e.g.Offer), orcommon(for the common fields across all ledger entries). The values of theobjectare an array of elements described as follows:namestringoptionalitystringsoeREQUIREDvalue of the field - one of the following values:INVALID,REQUIRED,OPTIONAL,DEFAULT.3.2.1.2. TRANSACTION_FORMATS
The format of this field is an
object. The keys of theobjectare the transaction type name (e.g.OfferCreate, orcommon(for the common fields across all transactions). The values of theobjectare an array of elements described as follows:namestringoptionalitystringsoeREQUIREDvalue of the field - one of the following values:INVALID,REQUIRED,OPTIONAL,DEFAULT.3.2.1.3. LEDGER_ENTRY_FLAGS
The format of this field is an
object, with the keys being the ledger entry type name (e.g.Offer) and the values being anotherobject. This nestedobject’s keys are thelsfname (e.g.lsfSell), and its values are the corresponding integer values (e.g.131072).Only ledger entry types that have flags are included in this.
3.2.1.4. TRANSACTION_FLAGS
The format of this field is an
object, with the keys being the transaction type name (e.g.OfferCreate) and the values being anotherobject. This nestedobject’s keys are thetfname (e.g.tfPassive), and its values are the corresponding integer values (e.g.65536).Only transaction types that have flags are included in this.
3.2.1.5. ACCOUNT_SET_FLAGS
The format of this field is an
object, with the keys being theasfname (e.g.asfDefaultRipple) and the values being the corresponding integer values (e.g.8).3.3. Failure Conditions
Currently, the only failure conditions are if the
hashfield submitted in the request is not a valid 256-bit hash.There are no changes to the failure conditions of the
server_definitionsRPC. There are no new reasons for the RPC to return failure codes.3.4. Sample Request
{ "command": "server_definitions" }3.5. Sample Response
A sample response is available here.
4. Rationale
Currently, clients must manually hardcode or scrape this structural information from the
rippledsource, which is brittle and creates high maintenance overhead. Centralizing these definitions on the server offers:4.1. Alternate Designs Rejected
server_definitionsRPC.5. Backwards Compatibility
New additions to the RPC responses do not affect backwards compatibility. None of the existing systems are affected if they choose to not make use of the proposed changes.
6. Test Plan
This feature needs to be accompanied with suitable unit tests in the rippled code repository. The number of transactions, ledger objects, ledger-specific flags, and transaction flags are suitably determined at compile-time. The tests can validate the content of the RPC responses for specific transactions and ledger-objects. This is not as exhaustive as validating every transaction and ledger object. However, it is easier to maintain the test cases.
7. Reference Implementation
A reference implementation can be found here and here. Note: This implementation does not comprehensively implement all the proposed changes yet.
8. Security Considerations
The information returned by the
server_definitionsRPC is already available in various configuration files across rippled. No private or confidential information is revealed by this proposal.This RPC also does not modify any ledger state.
The server caches the
server_definitionsresponse, since it does not change while the server is running. This severely mitigates DoS risks.Beta Was this translation helpful? Give feedback.
All reactions