SKILL.md
Subsystem: protocol-curr (Current-Protocol XDR Type Definitions)
Overview
The src/protocol-curr/xdr/ directory contains the canonical XDR (External Data Representation) type definitions for the current protocol version of stellar-core. These .x files define all on-wire and on-disk data structures used by the Stellar network. Corresponding .h files are auto-generated C++ headers from these XDR definitions via the xdrpp code generator. Never edit .h files directly; always modify the .x source files.
The directory is a git submodule pointing to the official Stellar XDR repository.
File Organization and Dependency Graph
The XDR files form a dependency DAG via %#include directives:
Stellar-types.x (base types, no dependencies)
├── Stellar-SCP.x (consensus protocol types)
├── Stellar-contract.x (smart contract value types)
│ └── Stellar-contract-config-setting.x (Soroban config settings)
├── Stellar-contract-env-meta.x (contract environment metadata)
├── Stellar-contract-meta.x (contract metadata)
├── Stellar-contract-spec.x (contract specification/ABI)
├── Stellar-ledger-entries.x (ledger state entries; depends on contract.x, contract-config-setting.x)
│ └── Stellar-transaction.x (transaction types; depends on ledger-entries.x, contract.x)
│ └── Stellar-ledger.x (ledger structure, meta; depends on transaction.x, SCP.x)
│ ├── Stellar-overlay.x (peer-to-peer network messages)
│ ├── Stellar-internal.x (internal-only persistence types)
│ └── Stellar-exporter.x (ledger export batch types)
Module Summaries
Stellar-types.x — Foundational Types
Defines primitive and shared types used throughout all other XDR files:
- Primitive typedefs:
Hash(32-byte opaque),uint256(32-byte opaque),uint32,int32,uint64,int64,TimePoint(uint64),Duration(uint64) ExtensionPoint: A union (always case 0/void) used as a placeholder in structs for future extensibility.- Cryptographic key types:
- CryptoKeyType enum: KEYTYPEED25519 (0), KEYTYPEPREAUTHTX (1), KEYTYPEHASHX (2), KEYTYPEED25519SIGNEDPAYLOAD (3), KEYTYPEMUXEDED25519 (0x100). - PublicKey union (discriminant PublicKeyType): wraps ed25519 key. - SignerKey union (discriminant SignerKeyType): supports ed25519, pre-auth tx hash, hash-x, ed25519+signed-payload.
- Identity typedefs:
NodeID = PublicKey,AccountID = PublicKey,ContractID = Hash,PoolID = Hash. - Signature types:
Signature(opaque<64>),SignatureHint(opaque[4]). - Crypto primitives:
Curve25519Secret,Curve25519Public,HmacSha256Key,HmacSha256Mac,ShortHashSeed. SerializedBinaryFuseFilter: Probabilistic filter with configurable bit-width (8/16/32-bit), used by bucket list.ClaimableBalanceID: Union keyed byClaimableBalanceIDType, currently onlyV0wrapping aHash.
Stellar-SCP.x — Stellar Consensus Protocol
Types for the SCP (Federated Byzantine Agreement) consensus mechanism:
SCPBallot:{counter, value}— a ballot in the SCP protocol.SCPStatementTypeenum:PREPARE (0),CONFIRM (1),EXTERNALIZE (2),NOMINATE (3).SCPStatement: ContainsnodeID,slotIndex, and apledgesunion discriminated bySCPStatementType:
- PREPARE: {quorumSetHash, ballot, prepared, preparedPrime, nC, nH} - CONFIRM: {ballot, nPrepared, nCommit, nH, quorumSetHash} - EXTERNALIZE: {commit, nH, commitQuorumSetHash} - NOMINATE: SCPNomination {quorumSetHash, votes<>, accepted<>}
SCPEnvelope:{statement, signature}— signed SCP message.SCPQuorumSet:{threshold, validators<>, innerSets<>}— recursive quorum slice definition (max 4 nesting levels).
Stellar-contract.x — Smart Contract (Soroban) Value Types
Core types for the Soroban smart contract system:
SCValTypeenum (22 variants):BOOL, VOID, ERROR, U32, I32, U64, I64, TIMEPOINT, DURATION, U128, I128, U256, I256, BYTES, STRING, SYMBOL, VEC, MAP, ADDRESS, CONTRACTINSTANCE, LEDGERKEYCONTRACTINSTANCE, LEDGERKEYNONCE.SCValunion: The universal polymorphic value type for Soroban, discriminated bySCValType.SCErrorunion: Discriminated bySCErrorType(10 types:CONTRACT, WASM_VM, CONTEXT, STORAGE, OBJECT, CRYPTO, EVENTS, BUDGET, VALUE, AUTH). Contract errors carry auint32code; all others carry anSCErrorCodeenum.SCErrorCodeenum:ARITHDOMAIN, INDEXBOUNDS, INVALIDINPUT, MISSINGVALUE, EXISTINGVALUE, EXCEEDEDLIMIT, INVALIDACTION, INTERNALERROR, UNEXPECTEDTYPE, UNEXPECTEDSIZE.- Large integer structs:
UInt128Parts {hi, lo},Int128Parts {hi(signed), lo},UInt256Parts {hihi, hilo, lohi, lolo},Int256Parts. ContractExecutableunion:WASM(carrieswasmhash) orSTELLARASSET(void).SCAddressunion (discriminantSCAddressType):ACCOUNT(AccountID),CONTRACT(ContractID),MUXEDACCOUNT,CLAIMABLEBALANCE,LIQUIDITY_POOL.- Collection types:
SCVec = SCVal<>,SCMap = SCMapEntry<>,SCMapEntry = {key: SCVal, val: SCVal}. - String types:
SCBytes = opaque<>,SCString = string<>,SCSymbol = string<32>. SCContractInstance:{executable: ContractExecutable, storage: SCMap*}.
Stellar-ledger-entries.x — Ledger State Entries
Defines all persistent ledger entry types:
LedgerEntryTypeenum (10 types):ACCOUNT(0), TRUSTLINE(1), OFFER(2), DATA(3), CLAIMABLEBALANCE(4), LIQUIDITYPOOL(5), CONTRACTDATA(6), CONTRACTCODE(7), CONFIG_SETTING(8), TTL(9).- Asset types:
- AssetType enum: NATIVE(0), CREDITALPHANUM4(1), CREDITALPHANUM12(2), POOLSHARE(3). - Asset union: void for native, AlphaNum4/12 for credits (each has assetCode + issuer). - TrustLineAsset: extends Asset with POOLSHARE variant carrying PoolID. - ChangeTrustAsset: extends Asset with POOL_SHARE variant carrying LiquidityPoolParameters. - Price: fractional {n: int32, d: int32}.
AccountEntry:{accountID, balance, seqNum, numSubEntries, inflationDest*, flags, homeDomain, thresholds, signers<20>}with extension versions V1 (addsLiabilities), V2 (adds sponsorship tracking), V3 (addsseqLedger,seqTime).
- AccountFlags: AUTHREQUIRED(0x1), AUTHREVOCABLE(0x2), AUTHIMMUTABLE(0x4), AUTHCLAWBACK_ENABLED(0x8).
TrustLineEntry:{accountID, asset, balance, limit, flags}with extensions for liabilities andliquidityPoolUseCount.
- TrustLineFlags: AUTHORIZED(1), AUTHORIZEDTOMAINTAINLIABILITIES(2), TRUSTLINECLAWBACK_ENABLED(4).
OfferEntry:{sellerID, offerID, selling, buying, amount, price, flags}.DataEntry:{accountID, dataName, dataValue}— arbitrary key-value data on accounts.ClaimableBalanceEntry:{balanceID, claimants<10>, asset, amount}withClaimPredicateunion (recursive:UNCONDITIONAL, AND, OR, NOT, BEFOREABSOLUTETIME, BEFORERELATIVETIME).LiquidityPoolEntry: ContainsLiquidityPoolConstantProductParameters {assetA, assetB, fee}and pool state{reserveA, reserveB, totalPoolShares, poolSharesTrustLineCount}.- Soroban entries:
- ContractDataEntry: {contract: SCAddress, key: SCVal, durability: ContractDataDurability, val: SCVal}. Durability is TEMPORARY(0) or PERSISTENT(1). - ContractCodeEntry: {hash, code<>} with optional ContractCodeCostInputs in V1 extension. - TTLEntry: {keyHash, liveUntilLedgerSeq} — tracks expiration of Soroban entries. - ConfigSettingEntry: see contract-config-setting.x below.
LedgerEntryunion: Wraps all entry types withlastModifiedLedgerSeqand optionalLedgerEntryExtensionV1(carriessponsoringID).LedgerKeyunion: Discriminated byLedgerEntryType, carries lookup keys for each entry type.EnvelopeTypeenum:TXV0(0), SCP(1), TX(2), AUTH(3), SCPVALUE(4), TXFEEBUMP(5), OPID(6), POOLREVOKEOPID(7), CONTRACTID(8), SOROBAN_AUTHORIZATION(9).- Bucket types:
- BucketListType: LIVE(0), HOT_ARCHIVE(1). - BucketEntryType: METAENTRY(-1), LIVEENTRY(0), DEADENTRY(1), INITENTRY(2). - BucketEntry union and HotArchiveBucketEntry union for live and hot-archive bucket lists. - BucketMetadata: {ledgerVersion} with optional BucketListType extension.
Stellar-transaction.x — Transactions and Operations
The largest XDR file (~2100 lines). Defines transaction structure, all 27 operation types, and all result types.
OperationTypeenum (27 operations):CREATEACCOUNT(0),PAYMENT(1),PATHPAYMENTSTRICTRECEIVE(2),MANAGESELLOFFER(3),CREATEPASSIVESELLOFFER(4),SETOPTIONS(5),CHANGETRUST(6),ALLOWTRUST(7),ACCOUNTMERGE(8),INFLATION(9),MANAGEDATA(10),BUMPSEQUENCE(11),MANAGEBUYOFFER(12),PATHPAYMENTSTRICTSEND(13),CREATECLAIMABLEBALANCE(14),CLAIMCLAIMABLEBALANCE(15),BEGINSPONSORINGFUTURERESERVES(16),ENDSPONSORINGFUTURERESERVES(17),REVOKESPONSORSHIP(18),CLAWBACK(19),CLAWBACKCLAIMABLEBALANCE(20),SETTRUSTLINEFLAGS(21),LIQUIDITYPOOLDEPOSIT(22),LIQUIDITYPOOLWITHDRAW(23),INVOKEHOSTFUNCTION(24),EXTENDFOOTPRINTTTL(25),RESTORE_FOOTPRINT(26).Operationstruct:{sourceAccount*: MuxedAccount, body: union(OperationType)}.MuxedAccountunion:ed25519or{id, ed25519}for multiplexed accounts.- Transaction envelope hierarchy:
- TransactionV0 / TransactionV0Envelope: Legacy format (raw ed25519 source key). - Transaction / TransactionV1Envelope: Current format with MuxedAccount source, Preconditions, Memo, operations<100>, optional SorobanTransactionData. - FeeBumpTransaction / FeeBumpTransactionEnvelope: Wraps an inner TransactionV1Envelope with feeSource and increased fee. - TransactionEnvelope union: Discriminated by EnvelopeType (TXV0, TX, TXFEE_BUMP).
- Preconditions:
Preconditionsunion (NONE, TIME, V2).PreconditionsV2addstimeBounds, ledgerBounds, minSeqNum*, minSeqAge, minSeqLedgerGap, extraSigners<2>. - Memo:
MemoTypeenum (NONE, TEXT, ID, HASH, RETURN). - Soroban-specific types:
- SorobanResources: {footprint: LedgerFootprint, instructions, diskReadBytes, writeBytes}. - SorobanTransactionData: {resources, resourceFee} with optional SorobanResourcesExtV0 for archived entries. - HostFunction union: INVOKECONTRACT, CREATECONTRACT, UPLOADCONTRACTWASM, CREATECONTRACTV2. - SorobanAuthorizationEntry: {credentials, rootInvocation} — authorization tree for Soroban calls. - SorobanCredentials union: SOURCE_ACCOUNT(void) or ADDRESS(SorobanAddressCredentials). - InvokeContractArgs: {contractAddress, functionName, args<>}.
HashIDPreimageunion: Used for deterministic ID generation, discriminated byEnvelopeType(OPID, POOLREVOKEOPID, CONTRACTID, SOROBANAUTHORIZATION).TransactionSignaturePayload:{networkId, taggedTransaction}— the structure that is SHA-256 hashed and signed.- Result types: Each operation has a corresponding
ResultCodeenum andResultunion. The top-level chain is:
- TransactionResult: {feeCharged, result union by TransactionResultCode}. For fee bumps, wraps InnerTransactionResultPair. - TransactionResultCode enum (18 codes): txFEEBUMPINNERSUCCESS(1), txSUCCESS(0), txFAILED(-1), ..., txSOROBANINVALID(-17). - OperationResult: {opINNER -> inner union by OperationType, or error code}.
- Claim atoms:
ClaimAtomunion (V0, ORDERBOOK, LIQUIDITYPOOL) — represents assets exchanged during offer matching.
Stellar-ledger.x — Ledger Structure and Metadata
Defines ledger headers, upgrades, transaction sets, and close metadata:
LedgerHeader:{ledgerVersion, previousLedgerHash, scpValue, txSetResultHash, bucketListHash, ledgerSeq, totalCoins, feePool, inflationSeq, idPool, baseFee, baseReserve, maxTxSetSize, skipList[4]}.
- Extension V1 adds flags (LedgerHeaderFlags: liquidity pool trading/deposit/withdrawal disable flags).
StellarValue:{txSetHash, closeTime, upgrades<6>}— the value SCP agrees on. HasBASICorSIGNEDvariant (withLedgerCloseValueSignature).LedgerUpgradeunion (7 types):VERSION, BASEFEE, MAXTXSETSIZE, BASERESERVE, FLAGS, CONFIG, MAXSOROBANTXSET_SIZE.- Transaction sets:
- TransactionSet: Legacy {previousLedgerHash, txs<>}. - TransactionSetV1: {previousLedgerHash, phases<>}. - TransactionPhase union: V0 has TxSetComponent<>, V1 has ParallelTxsComponent for parallel execution. - ParallelTxsComponent: {baseFee*, executionStages<>} — stages of clusters for parallel tx application. - GeneralizedTransactionSet union (v=1): wraps TransactionSetV1.
- Transaction metadata (multiple versions):
- TransactionMeta union (v0-v4): Records LedgerEntryChanges (created/updated/removed/state/restored) before/after operations. - TransactionMetaV3: Adds SorobanTransactionMeta (events, returnValue, diagnosticEvents). - TransactionMetaV4: Adds OperationMetaV2 (per-operation events), TransactionEvent (fee events with stage info), SorobanTransactionMetaV2. - ContractEvent: {contractID*, type(SYSTEM/CONTRACT/DIAGNOSTIC), body{topics<>, data}}. - SorobanTransactionMetaExtV1: Fee breakdown (nonRefundable, refundable, rent).
- Ledger close metadata:
- LedgerCloseMeta union (v0, v1, v2): Packages LedgerHeaderHistoryEntry, transaction set, processing results, upgrade meta, SCP info. - V1/V2 add totalByteSizeOfLiveSorobanState, evictedKeys<>. - V2 uses TransactionResultMetaV1 (adds postTxApplyFeeProcessing).
- History entries:
TransactionHistoryEntry,TransactionHistoryResultEntry,LedgerHeaderHistoryEntry,SCPHistoryEntry.
Stellar-contract-config-setting.x — Soroban Configuration
Network-wide Soroban settings stored as CONFIG_SETTING ledger entries:
ConfigSettingIDenum (17 settings): Controls max contract size, compute limits, ledger costs, historical data fees, event limits, bandwidth, cost model params, data size limits, state archival, execution lanes, eviction, parallel compute, SCP timing.ConfigSettingEntryunion: Discriminated byConfigSettingID.- Key config structs:
- ConfigSettingContractComputeV0: ledgerMaxInstructions, txMaxInstructions, feeRatePerInstructionsIncrement, txMemoryLimit. - ConfigSettingContractLedgerCostV0: Limits and fees for disk reads/writes, rent pricing. - ConfigSettingContractLedgerCostExtV0: txMaxFootprintEntries, feeWrite1KB. - ConfigSettingContractBandwidthV0: ledgerMaxTxsSizeBytes, txMaxSizeBytes, feeTxSize1KB. - ConfigSettingContractExecutionLanesV0: ledgerMaxTxCount. - ConfigSettingContractParallelComputeV0: ledgerMaxDependentTxClusters. - StateArchivalSettings: TTL bounds, rent rates, eviction parameters. - ConfigSettingSCPTiming: Target close time and nomination/ballot timeouts (in ms).
ContractCostTypeenum (85 cost types): Covers WASM execution, memory, hashing (SHA256, Keccak256), signature verification (Ed25519, ECDSA secp256k1/r1), BLS12-381 and BN254 elliptic curve operations, WASM parsing/instantiation costs.ContractCostParamEntry:{constTerm, linearTerm}— piecewise linear cost model.EvictionIterator:{bucketListLevel, isCurrBucket, bucketFileOffset}— tracks eviction scan position.
Stellar-overlay.x — Peer-to-Peer Network Messages
Types for node communication:
MessageTypeenum (24 message types): Covers error, auth handshake, peer exchange, transaction/tx-set relay, SCP messages, flow control (SENDMORE/SENDMOREEXTENDED), pull-mode flooding (FLOODADVERT/FLOOD_DEMAND), and time-sliced surveys.StellarMessageunion: Discriminated byMessageType, carrying the appropriate payload for each message.AuthenticatedMessageunion: Wraps{sequence, StellarMessage, HmacSha256Mac}.- Handshake:
Hello(version info, networkID, peer info, auth cert, nonce),Auth(flow control flags). - Survey types:
TimeSlicedSurveyRequestMessage,TopologyResponseBodyV2,PeerStats,TimeSlicedNodeData— for network topology discovery. - Flow control:
SendMore {numMessages},SendMoreExtended {numMessages, numBytes}. - Flooding:
FloodAdvert {txHashes<1000>},FloodDemand {txHashes<1000>}.
Stellar-contract-env-meta.x — Contract Environment Metadata
Minimal: defines SCEnvMetaEntry union with a single variant SCENVMETAKINDINTERFACE_VERSION carrying {protocol: uint32, preRelease: uint32}.
Stellar-contract-meta.x — Contract Metadata
Minimal: defines SCMetaEntry union with SCMETAV0 variant carrying SCMetaV0 {key: string, val: string} — arbitrary key-value metadata for contracts.
Stellar-contract-spec.x — Contract Specification (ABI)
Defines the Soroban contract ABI (Application Binary Interface):
SCSpecTypeenum: All Soroban types including primitives, parameterized types (OPTION, RESULT, VEC, MAP, TUPLE, BYTES_N), and user-defined types (UDT).SCSpecTypeDefunion: Recursive type definition supporting allSCSpecTypevariants.SCSpecEntryunion (6 kinds):FUNCTIONV0,UDTSTRUCTV0,UDTUNIONV0,UDTENUMV0,UDTERRORENUMV0,EVENT_V0.- Each entry includes documentation strings, names, and type information for contract interface description.
SCSpecFunctionV0:{doc, name, inputs<>, outputs<1>}.SCSpecEventV0:{doc, lib, name, prefixTopics<2>, params<>, dataFormat}.
Stellar-internal.x — Internal Persistence Types
Types used only within a single core instance (not cross-node):
StoredTransactionSetunion: Legacy or Generalized tx set.StoredDebugTransactionSet:{txSet, ledgerSeq, scpValue}— for debugging.PersistedSCPStateunion (v0, v1): Saved SCP state including envelopes, quorum sets, and optionally tx sets.
Stellar-exporter.x — Ledger Export Types
LedgerCloseMetaBatch:{startSequence, endSequence, ledgerCloseMetas<>}— batch of consecutive ledger close metadata for export to downstream systems.
Key Design Patterns
- Union versioning: Most types use
union switch (int v) { case 0: void; }extensions for forward compatibility. New fields are added via new case arms. - Envelope pattern: Data (Transaction, SCP statement) is wrapped in an envelope with signatures for authentication.
- Result codes: Every operation has a
ResultCodeenum (success = 0, failures < 0) and aResultunion. - Fee bump structure:
FeeBumpTransactionwrapsTransactionV1EnvelopeasinnerTx, enabling fee sponsorship.TransactionResulthas special codestxFEEBUMPINNER_SUCCESS/FAILEDthat carryInnerTransactionResultPair. - Soroban integration: Soroban operations (
INVOKEHOSTFUNCTION,EXTENDFOOTPRINTTTL,RESTORE_FOOTPRINT) useSorobanTransactionDatafor resource declarations andSorobanAuthorizationEntryfor per-address authorization trees. - Parallel execution support:
ParallelTxsComponentandParallelTxExecutionStageorganize transactions into dependency-aware clusters for parallel application.