Skip to content

feat: add PriceOracle support (XLS-47)#156

Draft
e-desouza wants to merge 8 commits intomainfrom
feat/xls-47-price-oracle
Draft

feat: add PriceOracle support (XLS-47)#156
e-desouza wants to merge 8 commits intomainfrom
feat/xls-47-price-oracle

Conversation

@e-desouza
Copy link
Copy Markdown
Collaborator

@e-desouza e-desouza commented Apr 3, 2026

Summary

Implements XLS-47 (PriceOracle) support for xrpl-rust.

New transaction types

  • OracleSet — Create or update a price oracle with up to 10 PriceData entries
  • OracleDelete — Delete an existing price oracle by OracleDocumentID

New ledger entry type

  • Oracle (LedgerEntryType = 0x0080) — On-ledger price oracle object with PriceDataSeries, Provider, AssetClass, URI, and LastUpdateTime

Shared types

  • PriceData — Nested STObject (via serde_with_tag!) with BaseAsset, QuoteAsset, AssetPrice, and Scale fields

Validation

  • OracleSet.price_data_series capped at 10 entries (per XLS-47 spec)
  • oracle_document_id and last_update_time are required (non-optional) fields

Registration

  • TransactionType::OracleSet, TransactionType::OracleDelete added to enum
  • LedgerEntryType::Oracle (0x0080) added to enum
  • Module re-exports and integration tests included

Test plan

  • Serde roundtrip tests for OracleSet, OracleDelete, Oracle
  • Builder pattern and new() constructor tests
  • get_transaction_type() variant tests
  • Validation: price_data_series length > 10 rejected
  • Integration tests in tests/transactions/
  • cargo fmt, cargo clippy --all-features, cargo test --release all pass
  • All 9 feature-matrix builds compile cleanly

Add PriceData struct using the serde_with_tag! macro to support
the XLS-47 PriceOracle amendment. Also adds OracleSet and OracleDelete
variants to the TransactionType enum and module declarations for the
oracle transaction types.
Implement the OracleSet transaction for creating and updating price
oracle ledger entries. Includes new() constructor, builder methods
for oracle-specific fields, and comprehensive unit tests covering
serialization round-trips, builder patterns, and edge cases.
Implement the OracleDelete transaction for removing price oracle
ledger entries. Includes new() constructor and unit tests covering
serialization, builder patterns, and boundary values.
Add the Oracle ledger object representing on-ledger price oracle
state. Includes Oracle variant in LedgerEntryType (0x0080) and
LedgerEntry enums, new() constructor, and serde tests.
Add integration test stubs for OracleSet and OracleDelete transactions.
These tests validate type construction and serde round-trips without
requiring a live rippled instance (gated behind the integration feature).
e-desouza

This comment was marked as resolved.

OracleDocumentID and LastUpdateTime are required by the XRPL protocol
but were typed as Option<u32>, allowing callers to construct invalid
transactions that rippled would reject. Changed both to u32 to match
the OracleDelete pattern and the protocol specification.

Added price_data_series length validation (max 10 entries) in
get_errors() to enforce the protocol limit at the model layer.
Address review findings on OracleSet / PriceData validation:

- Reject an empty `price_data_series` with `ValueTooLow { min: 1 }` when
  the field is present. rippled requires at least one entry.
- Implement `Model::get_errors` for `PriceData`, enforcing `0 <= scale
  <= 10` per XLS-47.
- Validate `base_asset` and `quote_asset` when present: must be either a
  3-character ISO-style code or a 40-character hex code, and cannot be
  the reserved symbol "XRP". `OracleSet::get_errors` now propagates each
  entry's validation error.
- Update pre-existing tests that used "XRP" as an asset and add new
  cases: empty series rejection, scale boundary (10 ok, 11 rejected),
  invalid 4-char base asset rejection, explicit "XRP" rejection, and
  40-char hex acceptance.
The rippleci/rippled:develop image updated after 2026-04-01 and broke
integration tests across all PRs (container exits before becoming healthy,
causing Connection refused on localhost:5005).

Pin to the last known-good digest and replace the simple until loop with
a bounded retry that checks container liveness, prints status per attempt,
and dumps container logs on failure.
pdp2121 pushed a commit that referenced this pull request Apr 21, 2026
… #3270) (#291)

## Summary

The `rippled` binary was renamed to `xrpld` upstream, and the
`rippleci/rippled` image stopped receiving updates. Our integration
tests across every open PR started failing because the published
`develop` image exited before becoming healthy (`Connection refused` on
`localhost:5005`, **0 passed / 41 failed**).

This PR mirrors the upstream fix in xrpl.js:
[XRPLF/xrpl.js#3270](XRPLF/xrpl.js#3270).
Switching to `rippleci/xrpld:develop` is the **actual root-cause fix**
rather than pinning an old digest of the deprecated image.

## Changes

`.github/workflows/integration_test.yml`:
- `RIPPLED_DOCKER_IMAGE` -> `XRPLD_DOCKER_IMAGE:
rippleci/xrpld:develop`.
- `docker run` simplified to `${IMAGE} --standalone` (the `xrpld` image
handles `mkdir` + launch internally; no more `bash -c "mkdir -p
/var/lib/rippled/db/ && rippled -a"` wrapper).
- Volume mount changed from `/etc/opt/ripple/` to `/etc/opt/xrpld/`.
- Container name: `rippled-service` -> `xrpld-service`.
- Removed the docker `--health-cmd` (which shelled out to the renamed
`rippled` CLI and always failed) in favour of a direct JSON-RPC poll
against `http://localhost:5005/`.
- Always dump container logs on the stop step for post-mortem
visibility.

`.ci-config/rippled.cfg` -> `.ci-config/xrpld.cfg`:
- `path=/var/lib/rippled/db/nudb` -> `path=/var/lib/xrpld/db/nudb`.
- `[database_path] /var/lib/rippled/db` -> `/var/lib/xrpld/db`.
- `[debug_logfile] /var/log/rippled/debug.log` ->
`/var/log/xrpld/debug.log`.

## Verification

Validated on throwaway PR #292 (now closed): **Integration Test green in
2m53s** on this exact workflow. Unit tests, Build & Lint, Quality Check
also pass.

## Related follow-up

The 7 in-flight PRs (#130, #131, #151, #153, #156, #157, #158) currently
carry a stopgap commit pinning `rippleci/rippled:develop` to a specific
digest. After this PR merges to `main`, those branches should:
1. Rebase on `main` to pick up the xrpld switch, or
2. Cherry-pick this commit and drop the stopgap digest pin.

## Test plan

- [x] Validated end-to-end on PR #292
- [x] Build & Lint, Unit Test, Integration Test, Quality Check all pass
- [ ] Merge and confirm subsequent PRs inherit the fix without manual
cherry-pick

## Credit

Approach lifted from @ckeshava's
[xrpl.js#3270](XRPLF/xrpl.js#3270).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant