RPC and Peer Transaction Lifecycle

← Back to Consensus I: Node, Consensus, and Ledger Fundamentals


Introduction

Transactions enter the XRP Ledger network through two primary channels: direct RPC submission from clients and relay from peer nodes. Understanding how transactions flow through these paths is essential for debugging submission issues, optimizing transaction throughput, and implementing client applications.

This chapter traces the complete journey of a transaction from submission to inclusion in a validated ledger.

Transaction Entry Points

┌─────────────────────────────────────────────────────────────┐
│              TRANSACTION ENTRY POINTS                       │
│                                                             │
│   ┌─────────────────┐          ┌─────────────────┐          │
│   │   RPC Client    │          │   Peer Node     │          │
│   │   (WebSocket,   │          │   (rippled)     │          │
│   │    JSON-RPC)    │          │                 │          │
│   └────────┬────────┘          └────────┬────────┘          │
│            │                            │                   │
│            ▼                            ▼                   │
│   ┌─────────────────┐          ┌─────────────────┐          │
│   │    doSubmit     │          │ PeerImp::       │          │
│   │                 │          │ onMessage       │          │
│   └────────┬────────┘          └────────┬────────┘          │
│            │                            │                   │
│            └──────────┬─────────────────┘                   │
│                       │                                     │
│                       ▼                                     │
│            ┌─────────────────────┐                          │
│            │  NetworkOPs::       │                          │
│            │  processTransaction │                          │
│            └─────────────────────┘                          │
└─────────────────────────────────────────────────────────────┘

Path 1: RPC Submission

Client submits via submit RPC:

Path 2: Peer Relay

Transaction received from peer:

Common Processing Path

After entry (RPC or Peer):

Transaction Application

The apply process (preflight → preclaim → doApply):

Transaction Queue (TxQ)

Queue management:

Network Relay

After successful application:

Complete Transaction Journey

Result Codes

Transaction result categories:

Prefix
Category
Description

tes

Success

Transaction succeeded

tec

Claim

Fee claimed but transaction failed

tef

Failure

Transaction failed, fee not claimed

tel

Local

Local error, not submitted

tem

Malformed

Transaction malformed

ter

Retry

Temporary failure, retry possible

Common Results:

processClosedLedger

When a ledger closes:

Open Ledger Accept

Preparing for next round:

Summary

Entry Points:

Path
Entry Function
Source

RPC

doSubmit()

Client applications

Peer

PeerImp::onMessage()

Network peers

Processing Stages:

  1. Entry: doSubmit / PeerImp::onMessage

  2. Validation: checkTransaction

  3. Processing: NetworkOPs::processTransaction

  4. Queue: TxQ::apply

  5. Application: preflight → preclaim → doApply

  6. Relay: overlay().relay()

  7. Consensus: Included in proposals

  8. Finality: Validated ledger

Key Functions:

Function
Purpose

preflight

Stateless validation

preclaim

Stateful validation

doApply

Execute and modify state

TxQ::apply

Fee and sequence management

relay

Network propagation

Design Principles:

  • Early rejection of invalid transactions

  • Fee-based prioritization

  • Sequence-ordered processing

  • Efficient network propagation

  • Clear result codes for debugging

Source Code References:

This completes our exploration of the consensus and ledger architecture module.

Last updated