Skip to main content

Crate ledger_engine

Crate ledger_engine 

Source
Expand description

Astraea Ledger Engine.

Loads validated ledgers from xrpld, checks them before writing and stores the header, transactions with metadata, and state changes.

  • api: Clio-compatible API (ledger, tx, account_tx and others);
  • bookchanges: book_changes, order book volumes and rates of a ledger;
  • nft: account_nfts, nft_buy_offers, nft_sell_offers from the state, nft_info, nft_history, nfts_by_issuer from the NFT index;
  • nftindex: what NFT transactions do to tokens, for the NFT index;
  • proof: Proof API, evidence bundles for a ledger, transaction or object;
  • selector: the object key from ledger_entry params (all selectors of Clio 2.8);
  • server: HTTP JSON-RPC and WebSocket for api;
  • guard: request limits per client, like Clio’s DOS guard;
  • source: xrpld gRPC client (same as Clio: GetLedger with objects);
  • limits: the time limit of one request;
  • ledger: a whole ledger, its verification and serialization for the log;
  • blocks: block storage with random access by ledger;
  • confirm: confirmation of ledgers by a quorum of UNL validators;
  • delta: state changes, diffed against the previous version and metadata;
  • coldpatch: state patches of cold segments, stored only where the metadata doesn’t give them;
  • history: history, format 2: transactions as one frame per ledger with a dictionary, state changes in separate blocks;
  • index: transaction by hash, ledger by hash, account history;
  • statetree: the state tree and its root at every ledger;
  • state: state over time, a snapshot plus object versions (fjall);
  • metrics: loader metrics for Prometheus;
  • xrpl_json: XRPL binary objects as JSON, like getJson in xrpld;
  • log: a segmented ledger log. This is the first storage version; a format with indexes and random access belongs to the storage format work.

The node is not trusted blindly: the transaction tree must match the root in the header, otherwise the ledger is not written. Whether the header itself was validated by the network is up to the Proof Engine (witness-core: quorum of validations).

Modules§

amendments
Amendments feature knows: every amendment of xrpld 3.4.1 (include/xrpl/protocol/detail/features.macro, newest first, with supported as there; retired ones are supported), then amendments that older xrpld versions knew and 3.4.1 dropped, which Clio 2.8 still lists as not supported. An amendment’s ID is SHA-512Half of its name. Update the table with each xrpld release, together with definitions.json.
api
Ledger Engine v0 API, compatible with Clio: ledger, tx, account_tx, ledger_entry, account_info, server_info, ping; account objects and ledger_data live in the owned module.
blocks
Block storage for ledgers: random access to any ledger without decompressing the whole archive.
bookchanges
book_changes: for every order book touched in a ledger, the volumes that crossed and the open, close, high and low rates, as in Clio 2.8 (BookChangesHelper.hpp) and xrpld (BookChanges.h).
cold
Cold history: ASTJ5 / JC05 segments, canonical profile (codec in the astj5 crate). For deep, closed history; the hot format (module history) and the API stay the same.
coldindex
Cold history indexes for the API: transaction by hash (XTXH), account history (XACC v2) and ledger hash → sequence, over a contiguous range of cold segments (a partition). There can be several partitions; queries walk them in order.
coldpatch
State patches of a cold segment, stored only where the metadata doesn’t give them.
coldreplay
Replays the state patches of cold history and checks them against the headers.
coldstate
Version index over cold history: for every object key, the ledgers whose state patches changed it, so that the object as of an old ledger can be read from the cold segments without a database.
coldversions
Measures what an index “object to the ledgers that changed it” over cold history would take, and how an object at an old ledger reads through it. Writes nothing to the store.
confirm
Confirmation of ledgers by a validator quorum, independent of the ledger source.
delta
A ledger’s state changes, stored as a diff against what is already known: the previous version of the object and the transaction metadata.
forward
Forwarding to a node: methods that Clio does not serve itself but passes to xrpld (node state, fees, the current ledger, field definitions). Nodes are tried round-robin, each with its own timeout; the node’s response is returned as is and marked forwarded, as in Clio. Identical requests within CACHE_FOR get the same response; this is how Clio absorbs bursts of fee polling. One request gets TOTAL_LIMIT over all nodes, and a node that just failed is tried last, so that one dead node doesn’t cost half of the requests a timeout.
guard
Request limits per client, like Clio’s DOS guard.
history
Ledger history, format 2: transactions and state changes in separate streams.
index
Ledger indexes: transaction by hash, ledger by hash, account history.
ledger
A whole ledger: header, transactions with metadata, state changes. Verification and serialization.
limits
Time limit for one request.
log
Ledger log: the first storage version of the Ledger Engine.
metrics
Loader metrics in Prometheus format, for any Prometheus-compatible scraper.
nft
NFT methods, as in Clio 2.8. account_nfts, nft_buy_offers and nft_sell_offers read the ledger state; nft_info, nft_history and nfts_by_issuer read the NFT index (nftindex, kept in the state store), and answer notReady until its backfill is done.
nftindex
What NFT transactions do to tokens, for the NFT index (nft_info, nft_history, nfts_by_issuer), following Clio’s NFTHelpers.
owned
Account objects and whole state: account_objects, account_lines, account_offers, ledger_data, as in Clio 2.8.
proof
Proof API: evidence bundles that can be verified without trusting us (witness-verify evidence).
proto
gRPC client code generated from proto/ at build time.
server
API server: JSON-RPC over HTTP and WebSocket on one port, as in Clio.
source
Ledger source: xrpld gRPC, as in Clio.
state
Ledger state over time: a snapshot plus object versions (fjall).
statetree
State tree (SHAMap) with the root recomputed on every ledger.
subs
WebSocket subscriptions, as in Clio 2.8: the ledger stream (ledgerClosed), the transactions stream, the book_changes stream, per-account transactions via accounts, and the validations and manifests streams. Other Clio streams (*_proposed, books) return notSupported: a subscription that never sends messages would mislead the client.
ter
Transaction result codes and their messages: engine_result_code and engine_result_message in subscription messages. The transResults table from src/libxrpl/protocol/TER.cpp in xrpld 3.4.1; codes checked against server_definitions from a node of the same version.
txindex
Static indexes for closed history: transaction by hash and account history. They are built once over an immutable range of ledgers; fresh ledgers still go into the fjall indexes.
unknown
What the network uses that this build does not know yet.
xrpl_json
XRPL binary objects as JSON, the same way getJson does it in xrpld.
xrpla
Reader for the XRPLA publication, a source of full mainnet history.