Files
rippled/include/xrpl/protocol_autogen
Ayaz Salikhov 9859e5ceda Merge remote-tracking branch 'upstream/release/3.3.x' into mathbunnyru/merge-3.3.0-to-develop
* upstream/release/3.3.x: (41 commits)
  chore: Bump version to 3.3.0
  chore: Bump version to 3.3.0-rc7
  fix: Increase manifest protocol message size cap and fix manifests relay
  fix: Cap untrusted manifests per message and drop oversized ones
  chore: Bump version to 3.2.1
  chore: Bump version to 3.2.1-rc1
  fix: Cap untrusted manifests per message and drop oversized ones
  fix: Reject oversized validator manifest before decoding
  fix: Reduce untrusted manifest cache cap to 100
  fix: Bound untrusted manifest cache
  chore: Bump version to 3.3.0-rc6
  feat: Package validator-keys inside rippled
  chore: Bump version to 3.3.0-rc5
  fix: Switch SponsorshipSet to use a delta for sfFeeAmount
  fix: Re-revert "fix: Set request size limits and differential pricing for get-object-by-hash calls"
  chore: Bump version to 3.3.0-rc4
  fix: Revert "fix: Set request size limits and differential pricing for get-object-by-hash calls"
  chore: Bump version to 3.3.0-rc3
  fix: Reduce untrusted manifest cache cap to 100
  fix: Revert "fix: Reject oversized SHAMap nodes in gotStaleData and fetch-pack path"
  ...
2026-08-07 16:00:25 +01:00
..

Protocol Autogen

This directory contains auto-generated C++ wrapper classes for XRP Ledger protocol types.

Generated Files

The files in this directory are generated from macro definition files:

  • Transaction classes (in transactions/): Generated from include/xrpl/protocol/detail/transactions.macro by cmake/scripts/codegen/generate_tx_classes.py
  • Ledger entry classes (in ledger_entries/): Generated from include/xrpl/protocol/detail/ledger_entries.macro by cmake/scripts/codegen/generate_ledger_classes.py

Generation Process

Generation requires a one-time setup step to create a virtual environment and install Python dependencies, followed by running the generation target:

cmake --build . --target setup_code_gen # create venv and install dependencies (once)
cmake --build . --target code_gen       # generate code

By default, CODEGEN_VENV_DIR points to .venv in the project root. The setup_code_gen target creates a venv there and installs the required packages. The code_gen target then uses the venv's Python interpreter to run generation.

Generation is pure Python, so the same targets are also available as a standalone project that needs neither the dependencies nor a compiler. This is what CI uses, and it is handy if you only want to regenerate these files:

cmake -S cmake/codegen -B build/codegen
cmake --build build/codegen --target setup_code_gen
cmake --build build/codegen --target code_gen

Python Dependencies

The code generation requires the following Python packages (installed by setup_code_gen):

  • pcpp - C preprocessor for Python
  • pyparsing - Parser combinator library
  • Mako - Template engine

Version Control

The generated .h files are checked into version control. This means:

  • Developers without Python 3 can still build the project using the committed files
  • CI/CD systems don't need to run code generation if files are up to date
  • Changes to generated files are visible in code review

Modifying Generated Code

Do not manually edit generated files. Any changes will be overwritten the next time code_gen is run.

To modify the generated classes:

  • Edit the macro files in include/xrpl/protocol/detail/
  • Edit the Mako templates in cmake/scripts/codegen/templates/
  • Edit the generation scripts in cmake/scripts/codegen/
  • Update Python dependencies in cmake/scripts/codegen/requirements.txt
  • Run cmake --build . --target code_gen to regenerate

Adding Common Fields

If you add a new common field to TxFormats.cpp or LedgerFormats.cpp, you should also update the corresponding base classes and templates manually:

Base classes:

  • TransactionBase.h - Add getters for new common transaction fields
  • TransactionBuilderBase.h - Add setters, and if the field is required, add it to the constructor parameters
  • LedgerEntryBase.h - Add getters for new common ledger entry fields
  • LedgerEntryBuilderBase.h - Add setters, and if the field is required, add it to the constructor parameters

Templates (update to pass required common fields to base class constructors):

  • cmake/scripts/codegen/templates/Transaction.h.mako
  • cmake/scripts/codegen/templates/LedgerEntry.h.mako

These files are not auto-generated and must be updated by hand.