원클릭으로
subsystem-summary-of-transactions
read this skill for a token-efficient summary of the transactions subsystem
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
read this skill for a token-efficient summary of the transactions subsystem
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
extending yourself with a new reusable skill by interviewing the user
analyzing a change to determine what tests are needed and adding them to the test suite
modifying build configuration to enable/disable variants, switch compilers or flags, or otherwise prepare for a build
reviewing a change for semantic correctness, simplicity, design consistency, and completeness
reviewing a git diff for small localized coding mistakes that can be fixed without high-level understanding
how to run make correctly to get a good build, and otherwise understand the build system
| name | subsystem-summary-of-transactions |
| description | read this skill for a token-efficient summary of the transactions subsystem |
The transactions subsystem implements the core transaction processing pipeline in stellar-core: parsing transaction envelopes from XDR, validating them, applying them to the ledger, and producing results and metadata. It encompasses the transaction frame hierarchy, all operation types (classic and Soroban), signature verification, offer exchange logic, sponsorship utilities, parallel apply infrastructure, and event/meta generation.
apply, checkValid, commonValid, processFeeSeqNum, parallelApply, and applyOperations logic.TransactionFrame (inner tx) for fee bump support. Delegates most operations to the inner tx.makeHelper creates concrete subclasses from XDR Operation. Contains apply, checkValid, parallelApply dispatch.MutableTransactionResult, FeeBumpMutableTransactionResult) that track transaction outcomes and fee refunds via RefundableFeeTracker.TransactionMetaBuilder and OperationMetaBuilder for building TransactionMeta XDR (ledger changes, events, return values).DiagnosticEventManager, OpEventManager, TxEventManager for emitting contract/diagnostic/fee events during tx processing.txbridge namespace: helpers for accessing/mutating TransactionEnvelope fields (signatures, operations, sequence numbers). Test-only mutation functions.populateCheckpointFilesFromDB: serializes transaction results from DB into checkpoint files.exchangeV10, convertWithOffersAndPools, price rounding, limit orders, liquidity pool interaction.TxEffects, TxBundle, Cluster, ApplyStage.GlobalParallelApplyLedgerState, ThreadParallelApplyLedgerState, TxParallelApplyLedgerState, LedgerAccessHelper hierarchy for parallel Soroban tx application.TransactionFrameBase (abstract)
├── TransactionFrame (regular V0/V1 transactions)
└── FeeBumpTransactionFrame (fee bump wrapping an inner TransactionFrame)
TransactionFrameBase — Pure virtual interface. Defines the contract for all transaction types:
apply(), checkValid(), parallelApply(), preParallelApply() — core lifecycle methodsprocessFeeSeqNum() — fee deduction and sequence number consumptionprocessPostApply(), processPostTxSetApply() — post-application hooks (Soroban refunds)getFullHash(), getContentsHash(), getEnvelope(), getSeqNum(), getSourceID(), getFeeSourceID(), getFullFee(), getInclusionFee(), getNumOperations(), isSoroban(), etc.insertKeysForFeeProcessing() / insertKeysForTxApply() — declare keys needed for prefetchingwithInnerTx() — visitor for fee bump inner tx accessTransactionFrameBasePtr = shared_ptr<TransactionFrameBase const>, MutableTxResultPtr = unique_ptr<MutableTransactionResultBase>TransactionFrame — The main transaction implementation.
mEnvelope (TransactionEnvelope), mNetworkID (Hash ref), mContentsHash/mFullHash (lazily computed), mOperations (vector of shared_ptr<OperationFrame const>, built in constructor via OperationFrame::makeHelper), mCachedAccountPreProtocol8kInvalid, kInvalidUpdateSeqNum, kInvalidPostAuth, kMaybeValid — used by commonValid to decide how to handle failures (e.g., whether to still update seq nums or remove one-time signers)FeeBumpTransactionFrame — Holds an outer mEnvelope plus mInnerTx (TransactionFramePtr). Delegates most operations to the inner tx. Has its own commonValid/commonValidPreSeqNum for validating the fee bump wrapper's signatures and fee source. ValidationType: kInvalid, kInvalidPostAuth, kFullyValid.
OperationFrame (abstract base)
├── CreateAccountOpFrame
├── PaymentOpFrame
├── PathPaymentOpFrameBase (abstract)
│ ├── PathPaymentStrictReceiveOpFrame
│ └── PathPaymentStrictSendOpFrame
├── ManageOfferOpFrameBase (abstract)
│ ├── ManageSellOfferOpFrame
│ │ └── CreatePassiveSellOfferOpFrame (via ManageSellOfferOpHolder)
│ └── ManageBuyOfferOpFrame
├── SetOptionsOpFrame
├── ChangeTrustOpFrame
├── TrustFlagsOpFrameBase (abstract)
│ ├── AllowTrustOpFrame
│ └── SetTrustLineFlagsOpFrame
├── MergeOpFrame
├── InflationOpFrame
├── ManageDataOpFrame
├── BumpSequenceOpFrame
├── CreateClaimableBalanceOpFrame
├── ClaimClaimableBalanceOpFrame
├── BeginSponsoringFutureReservesOpFrame
├── EndSponsoringFutureReservesOpFrame
├── RevokeSponsorshipOpFrame
├── ClawbackOpFrame
├── ClawbackClaimableBalanceOpFrame
├── LiquidityPoolDepositOpFrame
├── LiquidityPoolWithdrawOpFrame
├── InvokeHostFunctionOpFrame (Soroban)
├── ExtendFootprintTTLOpFrame (Soroban)
└── RestoreFootprintOpFrame (Soroban)
OperationFrame — Each operation holds a const Operation& reference and a const TransactionFrame& parent reference.
doCheckValid(ledgerVersion, res), doApply(app, ltx, res, opMeta) — must be overridden by every concrete op.doCheckValidForSoroban(...), doApplyForSoroban(...), doParallelApply(...) — overridden by Soroban ops (InvokeHostFunctionOpFrame, ExtendFootprintTTLOpFrame, RestoreFootprintOpFrame).getThresholdLevel() — returns LOW, MEDIUM, or HIGH; most ops default to MEDIUM, but MergeOpFrame, SetOptionsOpFrame, InflationOpFrame, BumpSequenceOpFrame, ClaimClaimableBalanceOpFrame, ExtendFootprintTTLOpFrame, RestoreFootprintOpFrame override.isOpSupported(header) — gates ops by protocol version.isDexOperation() — true for offer ops and path payments.isSoroban() — true for Soroban ops.insertLedgerKeysToPrefetch(keys) — allows ops to declare keys for bulk loading.ManageOfferOpFrameBase — Shared base for sell/buy offer management. Contains the complete offer matching logic: validates offers, computes exchange parameters, calls convertWithOffersAndPools, manages offer creation/modification/deletion in the DEX. Uses sheep/wheat terminology.
PathPaymentOpFrameBase — Shared base for path payments. Provides convert() (calls convertWithOffersAndPools for each path hop), updateSourceBalance, updateDestBalance, checkIssuer.
TrustFlagsOpFrameBase — Shared base for AllowTrustOpFrame and SetTrustLineFlagsOpFrame. Contains common doApply logic for flag validation, authorization changes, and offer removal on deauthorization.
MutableTransactionResultBase — Abstract base for mutable results during tx processing.
mTxResult (TransactionResult XDR), optional mRefundableFeeTrackersetError(), setInsufficientFeeErrorWithFeeCharged(), getResultCode(), isSuccess(), getOpResultAt(index), finalizeFeeRefund()MutableTransactionResult (regular tx), FeeBumpMutableTransactionResult (fee bump, wraps inner result)RefundableFeeTracker — Tracks consumed Soroban refundable resources (contract events size, rent fees) to compute fee refunds. consumeRefundableSorobanResources() returns false if the tx exceeds its refundable fee budget. getFeeRefund() returns unused portion.
TransactionMetaBuilder — Builds TransactionMeta XDR for a transaction. Creates OperationMetaBuilder instances for each operation. Methods: pushTxChangesBefore(), pushTxChangesAfter(), setNonRefundableResourceFee(), finalize(success).
OperationMetaBuilder — Per-operation meta builder. setLedgerChanges() captures LedgerEntryChanges from operation's LedgerTxn. setSorobanReturnValue(), getEventManager(), getDiagnosticEventManager().
DiagnosticEventManager — Buffers DiagnosticEvent entries. Created as enabled/disabled depending on context (apply vs. validation, meta enabled or not). pushEvent(), pushError().
OpEventManager — Per-operation contract event buffer. Provides high-level event constructors: newTransferEvent(), newMintEvent(), newBurnEvent(), newClawbackEvent(), newSetAuthorizedEvent(), eventsForClaimAtoms(), eventForTransferWithIssuerCheck().
TxEventManager — Transaction-level event buffer (fee events). newFeeEvent().
SignatureChecker — Constructed with (protocolVersion, contentsHash, signatures). checkSignature(signers, neededWeight) iterates decorated signatures, verifies each against provided signers, accumulates weight. Tracks which signatures have been used; checkAllSignaturesUsed() enforces no extra signatures. Maintains static counters for cache hit metrics.
ExchangeResultV10 — Result of a single offer crossing: numWheatReceived, numSheepSend, wheatStays.
exchangeV10(price, maxWheatSend, maxWheatReceive, maxSheepSend, maxSheepReceive, round) — Core exchange function. Computes amounts, applies rounding rules (NORMAL, PATH_PAYMENT_STRICT_SEND, PATH_PAYMENT_STRICT_RECEIVE), enforces 1% price error threshold.
convertWithOffersAndPools(...) — Buys wheat with sheep by crossing offers from the order book and/or using liquidity pools. Returns ConvertResult (eOK, ePartial, eFilterStopBadPrice, etc.). Takes a filter callback for price bounds and self-crossing prevention.
TxEffects — Container holding TransactionMetaBuilder and LedgerTxnDelta for a single transaction during parallel apply.
TxBundle — Groups a transaction pointer, its result payload reference, tx number, and TxEffects.
Cluster — vector<TxBundle> — a group of transactions that must be applied sequentially (they share footprint overlap).
ApplyStage — vector<Cluster> with iteration support. Contains non-overlapping clusters that can be applied in parallel.
Parallel Ledger State Hierarchy (scoped entry ownership for safety):
GlobalParallelApplyLedgerState — Owns the global entry map, hot archive snapshot, live snapshot, in-memory Soroban state, and restored entries. Splits state into per-thread maps before parallel execution, merges back after.ThreadParallelApplyLedgerState — Per-thread state copied from global. Owns mThreadEntryMap, mThreadRestoredEntries, RO TTL bumps buffer. Commits changes from successful txs.TxParallelApplyLedgerState — Per-transaction state within a thread. Owns mTxEntryMap (modified entries) and mTxRestoredEntries. Provides takeSuccess()/takeFailure() to produce ParallelTxReturnVal.LedgerAccessHelper — Abstract interface (getLedgerEntryOpt, upsertLedgerEntry, eraseLedgerEntryIfExists) with two implementations:
PreV23LedgerAccessHelper — wraps AbstractLedgerTxn for sequential applyParallelLedgerAccessHelper — wraps TxParallelApplyLedgerState for parallel applyParallelTxReturnVal — Returned by each parallel tx: contains success flag, TxModifiedEntryMap, and RestoredEntries.
Deserialization: TransactionFrameBase::makeTransactionFromWire(networkID, envelope) constructs either a TransactionFrame or FeeBumpTransactionFrame based on envelope type. TransactionFrame constructor invokes OperationFrame::makeHelper for each operation.
Validation (checkValid): Called during flood/herder acceptance.
TransactionFrame::checkValid() → checks XDR depth, validates fee XDR, creates MutableTransactionResult, calls checkValidWithOptionallyChargedFee().checkValidWithOptionallyChargedFee() → constructs SignatureChecker, computes Soroban resource fee if applicable, calls commonValid().commonValid() → calls commonValidPreSeqNum() (protocol version checks, time bounds, fee sufficiency, Soroban resource validation, footprint dedup), then validates sequence number (isBadSeq), checks account balance, verifies signatures via checkAllTransactionSignatures().op->checkValid() → doCheckValid() or doCheckValidForSoroban().signatureChecker.checkAllSignaturesUsed().FeeBumpTransactionFrame::checkValid() validates outer envelope, then calls inner tx's checkValidWithOptionallyChargedFee(chargeFee=false).Fee Processing (processFeeSeqNum): Called at ledger close before applying.
MutableTransactionResult::createSuccess(tx, feeCharged).Application (apply): Called for each tx in the tx set.
TransactionFrame::apply(chargeFee, app, ltx, meta, txResult, sorobanConfig, prngSeed):
commonPreApply(): builds SignatureChecker, calls commonValid(applying=true), processes sequence number (processSeqNum), processes signatures (processSignatures — removes one-time signers, validates op signatures). Returns the checker on success, nullptr on failure.applyOperations(): iterates operations, for each op calls op->apply() which does checkValid(forApply=true) then doApply() or doApplyForSoroban(). Commits or rolls back per-op LedgerTxn based on success.processPostApply() handles pre-v23 Soroban refunds. processPostTxSetApply() handles v23+ refunds (after all txs applied).Parallel Apply (Soroban txs only, v23+):
preParallelApply() — runs in sequential phase: validates signatures, processes seq num, builds signature checker. Called per-tx before parallel execution begins.parallelApply() — runs in parallel threads: asserts single-op Soroban tx, calls op->parallelApply() which dispatches to doParallelApply(). Uses TxParallelApplyLedgerState for ledger access. On success, ThreadParallelApplyLedgerState::setEffectsDeltaFromSuccessfulTx() records changes. Returns ParallelTxReturnVal.Soroban transactions are organized into stages of non-overlapping clusters:
GlobalParallelApplyLedgerState is constructed, collecting modified classic entries and setting up snapshots.ApplyStage: clusters are distributed across threads.ThreadParallelApplyLedgerState (split from global state for the cluster's footprint).TxParallelApplyLedgerState.commitChangesFromThreads().commitChangesToLedgerTxn() writes final state to the main LedgerTxn.For DEX operations (ManageSell/BuyOffer, PathPayment):
ManageOfferOpFrameBase::doApply() validates the offer, computes exchange parameters.convertWithOffersAndPools() which iterates matching offers in the order book.crossOfferV10() → exchangeV10() computes exact amounts.offerTrail (vector of ClaimAtom).Provides an extensive set of helpers used throughout the subsystem:
accountKey(), trustlineKey(), offerKey(), dataKey(), claimableBalanceKey(), liquidityPoolKey(), contractDataKey(), contractCodeKey()loadAccount(), loadTrustLine(), loadOffer(), loadClaimableBalance(), loadLiquidityPool(), loadData(), loadContractData(), loadContractCode()addBalance(), getAvailableBalance(), getMaxAmountReceive(), addBuyingLiabilities(), addSellingLiabilities(), getMinBalance()isAuthorized(), isAuthRequired(), isClawbackEnabledOnTrustline(), isClawbackEnabledOnAccount()getMinInclusionFee(), TransactionFrame::computeSorobanResourceFee()validateContractLedgerEntry(), getAssetContractInfo(), makeSymbolSCVal(), makeAddressSCVal(), toCxxBuf()FIRST_PROTOCOL_SUPPORTING_OPERATION_LIMITS (v11), EXPECTED_CLOSE_TIME_MULT (2), getAccountSubEntryLimit(), getMaxOffersToCross()Manages entry and signer sponsorship:
canEstablishEntrySponsorship() / establishEntrySponsorship() — check reserve constraints and set sponsorcanRemoveEntrySponsorship() / removeEntrySponsorship() — undo sponsoringcanTransferEntrySponsorship() / transferEntrySponsorship() — change sponsorcreateEntryWithPossibleSponsorship() / removeEntryWithPossibleSponsorship() — convenient wrappers used by operationsUtility namespace for accessing TransactionEnvelope internals:
getSignatures() / getSignaturesInner() — access signature vectorsgetOperations() — access operation vectorconvertForV13() — convert V0 envelopes to V1setSeqNum(), setFullFee(), setSorobanFees(), setMemo(), setMinTime(), setMaxTime()Sequential apply (classic transactions and pre-v23 Soroban): All transactions applied on the main thread using AbstractLedgerTxn for atomic state management. Each operation runs in a nested LedgerTxn that can be committed or rolled back.
Parallel apply (Soroban transactions, v23+): Transactions are grouped into ApplyStages containing Clusters. Non-overlapping clusters run on separate threads. Within each cluster, transactions are applied sequentially. The LedgerEntryScope template system enforces ownership discipline across global/thread/tx scopes, preventing accidental cross-scope reads via compile-time scope tagging (GlobalParApply, ThreadParApply, TxParApply).
Signature verification: SignatureChecker uses PubKeyUtils::VerifySigCacheLookupResult for caching. Static mutex-protected counters track cache metrics across threads. Background signature validation (for flooding) uses disableCacheMetricsTracking().
The transactions subsystem has many protocol-version-gated code paths:
PreconditionsV2 support (minSeqNum, minSeqAge, minSeqLedgerGap, extraSigners)OperationMetaV2TransactionFrame owns its mEnvelope and mOperations vector (shared_ptr to const OperationFrame).FeeBumpTransactionFrame owns its outer mEnvelope and a TransactionFramePtr to the inner tx.OperationFrame holds const references to its Operation and parent TransactionFrame.MutableTransactionResultBase owns the TransactionResult XDR and optional RefundableFeeTracker.TransactionMetaBuilder owns the TransactionMeta XDR, OperationMetaBuilder vector, and event managers.GlobalParallelApplyLedgerState owns the global entry map and restored entries; references snapshots and config.ThreadParallelApplyLedgerState owns per-thread entry map, restored entries, RO TTL bumps; references global config/snapshots.TxParallelApplyLedgerState owns per-tx entry map and restored entries; references parent thread state.TxBundle owns TxEffects (via unique_ptr); holds shared_ptr to tx and reference to result payload.