Compare commits

...

74 Commits

Author SHA1 Message Date
Ayaz Salikhov
07c64f07f0 chore: Revert "build: Switch to a new conan XRPLF remote (#7622)" (#7623) 2026-06-25 14:47:55 +00:00
Ayaz Salikhov
3097c157b6 build: Switch to a new conan XRPLF remote (#7622) 2026-06-25 08:40:06 -04:00
Michael Legleux
556d62a0de build: Align xrpld RPM packaging with DEB package (#7529) 2026-06-24 23:53:46 +00:00
Ayaz Salikhov
eef8f4a4ff chore: Use clang-tidy v22 new features (#7427) 2026-06-24 17:23:29 +00:00
Ayaz Salikhov
4fec58251b build: Patch nix binaries in CMake (#7539)
Co-authored-by: Bart <bthomee@users.noreply.github.com>
2026-06-24 13:56:18 +00:00
Ayaz Salikhov
8bbbc2051e chore: Check more tools to be available (#7600) 2026-06-24 12:25:03 +00:00
Mayukha Vadari
6736ab39df test: Add test for Permissioned Domain sequence fix (#7591)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-06-24 12:24:27 +00:00
Ayaz Salikhov
b68e1f7170 fix: Add pragma once checker (#7580) 2026-06-24 12:24:04 +00:00
Timothy Banks
bb7c4d1c9f fix: Additional RPC validation checks on ammRpcInfo account and amm_account fields. (#7324) 2026-06-24 12:23:12 +00:00
Zhiyuan Wang
69d289a388 fix: AMM Quality Leak into Domain BookStep for Permissioned DEX (#6853)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-06-24 12:15:45 +00:00
Jingchen
6341e75200 refactor: Refactor TaggedCache.ipp to remove const_cast in canonicalize_replace_cache (#5638)
Signed-off-by: JCW <a1q123456@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: xrplf-ai-reviewer[bot] <266832837+xrplf-ai-reviewer[bot]@users.noreply.github.com>
2026-06-24 12:15:11 +00:00
yinyiqian1
5a2c82f699 fix: Reject delegate permission to pseudo accounts (#7597) 2026-06-23 19:55:23 +00:00
Jingchen
0b22050b5e ci: Update workflows and conan to use VS2026 and grpc 1.81.0 (#7550)
Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com>
2026-06-23 19:25:38 +00:00
Bart
ff02269c0d refactor: Use dispatch instead of post (#7438)
Co-authored-by: Bart <11445373+bthomee@users.noreply.github.com>
2026-06-22 22:35:28 +00:00
Mayukha Vadari
dd7401fde2 refactor: Clean up tec object deletion logic (#6588)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-06-22 18:44:42 +00:00
Zhiyuan Wang
19a9ed7767 fix: Move AMMInvariant weakInvariantCheck logic into the transaction (#7032) 2026-06-22 18:42:57 +00:00
Zhiyuan Wang
93eab33dc2 fix: Improve ValidAMM invariant (#7295) 2026-06-22 17:45:42 +00:00
yinyiqian1
997267f845 feat: Remove clear mutable flags for DynamicMPT XLS-94 (#7439) 2026-06-22 17:36:06 +00:00
Ayaz Salikhov
e29b523620 ci: Build and push docker images in forks too (#7588) 2026-06-22 17:00:40 +00:00
dependabot[bot]
b1f794f067 ci: [DEPENDABOT] bump actions/checkout from 6.0.3 to 7.0.0 (#7585)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-06-22 13:39:38 +00:00
Michael Legleux
b6a1ad5bb3 fix: Ensure xrpld service directories exist at startup (#7565) 2026-06-18 19:21:12 +00:00
yinyiqian1
772ea80a25 fix: Use template for granular delegation permissions (#6613)
Co-authored-by: Bart <bthomee@users.noreply.github.com>
2026-06-17 23:20:54 +00:00
solunolab
480676d0bf docs: Fix some comments to improve readability (#7405)
Signed-off-by: solunolab <solunolab@outlook.com>
Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com>
2026-06-17 13:55:00 +00:00
Michael Legleux
f07de6c454 ci: Disable assertions on Release builds (#7443) 2026-06-17 13:54:55 +00:00
Ayaz Salikhov
cb2642be05 build: Add graphviz to Nix images (#7566) 2026-06-17 13:54:46 +00:00
Pratik Mankawde
7e0ff536f5 refactor: Rerevert "Explicitly trim the heap after cache sweeps (#6022)"
Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
2026-06-17 13:31:43 +01:00
Pratik Mankawde
044ca7719d release: Bump version to 3.3.0-b0
Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
2026-06-17 12:58:01 +01:00
Pratik Mankawde
cccce1c32e Merge remote-tracking branch 'origin/release/3.2.x' into pratik/merge_3.2.x
Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
2026-06-17 12:53:02 +01:00
Ayaz Salikhov
5de434436e ci: Make clang-tidy workflow adjustments to stay in sync with Clio (#7563) 2026-06-17 10:02:17 +00:00
Ayaz Salikhov
45ddc1d868 build: Add git-lfs to Nix images (#7561) 2026-06-16 23:13:33 +00:00
Ayaz Salikhov
7b9d55326d build: Add zip to Nix images (#7551) 2026-06-16 17:35:33 +00:00
Ayaz Salikhov
0364e4dc41 docs: Rewrite build environment docs (#7533)
Co-authored-by: Ed Hennis <ed@ripple.com>
2026-06-16 13:24:12 +00:00
Ayaz Salikhov
3c43f4614f release: Bump version to 3.2.0 2026-06-15 19:46:56 -04:00
dependabot[bot]
6b63f0ff61 ci: [DEPENDABOT] bump codecov/codecov-action from 6.0.1 to 7.0.0 (#7426)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-06-15 19:46:49 -04:00
Bart
0ac8e6cf1e release: Bump version to 3.2.0-rc6 2026-06-15 22:24:03 +01:00
Vito Tumas
ed5f13481a fix: Disable transaction invariants 2026-06-15 22:24:03 +01:00
Vito Tumas
781ef175c9 perf: Dispatch "hasInvalidAmount()" on type tag instead of dynamic_cast 2026-06-15 22:24:03 +01:00
Ed Hennis
e5785c4fcb fix: Fix Number comparison operator 2026-06-15 22:24:02 +01:00
Michael Legleux
96d0563ea6 fix: Adjust xrpld systemd service 2026-06-15 22:24:02 +01:00
Bart
61dae6f792 release: Bump version to 3.2.0-rc5 2026-06-15 22:24:02 +01:00
yinyiqian1
fded06652a fix: Add zero NFT Offer ID check for NFTokenCancelOffer 2026-06-15 22:24:02 +01:00
Valentin Balaschenko
e833e8884d refactor: Revert "Explicitly trim the heap after cache sweeps (#6022)" 2026-06-15 22:24:02 +01:00
Michael Legleux
8e3eabc398 refactor: Remove auto-update script and update RPM version
* refactor: Update RPM version scheme; remove auto-update script; service hardening

- **RPM version scheme**: pre-releases now use `~` in the `Version` field instead of the `0.<release>.<suffix>` `Release`-field hack. Matches Debian's `~` convention, so RPM and DEB version strings are symmetric. Requires rpm ≥ 4.10 (RHEL 9 ships 4.17).

  Before/after for a pre-release build:
  ```
  # before
  xrpld-3.2.0-0.1.rc3+202606011647.d4cb68d5.el9.x86_64.rpm

  # after (symmetric with DEB)
  xrpld-3.2.0~rc2+202606010139.7679a310-1.el9.x86_64.rpm
  xrpld_3.2.0~rc2+202606010139.7679a310-1_amd64.deb
  ```
- **Auto-update removed**: `update-xrpld`, `update-xrpld.service`, and `update-xrpld.timer` deleted. The `50-xrpld.preset` `disable` line for the timer is dropped too.
- **Service hardening** (two new `[Service]` directives in `xrpld.service`):
  - `CapabilityBoundingSet=CAP_NET_BIND_SERVICE` — drops every Linux capability except `CAP_NET_BIND_SERVICE`, capping the privilege ceiling to least-privilege while still letting operators bind ports <1024 (e.g. WS/HTTPS on 443).
  - `SystemCallArchitectures=native` — restricts the service to the native syscall ABI, blocking alternate-ABI (32-bit/x32) syscalls used to evade seccomp filtering.

- [ ] Build RPM from a pre-release version (e.g. `3.2.0-b1`) and confirm `rpm -qi` shows `Version: 3.2.0~b1`, `Release: 1`
- [ ] Confirm `3.2.0~b1` sorts before `3.2.0` via `rpmvercmp`
- [ ] Install package and confirm no `update-xrpld*` units appear in `systemctl list-unit-files`
- [ ] Confirm `systemctl show xrpld` reflects the new `CapabilityBoundingSet` and `SystemCallArchitectures`

* fix: Track tmpfiles-created directories in RPM %files as %ghost
2026-06-15 22:24:02 +01:00
Sergey Kuznetsov
47b06ecd17 refactor: Use rocksdb includes only when it is available 2026-06-15 22:23:54 +01:00
Bart
5a25c9188b release: Bump version to 3.2.0-rc4 2026-06-15 22:23:53 +01:00
Bart
82ee5b7556 refactor: Handle int and uint API versions separately 2026-06-15 22:23:38 +01:00
Pratik Mankawde
f98c251011 refactor: Improve tracking of book (un)subscriptions 2026-06-15 22:23:38 +01:00
Sergey Kuznetsov
e29dc474b3 refactor: Improve payment channel closing and returned error codes 2026-06-15 22:23:28 +01:00
Pratik Mankawde
2728e11809 fix: Set request size limits and differential pricing for get-object-by-hash calls 2026-06-15 22:23:28 +01:00
Jingchen
9650fe8a6e refactor: Use explicit types to help compiler 2026-06-15 22:22:53 +01:00
Pratik Mankawde
2df96b1550 fix: Silence UBSan diagnostics in the ubsan build config (#7531)
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-15 19:25:37 +00:00
Ayaz Salikhov
fe4c8ae82a build: Add ClangBuildAnalyzer to Nix (#7538)
Co-authored-by: Bart <bthomee@users.noreply.github.com>
2026-06-15 19:04:33 +00:00
Zhiyuan Wang
b34aa84e5a fix: Check Fee-Free Division by Zero in AMMWithdraw singleWithdrawEPrice (#6989) 2026-06-15 15:31:22 +00:00
Bart
f5985e73ec fix: Always charge peer on strand (#7422)
Co-authored-by: Bart <11445373+bthomee@users.noreply.github.com>
2026-06-15 14:55:56 +00:00
Sergey Kuznetsov
4387aac1a5 chore: Remove conan patch in nix (#7534) 2026-06-15 14:55:43 +00:00
Pratik Mankawde
df395d6851 test: Add null check unit test for Oracle::aggregatePrice (#7306)
Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
2026-06-11 18:05:36 +00:00
Ayaz Salikhov
8e618d68cd ci: Patch conan recipe for Nix to be able to use on macOS (#7532) 2026-06-11 17:36:33 +00:00
Ayaz Salikhov
cee157485e ci: Run sanitizers on release builds too (#7527) 2026-06-11 12:59:22 +00:00
Zhiyuan Wang
09c36d066e fix: Correct hybrid offer deletion on credential expiry (#6843)
Co-authored-by: Bart <bthomee@users.noreply.github.com>
2026-06-10 20:42:41 +00:00
Ayaz Salikhov
2f6b466feb ci: Make sanitizer flags lists in the profile, not a string (#7449) 2026-06-10 18:24:34 +00:00
Ayaz Salikhov
8000adfa79 ci: Make configurations launch on certain event types (#7447) 2026-06-10 18:08:34 +00:00
Shi Cheng
1f359f719c fix: Add [[maybe_unused]] to fix320Enabled for assert=OFF builds (#7446)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 17:24:44 +00:00
Ayaz Salikhov
dd0b6754d4 ci: Add gh and file to nix packages (#7444) 2026-06-10 14:45:51 +00:00
Vito Tumas
83cc5df72e fix: Disable transaction invariants (#7409) 2026-06-10 12:05:53 +00:00
Vito Tumas
97ca7d57bc perf: Dispatch "hasInvalidAmount()" on type tag instead of dynamic_cast (#7402) 2026-06-10 11:44:57 +00:00
Pratik Mankawde
8a4bf2dee6 refactor: Retire fixUniversalNumber amendment (#5962)
Signed-off-by: Pratik Mankawde <pmankawde@ripple.com>
Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-06-10 10:16:03 +00:00
Bart
742aa0878b test: Do not create data directory for memory databases (#7323)
Co-authored-by: Bart <11445373+bthomee@users.noreply.github.com>
2026-06-10 09:16:53 +00:00
Ayaz Salikhov
8617eaeb26 ci: Launch upload-conan-deps on profile change (#7442) 2026-06-10 00:00:19 +00:00
Ed Hennis
2cbc3c139e fix: Fix Number comparison operator (#7406) 2026-06-09 17:46:56 +00:00
Ayaz Salikhov
fccb109e48 feat: Use C++ 23 standard (#7431) 2026-06-09 17:36:17 +00:00
Vito Tumas
0fb1aca461 refactor: Introduce XRPL_ASSERT_IF for amendment-gated assertions (#7378)
Co-authored-by: xrplf-ai-reviewer[bot] <266832837+xrplf-ai-reviewer[bot]@users.noreply.github.com>
2026-06-09 17:02:06 +00:00
Bart
c552eb333f refactor: Change config section and key string literals into constants (#7095)
Co-authored-by: Bart <11445373+bthomee@users.noreply.github.com>
2026-06-09 14:58:21 +00:00
Bart
c9769d1add refactor: Use std::move and std::string_view where possible (#7424)
Co-authored-by: Bart <11445373+bthomee@users.noreply.github.com>
2026-06-09 13:56:32 +00:00
Bart
ee9fbc4e08 refactor: Use const function arguments where possible (#7423)
Co-authored-by: Bart <11445373+bthomee@users.noreply.github.com>
2026-06-09 10:04:09 +00:00
407 changed files with 7852 additions and 6454 deletions

View File

@@ -11,6 +11,7 @@ Checks: "-*,
bugprone-copy-constructor-init, bugprone-copy-constructor-init,
bugprone-crtp-constructor-accessibility, bugprone-crtp-constructor-accessibility,
bugprone-dangling-handle, bugprone-dangling-handle,
bugprone-derived-method-shadowing-base-method,
bugprone-dynamic-static-initializers, bugprone-dynamic-static-initializers,
bugprone-empty-catch, bugprone-empty-catch,
bugprone-fold-init-type, bugprone-fold-init-type,
@@ -21,6 +22,7 @@ Checks: "-*,
bugprone-incorrect-roundings, bugprone-incorrect-roundings,
bugprone-infinite-loop, bugprone-infinite-loop,
bugprone-integer-division, bugprone-integer-division,
bugprone-invalid-enum-default-initialization,
bugprone-lambda-function-name, bugprone-lambda-function-name,
bugprone-macro-parentheses, bugprone-macro-parentheses,
bugprone-macro-repeated-side-effects, bugprone-macro-repeated-side-effects,
@@ -137,6 +139,7 @@ Checks: "-*,
readability-enum-initial-value, readability-enum-initial-value,
readability-identifier-naming, readability-identifier-naming,
readability-implicit-bool-conversion, readability-implicit-bool-conversion,
readability-inconsistent-ifelse-braces,
readability-make-member-function-const, readability-make-member-function-const,
readability-math-missing-parentheses, readability-math-missing-parentheses,
readability-misleading-indentation, readability-misleading-indentation,
@@ -145,7 +148,9 @@ Checks: "-*,
readability-redundant-declaration, readability-redundant-declaration,
readability-redundant-inline-specifier, readability-redundant-inline-specifier,
readability-redundant-member-init, readability-redundant-member-init,
readability-redundant-parentheses,
readability-redundant-string-init, readability-redundant-string-init,
readability-redundant-typename,
readability-reference-to-constructed-temporary, readability-reference-to-constructed-temporary,
readability-simplify-boolean-expr, readability-simplify-boolean-expr,
readability-static-definition-in-anonymous-namespace, readability-static-definition-in-anonymous-namespace,
@@ -153,7 +158,9 @@ Checks: "-*,
readability-use-std-min-max readability-use-std-min-max
" "
# --- # ---
# readability-inconsistent-declaration-parameter-name, # in this codebase this check will break a lot of arg names # bugprone-narrowing-conversions, # This will break a lot of code but we should enable it in the future because it can eliminate a lot of bugs
# misc-override-with-different-visibility, # Will be addressed in a future PR, but for now it generates too many warnings
# readability-inconsistent-declaration-parameter-name, # In this codebase this check will break a lot of arg names
# readability-static-accessed-through-instance, # this check is probably unnecessary. It makes the code less readable # readability-static-accessed-through-instance, # this check is probably unnecessary. It makes the code less readable
# --- # ---

View File

@@ -96,3 +96,6 @@ function(verbose_find_path variable name)
${ARGN} ${ARGN}
) )
endfunction() endfunction()
function(patch_nix_binary target)
endfunction()

View File

@@ -1,6 +1,8 @@
libxrpl.basics > xrpl.basics libxrpl.basics > xrpl.basics
libxrpl.conditions > xrpl.basics libxrpl.conditions > xrpl.basics
libxrpl.conditions > xrpl.conditions libxrpl.conditions > xrpl.conditions
libxrpl.config > xrpl.basics
libxrpl.config > xrpl.config
libxrpl.core > xrpl.basics libxrpl.core > xrpl.basics
libxrpl.core > xrpl.core libxrpl.core > xrpl.core
libxrpl.core > xrpl.json libxrpl.core > xrpl.json
@@ -12,11 +14,11 @@ libxrpl.ledger > xrpl.json
libxrpl.ledger > xrpl.ledger libxrpl.ledger > xrpl.ledger
libxrpl.ledger > xrpl.nodestore libxrpl.ledger > xrpl.nodestore
libxrpl.ledger > xrpl.protocol libxrpl.ledger > xrpl.protocol
libxrpl.ledger > xrpl.server
libxrpl.ledger > xrpl.shamap libxrpl.ledger > xrpl.shamap
libxrpl.net > xrpl.basics libxrpl.net > xrpl.basics
libxrpl.net > xrpl.net libxrpl.net > xrpl.net
libxrpl.nodestore > xrpl.basics libxrpl.nodestore > xrpl.basics
libxrpl.nodestore > xrpl.config
libxrpl.nodestore > xrpl.json libxrpl.nodestore > xrpl.json
libxrpl.nodestore > xrpl.nodestore libxrpl.nodestore > xrpl.nodestore
libxrpl.nodestore > xrpl.protocol libxrpl.nodestore > xrpl.protocol
@@ -24,6 +26,7 @@ libxrpl.protocol > xrpl.basics
libxrpl.protocol > xrpl.json libxrpl.protocol > xrpl.json
libxrpl.protocol > xrpl.protocol libxrpl.protocol > xrpl.protocol
libxrpl.rdb > xrpl.basics libxrpl.rdb > xrpl.basics
libxrpl.rdb > xrpl.config
libxrpl.rdb > xrpl.core libxrpl.rdb > xrpl.core
libxrpl.rdb > xrpl.rdb libxrpl.rdb > xrpl.rdb
libxrpl.resource > xrpl.basics libxrpl.resource > xrpl.basics
@@ -31,6 +34,7 @@ libxrpl.resource > xrpl.json
libxrpl.resource > xrpl.protocol libxrpl.resource > xrpl.protocol
libxrpl.resource > xrpl.resource libxrpl.resource > xrpl.resource
libxrpl.server > xrpl.basics libxrpl.server > xrpl.basics
libxrpl.server > xrpl.config
libxrpl.server > xrpl.core libxrpl.server > xrpl.core
libxrpl.server > xrpl.json libxrpl.server > xrpl.json
libxrpl.server > xrpl.protocol libxrpl.server > xrpl.protocol
@@ -52,6 +56,7 @@ libxrpl.tx > xrpl.tx
test.app > test.jtx test.app > test.jtx
test.app > test.unit_test test.app > test.unit_test
test.app > xrpl.basics test.app > xrpl.basics
test.app > xrpl.config
test.app > xrpl.core test.app > xrpl.core
test.app > xrpld.app test.app > xrpld.app
test.app > xrpld.consensus test.app > xrpld.consensus
@@ -78,7 +83,6 @@ test.conditions > xrpl.basics
test.conditions > xrpl.conditions test.conditions > xrpl.conditions
test.consensus > test.csf test.consensus > test.csf
test.consensus > test.jtx test.consensus > test.jtx
test.consensus > test.toplevel
test.consensus > test.unit_test test.consensus > test.unit_test
test.consensus > xrpl.basics test.consensus > xrpl.basics
test.consensus > xrpld.app test.consensus > xrpld.app
@@ -90,6 +94,7 @@ test.consensus > xrpl.tx
test.core > test.jtx test.core > test.jtx
test.core > test.unit_test test.core > test.unit_test
test.core > xrpl.basics test.core > xrpl.basics
test.core > xrpl.config
test.core > xrpl.core test.core > xrpl.core
test.core > xrpld.core test.core > xrpld.core
test.core > xrpl.json test.core > xrpl.json
@@ -104,6 +109,7 @@ test.csf > xrpl.protocol
test.json > test.jtx test.json > test.jtx
test.json > xrpl.json test.json > xrpl.json
test.jtx > xrpl.basics test.jtx > xrpl.basics
test.jtx > xrpl.config
test.jtx > xrpl.core test.jtx > xrpl.core
test.jtx > xrpld.app test.jtx > xrpld.app
test.jtx > xrpld.core test.jtx > xrpld.core
@@ -126,6 +132,7 @@ test.ledger > xrpl.protocol
test.nodestore > test.jtx test.nodestore > test.jtx
test.nodestore > test.unit_test test.nodestore > test.unit_test
test.nodestore > xrpl.basics test.nodestore > xrpl.basics
test.nodestore > xrpl.config
test.nodestore > xrpld.core test.nodestore > xrpld.core
test.nodestore > xrpl.nodestore test.nodestore > xrpl.nodestore
test.nodestore > xrpl.protocol test.nodestore > xrpl.protocol
@@ -133,6 +140,7 @@ test.nodestore > xrpl.rdb
test.overlay > test.jtx test.overlay > test.jtx
test.overlay > test.unit_test test.overlay > test.unit_test
test.overlay > xrpl.basics test.overlay > xrpl.basics
test.overlay > xrpl.config
test.overlay > xrpld.app test.overlay > xrpld.app
test.overlay > xrpld.core test.overlay > xrpld.core
test.overlay > xrpld.overlay test.overlay > xrpld.overlay
@@ -159,6 +167,7 @@ test.resource > xrpl.basics
test.resource > xrpl.resource test.resource > xrpl.resource
test.rpc > test.jtx test.rpc > test.jtx
test.rpc > xrpl.basics test.rpc > xrpl.basics
test.rpc > xrpl.config
test.rpc > xrpl.core test.rpc > xrpl.core
test.rpc > xrpld.app test.rpc > xrpld.app
test.rpc > xrpld.core test.rpc > xrpld.core
@@ -173,6 +182,7 @@ test.rpc > xrpl.tx
test.server > test.jtx test.server > test.jtx
test.server > test.unit_test test.server > test.unit_test
test.server > xrpl.basics test.server > xrpl.basics
test.server > xrpl.config
test.server > xrpld.app test.server > xrpld.app
test.server > xrpld.core test.server > xrpld.core
test.server > xrpl.json test.server > xrpl.json
@@ -180,6 +190,7 @@ test.server > xrpl.protocol
test.server > xrpl.server test.server > xrpl.server
test.shamap > test.unit_test test.shamap > test.unit_test
test.shamap > xrpl.basics test.shamap > xrpl.basics
test.shamap > xrpl.config
test.shamap > xrpl.nodestore test.shamap > xrpl.nodestore
test.shamap > xrpl.protocol test.shamap > xrpl.protocol
test.shamap > xrpl.shamap test.shamap > xrpl.shamap
@@ -188,6 +199,7 @@ test.toplevel > xrpl.json
test.unit_test > xrpl.basics test.unit_test > xrpl.basics
test.unit_test > xrpl.protocol test.unit_test > xrpl.protocol
tests.libxrpl > xrpl.basics tests.libxrpl > xrpl.basics
tests.libxrpl > xrpl.config
tests.libxrpl > xrpl.core tests.libxrpl > xrpl.core
tests.libxrpl > xrpl.json tests.libxrpl > xrpl.json
tests.libxrpl > xrpl.ledger tests.libxrpl > xrpl.ledger
@@ -200,16 +212,17 @@ tests.libxrpl > xrpl.shamap
tests.libxrpl > xrpl.tx tests.libxrpl > xrpl.tx
xrpl.conditions > xrpl.basics xrpl.conditions > xrpl.basics
xrpl.conditions > xrpl.protocol xrpl.conditions > xrpl.protocol
xrpl.config > xrpl.basics
xrpl.core > xrpl.basics xrpl.core > xrpl.basics
xrpl.core > xrpl.json xrpl.core > xrpl.json
xrpl.core > xrpl.protocol xrpl.core > xrpl.protocol
xrpl.json > xrpl.basics xrpl.json > xrpl.basics
xrpl.ledger > xrpl.basics xrpl.ledger > xrpl.basics
xrpl.ledger > xrpl.protocol xrpl.ledger > xrpl.protocol
xrpl.ledger > xrpl.server
xrpl.ledger > xrpl.shamap xrpl.ledger > xrpl.shamap
xrpl.net > xrpl.basics xrpl.net > xrpl.basics
xrpl.nodestore > xrpl.basics xrpl.nodestore > xrpl.basics
xrpl.nodestore > xrpl.config
xrpl.nodestore > xrpl.protocol xrpl.nodestore > xrpl.protocol
xrpl.protocol > xrpl.basics xrpl.protocol > xrpl.basics
xrpl.protocol > xrpl.json xrpl.protocol > xrpl.json
@@ -237,6 +250,7 @@ xrpl.tx > xrpl.ledger
xrpl.tx > xrpl.protocol xrpl.tx > xrpl.protocol
xrpld.app > test.unit_test xrpld.app > test.unit_test
xrpld.app > xrpl.basics xrpld.app > xrpl.basics
xrpld.app > xrpl.config
xrpld.app > xrpl.core xrpld.app > xrpl.core
xrpld.app > xrpld.consensus xrpld.app > xrpld.consensus
xrpld.app > xrpld.core xrpld.app > xrpld.core
@@ -255,11 +269,13 @@ xrpld.consensus > xrpl.json
xrpld.consensus > xrpl.ledger xrpld.consensus > xrpl.ledger
xrpld.consensus > xrpl.protocol xrpld.consensus > xrpl.protocol
xrpld.core > xrpl.basics xrpld.core > xrpl.basics
xrpld.core > xrpl.config
xrpld.core > xrpl.core xrpld.core > xrpl.core
xrpld.core > xrpl.net xrpld.core > xrpl.net
xrpld.core > xrpl.protocol xrpld.core > xrpl.protocol
xrpld.core > xrpl.rdb xrpld.core > xrpl.rdb
xrpld.overlay > xrpl.basics xrpld.overlay > xrpl.basics
xrpld.overlay > xrpl.config
xrpld.overlay > xrpl.core xrpld.overlay > xrpl.core
xrpld.overlay > xrpld.consensus xrpld.overlay > xrpld.consensus
xrpld.overlay > xrpld.core xrpld.overlay > xrpld.core
@@ -272,15 +288,18 @@ xrpld.overlay > xrpl.server
xrpld.overlay > xrpl.shamap xrpld.overlay > xrpl.shamap
xrpld.overlay > xrpl.tx xrpld.overlay > xrpl.tx
xrpld.peerfinder > xrpl.basics xrpld.peerfinder > xrpl.basics
xrpld.peerfinder > xrpl.config
xrpld.peerfinder > xrpld.core xrpld.peerfinder > xrpld.core
xrpld.peerfinder > xrpl.protocol xrpld.peerfinder > xrpl.protocol
xrpld.peerfinder > xrpl.rdb xrpld.peerfinder > xrpl.rdb
xrpld.perflog > xrpl.basics xrpld.perflog > xrpl.basics
xrpld.perflog > xrpl.config
xrpld.perflog > xrpl.core xrpld.perflog > xrpl.core
xrpld.perflog > xrpld.rpc xrpld.perflog > xrpld.rpc
xrpld.perflog > xrpl.json xrpld.perflog > xrpl.json
xrpld.perflog > xrpl.protocol xrpld.perflog > xrpl.protocol
xrpld.rpc > xrpl.basics xrpld.rpc > xrpl.basics
xrpld.rpc > xrpl.config
xrpld.rpc > xrpl.core xrpld.rpc > xrpl.core
xrpld.rpc > xrpld.core xrpld.rpc > xrpld.core
xrpld.rpc > xrpl.json xrpld.rpc > xrpl.json

View File

@@ -20,13 +20,24 @@ _SANITIZER_SUFFIX: dict[str, str] = {
def get_cmake_args(build_type: str, extra_args: str) -> str: def get_cmake_args(build_type: str, extra_args: str) -> str:
"""Get the full list of CMake arguments for a config.""" """Get the full list of CMake arguments for a config."""
args = _BASE_CMAKE_ARGS.copy() args = _BASE_CMAKE_ARGS.copy()
if build_type == "Release":
args.append("-Dassert=ON")
if extra_args: if extra_args:
args.extend(extra_args.split()) args.extend(extra_args.split())
return " ".join(args) return " ".join(args)
def runs_on_event(exclude_event_types: list[str], event: str | None) -> bool:
"""Whether a config should run for the current event.
'exclude_event_types' is a list of GitHub event names (e.g.
["pull_request"]) on which the config should NOT run; an empty list means
the config runs on every event. When no event is given (event is None), no
filtering is applied.
"""
if event is None:
return True
return event not in exclude_event_types
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Input types — shapes of the JSON config files # Input types — shapes of the JSON config files
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
@@ -43,6 +54,9 @@ class LinuxConfig:
suffix: str = "" suffix: str = ""
extra_cmake_args: str = "" extra_cmake_args: str = ""
image: str = "" # only used by package_configs entries image: str = "" # only used by package_configs entries
# List of GitHub event names (e.g. "pull_request") on which this config
# should NOT run. Empty means it runs on every event.
exclude_event_types: list[str] = dataclasses.field(default_factory=list)
@dataclasses.dataclass @dataclasses.dataclass
@@ -77,6 +91,9 @@ class PlatformConfig:
build_type: list[str] build_type: list[str]
build_only: bool = False # if true, skip tests (e.g. macos/Windows Debug) build_only: bool = False # if true, skip tests (e.g. macos/Windows Debug)
extra_cmake_args: str = "" extra_cmake_args: str = ""
# List of GitHub event names (e.g. "pull_request") on which this config
# should NOT run. Empty means it runs on every event.
exclude_event_types: list[str] = dataclasses.field(default_factory=list)
def __post_init__(self) -> None: def __post_init__(self) -> None:
if isinstance(self.build_type, str): if isinstance(self.build_type, str):
@@ -151,16 +168,21 @@ _ARCHS: dict[str, Architecture] = {
} }
def expand_linux_matrix(linux: LinuxFile) -> list[MatrixEntry]: def expand_linux_matrix(
linux: LinuxFile, event: str | None = None
) -> list[MatrixEntry]:
"""Expand a LinuxFile into a flat list of matrix entries. """Expand a LinuxFile into a flat list of matrix entries.
Each config entry is expanded over the cross-product of its Each config entry is expanded over the cross-product of its
compiler, build_type, sanitizers, and architecture lists. compiler, build_type, sanitizers, and architecture lists. Configs that
exclude the current event are skipped.
""" """
entries: list[MatrixEntry] = [] entries: list[MatrixEntry] = []
for distro, configs in linux.configs.items(): for distro, configs in linux.configs.items():
for cfg in configs: for cfg in configs:
if not runs_on_event(cfg.exclude_event_types, event):
continue
# An empty sanitizers list means "one entry with no sanitizer". # An empty sanitizers list means "one entry with no sanitizer".
effective_sanitizers = cfg.sanitizers or [""] effective_sanitizers = cfg.sanitizers or [""]
effective_archs = {arch: _ARCHS[arch] for arch in cfg.arch} effective_archs = {arch: _ARCHS[arch] for arch in cfg.arch}
@@ -218,13 +240,20 @@ def expand_linux_packaging(linux: LinuxFile) -> list[PackagingEntry]:
return entries return entries
def expand_platform_matrix(pf: PlatformFile) -> list[MatrixEntry]: def expand_platform_matrix(
"""Expand a PlatformFile (macOS or Windows) into matrix entries.""" pf: PlatformFile, event: str | None = None
) -> list[MatrixEntry]:
"""Expand a PlatformFile (macOS or Windows) into matrix entries.
Configs that exclude the current event are skipped.
"""
platform_name, arch = pf.platform.split("/") platform_name, arch = pf.platform.split("/")
is_windows = platform_name == "windows" is_windows = platform_name == "windows"
entries: list[MatrixEntry] = [] entries: list[MatrixEntry] = []
for cfg in pf.configs: for cfg in pf.configs:
if not runs_on_event(cfg.exclude_event_types, event):
continue
for build_type in cfg.build_type: for build_type in cfg.build_type:
entries.append( entries.append(
MatrixEntry( MatrixEntry(
@@ -262,6 +291,14 @@ if __name__ == "__main__":
help="Emit the Linux packaging matrix instead of the build/test matrix.", help="Emit the Linux packaging matrix instead of the build/test matrix.",
action="store_true", action="store_true",
) )
parser.add_argument(
"-e",
"--event",
help="The GitHub event name that triggered the workflow (e.g. 'push', "
"'pull_request'). Configs are filtered by their 'event_type'. If "
"omitted, no filtering is applied.",
default=None,
)
args = parser.parse_args() args = parser.parse_args()
matrix: list[MatrixEntry] | list[PackagingEntry] = [] matrix: list[MatrixEntry] | list[PackagingEntry] = []
@@ -270,12 +307,16 @@ if __name__ == "__main__":
matrix = expand_linux_packaging(LinuxFile.load(THIS_DIR / "linux.json")) matrix = expand_linux_packaging(LinuxFile.load(THIS_DIR / "linux.json"))
else: else:
if args.config in ("linux", None): if args.config in ("linux", None):
matrix += expand_linux_matrix(LinuxFile.load(THIS_DIR / "linux.json")) matrix += expand_linux_matrix(
LinuxFile.load(THIS_DIR / "linux.json"), args.event
)
if args.config in ("macos", None): if args.config in ("macos", None):
matrix += expand_platform_matrix(PlatformFile.load(THIS_DIR / "macos.json")) matrix += expand_platform_matrix(
PlatformFile.load(THIS_DIR / "macos.json"), args.event
)
if args.config in ("windows", None): if args.config in ("windows", None):
matrix += expand_platform_matrix( matrix += expand_platform_matrix(
PlatformFile.load(THIS_DIR / "windows.json") PlatformFile.load(THIS_DIR / "windows.json"), args.event
) )
print(f"matrix={json.dumps({'include': [dataclasses.asdict(e) for e in matrix]})}") print(f"matrix={json.dumps({'include': [dataclasses.asdict(e) for e in matrix]})}")

View File

@@ -1,5 +1,5 @@
{ {
"image_tag": "sha-63ffdc3", "image_tag": "sha-e29b523",
"configs": { "configs": {
"ubuntu": [ "ubuntu": [
{ {
@@ -10,7 +10,7 @@
{ {
"compiler": ["gcc", "clang"], "compiler": ["gcc", "clang"],
"build_type": ["Debug"], "build_type": ["Debug", "Release"],
"arch": ["amd64"], "arch": ["amd64"],
"sanitizers": ["address", "undefinedbehavior"] "sanitizers": ["address", "undefinedbehavior"]
}, },
@@ -41,7 +41,8 @@
"build_type": ["Debug"], "build_type": ["Debug"],
"arch": ["amd64"], "arch": ["amd64"],
"suffix": "unity", "suffix": "unity",
"extra_cmake_args": "-Dunity=ON" "extra_cmake_args": "-Dunity=ON",
"exclude_event_types": ["pull_request"]
} }
], ],
@@ -67,7 +68,7 @@
"compiler": ["gcc"], "compiler": ["gcc"],
"build_type": ["Release"], "build_type": ["Release"],
"arch": ["amd64"], "arch": ["amd64"],
"image": "ghcr.io/xrplf/xrpld/packaging-debian:sha-63ffdc3" "image": "ghcr.io/xrplf/xrpld/packaging-debian:sha-577d745"
} }
], ],
@@ -76,7 +77,7 @@
"compiler": ["gcc"], "compiler": ["gcc"],
"build_type": ["Release"], "build_type": ["Release"],
"arch": ["amd64"], "arch": ["amd64"],
"image": "ghcr.io/xrplf/xrpld/packaging-rhel:sha-63ffdc3" "image": "ghcr.io/xrplf/xrpld/packaging-rhel:sha-577d745"
} }
] ]
} }

View File

@@ -9,7 +9,8 @@
{ {
"build_type": "Debug", "build_type": "Debug",
"extra_cmake_args": "-DCMAKE_POLICY_VERSION_MINIMUM=3.5", "extra_cmake_args": "-DCMAKE_POLICY_VERSION_MINIMUM=3.5",
"build_only": true "build_only": true,
"exclude_event_types": ["pull_request"]
} }
] ]
} }

View File

@@ -1,8 +1,12 @@
{ {
"platform": "windows/amd64", "platform": "windows/amd64",
"runner": ["self-hosted", "Windows", "devbox"], "runner": ["self-hosted", "Windows", "dev-box-windows-2026"],
"configs": [ "configs": [
{ "build_type": "Release" }, { "build_type": "Release" },
{ "build_type": "Debug", "build_only": true } {
"build_type": "Debug",
"build_only": true,
"exclude_event_types": ["pull_request"]
}
] ]
} }

View File

@@ -9,12 +9,20 @@ on:
- "flake.nix" - "flake.nix"
- "flake.lock" - "flake.lock"
- "nix/**" - "nix/**"
- "!nix/docker/README.md"
- "!nix/devshell.nix"
- "bin/check-tools.sh"
- "bin/install-sanitizer-libs.sh"
pull_request: pull_request:
paths: paths:
- ".github/workflows/build-nix-images.yml" - ".github/workflows/build-nix-images.yml"
- "flake.nix" - "flake.nix"
- "flake.lock" - "flake.lock"
- "nix/**" - "nix/**"
- "!nix/docker/README.md"
- "!nix/devshell.nix"
- "bin/check-tools.sh"
- "bin/install-sanitizer-libs.sh"
workflow_dispatch: workflow_dispatch:
concurrency: concurrency:
@@ -46,9 +54,9 @@ jobs:
base_image: debian:bookworm base_image: debian:bookworm
- name: rhel - name: rhel
base_image: registry.access.redhat.com/ubi9/ubi:latest base_image: registry.access.redhat.com/ubi9/ubi:latest
uses: XRPLF/actions/.github/workflows/build-multiarch-image.yml@c1b480188519e0cad040e6aa70db1cbc5a797e07 uses: XRPLF/actions/.github/workflows/build-multiarch-image.yml@ee03d31bcc4501d7599dc1b1ecd7a34af582ad1c
with: with:
image_name: ghcr.io/xrplf/xrpld/nix-${{ matrix.distro.name }} image_name: xrpld/nix-${{ matrix.distro.name }}
dockerfile: nix/docker/Dockerfile dockerfile: nix/docker/Dockerfile
base_image: ${{ matrix.distro.base_image }} base_image: ${{ matrix.distro.base_image }}
push: ${{ github.repository == 'XRPLF/rippled' && github.event_name == 'push' }} push: ${{ github.event_name == 'push' }}

View File

@@ -38,9 +38,9 @@ jobs:
base_image: debian:bookworm base_image: debian:bookworm
- name: rhel - name: rhel
base_image: registry.access.redhat.com/ubi9/ubi:latest base_image: registry.access.redhat.com/ubi9/ubi:latest
uses: XRPLF/actions/.github/workflows/build-multiarch-image.yml@c1b480188519e0cad040e6aa70db1cbc5a797e07 uses: XRPLF/actions/.github/workflows/build-multiarch-image.yml@ee03d31bcc4501d7599dc1b1ecd7a34af582ad1c
with: with:
image_name: ghcr.io/xrplf/xrpld/packaging-${{ matrix.distro.name }} image_name: xrpld/packaging-${{ matrix.distro.name }}
dockerfile: package/Dockerfile dockerfile: package/Dockerfile
base_image: ${{ matrix.distro.base_image }} base_image: ${{ matrix.distro.base_image }}
push: ${{ github.repository == 'XRPLF/rippled' && github.event_name == 'push' }} push: ${{ github.event_name == 'push' }}

View File

@@ -23,7 +23,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Write PR body to file - name: Write PR body to file
env: env:

View File

@@ -33,7 +33,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Determine changed files - name: Determine changed files
# This step checks whether any files have changed that should # This step checks whether any files have changed that should
# cause the next jobs to run. We do it this way rather than # cause the next jobs to run. We do it this way rather than
@@ -70,6 +70,7 @@ jobs:
.github/workflows/reusable-upload-recipe.yml .github/workflows/reusable-upload-recipe.yml
.clang-tidy .clang-tidy
.codecov.yml .codecov.yml
bin/check-tools.sh
cfg/** cfg/**
cmake/** cmake/**
conan/** conan/**

View File

@@ -27,6 +27,7 @@ on:
- ".github/workflows/reusable-upload-recipe.yml" - ".github/workflows/reusable-upload-recipe.yml"
- ".clang-tidy" - ".clang-tidy"
- ".codecov.yml" - ".codecov.yml"
- "bin/check-tools.sh"
- "cfg/**" - "cfg/**"
- "cmake/**" - "cmake/**"
- "conan/**" - "conan/**"

View File

@@ -14,7 +14,7 @@ on:
jobs: jobs:
# Call the workflow in the XRPLF/actions repo that runs the pre-commit hooks. # Call the workflow in the XRPLF/actions repo that runs the pre-commit hooks.
run-hooks: run-hooks:
uses: XRPLF/actions/.github/workflows/pre-commit.yml@312aaab296060ff89d7f798dcab59f019bea6e02 uses: XRPLF/actions/.github/workflows/pre-commit.yml@e06d4138c9ec8dceeb7c818645faa38087ea9e3d
with: with:
runs_on: ubuntu-latest runs_on: ubuntu-latest
container: '{ "image": "ghcr.io/xrplf/ci/tools-rippled-pre-commit:sha-41ec7c1" }' container: '{ "image": "ghcr.io/xrplf/ci/tools-rippled-pre-commit:sha-41ec7c1" }'

View File

@@ -41,10 +41,10 @@ env:
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: ghcr.io/xrplf/xrpld/nix-ubuntu:sha-63ffdc3 container: ghcr.io/xrplf/xrpld/nix-ubuntu:sha-e29b523
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Prepare runner - name: Prepare runner
uses: XRPLF/actions/prepare-runner@c47daebb2f9db64ffbac71b47d68a661498d5ce8 uses: XRPLF/actions/prepare-runner@c47daebb2f9db64ffbac71b47d68a661498d5ce8

View File

@@ -82,7 +82,7 @@ jobs:
name: ${{ inputs.config_name }} name: ${{ inputs.config_name }}
runs-on: ${{ fromJSON(inputs.runs_on) }} runs-on: ${{ fromJSON(inputs.runs_on) }}
container: ${{ inputs.image != '' && inputs.image || null }} container: ${{ inputs.image != '' && inputs.image || null }}
timeout-minutes: ${{ inputs.sanitizers != '' && 360 || 60 }} timeout-minutes: ${{ inputs.sanitizers != '' && 360 || 180 }}
env: env:
# Use a namespace to keep the objects separate for each configuration. # Use a namespace to keep the objects separate for each configuration.
CCACHE_NAMESPACE: ${{ inputs.config_name }} CCACHE_NAMESPACE: ${{ inputs.config_name }}
@@ -110,7 +110,7 @@ jobs:
uses: XRPLF/actions/cleanup-workspace@c7d9ce5ebb03c752a354889ecd870cadfc2b1cd4 uses: XRPLF/actions/cleanup-workspace@c7d9ce5ebb03c752a354889ecd870cadfc2b1cd4
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Prepare runner - name: Prepare runner
uses: XRPLF/actions/prepare-runner@c47daebb2f9db64ffbac71b47d68a661498d5ce8 uses: XRPLF/actions/prepare-runner@c47daebb2f9db64ffbac71b47d68a661498d5ce8
@@ -121,6 +121,11 @@ jobs:
if: ${{ inputs.ccache_enabled && runner.debug == '1' }} if: ${{ inputs.ccache_enabled && runner.debug == '1' }}
run: echo "CCACHE_LOGFILE=${{ runner.temp }}/ccache.log" >>"${GITHUB_ENV}" run: echo "CCACHE_LOGFILE=${{ runner.temp }}/ccache.log" >>"${GITHUB_ENV}"
- name: Check tools
env:
CHECK_TOOLS_SKIP_CLONE: "1"
run: ./bin/check-tools.sh
- name: Print build environment - name: Print build environment
uses: XRPLF/actions/print-build-env@59dec886e4afb05a1724443af08baccbc045b574 uses: XRPLF/actions/print-build-env@59dec886e4afb05a1724443af08baccbc045b574
@@ -158,12 +163,33 @@ jobs:
CMAKE_ARGS: ${{ inputs.cmake_args }} CMAKE_ARGS: ${{ inputs.cmake_args }}
run: | run: |
cmake \ cmake \
-G '${{ runner.os == 'Windows' && 'Visual Studio 17 2022' || 'Ninja' }}' \ -G '${{ runner.os == 'Windows' && 'Visual Studio 18 2026' || 'Ninja' }}' \
-DCMAKE_TOOLCHAIN_FILE:FILEPATH=build/generators/conan_toolchain.cmake \ -DCMAKE_TOOLCHAIN_FILE:FILEPATH=build/generators/conan_toolchain.cmake \
-DCMAKE_BUILD_TYPE="${BUILD_TYPE}" \ -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" \
${CMAKE_ARGS} \ ${CMAKE_ARGS} \
.. ..
# Export the sanitizer options before any instrumented binary runs. The
# protocol code-gen and build steps below invoke instrumented dependency
# tools (protoc, grpc), so setting UBSAN_OPTIONS here lets the UBSan
# suppression list silence their diagnostics too, not just at test time.
# GITHUB_WORKSPACE (not the github.workspace context) is used so the path
# resolves correctly inside the container job.
- name: Set sanitizer options
if: ${{ !inputs.build_only && env.SANITIZERS_ENABLED == 'true' }}
env:
CONFIG_NAME: ${{ inputs.config_name }}
run: |
SUPP="${GITHUB_WORKSPACE}/sanitizers/suppressions"
ASAN_OPTS="include=${SUPP}/runtime-asan-options.txt:suppressions=${SUPP}/asan.supp"
if [[ "${CONFIG_NAME}" == *gcc* ]]; then
ASAN_OPTS="${ASAN_OPTS}:alloc_dealloc_mismatch=0"
fi
echo "ASAN_OPTIONS=${ASAN_OPTS}" >>${GITHUB_ENV}
echo "TSAN_OPTIONS=include=${SUPP}/runtime-tsan-options.txt:suppressions=${SUPP}/tsan.supp" >>${GITHUB_ENV}
echo "UBSAN_OPTIONS=include=${SUPP}/runtime-ubsan-options.txt:suppressions=${SUPP}/ubsan.supp" >>${GITHUB_ENV}
echo "LSAN_OPTIONS=include=${SUPP}/runtime-lsan-options.txt:suppressions=${SUPP}/lsan.supp" >>${GITHUB_ENV}
- name: Check protocol autogen files are up-to-date - name: Check protocol autogen files are up-to-date
working-directory: ${{ env.BUILD_DIR }} working-directory: ${{ env.BUILD_DIR }}
env: env:
@@ -203,21 +229,6 @@ jobs:
--parallel "${BUILD_NPROC}" \ --parallel "${BUILD_NPROC}" \
--target "${CMAKE_TARGET}" --target "${CMAKE_TARGET}"
# This step is needed to allow running in non-Nix environments
- name: Patch binary to use default loader and remove rpath (Linux)
if: ${{ runner.os == 'Linux' && env.SANITIZERS_ENABLED == 'false' }}
run: |
loader="$(/tmp/loader-path.sh)"
patchelf --set-interpreter "${loader}" --remove-rpath "${{ env.BUILD_DIR }}/xrpld"
# We're only running aarch64 Linux builds in Ubuntu-based images, so this is kept simple
- name: Install libatomic (Linux aarch64)
if: ${{ runner.os == 'Linux' && runner.arch == 'ARM64' }}
run: |
apt update --yes
apt install -y --no-install-recommends \
libatomic1
- name: Show ccache statistics - name: Show ccache statistics
if: ${{ inputs.ccache_enabled }} if: ${{ inputs.ccache_enabled }}
run: | run: |
@@ -279,20 +290,6 @@ jobs:
run: | run: |
./xrpld --version | grep libvoidstar ./xrpld --version | grep libvoidstar
- name: Set sanitizer options
if: ${{ !inputs.build_only && env.SANITIZERS_ENABLED == 'true' }}
env:
CONFIG_NAME: ${{ inputs.config_name }}
run: |
ASAN_OPTS="include=${GITHUB_WORKSPACE}/sanitizers/suppressions/runtime-asan-options.txt:suppressions=${GITHUB_WORKSPACE}/sanitizers/suppressions/asan.supp"
if [[ "${CONFIG_NAME}" == *gcc* ]]; then
ASAN_OPTS="${ASAN_OPTS}:alloc_dealloc_mismatch=0"
fi
echo "ASAN_OPTIONS=${ASAN_OPTS}" >>${GITHUB_ENV}
echo "TSAN_OPTIONS=include=${GITHUB_WORKSPACE}/sanitizers/suppressions/runtime-tsan-options.txt:suppressions=${GITHUB_WORKSPACE}/sanitizers/suppressions/tsan.supp" >>${GITHUB_ENV}
echo "UBSAN_OPTIONS=include=${GITHUB_WORKSPACE}/sanitizers/suppressions/runtime-ubsan-options.txt:suppressions=${GITHUB_WORKSPACE}/sanitizers/suppressions/ubsan.supp" >>${GITHUB_ENV}
echo "LSAN_OPTIONS=include=${GITHUB_WORKSPACE}/sanitizers/suppressions/runtime-lsan-options.txt:suppressions=${GITHUB_WORKSPACE}/sanitizers/suppressions/lsan.supp" >>${GITHUB_ENV}
- name: Run the separate tests - name: Run the separate tests
if: ${{ !inputs.build_only }} if: ${{ !inputs.build_only }}
working-directory: ${{ runner.os == 'Windows' && format('{0}/{1}', env.BUILD_DIR, inputs.build_type) || env.BUILD_DIR }} working-directory: ${{ runner.os == 'Windows' && format('{0}/{1}', env.BUILD_DIR, inputs.build_type) || env.BUILD_DIR }}

View File

@@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Check levelization - name: Check levelization
run: python .github/scripts/levelization/generate.py run: python .github/scripts/levelization/generate.py
- name: Check for differences - name: Check for differences

View File

@@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Check definitions - name: Check definitions
run: .github/scripts/rename/definitions.sh . run: .github/scripts/rename/definitions.sh .
- name: Check copyright notices - name: Check copyright notices

View File

@@ -20,29 +20,32 @@ env:
BUILD_DIR: build BUILD_DIR: build
BUILD_TYPE: Debug # Debug so that ASSERTS and such participate in clang-tidy check BUILD_TYPE: Debug # Debug so that ASSERTS and such participate in clang-tidy check
OUTPUT_FILE: clang-tidy-output.txt OUTPUT_FILE: /tmp/clang-tidy-output.txt
DIFF_FILE: clang-tidy-git-diff.txt FILTERED_OUTPUT_FILE: /tmp/clang-tidy-filtered-output.txt
ISSUE_FILE: clang-tidy-issue.md DIFF_FILE: /tmp/clang-tidy-git-diff.txt
ISSUE_FILE: /tmp/clang-tidy-issue.md
COMPILER: clang
jobs: jobs:
determine-files: determine-files:
if: ${{ inputs.check_only_changed }} if: ${{ inputs.check_only_changed }}
permissions: permissions:
contents: read contents: read
uses: XRPLF/actions/.github/workflows/determine-tidy-files.yml@312aaab296060ff89d7f798dcab59f019bea6e02 uses: XRPLF/actions/.github/workflows/determine-tidy-files.yml@c7045074aafe9fb92fa537aa4446f81fbfc17e8b
run-clang-tidy: run-clang-tidy:
name: Run clang tidy name: Run clang tidy
needs: [determine-files] needs: [determine-files]
if: ${{ always() && !cancelled() && (!inputs.check_only_changed || needs.determine-files.outputs.cpp_changed_files != '' || needs.determine-files.outputs.clang_tidy_config_changed == 'true') }} if: ${{ always() && !cancelled() && (!inputs.check_only_changed || needs.determine-files.outputs.cpp_changed_files != '' || needs.determine-files.outputs.clang_tidy_config_changed == 'true') }}
runs-on: ["self-hosted", "Linux", "X64", "heavy"] runs-on: ["self-hosted", "Linux", "X64", "heavy"]
container: "ghcr.io/xrplf/xrpld/nix-debian:sha-63ffdc3" container: "ghcr.io/xrplf/xrpld/nix-debian:sha-e29b523"
permissions: permissions:
contents: read contents: read
issues: write issues: write
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Prepare runner - name: Prepare runner
uses: XRPLF/actions/prepare-runner@c47daebb2f9db64ffbac71b47d68a661498d5ce8 uses: XRPLF/actions/prepare-runner@c47daebb2f9db64ffbac71b47d68a661498d5ce8
@@ -59,7 +62,7 @@ jobs:
- name: Set compiler environment - name: Set compiler environment
uses: ./.github/actions/set-compiler-env uses: ./.github/actions/set-compiler-env
with: with:
compiler: clang compiler: ${{ env.COMPILER }}
- name: Setup Conan - name: Setup Conan
uses: ./.github/actions/setup-conan uses: ./.github/actions/setup-conan
@@ -150,21 +153,21 @@ jobs:
run: | run: |
if [ -f "${OUTPUT_FILE}" ]; then if [ -f "${OUTPUT_FILE}" ]; then
# Extract lines containing 'error:', 'warning:', or 'note:' # Extract lines containing 'error:', 'warning:', or 'note:'
grep -E '(error:|warning:|note:)' "${OUTPUT_FILE}" >filtered-output.txt || true grep -E '(error:|warning:|note:)' "${OUTPUT_FILE}" >"${FILTERED_OUTPUT_FILE}" || true
# If filtered output is empty, use original (might be a different error format) # If filtered output is empty, use original (might be a different error format)
if [ ! -s filtered-output.txt ]; then if [ ! -s "${FILTERED_OUTPUT_FILE}" ]; then
cp "${OUTPUT_FILE}" filtered-output.txt cp "${OUTPUT_FILE}" "${FILTERED_OUTPUT_FILE}"
fi fi
# Truncate if too large # Truncate if too large
head -c 60000 filtered-output.txt >>"${ISSUE_FILE}" head -c 60000 "${FILTERED_OUTPUT_FILE}" >>"${ISSUE_FILE}"
if [ "$(wc -c <filtered-output.txt)" -gt 60000 ]; then if [ "$(wc -c <"${FILTERED_OUTPUT_FILE}")" -gt 60000 ]; then
echo "" >>"${ISSUE_FILE}" echo "" >>"${ISSUE_FILE}"
echo "... (output truncated, see artifacts for full output)" >>"${ISSUE_FILE}" echo "... (output truncated, see artifacts for full output)" >>"${ISSUE_FILE}"
fi fi
rm filtered-output.txt rm "${FILTERED_OUTPUT_FILE}"
else else
echo "No output file found" >>"${ISSUE_FILE}" echo "No output file found" >>"${ISSUE_FILE}"
fi fi

View File

@@ -27,7 +27,7 @@ jobs:
matrix: ${{ steps.generate.outputs.matrix }} matrix: ${{ steps.generate.outputs.matrix }}
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Set up Python - name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
@@ -39,23 +39,8 @@ jobs:
working-directory: .github/scripts/strategy-matrix working-directory: .github/scripts/strategy-matrix
run: ./generate.py --packaging >>"${GITHUB_OUTPUT}" run: ./generate.py --packaging >>"${GITHUB_OUTPUT}"
generate-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
sparse-checkout: |
.github/actions/generate-version
src/libxrpl/protocol/BuildInfo.cpp
- name: Generate version
id: version
uses: ./.github/actions/generate-version
package: package:
needs: [generate-matrix, generate-version] needs: [generate-matrix]
if: ${{ github.event.repository.visibility == 'public' }} if: ${{ github.event.repository.visibility == 'public' }}
strategy: strategy:
fail-fast: false fail-fast: false
@@ -69,7 +54,7 @@ jobs:
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download pre-built binary - name: Download pre-built binary
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
@@ -82,14 +67,13 @@ jobs:
- name: Build package - name: Build package
env: env:
PKG_VERSION: ${{ needs.generate-version.outputs.version }}
PKG_RELEASE: ${{ inputs.pkg_release }} PKG_RELEASE: ${{ inputs.pkg_release }}
run: ./package/build_pkg.sh run: ./package/build_pkg.sh
- name: Upload package artifact - name: Upload package artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with: with:
name: ${{ matrix.artifact_name }}-pkg-${{ needs.generate-version.outputs.version }} name: ${{ matrix.artifact_name }}-pkg
path: | path: |
${{ env.BUILD_DIR }}/debbuild/*.deb ${{ env.BUILD_DIR }}/debbuild/*.deb
${{ env.BUILD_DIR }}/debbuild/*.ddeb ${{ env.BUILD_DIR }}/debbuild/*.ddeb

View File

@@ -23,7 +23,7 @@ jobs:
matrix: ${{ steps.generate.outputs.matrix }} matrix: ${{ steps.generate.outputs.matrix }}
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Set up Python - name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
@@ -35,4 +35,5 @@ jobs:
id: generate id: generate
env: env:
GENERATE_CONFIG: ${{ inputs.os != '' && format('--config={0}', inputs.os) || '' }} GENERATE_CONFIG: ${{ inputs.os != '' && format('--config={0}', inputs.os) || '' }}
run: ./generate.py ${GENERATE_CONFIG} >>"${GITHUB_OUTPUT}" GENERATE_EVENT: ${{ github.event_name }}
run: ./generate.py ${GENERATE_CONFIG} --event="${GENERATE_EVENT}" >>"${GITHUB_OUTPUT}"

View File

@@ -40,10 +40,10 @@ defaults:
jobs: jobs:
upload: upload:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: ghcr.io/xrplf/xrpld/nix-ubuntu:sha-63ffdc3 container: ghcr.io/xrplf/xrpld/nix-ubuntu:sha-e29b523
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Generate build version number - name: Generate build version number
id: version id: version

View File

@@ -30,6 +30,7 @@ on:
- ".github/scripts/strategy-matrix/**" - ".github/scripts/strategy-matrix/**"
- conanfile.py - conanfile.py
- conan.lock - conan.lock
- conan/profiles/**
env: env:
CONAN_REMOTE_NAME: xrplf CONAN_REMOTE_NAME: xrplf
@@ -64,7 +65,7 @@ jobs:
uses: XRPLF/actions/cleanup-workspace@c7d9ce5ebb03c752a354889ecd870cadfc2b1cd4 uses: XRPLF/actions/cleanup-workspace@c7d9ce5ebb03c752a354889ecd870cadfc2b1cd4
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Prepare runner - name: Prepare runner
uses: XRPLF/actions/prepare-runner@c47daebb2f9db64ffbac71b47d68a661498d5ce8 uses: XRPLF/actions/prepare-runner@c47daebb2f9db64ffbac71b47d68a661498d5ce8

View File

@@ -15,6 +15,7 @@ repos:
hooks: hooks:
- id: check-added-large-files - id: check-added-large-files
args: [--maxkb=400, --enforce-all] args: [--maxkb=400, --enforce-all]
- id: check-executables-have-shebangs
- id: trailing-whitespace - id: trailing-whitespace
- id: end-of-file-fixer - id: end-of-file-fixer
- id: check-merge-conflict - id: check-merge-conflict
@@ -35,13 +36,18 @@ repos:
language: python language: python
types_or: [c++, c] types_or: [c++, c]
exclude: ^include/xrpl/protocol_autogen/(transactions|ledger_entries)/ exclude: ^include/xrpl/protocol_autogen/(transactions|ledger_entries)/
- id: fix-pragma-once
name: fix missing '#pragma once' declarations in header files
language: python
entry: ./bin/pre-commit/fix_pragma_once.py
files: \.(h|hpp)$
- repo: https://github.com/pre-commit/mirrors-clang-format - repo: https://github.com/pre-commit/mirrors-clang-format
rev: dd18dad857d6133e90bbe478f4f2f22ec0030269 # frozen: v22.1.5 rev: dd18dad857d6133e90bbe478f4f2f22ec0030269 # frozen: v22.1.5
hooks: hooks:
- id: clang-format - id: clang-format
args: [--style=file] args: [--style=file]
"types_or": [c++, c, proto] types_or: [c++, c, proto]
exclude: ^include/xrpl/protocol_autogen/(transactions|ledger_entries)/ exclude: ^include/xrpl/protocol_autogen/(transactions|ledger_entries)/
- repo: https://github.com/BlankSpruce/gersemi-pre-commit - repo: https://github.com/BlankSpruce/gersemi-pre-commit

391
BUILD.md
View File

@@ -1,26 +1,57 @@
| :warning: **WARNING** :warning: | | :warning: **WARNING** :warning: |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| These instructions assume you have a C++ development environment ready with Git, Python, Conan, CMake, and a C++ compiler. For help setting one up on Linux, macOS, or Windows, [see this guide](./docs/build/environment.md). | | These instructions assume you have a C++ development environment ready with Git, Python, Conan, CMake, and a C++ compiler. For help setting one up on Linux, macOS, or Windows, [see this guide](./docs/build/environment.md).<br><br>These instructions also assume a basic familiarity with Conan and CMake. If you are unfamiliar with Conan, you can read our [crash course](./docs/build/conan.md) or the official [Getting Started][conan-getting-started] walkthrough. |
> These instructions also assume a basic familiarity with Conan and CMake. ## Minimum Requirements
> If you are unfamiliar with Conan, you can read our
> [crash course](./docs/build/conan.md) or the official [Getting Started][3]
> walkthrough.
## Branches See [System Requirements](https://xrpl.org/system-requirements.html).
For a stable release, choose the `master` branch or one of the [tagged Building xrpld generally requires Git, Python, Conan, CMake, and a C++
releases](https://github.com/XRPLF/rippled/releases). compiler.
- [Python](https://www.python.org/downloads/)
- [Conan](https://conan.io/downloads.html)
- [CMake](https://cmake.org/download/)
You can verify that the required tools are installed and runnable with:
```bash ```bash
git checkout master ./bin/check-tools.sh
``` ```
For the latest release candidate, choose the `release` branch. `xrpld` is written in the C++23 dialect. The [tested compiler versions][cpp23-support] are:
```bash | Compiler | Version |
git checkout release | ----------- | --------------- |
``` | GCC | 15.2 |
| Clang | 22 |
| Apple Clang | 17 |
| MSVC | 19.44[^windows] |
## Operating Systems
Please see the [environment setup guide](./docs/build/environment.md) for detailed instructions for all platforms.
### Linux
The Ubuntu Linux distribution has received the highest level of quality
assurance, testing, and support. We also support Red Hat and use Debian
internally.
Our Linux CI tooling is distro-independent and uses a Nix-based environment, so it should be possible to build on other Linux distributions as well, although we have not tested them.
### macOS
Many `xrpld` engineers use macOS for development.
### Windows
Windows is used by some engineers for development only.
[^windows]: Windows is not recommended for production use.
## Steps
### Branches
For the latest set of untested features, or to contribute, choose the `develop` For the latest set of untested features, or to contribute, choose the `develop`
branch. branch.
@@ -29,55 +60,15 @@ branch.
git checkout develop git checkout develop
``` ```
## Minimum Requirements For a release candidate, choose the relevant release branch, e.g.
`release/3.2.x`.
See [System Requirements](https://xrpl.org/system-requirements.html). ```bash
git checkout release/3.2.x
```
Building xrpld generally requires git, Python, Conan, CMake, and a C++ For a stable release, choose one of the [tagged
compiler. Some guidance on setting up such a [C++ development environment can be releases](https://github.com/XRPLF/rippled/releases).
found here](./docs/build/environment.md).
- [Python 3.11](https://www.python.org/downloads/), or higher
- [Conan 2.17](https://conan.io/downloads.html)[^1], or higher
- [CMake 3.22](https://cmake.org/download/), or higher
[^1]:
It is possible to build with Conan 1.60+, but the instructions are
significantly different, which is why we are not recommending it.
`xrpld` is written in the C++20 dialect and includes the `<concepts>` header.
The [minimum compiler versions][2] required are:
| Compiler | Version |
| ----------- | --------- |
| GCC | 12 |
| Clang | 16 |
| Apple Clang | 16 |
| MSVC | 19.44[^3] |
### Linux
The Ubuntu Linux distribution has received the highest level of quality
assurance, testing, and support. We also support Red Hat and use Debian
internally.
Here are [sample instructions for setting up a C++ development environment on
Linux](./docs/build/environment.md#linux).
### Mac
Many xrpld engineers use macOS for development.
Here are [sample instructions for setting up a C++ development environment on
macOS](./docs/build/environment.md#macos).
### Windows
Windows is used by some engineers for development only.
[^3]: Windows is not recommended for production use.
## Steps
### Set Up Conan ### Set Up Conan
@@ -86,18 +77,11 @@ Conan, CMake, and a C++ compiler, you may need to set up your Conan profile.
These instructions assume a basic familiarity with Conan and CMake. If you are These instructions assume a basic familiarity with Conan and CMake. If you are
unfamiliar with Conan, then please read [this crash course](./docs/build/conan.md) or the official unfamiliar with Conan, then please read [this crash course](./docs/build/conan.md) or the official
[Getting Started][3] walkthrough. [Getting Started][conan-getting-started] walkthrough.
#### Conan lockfile #### Profiles
To achieve reproducible dependencies, we use a [Conan lockfile](https://docs.conan.io/2/tutorial/versioning/lockfiles.html), We recommend that you install our Conan profiles:
which has to be updated every time dependencies change.
Please see the [instructions on how to regenerate the lockfile](conan/lockfile/README.md).
#### Default profile
We recommend that you import the provided `conan/profiles/default` profile:
```bash ```bash
conan config install conan/profiles/ -tf $(conan config home)/profiles/ conan config install conan/profiles/ -tf $(conan config home)/profiles/
@@ -109,222 +93,15 @@ You can check your Conan profile by running:
conan profile show conan profile show
``` ```
#### Custom profile If the default profile is not suitable for your environment, you can create a custom profile and pass it to Conan.
More information on customizing Conan can be found in the [Advanced Conan configuration](./docs/build/advanced_conan.md).
If the default profile does not work for you and you do not yet have a Conan #### Add xrplf remote
profile, you can create one by running:
Run the following command to add the `xrplf` remote, which hosts some of our dependencies:
```bash ```bash
conan profile detect conan remote add --index 0 --force xrplf https://conan.ripplex.io
```
You may need to make changes to the profile to suit your environment. You can
refer to the provided `conan/profiles/default` profile for inspiration, and you
may also need to apply the required [tweaks](#conan-profile-tweaks) to this
default profile.
### Patched recipes
Occasionally, we need patched recipes or recipes not present in Conan Center.
We maintain a fork of the Conan Center Index
[here](https://github.com/XRPLF/conan-center-index/) containing the modified and newly added recipes.
To ensure our patched recipes are used, you must add our Conan remote at a
higher index than the default Conan Center remote, so it is consulted first. You
can do this by running:
```bash
conan remote add --index 0 xrplf https://conan.ripplex.io
```
Alternatively, you can pull our recipes from the repository and export them locally:
```bash
# Define which recipes to export.
recipes=('abseil' 'ed25519' 'mpt-crypto' 'openssl' 'secp256k1' 'snappy' 'soci' 'wasm-xrplf' 'wasmi')
# Selectively check out the recipes from our CCI fork.
cd external
mkdir -p conan-center-index
cd conan-center-index
git init
git remote add origin git@github.com:XRPLF/conan-center-index.git
git sparse-checkout init
for recipe in "${recipes[@]}"; do
echo "Checking out recipe '${recipe}'..."
git sparse-checkout add recipes/${recipe}
done
git fetch origin master
git checkout master
./export_all.sh
cd ../../
```
In the case we switch to a newer version of a dependency that still requires a
patch or add a new dependency, it will be necessary for you to pull in the changes and re-export the
updated dependencies with the newer version. However, if we switch to a newer
version that no longer requires a patch, no action is required on your part, as
the new recipe will be automatically pulled from the official Conan Center.
> [!NOTE]
> You might need to add `--lockfile=""` to your `conan install` command
> to avoid automatic use of the existing `conan.lock` file when you run
> `conan export` manually on your machine
>
> This is not recommended though, as you might end up using different revisions of recipes.
### Conan profile tweaks
#### Missing compiler version
If you see an error similar to the following after running `conan profile show`:
```text
ERROR: Invalid setting '17' is not a valid 'settings.compiler.version' value.
Possible values are ['5.0', '5.1', '6.0', '6.1', '7.0', '7.3', '8.0', '8.1',
'9.0', '9.1', '10.0', '11.0', '12.0', '13', '13.0', '13.1', '14', '14.0', '15',
'15.0', '16', '16.0']
Read "http://docs.conan.io/2/knowledge/faq.html#error-invalid-setting"
```
you need to add your compiler to the list of compiler versions in
`$(conan config home)/settings_user.yml`, by adding the required version number(s)
to the `version` array specific for your compiler. For example:
```yaml
compiler:
apple-clang:
version: ["17.0"]
```
#### Multiple compilers
If you have multiple compilers installed, make sure to select the one to use in
your default Conan configuration **before** running `conan profile detect`, by
setting the `CC` and `CXX` environment variables.
For example, if you are running MacOS and have [homebrew
LLVM@18](https://formulae.brew.sh/formula/llvm@18), and want to use it as a
compiler in the new Conan profile:
```bash
export CC=$(brew --prefix llvm@18)/bin/clang
export CXX=$(brew --prefix llvm@18)/bin/clang++
conan profile detect
```
You should also explicitly set the path to the compiler in the profile file,
which helps to avoid errors when `CC` and/or `CXX` are set and disagree with the
selected Conan profile. For example:
```text
[conf]
tools.build:compiler_executables={'c':'/usr/bin/gcc','cpp':'/usr/bin/g++'}
```
#### Multiple profiles
You can manage multiple Conan profiles in the directory
`$(conan config home)/profiles`, for example renaming `default` to a different
name and then creating a new `default` profile for a different compiler.
#### Select language
The default profile created by Conan will typically select different C++ dialect
than C++20 used by this project. You should set `20` in the profile line
starting with `compiler.cppstd=`. For example:
```bash
sed -i.bak -e 's|^compiler\.cppstd=.*$|compiler.cppstd=20|' $(conan config home)/profiles/default
```
#### Select standard library in Linux
**Linux** developers will commonly have a default Conan [profile][] that
compiles with GCC and links with libstdc++. If you are linking with libstdc++
(see profile setting `compiler.libcxx`), then you will need to choose the
`libstdc++11` ABI:
```bash
sed -i.bak -e 's|^compiler\.libcxx=.*$|compiler.libcxx=libstdc++11|' $(conan config home)/profiles/default
```
#### Select architecture and runtime in Windows
**Windows** developers may need to use the x64 native build tools. An easy way
to do that is to run the shortcut "x64 Native Tools Command Prompt" for the
version of Visual Studio that you have installed.
Windows developers must also build `xrpld` and its dependencies for the x64
architecture:
```bash
sed -i.bak -e 's|^arch=.*$|arch=x86_64|' $(conan config home)/profiles/default
```
**Windows** developers also must select static runtime:
```bash
sed -i.bak -e 's|^compiler\.runtime=.*$|compiler.runtime=static|' $(conan config home)/profiles/default
```
#### Clang workaround for grpc
If your compiler is clang, version 19 or later, or apple-clang, version 17 or
later, you may encounter a compilation error while building the `grpc`
dependency:
```text
In file included from .../lib/promise/try_seq.h:26:
.../lib/promise/detail/basic_seq.h:499:38: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
499 | Traits::template CallSeqFactory(f_, *cur_, std::move(arg)));
| ^
```
The workaround for this error is to add two lines to profile:
```text
[conf]
tools.build:cxxflags=['-Wno-missing-template-arg-list-after-template-kw']
```
#### Workaround for gcc 12
If your compiler is gcc, version 12, and you have enabled `werr` option, you may
encounter a compilation error such as:
```text
/usr/include/c++/12/bits/char_traits.h:435:56: error: 'void* __builtin_memcpy(void*, const void*, long unsigned int)' accessing 9223372036854775810 or more bytes at offsets [2, 9223372036854775807] and 1 may overlap up to 9223372036854775813 bytes at offset -3 [-Werror=restrict]
435 | return static_cast<char_type*>(__builtin_memcpy(__s1, __s2, __n));
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
```
The workaround for this error is to add two lines to your profile:
```text
[conf]
tools.build:cxxflags=['-Wno-restrict']
```
#### Workaround for clang 16
If your compiler is clang, version 16, you may encounter compilation error such
as:
```text
In file included from .../boost/beast/websocket/stream.hpp:2857:
.../boost/beast/websocket/impl/read.hpp:695:17: error: call to 'async_teardown' is ambiguous
async_teardown(impl.role, impl.stream(),
^~~~~~~~~~~~~~
```
The workaround for this error is to add two lines to your profile:
```text
[conf]
tools.build:cxxflags=['-DBOOST_ASIO_DISABLE_CONCEPTS']
``` ```
### Set Up Ccache ### Set Up Ccache
@@ -333,14 +110,7 @@ To speed up repeated compilations, we recommend that you install
[ccache](https://ccache.dev), a tool that wraps your compiler so that it can [ccache](https://ccache.dev), a tool that wraps your compiler so that it can
cache build objects locally. cache build objects locally.
#### Linux On Linux and macOS, `ccache` is included in the [Nix development shell](./docs/build/nix.md).
You can install it using the package manager, e.g. `sudo apt install ccache`
(Ubuntu) or `sudo dnf install ccache` (RHEL).
#### macOS
You can install it using Homebrew, i.e. `brew install ccache`.
#### Windows #### Windows
@@ -549,7 +319,7 @@ See [Sanitizers docs](./docs/build/sanitizers.md) for more details.
| Option | Default Value | Description | | Option | Default Value | Description |
| ---------- | ------------- | -------------------------------------------------------------- | | ---------- | ------------- | -------------------------------------------------------------- |
| `assert` | OFF | Enable assertions. | | `assert` | OFF | Force enabling assertions. |
| `coverage` | OFF | Prepare the coverage report. | | `coverage` | OFF | Prepare the coverage report. |
| `tests` | OFF | Build tests. | | `tests` | OFF | Build tests. |
| `unity` | OFF | Configure a unity build. | | `unity` | OFF | Configure a unity build. |
@@ -557,7 +327,7 @@ See [Sanitizers docs](./docs/build/sanitizers.md) for more details.
| `werr` | OFF | Treat compilation warnings as errors | | `werr` | OFF | Treat compilation warnings as errors |
| `wextra` | OFF | Enable additional compilation warnings | | `wextra` | OFF | Enable additional compilation warnings |
[Unity builds][5] may be faster for the first build (at the cost of much more [Unity builds][unity-build] may be faster for the first build (at the cost of much more
memory) since they concatenate sources into fewer translation units. Non-unity memory) since they concatenate sources into fewer translation units. Non-unity
builds may be faster for incremental builds, and can be helpful for detecting builds may be faster for incremental builds, and can be helpful for detecting
`#include` omissions. `#include` omissions.
@@ -583,14 +353,14 @@ After any updates or changes to dependencies, you may need to do the following:
conan remove '*' conan remove '*'
``` ```
3. Re-run [conan export](#patched-recipes) if needed. 3. Re-run [conan export](./docs/build/advanced_conan.md#patched-recipes) if needed.
4. [Regenerate lockfile](#conan-lockfile). 4. [Regenerate lockfile](./docs/build/advanced_conan.md#conan-lockfile).
5. Re-run [conan install](#build-and-test). 5. Re-run [conan install](#build-and-test).
#### ERROR: Package not resolved #### ERROR: Package not resolved
If you're seeing an error like `ERROR: Package 'snappy/1.1.10' not resolved: Unable to find 'snappy/1.1.10#968fef506ff261592ec30c574d4a7809%1756234314.246' in remotes.`, If you're seeing an error like `ERROR: Package 'snappy/1.1.10' not resolved: Unable to find 'snappy/1.1.10#968fef506ff261592ec30c574d4a7809%1756234314.246' in remotes.`,
please add `xrplf` remote or re-run `conan export` for [patched recipes](#patched-recipes). please [add `xrplf` remote](#add-xrplf-remote) or re-run `conan export` for [patched recipes](./docs/build/advanced_conan.md#patched-recipes).
### `protobuf/port_def.inc` file not found ### `protobuf/port_def.inc` file not found
@@ -610,28 +380,9 @@ For example, if you want to build Debug:
1. For conan install, pass `--settings build_type=Debug` 1. For conan install, pass `--settings build_type=Debug`
2. For cmake, pass `-DCMAKE_BUILD_TYPE=Debug` 2. For cmake, pass `-DCMAKE_BUILD_TYPE=Debug`
## Add a Dependency [cpp23-support]: https://en.cppreference.com/w/cpp/compiler_support/23
[conan-getting-started]: https://docs.conan.io/en/latest/getting_started.html
If you want to experiment with a new package, follow these steps: [unity-build]: https://en.wikipedia.org/wiki/Unity_build
1. Search for the package on [Conan Center](https://conan.io/center/).
2. Modify [`conanfile.py`](./conanfile.py):
- Add a version of the package to the `requires` property.
- Change any default options for the package by adding them to the
`default_options` property (with syntax `'$package:$option': $value`).
3. Modify [`CMakeLists.txt`](./CMakeLists.txt):
- Add a call to `find_package($package REQUIRED)`.
- Link a library from the package to the target `xrpl_libs`
(search for the existing call to `target_link_libraries(xrpl_libs INTERFACE ...)`).
4. Start coding! Don't forget to include whatever headers you need from the package.
[1]: https://github.com/conan-io/conan-center-index/issues/13168
[2]: https://en.cppreference.com/w/cpp/compiler_support/20
[3]: https://docs.conan.io/en/latest/getting_started.html
[5]: https://en.wikipedia.org/wiki/Unity_build
[6]: https://github.com/boostorg/beast/issues/2648
[7]: https://github.com/boostorg/beast/issues/2661
[gcovr]: https://gcovr.com/en/stable/getting-started.html [gcovr]: https://gcovr.com/en/stable/getting-started.html
[python-pip]: https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/ [python-pip]: https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/
[build_type]: https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html [build_type]: https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html
[profile]: https://docs.conan.io/en/latest/reference/profiles.html

View File

@@ -15,7 +15,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
project(xrpl) project(xrpl)
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
@@ -57,6 +57,8 @@ if(target)
) )
endif() endif()
include(PatchNixBinary)
include(XrplSanity) include(XrplSanity)
include(XrplVersion) include(XrplVersion)
include(XrplSettings) include(XrplSettings)

View File

@@ -14,9 +14,9 @@ The following branches exist in the main project repository:
- `develop`: The latest set of unreleased features, and the most common - `develop`: The latest set of unreleased features, and the most common
starting point for contributions. starting point for contributions.
- `release`: The latest beta release or release candidate. - `release/*` (e.g. `release/3.2.x`): Release branches, one per release line,
- `master`: The latest stable release. holding the latest release candidate, or stable release for that line.
- `gh-pages`: The documentation for this project, built by Doxygen. Stable releases are published as [tagged releases](https://github.com/XRPLF/rippled/releases).
The tip of each branch must be signed. In order for GitHub to sign a The tip of each branch must be signed. In order for GitHub to sign a
squashed commit that it builds from your pull request, GitHub must know squashed commit that it builds from your pull request, GitHub must know
@@ -130,11 +130,9 @@ tl;dr
## Pull requests ## Pull requests
In general, pull requests use `develop` as the base branch. In general, pull requests use `develop` as the base branch.
The exceptions are
- Fixes and improvements to a release candidate use `release` as the The exceptions are fixes, improvements, and hotfixes for an existing release,
base. which use that release's branch (e.g. `release/3.2.x`) as the base.
- Hotfixes use `master` as the base.
If your changes are not quite ready, but you want to make it easily available If your changes are not quite ready, but you want to make it easily available
for preliminary examination or review, you can create a "Draft" pull request. for preliminary examination or review, you can create a "Draft" pull request.
@@ -216,7 +214,7 @@ coherent rather than a set of _thou shalt not_ commandments.
## Formatting ## Formatting
All code must conform to `clang-format` version 21, All code must conform to `clang-format` version 22,
according to the settings in [`.clang-format`](./.clang-format), according to the settings in [`.clang-format`](./.clang-format),
unless the result would be unreasonably difficult to read or maintain. unless the result would be unreasonably difficult to read or maintain.
To demarcate lines that should be left as-is, surround them with comments like To demarcate lines that should be left as-is, surround them with comments like
@@ -261,7 +259,7 @@ This ensures that configuration changes don't introduce new warnings across the
### Installing clang-tidy ### Installing clang-tidy
See the [environment setup guide](./docs/build/environment.md#clang-tidy) for platform-specific installation instructions. See the [environment setup guide](./docs/build/environment.md#clang-tidy) for how to get clang-tidy.
### Running clang-tidy locally ### Running clang-tidy locally

161
bin/check-tools.sh Executable file
View File

@@ -0,0 +1,161 @@
#!/usr/bin/env bash
#
# check-tools.sh — verify the xrpld development tooling is present and runnable.
#
# Works on Linux, macOS, and Windows (Git Bash / MSYS). For every expected tool
# it runs a version probe, collecting anything that is missing or fails to run,
# and prints a summary at the end (exiting non-zero if anything is missing).
#
# The tool set is platform-aware:
# - Linux: the full Nix CI environment (see nix/packages.nix, nix/ci-env.nix),
# with GCC, Clang and the sanitizer/coverage tooling. This script is
# run during the Nix Docker image build (nix/docker/Dockerfile), so
# the Linux list is kept in sync with that environment.
# - macOS: the same tooling, minus GCC/g++/gcov/mold
# - Windows: the core build tools only (CMake, Conan, Git, Python).
# MSVC is expected to be provided separately and is not checked here.
#
# Some tools (clang-format, doxygen, gcovr, gh, git-cliff, gpg, pre-commit,
# run-clang-tidy) are present in our Linux CI images and in local development
# setups, but not in the macOS CI environment. They are checked everywhere
# except when running in CI on macOS.
#
# Environment variables:
# CI if set, skip the tools above when on macOS.
# CHECK_TOOLS_SKIP_CLONE if set, skip the git-over-HTTPS connectivity check.
set -uo pipefail
missing=()
checked=0
# check <name> [probe-command...]
# Runs the probe (default: "<name> --version") quietly. Records <name> as
# missing if the command is not found or exits non-zero.
check() {
local name="$1"
shift
local -a probe=("$@")
if [ "${#probe[@]}" -eq 0 ]; then
probe=("${name}" --version)
fi
echo "Checking ${name}..."
checked=$((checked + 1))
if "${probe[@]}" | head -n 1; then
printf ' [ ok ] %s\n' "${name}"
else
printf ' [MISS] %s\n' "${name}"
missing+=("${name}")
fi
}
case "$(uname -s)" in
Linux*) os=linux ;;
Darwin*) os=macos ;;
MINGW* | MSYS* | CYGWIN*) os=windows ;;
*)
echo "Unknown OS: $(uname -s)" >&2
exit 1
;;
esac
echo "Detected OS: ${os} ($(uname -s) $(uname -m))"
echo
echo "Core build tools:"
check cmake
check conan
check git
if [ "${os}" = "windows" ]; then
check python python --version
else
check python3
fi
# The full development toolchain. Available from Nix on Linux and macOS; on
# Windows these are typically not installed, so they are skipped.
if [ "${os}" = "linux" ] || [ "${os}" = "macos" ]; then
echo
echo "Development tooling:"
check ccache
check clang
check clang++
check ClangBuildAnalyzer
check curl
check file
check less
check make
check netstat which netstat
check ninja
check perl
check pkg-config
check vim
check zip
# These tools are present in our Linux CI images and in local development
# setups, but not in the macOS CI environment. So check them everywhere
# except when running in CI on macOS.
if [ "${os}" = "linux" ] || [ -z "${CI:-}" ]; then
check clang-format
check dot
check doxygen
check gcovr
check gh
check git-cliff
check git-lfs
check gpg
# pre-commit, or its alternative implementation prek
check pre-commit sh -c 'pre-commit --version || prek --version'
check run-clang-tidy run-clang-tidy --help
fi
fi
# GCC is the default compiler on Linux. macOS uses the system Apple Clang
# instead, so GCC/g++/gcov are not expected there.
if [ "${os}" = "linux" ]; then
echo
echo "GCC toolchain:"
check gcc
check g++
check gcov
echo
echo "Mold:"
check mold
fi
if [ "${os}" = "windows" ]; then
echo
echo "Note: on Windows the C++ compiler is MSVC, which is provided"
echo " separately (e.g. via Visual Studio) and is not checked here."
fi
# A simple test to verify that git can clone a repository over HTTPS
# (i.e. the CA bundle is wired up). Clone to a temp dir and clean up.
if [ -n "${CHECK_TOOLS_SKIP_CLONE:-}" ]; then
echo
echo "Skipping git-over-HTTPS check (CHECK_TOOLS_SKIP_CLONE is set)."
else
echo
echo "Connectivity check:"
checked=$((checked + 1))
tmp_clone="$(mktemp -d)"
if git clone --depth 1 https://github.com/XRPLF/actions.git "${tmp_clone}/actions" >/dev/null 2>&1; then
printf ' [ ok ] git clone over HTTPS\n'
else
printf ' [MISS] git clone over HTTPS\n'
missing+=("git-https-clone")
fi
rm -rf "${tmp_clone}"
fi
echo
if [ "${#missing[@]}" -eq 0 ]; then
echo "All ${checked} checked tools are present and runnable."
else
echo "Missing or non-functional tools (${#missing[@]} of ${checked}):" >&2
for tool in "${missing[@]}"; do
echo " - ${tool}" >&2
done
exit 1
fi

View File

@@ -0,0 +1,34 @@
#!/usr/bin/env python3
"""
Adds "#pragma once" to the top of header files that don't already have it.
Usage: ./bin/pre-commit/fix_pragma_once.py <file1> <file2> ...
"""
import sys
from pathlib import Path
PRAGMA_ONCE = "#pragma once\n\n"
def fix_pragma_once(path: Path) -> bool:
original = path.read_text(encoding="utf-8")
if PRAGMA_ONCE not in original:
path.write_text(PRAGMA_ONCE + original, encoding="utf-8")
return False
return True
def main() -> int:
files = [Path(f) for f in sys.argv[1:]]
success = True
for path in files:
success &= fix_pragma_once(path)
return 0 if success else 1
if __name__ == "__main__":
sys.exit(main())

View File

@@ -56,3 +56,16 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|arm64|ARM64")
else() else()
message(FATAL_ERROR "Unknown architecture: ${CMAKE_SYSTEM_PROCESSOR}") message(FATAL_ERROR "Unknown architecture: ${CMAKE_SYSTEM_PROCESSOR}")
endif() endif()
# --------------------------------------------------------------------
# Sanitizers
# --------------------------------------------------------------------
# SANITIZERS is injected by the Conan toolchain when a sanitizer build is
# requested (see conan/profiles/sanitizers). The flags are applied to the
# 'common' target in XrplSanitizers; this flag lets other modules know a
# sanitizer build is active without depending on that module.
if(DEFINED SANITIZERS)
set(SANITIZERS_ENABLED TRUE)
else()
set(SANITIZERS_ENABLED FALSE)
endif()

View File

@@ -0,0 +1,53 @@
#[===================================================================[
Patch executables to run in non-Nix environments.
The Nix-based CI image links binaries against an ELF interpreter (loader)
that lives in the Nix store, so the resulting binaries don't run elsewhere
(including once installed from the .deb package). `patch_nix_binary` adds a
POST_BUILD step that resets the interpreter to the system default loader and
drops the rpath.
This is only active inside the Nix-based image, detected by the presence of
/tmp/loader-path.sh (shipped by that image, resolves the default loader). It
is skipped for sanitizer builds, whose runtime libraries are resolved through
the rpath. Everywhere else `patch_nix_binary` is a no-op.
#]===================================================================]
include_guard(GLOBAL)
include(CompilationEnv)
# Provided by the Nix-based CI image; prints the system default ELF loader path.
set(_loader_path_script "/tmp/loader-path.sh")
if(is_linux AND NOT SANITIZERS_ENABLED AND EXISTS "${_loader_path_script}")
execute_process(
COMMAND "${_loader_path_script}"
OUTPUT_VARIABLE DEFAULT_LOADER_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE
COMMAND_ERROR_IS_FATAL ANY
)
find_program(PATCHELF_COMMAND patchelf REQUIRED)
set(PATCH_NIX_BINARIES TRUE)
message(
STATUS
"Binaries will be patched to use loader '${DEFAULT_LOADER_PATH}'"
)
else()
set(PATCH_NIX_BINARIES FALSE)
endif()
function(patch_nix_binary target)
if(NOT PATCH_NIX_BINARIES)
return()
endif()
add_custom_command(
TARGET ${target}
POST_BUILD
COMMAND
"${PATCHELF_COMMAND}" --set-interpreter "${DEFAULT_LOADER_PATH}"
--remove-rpath "$<TARGET_FILE:${target}>"
COMMENT "Patching ${target}: set default loader, remove rpath"
VERBATIM
)
endfunction()

View File

@@ -154,6 +154,15 @@ else()
> >
) )
# On aarch64, libatomic is required for atomic operations. It is not needed on x86_64.
# Linking it statically on Linux
if(is_arm64 AND is_linux)
target_link_options(
common
INTERFACE -Wl,--push-state -Wl,-Bstatic -latomic -Wl,--pop-state
)
endif()
# Keep -stdlib=libstdc++ off the compile commands, but preserve it for linking. # Keep -stdlib=libstdc++ off the compile commands, but preserve it for linking.
# #
# Conan turns `compiler.libcxx=libstdc++` into `-stdlib=libstdc++` and puts it in # Conan turns `compiler.libcxx=libstdc++` into `-stdlib=libstdc++` and puts it in

View File

@@ -94,6 +94,9 @@ add_module(xrpl basics)
target_link_libraries(xrpl.libxrpl.basics PUBLIC xrpl.libxrpl.beast) target_link_libraries(xrpl.libxrpl.basics PUBLIC xrpl.libxrpl.beast)
# Level 03 # Level 03
add_module(xrpl config)
target_link_libraries(xrpl.libxrpl.config PUBLIC xrpl.libxrpl.basics)
add_module(xrpl json) add_module(xrpl json)
target_link_libraries(xrpl.libxrpl.json PUBLIC xrpl.libxrpl.basics) target_link_libraries(xrpl.libxrpl.json PUBLIC xrpl.libxrpl.basics)
@@ -120,6 +123,7 @@ target_link_libraries(
xrpl.libxrpl.core xrpl.libxrpl.core
PUBLIC PUBLIC
xrpl.libxrpl.basics xrpl.libxrpl.basics
xrpl.libxrpl.config
xrpl.libxrpl.json xrpl.libxrpl.json
xrpl.libxrpl.protocol xrpl.libxrpl.protocol
xrpl.libxrpl.protocol_autogen xrpl.libxrpl.protocol_autogen
@@ -143,7 +147,11 @@ target_link_libraries(
add_module(xrpl nodestore) add_module(xrpl nodestore)
target_link_libraries( target_link_libraries(
xrpl.libxrpl.nodestore xrpl.libxrpl.nodestore
PUBLIC xrpl.libxrpl.basics xrpl.libxrpl.json xrpl.libxrpl.protocol PUBLIC
xrpl.libxrpl.basics
xrpl.libxrpl.config
xrpl.libxrpl.json
xrpl.libxrpl.protocol
) )
add_module(xrpl shamap) add_module(xrpl shamap)
@@ -159,13 +167,14 @@ target_link_libraries(
add_module(xrpl rdb) add_module(xrpl rdb)
target_link_libraries( target_link_libraries(
xrpl.libxrpl.rdb xrpl.libxrpl.rdb
PUBLIC xrpl.libxrpl.basics xrpl.libxrpl.core PUBLIC xrpl.libxrpl.basics xrpl.libxrpl.config xrpl.libxrpl.core
) )
add_module(xrpl server) add_module(xrpl server)
target_link_libraries( target_link_libraries(
xrpl.libxrpl.server xrpl.libxrpl.server
PUBLIC PUBLIC
xrpl.libxrpl.config
xrpl.libxrpl.protocol xrpl.libxrpl.protocol
xrpl.libxrpl.core xrpl.libxrpl.core
xrpl.libxrpl.rdb xrpl.libxrpl.rdb
@@ -210,6 +219,7 @@ target_link_modules(
basics basics
beast beast
conditions conditions
config
core core
crypto crypto
git git
@@ -237,6 +247,7 @@ target_link_modules(
if(xrpld) if(xrpld)
add_executable(xrpld) add_executable(xrpld)
patch_nix_binary(xrpld)
if(tests) if(tests)
target_compile_definitions(xrpld PUBLIC ENABLE_TESTS) target_compile_definitions(xrpld PUBLIC ENABLE_TESTS)
target_compile_definitions( target_compile_definitions(

View File

@@ -28,7 +28,6 @@ endif()
set(package_env set(package_env
SRC_DIR=${CMAKE_SOURCE_DIR} SRC_DIR=${CMAKE_SOURCE_DIR}
BUILD_DIR=${CMAKE_BINARY_DIR} BUILD_DIR=${CMAKE_BINARY_DIR}
PKG_VERSION=${xrpld_version}
PKG_RELEASE=${pkg_release} PKG_RELEASE=${pkg_release}
) )

View File

@@ -14,11 +14,9 @@
include_guard(GLOBAL) include_guard(GLOBAL)
include(CompilationEnv) include(CompilationEnv)
if(NOT DEFINED SANITIZERS) if(NOT SANITIZERS_ENABLED)
set(SANITIZERS_ENABLED FALSE)
return() return()
endif() endif()
set(SANITIZERS_ENABLED TRUE)
message(STATUS "=== Configuring Sanitizers ===") message(STATUS "=== Configuring Sanitizers ===")
message(STATUS " SANITIZERS: ${SANITIZERS}") message(STATUS " SANITIZERS: ${SANITIZERS}")

View File

@@ -1,9 +1,9 @@
{ {
"version": "0.5", "version": "0.5",
"requires": [ "requires": [
"zlib/1.3.2#1cb806da49011867778ffb6ac7190fcb%1777558780.503", "zlib/1.3.2#1cb806da49011867778ffb6ac7190fcb%1778091116.056",
"xxhash/0.8.3#681d36a0a6111fc56e5e45ea182c19cc%1765850149.987", "xxhash/0.8.3#681d36a0a6111fc56e5e45ea182c19cc%1765850149.987",
"sqlite3/3.53.0#324ada52333108388a9a6108bfa96734%1776096494.149", "sqlite3/3.53.0#324ada52333108388a9a6108bfa96734%1778091117.311",
"soci/4.0.3#fe32b9ad5eb47e79ab9e45a68f363945%1774450067.231", "soci/4.0.3#fe32b9ad5eb47e79ab9e45a68f363945%1774450067.231",
"snappy/1.1.10#968fef506ff261592ec30c574d4a7809%1765850147.878", "snappy/1.1.10#968fef506ff261592ec30c574d4a7809%1765850147.878",
"secp256k1/0.7.1#481881709eb0bdd0185a12b912bbe8ad%1770910500.329", "secp256k1/0.7.1#481881709eb0bdd0185a12b912bbe8ad%1770910500.329",
@@ -15,19 +15,19 @@
"lz4/1.10.0#59fc63cac7f10fbe8e05c7e62c2f3504%1765850143.914", "lz4/1.10.0#59fc63cac7f10fbe8e05c7e62c2f3504%1765850143.914",
"libiconv/1.17#1e65319e945f2d31941a9d28cc13c058%1765842973.492", "libiconv/1.17#1e65319e945f2d31941a9d28cc13c058%1765842973.492",
"libbacktrace/cci.20210118#a7691bfccd8caaf66309df196790a5a1%1765842973.03", "libbacktrace/cci.20210118#a7691bfccd8caaf66309df196790a5a1%1765842973.03",
"libarchive/3.8.7#c446109bd1f1d8ba7936c94189bc50e6%1776147552.838", "libarchive/3.8.7#c446109bd1f1d8ba7936c94189bc50e6%1778091117.848",
"jemalloc/5.3.1#1fc58d55316041f10fbc1e8a2eae632a%1776700028.228", "jemalloc/5.3.1#1fc58d55316041f10fbc1e8a2eae632a%1776700028.228",
"gtest/1.17.0#5224b3b3ff3b4ce1133cbdd27d53ee7d%1768312129.152", "gtest/1.17.0#5224b3b3ff3b4ce1133cbdd27d53ee7d%1768312129.152",
"grpc/1.78.1#b1a9e74b145cc471bed4dc64dc6eb2c1%1774467387.342", "grpc/1.81.0#2fb144aeb47e7f35c6ebb0e5f35bed31%1781620605.685",
"ed25519/2015.03#ae761bdc52730a843f0809bdf6c1b1f6%1765850143.772", "ed25519/2015.03#ae761bdc52730a843f0809bdf6c1b1f6%1765850143.772",
"date/3.0.4#862e11e80030356b53c2c38599ceb32b%1765850143.772", "date/3.0.4#862e11e80030356b53c2c38599ceb32b%1765850143.772",
"c-ares/1.34.6#545240bb1c40e2cacd4362d6b8967650%1774439234.681", "c-ares/1.34.6#545240bb1c40e2cacd4362d6b8967650%1774439234.681",
"bzip2/1.0.8#c470882369c2d95c5c77e970c0c7e321%1765850143.837", "bzip2/1.0.8#c470882369c2d95c5c77e970c0c7e321%1765850143.837",
"boost/1.91.0#ea540ca2133d831b560036aa24dece3c%1778050991.9", "boost/1.91.0#ea540ca2133d831b560036aa24dece3c%1778091165.282",
"abseil/20250127.0#bb0baf1f362bc4a725a24eddd419b8f7%1774365460.196" "abseil/20250127.0#bb0baf1f362bc4a725a24eddd419b8f7%1774365460.196"
], ],
"build_requires": [ "build_requires": [
"zlib/1.3.2#1cb806da49011867778ffb6ac7190fcb%1777558780.503", "zlib/1.3.2#1cb806da49011867778ffb6ac7190fcb%1778091116.056",
"strawberryperl/5.32.1.1#8d114504d172cfea8ea1662d09b6333e%1774447376.964", "strawberryperl/5.32.1.1#8d114504d172cfea8ea1662d09b6333e%1774447376.964",
"protobuf/6.33.5#d96d52ba5baaaa532f47bda866ad87a5%1774467363.12", "protobuf/6.33.5#d96d52ba5baaaa532f47bda866ad87a5%1774467363.12",
"nasm/2.16.01#31e26f2ee3c4346ecd347911bd126904%1765850144.707", "nasm/2.16.01#31e26f2ee3c4346ecd347911bd126904%1765850144.707",

View File

@@ -2,7 +2,7 @@
arch=x86_64 arch=x86_64
build_type=Release build_type=Release
compiler=gcc compiler=gcc
compiler.cppstd=20 compiler.cppstd=23
compiler.libcxx=libstdc++11 compiler.libcxx=libstdc++11
compiler.version=13 compiler.version=13
os=Linux os=Linux

View File

@@ -2,7 +2,7 @@
arch=armv8 arch=armv8
build_type=Release build_type=Release
compiler=apple-clang compiler=apple-clang
compiler.cppstd=20 compiler.cppstd=23
compiler.libcxx=libc++ compiler.libcxx=libc++
compiler.version=17.0 compiler.version=17.0
os=Macos os=Macos

View File

@@ -2,7 +2,7 @@
arch=x86_64 arch=x86_64
build_type=Release build_type=Release
compiler=msvc compiler=msvc
compiler.cppstd=20 compiler.cppstd=23
compiler.runtime=dynamic compiler.runtime=dynamic
compiler.runtime_type=Release compiler.runtime_type=Release
compiler.version=194 compiler.version=194

View File

@@ -12,7 +12,7 @@ arch={{ arch }}
build_type=Debug build_type=Debug
compiler={{compiler}} compiler={{compiler}}
compiler.version={{ compiler_version }} compiler.version={{ compiler_version }}
compiler.cppstd=20 compiler.cppstd=23
{% if os == "Windows" %} {% if os == "Windows" %}
compiler.runtime=static compiler.runtime=static
{% else %} {% else %}

View File

@@ -52,52 +52,50 @@ include(default)
{% endif %} {% endif %}
{# Frame pointer required for meaningful stack traces; -O1 for reasonable performance #} {# Frame pointer required for meaningful stack traces; -O1 for reasonable performance #}
{% set compile_flags = ["-fno-omit-frame-pointer", "-O1"] %} {% set sanitizer_compiler_flags = ["-fno-omit-frame-pointer", "-O1"] %}
{% if compiler == "gcc" %} {% if compiler == "gcc" %}
{# Suppress false positive warnings with GCC #} {# Suppress false positive warnings with GCC #}
{% set _ = compile_flags.append("-Wno-stringop-overflow") %} {% set _ = sanitizer_compiler_flags.append("-Wno-stringop-overflow") %}
{% set relocation_flags = [] %} {% set relocation_flags = [] %}
{% if arch == "x86_64" and enable_asan %} {% if arch == "x86_64" and enable_asan %}
{# Large code model prevents relocation errors in instrumented ASAN binaries #} {# Large code model prevents relocation errors in instrumented ASAN binaries #}
{% set _ = compile_flags.append("-mcmodel=large") %} {% set _ = sanitizer_compiler_flags.append("-mcmodel=large") %}
{% set _ = relocation_flags.append("-mcmodel=large") %} {% set _ = relocation_flags.append("-mcmodel=large") %}
{% elif enable_tsan %} {% elif enable_tsan %}
{# GCC doesn't support atomic_thread_fence with TSAN; suppress warnings #} {# GCC doesn't support atomic_thread_fence with TSAN; suppress warnings #}
{% set _ = compile_flags.append("-Wno-tsan") %} {% set _ = sanitizer_compiler_flags.append("-Wno-tsan") %}
{% if arch == "x86_64" %} {% if arch == "x86_64" %}
{# Medium code model for TSAN; large is incompatible #} {# Medium code model for TSAN; large is incompatible #}
{% set _ = compile_flags.append("-mcmodel=medium") %} {% set _ = sanitizer_compiler_flags.append("-mcmodel=medium") %}
{% set _ = relocation_flags.append("-mcmodel=medium") %} {% set _ = relocation_flags.append("-mcmodel=medium") %}
{% endif %} {% endif %}
{% endif %} {% endif %}
{% set fsanitize = "-fsanitize=" ~ ",".join(sanitizer_types) %} {% set fsanitize = "-fsanitize=" ~ ",".join(sanitizer_types) %}
{% set _ = compile_flags.append(fsanitize) %} {% set _ = sanitizer_compiler_flags.append(fsanitize) %}
{% set _ = relocation_flags.append(fsanitize) %} {% set _ = relocation_flags.append(fsanitize) %}
{% set sanitizer_compiler_flags = " ".join(compile_flags) %} {% set sanitizer_linker_flags = relocation_flags %}
{% set sanitizer_linker_flags = " ".join(relocation_flags) %}
{% elif compiler == "clang" or compiler == "apple-clang" %} {% elif compiler == "clang" or compiler == "apple-clang" %}
{% set fsanitize = "-fsanitize=" ~ ",".join(sanitizer_types) %} {% set fsanitize = "-fsanitize=" ~ ",".join(sanitizer_types) %}
{% set _ = compile_flags.append(fsanitize) %} {% set _ = sanitizer_compiler_flags.append(fsanitize) %}
{% set sanitizer_compiler_flags = " ".join(compile_flags) %} {% set sanitizer_linker_flags = [fsanitize] %}
{% set sanitizer_linker_flags = fsanitize %}
{% endif %} {% endif %}
[conf] [conf]
tools.build:defines+={{defines}} tools.build:defines+={{defines}}
tools.build:cxxflags+=['{{sanitizer_compiler_flags}}'] tools.build:cxxflags+={{sanitizer_compiler_flags}}
tools.build:sharedlinkflags+=['{{sanitizer_linker_flags}}'] tools.build:sharedlinkflags+={{sanitizer_linker_flags}}
tools.build:exelinkflags+=['{{sanitizer_linker_flags}}'] tools.build:exelinkflags+={{sanitizer_linker_flags}}
tools.info.package_id:confs+=["tools.build:cxxflags", "tools.build:exelinkflags", "tools.build:sharedlinkflags", "tools.build:defines"] tools.info.package_id:confs+=["tools.build:cxxflags", "tools.build:exelinkflags", "tools.build:sharedlinkflags", "tools.build:defines"]
# &: means "apply only to the consumer/root package" # &: means "apply only to the consumer/root package"
&:tools.cmake.cmaketoolchain:extra_variables={"SANITIZERS": "{{sanitizers}}", "SANITIZERS_COMPILER_FLAGS": "{{sanitizer_compiler_flags}}", "SANITIZERS_LINKER_FLAGS": "{{sanitizer_linker_flags}}"} &:tools.cmake.cmaketoolchain:extra_variables={"SANITIZERS": "{{sanitizers}}", "SANITIZERS_COMPILER_FLAGS": "{{sanitizer_compiler_flags | join(' ')}}", "SANITIZERS_LINKER_FLAGS": "{{sanitizer_linker_flags | join(' ')}}"}
[options] [options]
{% if enable_asan %} {% if enable_asan %}

View File

@@ -28,7 +28,7 @@ class Xrpl(ConanFile):
requires = [ requires = [
"ed25519/2015.03", "ed25519/2015.03",
"grpc/1.78.1", "grpc/1.81.0",
"libarchive/3.8.7", "libarchive/3.8.7",
"nudb/2.0.9", "nudb/2.0.9",
"openssl/3.6.2", "openssl/3.6.2",

View File

@@ -84,6 +84,7 @@ words:
- coro - coro
- coros - coros
- cowid - cowid
- cpack
- cryptocondition - cryptocondition
- cryptoconditional - cryptoconditional
- cryptoconditions - cryptoconditions
@@ -108,6 +109,7 @@ words:
- enabled - enabled
- enablerepo - enablerepo
- endmacro - endmacro
- envrc
- exceptioned - exceptioned
- EXPECT_STREQ - EXPECT_STREQ
- Falco - Falco
@@ -232,8 +234,10 @@ words:
- pyenv - pyenv
- pyparsing - pyparsing
- qalloc - qalloc
- qbsprofile
- queuable - queuable
- Raphson - Raphson
- rcflags
- replayer - replayer
- rerere - rerere
- retriable - retriable
@@ -297,6 +301,7 @@ words:
- txs - txs
- ubsan - ubsan
- UBSAN - UBSAN
- ufdio
- umant - umant
- unacquired - unacquired
- unambiguity - unambiguity

193
docs/build/advanced_conan.md vendored Normal file
View File

@@ -0,0 +1,193 @@
# Advanced Conan configuration
This document provides advanced instructions for setting up and configuring Conan for `xrpld` development: custom profiles, the lockfile, patched recipes, and profile tweaks.
## Custom profile
If the default profile does not work for you and you do not yet have a Conan
profile, you can create one by running:
```bash
conan profile detect
```
You may need to make changes to the profile to suit your environment. You can
refer to the provided `conan/profiles/default` profile for inspiration, and you
may also need to apply the required [tweaks](#conan-profile-tweaks) to this
default profile.
## Conan lockfile
To achieve reproducible dependencies, we use a [Conan lockfile](https://docs.conan.io/2/tutorial/versioning/lockfiles.html),
which has to be updated every time dependencies change.
Please see the [instructions on how to regenerate the lockfile](../../conan/lockfile/README.md).
## Patched recipes
Occasionally, we need patched recipes or recipes not present in Conan Center.
We maintain a fork of the Conan Center Index
[here](https://github.com/XRPLF/conan-center-index/) containing the modified and newly added recipes.
To ensure our patched recipes are used, you must add our Conan remote at a
higher index than the default Conan Center remote, so it is consulted first. You
can do this by running:
```bash
conan remote add --index 0 --force xrplf https://conan.ripplex.io
```
Alternatively, you can pull our recipes from the repository and export them locally:
```bash
# Define which recipes to export.
recipes=('abseil' 'ed25519' 'mpt-crypto' 'openssl' 'secp256k1' 'snappy' 'soci' 'wasm-xrplf' 'wasmi')
# Selectively check out the recipes from our CCI fork.
cd external
mkdir -p conan-center-index
cd conan-center-index
git init
git remote add origin git@github.com:XRPLF/conan-center-index.git
git sparse-checkout init
for recipe in "${recipes[@]}"; do
echo "Checking out recipe '${recipe}'..."
git sparse-checkout add recipes/${recipe}
done
git fetch origin master
git checkout master
./export_all.sh
cd ../../
```
In the case we switch to a newer version of a dependency that still requires a
patch or add a new dependency, it will be necessary for you to pull in the changes and re-export the
updated dependencies with the newer version. However, if we switch to a newer
version that no longer requires a patch, no action is required on your part, as
the new recipe will be automatically pulled from the official Conan Center.
> [!NOTE]
> You might need to add `--lockfile=""` to your `conan install` command
> to avoid automatic use of the existing `conan.lock` file when you run
> `conan export` manually on your machine
>
> This is not recommended though, as you might end up using different revisions of recipes.
## Conan profile tweaks
### Missing compiler version
If you see an error similar to the following after running `conan profile show`:
```text
ERROR: Invalid setting '17' is not a valid 'settings.compiler.version' value.
Possible values are ['5.0', '5.1', '6.0', '6.1', '7.0', '7.3', '8.0', '8.1',
'9.0', '9.1', '10.0', '11.0', '12.0', '13', '13.0', '13.1', '14', '14.0', '15',
'15.0', '16', '16.0']
Read "http://docs.conan.io/2/knowledge/faq.html#error-invalid-setting"
```
you need to create `$(conan config home)/settings_user.yml` file if it doesn't exist and add the required version number(s)
to the `version` array specific for your compiler. For example:
```yaml
compiler:
apple-clang:
version: ["17.0"]
```
### Multiple compilers
If you have multiple compilers installed, make sure to select the one to use in
your default Conan configuration **before** running `conan profile detect`, by
setting the `CC` and `CXX` environment variables.
For example, if you are running MacOS and have [homebrew
LLVM@18](https://formulae.brew.sh/formula/llvm@18), and want to use it as a
compiler in the new Conan profile:
```bash
export CC=$(brew --prefix llvm@18)/bin/clang
export CXX=$(brew --prefix llvm@18)/bin/clang++
conan profile detect
```
You should also explicitly set the path to the compiler in the profile file,
which helps to avoid errors when `CC` and/or `CXX` are set and disagree with the
selected Conan profile. For example:
```text
[conf]
tools.build:compiler_executables={'c':'/usr/bin/gcc','cpp':'/usr/bin/g++'}
```
### Multiple profiles
You can manage multiple Conan profiles in the directory
`$(conan config home)/profiles`, for example renaming `default` to a different
name and then creating a new `default` profile for a different compiler.
### Select language
The default profile created by Conan will typically select different C++ dialect
than C++23 used by this project. You should set `23` in the profile line
starting with `compiler.cppstd=`. For example:
```bash
sed -i.bak -e 's|^compiler\.cppstd=.*$|compiler.cppstd=23|' $(conan config home)/profiles/default
```
### Select standard library in Linux
**Linux** developers will commonly have a default Conan [profile][] that
compiles with GCC and links with libstdc++. If you are linking with libstdc++
(see profile setting `compiler.libcxx`), then you will need to choose the
`libstdc++11` ABI:
```bash
sed -i.bak -e 's|^compiler\.libcxx=.*$|compiler.libcxx=libstdc++11|' $(conan config home)/profiles/default
```
### Select architecture and runtime in Windows
**Windows** developers may need to use the x64 native build tools. An easy way
to do that is to run the shortcut "x64 Native Tools Command Prompt" for the
version of Visual Studio that you have installed.
Windows developers must also build `xrpld` and its dependencies for the x64
architecture:
```bash
sed -i.bak -e 's|^arch=.*$|arch=x86_64|' $(conan config home)/profiles/default
```
**Windows** developers also must select static runtime:
```bash
sed -i.bak -e 's|^compiler\.runtime=.*$|compiler.runtime=static|' $(conan config home)/profiles/default
```
## Add a Dependency
If you want to experiment with a new package, follow these steps:
1. Search for the package on [Conan Center](https://conan.io/center/).
2. Modify [`conanfile.py`](../../conanfile.py):
- Add a version of the package to the `requires` property.
- Change any default options for the package by adding them to the
`default_options` property (with syntax `'$package:$option': $value`).
3. Regenerate the [Conan lockfile](../../conan/lockfile/README.md) so the new
dependency is captured:
```bash
./conan/lockfile/regenerate.sh
```
4. Modify [`CMakeLists.txt`](../../CMakeLists.txt):
- Add a call to `find_package($package REQUIRED)`.
- Link a library from the package to the target `xrpl_libs`
(search for the existing call to `target_link_libraries(xrpl_libs INTERFACE ...)`).
5. Start coding! Don't forget to include whatever headers you need from the package.
[profile]: https://docs.conan.io/2/reference/config_files/profiles.html

2
docs/build/conan.md vendored
View File

@@ -115,7 +115,7 @@ By default, Conan will use the profile named "default".
[find_package]: https://cmake.org/cmake/help/latest/command/find_package.html [find_package]: https://cmake.org/cmake/help/latest/command/find_package.html
[pcf]: https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#package-configuration-file [pcf]: https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#package-configuration-file
[prefix_path]: https://cmake.org/cmake/help/latest/variable/CMAKE_PREFIX_PATH.html [prefix_path]: https://cmake.org/cmake/help/latest/variable/CMAKE_PREFIX_PATH.html
[profile]: https://docs.conan.io/en/latest/reference/profiles.html [profile]: https://docs.conan.io/2/reference/config_files/profiles.html
[pvf]: https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#package-version-file [pvf]: https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#package-version-file
[runtime]: https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html [runtime]: https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html
[search]: https://cmake.org/cmake/help/latest/command/find_package.html#search-procedure [search]: https://cmake.org/cmake/help/latest/command/find_package.html#search-procedure

View File

@@ -1,69 +1,73 @@
Our [build instructions][BUILD.md] assume you have a C++ development Our [build instructions][BUILD.md] assume you have a C++ development
environment complete with Git, Python, Conan, CMake, and a C++ compiler. environment complete with Git, Python, Conan, CMake, and a C++ compiler.
This document exists to help readers set one up on any of the Big Three This document explains how to set one up.
platforms: Linux, macOS, or Windows.
As an alternative to system packages, the Nix development shell can be used to provide a development environment. See [using nix development shell](./nix.md) for more details.
[BUILD.md]: ../../BUILD.md [BUILD.md]: ../../BUILD.md
## Linux ## Tested compiler versions
Package ecosystems vary across Linux distributions, `xrpld` is built in the **C++23** dialect by default.
so there is no one set of instructions that will work for every Linux user. Make sure your toolchain is recent enough — the compiler versions currently tested in CI are:
The instructions below are written for Debian 12 (Bookworm).
``` | Compiler | Version |
export GCC_RELEASE=12 | ----------- | ------- |
sudo apt update | GCC | 15.2 |
sudo apt install --yes gcc-${GCC_RELEASE} g++-${GCC_RELEASE} python3-pip \ | Clang | 22 |
python-is-python3 python3-venv python3-dev curl wget ca-certificates \ | Apple Clang | 17 |
git build-essential cmake ninja-build libc6-dev | MSVC | 19.44 |
sudo pip install --break-system-packages conan
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-${GCC_RELEASE} 999 LLVM tools (`clang-tidy` and `clang-format`) are also pinned to version 22.
sudo update-alternatives --install \
/usr/bin/gcc gcc /usr/bin/gcc-${GCC_RELEASE} 100 \ Older compilers may fail to build the latest `develop` code: the codebase now
--slave /usr/bin/g++ g++ /usr/bin/g++-${GCC_RELEASE} \ relies on C++23 features and has been adjusted for `clang-tidy`.
--slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-${GCC_RELEASE} \ If the latest code doesn't build for you, update your build toolchain first.
--slave /usr/bin/gcc-nm gcc-nm /usr/bin/gcc-nm-${GCC_RELEASE} \
--slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-${GCC_RELEASE} \ ## Linux and macOS
--slave /usr/bin/gcov gcov /usr/bin/gcov-${GCC_RELEASE} \
--slave /usr/bin/gcov-tool gcov-tool /usr/bin/gcov-tool-${GCC_RELEASE} \ The **recommended way** to get a development environment on Linux and macOS is
--slave /usr/bin/gcov-dump gcov-dump /usr/bin/gcov-dump-${GCC_RELEASE} \ the Nix development shell. It provides the exact tooling used in CI — `git`,
--slave /usr/bin/lto-dump lto-dump /usr/bin/lto-dump-${GCC_RELEASE} `python`, `conan`, `cmake`, `clang-tidy`, `clang-format`, and everything else —
sudo update-alternatives --auto cc with a single command and without installing anything system-wide:
sudo update-alternatives --auto gcc
```bash
nix --experimental-features 'nix-command flakes' develop
``` ```
If you use different Linux distribution, hope the instruction above can guide On **Linux**, Nix also provides the compiler (GCC). On **macOS**, the shell uses
you in the right direction. We try to maintain compatibility with all recent your **system-wide Apple Clang** as the compiler, so you still need to manage
compiler releases, so if you use a rolling distribution like e.g. Arch or CentOS its version (see below).
then there is a chance that everything will "just work".
## macOS See [Using the Nix development shell](./nix.md) for installation and usage
details, including how to select a different compiler.
Open a Terminal and enter the below command to bring up a dialog to install > [!NOTE]
the command line developer tools. > Using Nix is not mandatory. Any custom environment (Homebrew packages or
Once it is finished, this command should return a version greater than the > anything else) will continue to work, but then it is up to you to keep it in
minimum required (see [BUILD.md][]). > sync with the environment used in CI. Nix unifies the development environment
> for everyone and synchronizes updates, which is why we recommend it.
``` ### macOS: managing the Apple Clang version
Because the Nix shell uses the system-wide Apple Clang on macOS, the compiler
version is whatever your installed Xcode (or Command Line Tools) provides. The
following command should return a version greater than or equal to the
[minimum required](#tested-compiler-versions):
```bash
clang --version clang --version
``` ```
### Install Xcode Specific Version (Optional) If you develop other applications using Xcode, you might be consistently
updating to the newest version of Apple Clang, which will likely cause issues
If you develop other applications using XCode you might be consistently updating to the newest version of Apple Clang. building xrpld. You may want to install and pin a specific version of Xcode:
This will likely cause issues building xrpld. You may want to install a specific version of Xcode:
1. **Download Xcode** 1. **Download Xcode**
- Visit [Apple Developer Downloads](https://developer.apple.com/download/more/) - Visit [Apple Developer Downloads](https://developer.apple.com/download/more/)
- Sign in with your Apple Developer account - Sign in with your Apple Developer account
- Search for an Xcode version that includes **Apple Clang (Expected Version)** - Search for an Xcode version that includes the expected Apple Clang version
- Download the `.xip` file - Download the `.xip` file
2. **Install and Configure Xcode** 2. **Install and configure Xcode**
```bash ```bash
# Extract the .xip file and rename for version management # Extract the .xip file and rename for version management
@@ -79,62 +83,28 @@ This will likely cause issues building xrpld. You may want to install a specific
export DEVELOPER_DIR=/Applications/Xcode_16.2.app/Contents/Developer export DEVELOPER_DIR=/Applications/Xcode_16.2.app/Contents/Developer
``` ```
The command line developer tools should include Git too: ## Windows
``` Nix is not available on Windows, so the required tools have to be installed
git --version manually:
```
Install [Homebrew][], - [Visual Studio 2022](https://visualstudio.microsoft.com/) with the
use it to install [pyenv][], **"Desktop development with C++"** workload — this provides MSVC and the
use it to install Python, "x64 Native Tools Command Prompt".
and use it to install Conan: - [Git for Windows](https://git-scm.com/download/win)
- [Python 3.11](https://www.python.org/downloads/), or higher
- [Conan 2.17](https://conan.io/downloads.html), or higher
- [CMake 3.22](https://cmake.org/download/), or higher
[Homebrew]: https://brew.sh/ > [!NOTE]
[pyenv]: https://github.com/pyenv/pyenv > Windows is used for development only and is not recommended for production.
```
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew update
brew install xz
brew install pyenv
pyenv install 3.11
pyenv global 3.11
eval "$(pyenv init -)"
pip install 'conan'
```
Install CMake with Homebrew too:
```
brew install cmake
```
## Clang-tidy ## Clang-tidy
Clang-tidy is required to run static analysis checks locally (see [CONTRIBUTING.md](../../CONTRIBUTING.md)). `clang-tidy` is required to run static analysis checks locally (see
It is not required to build the project. Currently this project uses clang-tidy version 21. [CONTRIBUTING.md](../../CONTRIBUTING.md)). It is not required to build the
project. This project currently uses `clang-tidy` version 22.
### Linux On Linux and macOS, the [Nix development shell](./nix.md) provides `clang-tidy`
22 out of the box — run it via `run-clang-tidy`. No separate installation is
LLVM 21 is not available in the default Debian 12 (Bookworm) repositories. needed.
Install it using the official LLVM apt installer:
```
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 21
sudo apt install --yes clang-tidy-21
```
Then use `run-clang-tidy-21` when running clang-tidy locally.
### macOS
Install LLVM 21 via Homebrew:
```
brew install llvm@21
```
Then use `run-clang-tidy` from the LLVM 21 Homebrew prefix when running clang-tidy locally.

45
docs/build/nix.md vendored
View File

@@ -2,9 +2,12 @@
This guide explains how to use Nix to set up a reproducible development environment for xrpld. Using Nix eliminates the need to manually install utilities and ensures consistent tooling across different machines. This guide explains how to use Nix to set up a reproducible development environment for xrpld. Using Nix eliminates the need to manually install utilities and ensures consistent tooling across different machines.
**The Nix development shell is the recommended way to develop xrpld.** It unifies the development environment for everyone and synchronizes updates: the same tooling and compiler versions are used both here and in CI. Any custom environment (Homebrew packages or anything else) will continue to work, but then it is up to you to keep it in sync with the environment used in CI.
## Benefits of Using Nix ## Benefits of Using Nix
- **Reproducible environment**: Everyone gets the same versions of tools and compilers - **Reproducible environment**: Everyone gets the same versions of tools and compilers
- **Matches CI**: The Linux CI runs in Docker images built from this exact Nix environment
- **No system pollution**: Dependencies are isolated and don't affect your system packages - **No system pollution**: Dependencies are isolated and don't affect your system packages
- **Multiple compiler versions**: Easily switch between different GCC and Clang versions - **Multiple compiler versions**: Easily switch between different GCC and Clang versions
- **Quick setup**: Get started with a single command - **Quick setup**: Get started with a single command
@@ -28,11 +31,22 @@ This will:
- Download and set up all required development tools (CMake, Ninja, Conan, etc.) - Download and set up all required development tools (CMake, Ninja, Conan, etc.)
- Configure the appropriate compiler for your platform: - Configure the appropriate compiler for your platform:
- **macOS**: Apple Clang (default system compiler) - **Linux**: GCC 15.2 (provided by Nix)
- **Linux**: GCC 15 - **macOS**: Apple Clang (your system compiler)
The first time you run this command, it will take a few minutes to download and build the environment. Subsequent runs will be much faster. The first time you run this command, it will take a few minutes to download and build the environment. Subsequent runs will be much faster.
### Platform notes
- **Linux**: `nix develop` gives you a shell with all the tooling necessary to
develop xrpld and with GCC 15.2 (also provided by Nix). There are no caveats.
- **macOS**: `nix develop` gives you a full environment too. The compiler is
your system-wide Apple Clang, while every other tool — including Conan — is
provided by Nix. Conan has no binary in the Nix cache for macOS, so it is
built from source the first time you enter the shell, which makes the initial
setup slower (this is handled automatically; see
[`nix/devshell.nix`](../../nix/devshell.nix)).
> [!TIP] > [!TIP]
> To avoid typing `--experimental-features 'nix-command flakes'` every time, you can permanently enable flakes by creating `~/.config/nix/nix.conf`: > To avoid typing `--experimental-features 'nix-command flakes'` every time, you can permanently enable flakes by creating `~/.config/nix/nix.conf`:
> >
@@ -51,7 +65,7 @@ The first time you run this command, it will take a few minutes to download and
A compiler can be chosen by providing its name with the `.#` prefix, e.g. `nix develop .#gcc15`. A compiler can be chosen by providing its name with the `.#` prefix, e.g. `nix develop .#gcc15`.
Use `nix flake show` to see all the available development shells. Use `nix flake show` to see all the available development shells.
Use `nix develop .#no_compiler` to use the compiler from your system. Use `nix develop .#no-compiler` to use the compiler from your system.
### Example Usage ### Example Usage
@@ -68,12 +82,28 @@ nix develop
### Using a different shell ### Using a different shell
`nix develop` opens bash by default. If you want to use another shell this could be done by adding `-c` flag. For example: `nix develop` opens bash by default. To use another shell, pass it with the `-c` flag — this works with any shell, e.g. `zsh` or `fish`:
```bash ```bash
# Use zsh
nix develop -c zsh nix develop -c zsh
# Use fish
nix develop -c fish
# Use your login shell
nix develop -c "$SHELL"
``` ```
> [!WARNING]
> Your shell's interactive startup files (e.g. `config.fish`, `.zshrc`) may prepend other directories — most commonly Homebrew — to `$PATH`, which can shadow the tools provided by the Nix shell. After entering, verify that tools resolve into the Nix store:
>
> ```bash
> command -v cmake # should print a /nix/store/... path
> ```
>
> If it doesn't, either adjust your shell configuration so it doesn't override `$PATH`, or use [direnv](#automatic-activation-with-direnv) (below), which loads the environment _after_ your shell config and so takes precedence regardless of the shell you use.
## Building xrpld with Nix ## Building xrpld with Nix
Once inside the Nix development shell, follow the standard [build instructions](../../BUILD.md#steps). The Nix shell provides all necessary tools (CMake, Ninja, Conan, etc.). Once inside the Nix development shell, follow the standard [build instructions](../../BUILD.md#steps). The Nix shell provides all necessary tools (CMake, Ninja, Conan, etc.).
@@ -82,6 +112,8 @@ Once inside the Nix development shell, follow the standard [build instructions](
[direnv](https://direnv.net/) or [nix-direnv](https://github.com/nix-community/nix-direnv) can automatically activate the Nix development shell when you enter the repository directory. [direnv](https://direnv.net/) or [nix-direnv](https://github.com/nix-community/nix-direnv) can automatically activate the Nix development shell when you enter the repository directory.
This is also the most robust way to use the environment from **any shell** (bash, zsh, fish, …): direnv stays in your current shell and loads the environment _after_ your shell's startup files have run, so the Nix-provided tools take precedence over anything your shell configuration adds to `$PATH`. To use it, install direnv for your shell, then add an `.envrc` containing `use flake` at the repository root and run `direnv allow`.
## Conan and Prebuilt Packages ## Conan and Prebuilt Packages
Please note that there is no guarantee that binaries from conan cache will work when using nix. If you encounter any errors, please use `--build '*'` to force conan to compile everything from source: Please note that there is no guarantee that binaries from conan cache will work when using nix. If you encounter any errors, please use `--build '*'` to force conan to compile everything from source:
@@ -93,3 +125,8 @@ conan install .. --output-folder . --build '*' --settings build_type=Release
## Updating `flake.lock` file ## Updating `flake.lock` file
To update `flake.lock` to the latest revision use `nix flake update` command. To update `flake.lock` to the latest revision use `nix flake update` command.
## Troubleshooting
See [Troubleshooting Nix problems](./nix_troubleshooting.md) for common issues,
such as `nix develop` failing inside Git worktrees.

61
docs/build/nix_troubleshooting.md vendored Normal file
View File

@@ -0,0 +1,61 @@
# Troubleshooting Nix problems
Common issues encountered when using the [Nix development shell](./nix.md), and
how to resolve them.
## Git worktrees
If `nix develop` fails with an error like:
```
error:
… while fetching the input 'git+file:///path/to/rippled'
error: opening Git repository "/path/to/rippled": unsupported extension name extensions.relativeworktrees (libgit2 error code = 6)
```
then your Nix is linked against a libgit2 older than **1.9.4**. Git 2.48+ writes
the `extensions.relativeWorktrees` config entry when a worktree is created with
relative paths (`git worktree add --relative-paths`, or with
`worktree.useRelativePaths=true`), and older libgit2 versions refuse to open a
repository that uses it. Nix uses libgit2 to read the flake, so evaluation
fails.
> [!IMPORTANT]
> This entry is written to the **shared** repository config, so once any
> relative worktree exists, `nix develop` fails in the main checkout too — not
> just inside the worktree.
### Workarounds
These work today, with any Nix version:
- bypass libgit2 with a `path:` flakeref: `nix develop "path:$PWD"`
(note: this copies the working tree to the store and ignores `.gitignore`); or
- create worktrees with absolute paths (omit `--relative-paths`); or
- clear the extension if you don't need relative worktrees:
`git config --unset extensions.relativeWorktrees`.
### Permanent fix
The fix is in [libgit2 1.9.4](https://github.com/libgit2/libgit2/releases/tag/v1.9.4),
so the real solution is a Nix that links against libgit2 `1.9.4` or newer. Check
which version yours links against:
```bash
nix-store -qR "$(readlink -f "$(command -v nix)")" | grep libgit2
```
> [!WARNING]
> `nix upgrade-nix` does **not** help yet. It installs the build from the
> official [`nix-fallback-paths`](https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/installer/tools/nix-fallback-paths.nix),
> which is still linked against libgit2 `1.9.2` — there is no new upstream Nix
> release with the fix. (On some systems that build is even the exact store path
> you already have, making the upgrade a no-op.)
nixpkgs has already rebuilt Nix against the fixed libgit2 (e.g. `nix-2.34.7+1`),
so the cleanest path is to reinstall Nix using your usual installation method
once it picks up that rebuild, then re-run the `grep libgit2` check above to
confirm it reports `1.9.4` or newer.
Until then, prefer the workarounds above.

13
flake.lock generated
View File

@@ -2,17 +2,18 @@
"nodes": { "nodes": {
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1780243769, "lastModified": 1781173989,
"narHash": "sha256-x5UQuRsH3MqI0U9afaXSNqzTPSeZlRLvFAav2Ux1pNw=", "narHash": "sha256-fnzKKPvS+oieI/pTzotA5tkoM47EB1NpaBcgk4R97hE=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "331800de5053fcebacf6813adb5db9c9dca22a0c", "rev": "8c91a71d13451abc40eb9dae8910f972f979852f",
"type": "github" "type": "github"
}, },
"original": { "original": {
"id": "nixpkgs", "owner": "NixOS",
"ref": "nixos-unstable", "ref": "nixpkgs-unstable",
"type": "indirect" "repo": "nixpkgs",
"type": "github"
} }
}, },
"nixpkgs-custom-glibc": { "nixpkgs-custom-glibc": {

View File

@@ -1,7 +1,7 @@
{ {
description = "Nix related things for xrpld"; description = "Nix related things for xrpld";
inputs = { inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
# nixpkgs snapshot (2020-06-30) that shipped glibc 2.31 as the primary # nixpkgs snapshot (2020-06-30) that shipped glibc 2.31 as the primary
# version — matches the system libc on Ubuntu 20.04 LTS. Imported # version — matches the system libc on Ubuntu 20.04 LTS. Imported
# manually (flake = false) because this revision predates nixpkgs' # manually (flake = false) because this revision predates nixpkgs'

View File

@@ -12,8 +12,8 @@ template <int Window, typename Clock>
class DecayingSample class DecayingSample
{ {
public: public:
using value_type = typename Clock::duration::rep; using value_type = Clock::duration::rep;
using time_point = typename Clock::time_point; using time_point = Clock::time_point;
DecayingSample() = delete; DecayingSample() = delete;
@@ -93,7 +93,7 @@ template <int HalfLife, class Clock>
class DecayWindow class DecayWindow
{ {
public: public:
using time_point = typename Clock::time_point; using time_point = Clock::time_point;
explicit DecayWindow(time_point now) : when_(now) explicit DecayWindow(time_point now) : when_(now)
{ {

View File

@@ -1,248 +0,0 @@
#pragma once
#include <xrpl/basics/contract.h>
#include <boost/outcome.hpp>
#include <stdexcept>
namespace xrpl {
/** Expected is an approximation of std::expected (hoped for in C++23)
See: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p0323r10.html
The implementation is entirely based on boost::outcome_v2::result.
*/
// Exception thrown by an invalid access to Expected.
struct BadExpectedAccess : public std::runtime_error
{
BadExpectedAccess() : runtime_error("bad expected access")
{
}
};
namespace detail {
// Custom policy for Expected. Always throw on an invalid access.
struct ThrowPolicy : public boost::outcome_v2::policy::base
{
template <class Impl>
static constexpr void
// NOLINTNEXTLINE(readability-identifier-naming)
wide_value_check(Impl&& self)
{
if (!base::_has_value(std::forward<Impl>(self)))
Throw<BadExpectedAccess>();
}
template <class Impl>
static constexpr void
// NOLINTNEXTLINE(readability-identifier-naming)
wide_error_check(Impl&& self)
{
if (!base::_has_error(std::forward<Impl>(self)))
Throw<BadExpectedAccess>();
}
template <class Impl>
static constexpr void
// NOLINTNEXTLINE(readability-identifier-naming)
wide_exception_check(Impl&& self)
{
if (!base::_has_exception(std::forward<Impl>(self)))
Throw<BadExpectedAccess>();
}
};
} // namespace detail
// Definition of Unexpected, which is used to construct the unexpected
// return type of an Expected.
template <class E>
class Unexpected
{
public:
static_assert(!std::is_same_v<E, void>, "E must not be void");
Unexpected() = delete;
constexpr explicit Unexpected(E const& e) : val_(e)
{
}
constexpr explicit Unexpected(E&& e) : val_(std::move(e))
{
}
[[nodiscard]] constexpr E const&
value() const&
{
return val_;
}
constexpr E&
value() &
{
return val_;
}
constexpr E&&
value() &&
{
return std::move(val_);
}
[[nodiscard]] constexpr E const&&
value() const&&
{
return std::move(val_);
}
private:
E val_;
};
// Unexpected deduction guide that converts array to const*.
template <typename E, std::size_t N>
Unexpected(E (&)[N]) -> Unexpected<E const*>;
// Definition of Expected. All of the machinery comes from boost::result.
template <class T, class E>
class [[nodiscard]] Expected : private boost::outcome_v2::result<T, E, detail::ThrowPolicy>
{
using Base = boost::outcome_v2::result<T, E, detail::ThrowPolicy>;
public:
template <typename U>
requires std::convertible_to<U, T>
constexpr Expected(U&& r) : Base(boost::outcome_v2::in_place_type_t<T>{}, std::forward<U>(r))
{
}
template <typename U>
requires std::convertible_to<U, E> && (!std::is_reference_v<U>)
constexpr Expected(Unexpected<U> e)
: Base(boost::outcome_v2::in_place_type_t<E>{}, std::move(e.value()))
{
}
[[nodiscard]] constexpr bool
// NOLINTNEXTLINE(readability-identifier-naming)
has_value() const
{
return Base::has_value();
}
[[nodiscard]] constexpr T const&
value() const
{
return Base::value();
}
constexpr T&
value()
{
return Base::value();
}
[[nodiscard]] constexpr E const&
error() const&
{
return Base::error();
}
[[nodiscard]] constexpr E&
error() &
{
return Base::error();
}
[[nodiscard]] constexpr E&&
error() &&
{
return std::move(Base::error());
}
constexpr explicit
operator bool() const
{
return has_value();
}
// Add operator* and operator-> so the Expected API looks a bit more like
// what std::expected is likely to look like. See:
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p0323r10.html
[[nodiscard]] constexpr T&
operator*()
{
return this->value();
}
[[nodiscard]] constexpr T const&
operator*() const
{
return this->value();
}
[[nodiscard]] constexpr T*
operator->()
{
return &this->value();
}
[[nodiscard]] constexpr T const*
operator->() const
{
return &this->value();
}
};
// Specialization of Expected<void, E>. Allows returning either success
// (without a value) or the reason for the failure.
template <class E>
class [[nodiscard]]
Expected<void, E> : private boost::outcome_v2::result<void, E, detail::ThrowPolicy>
{
using Base = boost::outcome_v2::result<void, E, detail::ThrowPolicy>;
public:
// The default constructor makes a successful Expected<void, E>.
// This aligns with std::expected behavior proposed in P0323R10.
constexpr Expected() : Base(boost::outcome_v2::success())
{
}
template <typename U>
requires std::convertible_to<U, E> && (!std::is_reference_v<U>)
constexpr Expected(Unexpected<U> e) : Base(E(std::move(e.value())))
{
}
[[nodiscard]] constexpr E const&
error() const&
{
return Base::error();
}
[[nodiscard]] constexpr E&
error() &
{
return Base::error();
}
[[nodiscard]] constexpr E&&
error() &&
{
return std::move(Base::error());
}
constexpr explicit
operator bool() const
{
return Base::has_value();
}
};
} // namespace xrpl

View File

@@ -206,8 +206,7 @@ private:
#ifndef JLOG #ifndef JLOG
#define JLOG(x) \ #define JLOG(x) \
if (!(x)) \ if (!(x)) \
{ \ ; \
} \
else \ else \
x x
#endif #endif

View File

@@ -408,33 +408,40 @@ public:
} }
friend constexpr bool friend constexpr bool
operator<(Number const& x, Number const& y) noexcept operator<(Number const& l, Number const& r) noexcept
{ {
bool const lneg = l.negative_;
bool const rneg = r.negative_;
// If the two amounts have different signs (zero is treated as positive) // If the two amounts have different signs (zero is treated as positive)
// then the comparison is true iff the left is negative. // then the comparison is true iff the left is negative.
bool const lneg = x.negative_;
bool const rneg = y.negative_;
if (lneg != rneg) if (lneg != rneg)
return lneg; return lneg;
// Both have same sign and the left is zero: the right must be // Both have same sign and the left is zero: both must be non-negative.
// greater than 0. // If the right is greater than 0, then it is larger, so the comparison is true.
if (x.mantissa_ == 0) if (l.mantissa_ == 0)
return y.mantissa_ > 0; return r.mantissa_ > 0;
// Both have same sign, the right is zero and the left is non-zero. // Both have same sign, the right is zero and the left is non-zero, so the left must be
if (y.mantissa_ == 0) // positive, and thus is larger, so the comparison is false.
if (r.mantissa_ == 0)
return false; return false;
// Both have the same sign, compare by exponents: // Both have the same sign, compare by exponents:
if (x.exponent_ > y.exponent_) if (l.exponent_ > r.exponent_)
return lneg; return lneg;
if (x.exponent_ < y.exponent_) if (l.exponent_ < r.exponent_)
return !lneg; return !lneg;
// If equal exponents, compare mantissas // If equal signs and exponents, compare mantissas.
return x.mantissa_ < y.mantissa_; if (lneg)
{
// If negative, the operator is reversed.
return l.mantissa_ > r.mantissa_;
}
return l.mantissa_ < r.mantissa_;
} }
/** Return the sign of the amount */ /** Return the sign of the amount */

View File

@@ -11,6 +11,7 @@
#include <cstdint> #include <cstdint>
#include <optional> #include <optional>
#include <string> #include <string>
#include <string_view>
#include <type_traits> #include <type_traits>
namespace xrpl { namespace xrpl {
@@ -95,13 +96,7 @@ strUnHex(std::size_t strSize, Iterator begin, Iterator end)
} }
inline std::optional<Blob> inline std::optional<Blob>
strUnHex(std::string const& strSrc) strUnHex(std::string_view strSrc)
{
return strUnHex(strSrc.size(), strSrc.cbegin(), strSrc.cend());
}
inline std::optional<Blob>
strViewUnHex(std::string_view strSrc)
{ {
return strUnHex(strSrc.size(), strSrc.cbegin(), strSrc.cend()); return strUnHex(strSrc.size(), strSrc.cbegin(), strSrc.cend());
} }

View File

@@ -9,6 +9,7 @@
#include <xrpl/beast/insight/Insight.h> #include <xrpl/beast/insight/Insight.h>
#include <atomic> #include <atomic>
#include <cstddef>
#include <functional> #include <functional>
#include <mutex> #include <mutex>
#include <thread> #include <thread>
@@ -17,6 +18,22 @@
namespace xrpl { namespace xrpl {
namespace detail {
// Replace-policy tags selecting how TaggedCache::canonicalizeImpl resolves a
// collision when the key already exists (defined in TaggedCache.ipp):
// - ReplaceCached: always replace the cached value with `data`. `data` is
// never written back and may be const.
// - ReplaceClient: keep the cached value and write it back into `data` (the
// client's pointer), which must therefore be writable.
// - ReplaceDynamically: call the supplied callback to decide per call; `data`
// is written back when the cached value is kept, so it must be writable.
struct ReplaceCached;
struct ReplaceClient;
struct ReplaceDynamically;
} // namespace detail
/** Map/cache combination. /** Map/cache combination.
This class implements a cache and a map. The cache keeps objects alive This class implements a cache and a map. The cache keeps objects alive
in the map. The map allows multiple code paths that reference objects in the map. The map allows multiple code paths that reference objects
@@ -96,6 +113,32 @@ public:
bool bool
del(key_type const& key, bool valid); del(key_type const& key, bool valid);
private:
// Selects the `data` parameter type of canonicalizeImpl from the replace
// policy: const for detail::ReplaceCached (never written back), otherwise
// writable.
template <typename Policy>
using CanonicalizeClientPointerType = std::conditional_t<
std::is_same_v<detail::ReplaceCached, Policy>,
SharedPointerType const&,
SharedPointerType&>;
/** Shared implementation of the canonicalize family.
`policy` selects how a collision is resolved when `key` already exists:
detail::ReplaceCached, detail::ReplaceClient or
detail::ReplaceDynamically. For ReplaceDynamically `replaceCallback` is
invoked with the existing strong pointer and returns whether to replace
the cached value with `data`; for the tag policies it is unused.
*/
template <class Policy, class Callback = std::nullptr_t>
bool
canonicalizeImpl(
key_type const& key,
CanonicalizeClientPointerType<Policy> data,
Policy policy,
Callback&& replaceCallback = nullptr);
public: public:
/** Replace aliased objects with originals. /** Replace aliased objects with originals.
@@ -104,19 +147,52 @@ public:
This routine eliminates the duplicate and performs a replacement This routine eliminates the duplicate and performs a replacement
on the callers shared pointer if needed. on the callers shared pointer if needed.
`replaceCallback` is a callable taking the existing strong pointer and
returning whether to replace the cached value with `data` (true) or to
keep the cached value and write it back into `data` (false). Because the
write-back case mutates `data`, `data` must be writable.
@param key The key corresponding to the object @param key The key corresponding to the object
@param data A shared pointer to the data corresponding to the object. @param data A shared pointer to the data corresponding to the object.
@param replace Function that decides if cache should be replaced @param replaceCallback A callable (existing strong pointer -> bool).
@return `true` If the key already existed. @return `true` if an existing live entry was found and used; `false` if a new entry was
*/ inserted or an expired tracked entry was re-cached.
template <class R> **/
template <class Callback>
bool bool
canonicalize(key_type const& key, SharedPointerType& data, R&& replaceCallback); canonicalize(key_type const& key, SharedPointerType& data, Callback&& replaceCallback);
/** Insert/update the canonical entry for `key`, always replacing the
cached value with `data`.
If an entry already exists for `key`, the cached value is unconditionally
replaced with `data`; otherwise `data` is inserted. `data` is never
written back, so it may be const.
@param key The key corresponding to the object.
@param data A shared pointer to the data corresponding to the object.
@return `true` if an existing live entry was found and used; `false` if a new entry was
inserted or an expired tracked entry was re-cached.
**/
bool bool
canonicalizeReplaceCache(key_type const& key, SharedPointerType const& data); canonicalizeReplaceCache(key_type const& key, SharedPointerType const& data);
/** Insert the canonical entry for `key`, keeping any existing cached value.
If an entry already exists for `key`, the cached value is kept and
written back into `data` so the caller ends up with the canonical
object; otherwise `data` is inserted. Because `data` may be overwritten
it must be writable.
@param key The key corresponding to the object.
@param data A shared pointer to the data corresponding to the object;
updated to the canonical value when one already exists.
@return `true` if an existing live entry was found and used; `false` if a new entry was
inserted or an expired tracked entry was re-cached.
**/
bool bool
canonicalizeReplaceClient(key_type const& key, SharedPointerType& data); canonicalizeReplaceClient(key_type const& key, SharedPointerType& data);
@@ -262,7 +338,7 @@ private:
sweepHelper( sweepHelper(
clock_type::time_point const& whenExpire, clock_type::time_point const& whenExpire,
[[maybe_unused]] clock_type::time_point const& now, [[maybe_unused]] clock_type::time_point const& now,
typename KeyValueCacheType::map_type& partition, KeyValueCacheType::map_type& partition,
SweptPointersVector& stuffToSweep, SweptPointersVector& stuffToSweep,
std::atomic<int>& allRemovals, std::atomic<int>& allRemovals,
std::scoped_lock<std::recursive_mutex> const&); std::scoped_lock<std::recursive_mutex> const&);
@@ -271,7 +347,7 @@ private:
sweepHelper( sweepHelper(
clock_type::time_point const& whenExpire, clock_type::time_point const& whenExpire,
clock_type::time_point const& now, clock_type::time_point const& now,
typename KeyOnlyCacheType::map_type& partition, KeyOnlyCacheType::map_type& partition,
SweptPointersVector&, SweptPointersVector&,
std::atomic<int>& allRemovals, std::atomic<int>& allRemovals,
std::scoped_lock<std::recursive_mutex> const&); std::scoped_lock<std::recursive_mutex> const&);

View File

@@ -5,6 +5,30 @@
namespace xrpl { namespace xrpl {
namespace detail {
// Replace-policy tags selecting how TaggedCache::canonicalizeImpl resolves a
// collision when the key already exists:
// - ReplaceCached: always replace the cached value with `data`. `data` is
// never written back and may be const.
// - ReplaceClient: keep the cached value and write it back into `data` (the
// client's pointer), which must therefore be writable.
// - ReplaceDynamically: call the supplied callback to decide per call; `data`
// is written back when the cached value is kept, so it must be writable.
struct ReplaceCached
{
};
struct ReplaceClient
{
};
struct ReplaceDynamically
{
};
} // namespace detail
template < template <
class Key, class Key,
class T, class T,
@@ -300,13 +324,29 @@ template <
class Hash, class Hash,
class KeyEqual, class KeyEqual,
class Mutex> class Mutex>
template <class R> template <class Policy, class Callback>
inline bool inline bool
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>:: TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
canonicalize(key_type const& key, SharedPointerType& data, R&& replaceCallback) canonicalizeImpl(
key_type const& key,
CanonicalizeClientPointerType<Policy> data,
[[maybe_unused]] Policy policy,
[[maybe_unused]] Callback&& replaceCallback)
{ {
// Return canonical value, store if needed, refresh in cache // Return canonical value, store if needed, refresh in cache
// Return values: true=we had the data already // Return values: true=we had the data already
// `Policy` is one of:
// - detail::ReplaceCached: always replace the cached value with `data`;
// `data` is never written back and may be const.
// - detail::ReplaceClient: keep the cached value and write it back into
// `data` (the client's pointer), which must therefore be writable.
// - detail::ReplaceDynamically: call `replaceCallback` to decide at run
// time; `data` must be writable.
// For the latter two the write-back below requires a mutable `data`, so
// passing a const argument is a compile error.
constexpr bool replaceCached = std::is_same_v<Policy, detail::ReplaceCached>;
std::scoped_lock const lock(mutex_); std::scoped_lock const lock(mutex_);
auto cit = cache_.find(key); auto cit = cache_.find(key);
@@ -324,13 +364,14 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
Entry& entry = cit->second; Entry& entry = cit->second;
entry.touch(clock_.now()); entry.touch(clock_.now());
auto shouldReplace = [&] { auto shouldReplaceCached = [&] {
if constexpr (std::is_invocable_r_v<bool, R>) if constexpr (replaceCached)
{ {
// The reason for this extra complexity is for intrusive return true;
// strong/weak combo getting a strong is relatively expensive }
// and not needed for many cases. else if constexpr (std::is_same_v<Policy, detail::ReplaceClient>)
return replaceCallback(); {
return false;
} }
else else
{ {
@@ -340,11 +381,11 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
if (entry.isCached()) if (entry.isCached())
{ {
if (shouldReplace()) if (shouldReplaceCached())
{ {
entry.ptr = data; entry.ptr = data;
} }
else else if constexpr (!replaceCached)
{ {
data = entry.ptr.getStrong(); data = entry.ptr.getStrong();
} }
@@ -356,11 +397,11 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
if (cachedData) if (cachedData)
{ {
if (shouldReplace()) if (shouldReplaceCached())
{ {
entry.ptr = data; entry.ptr = data;
} }
else else if constexpr (!replaceCached)
{ {
entry.ptr.convertToStrong(); entry.ptr.convertToStrong();
data = cachedData; data = cachedData;
@@ -376,6 +417,24 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
return false; return false;
} }
template <
class Key,
class T,
bool IsKeyCache,
class SharedWeakUnionPointer,
class SharedPointerType,
class Hash,
class KeyEqual,
class Mutex>
template <class Callback>
inline bool
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
canonicalize(key_type const& key, SharedPointerType& data, Callback&& replaceCallback)
{
return canonicalizeImpl(
key, data, detail::ReplaceDynamically{}, std::forward<Callback>(replaceCallback));
}
template < template <
class Key, class Key,
class T, class T,
@@ -389,7 +448,7 @@ inline bool
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>:: TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
canonicalizeReplaceCache(key_type const& key, SharedPointerType const& data) canonicalizeReplaceCache(key_type const& key, SharedPointerType const& data)
{ {
return canonicalize(key, const_cast<SharedPointerType&>(data), []() { return true; }); return canonicalizeImpl(key, data, detail::ReplaceCached{});
} }
template < template <
@@ -405,7 +464,7 @@ inline bool
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>:: TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
canonicalizeReplaceClient(key_type const& key, SharedPointerType& data) canonicalizeReplaceClient(key_type const& key, SharedPointerType& data)
{ {
return canonicalize(key, data, []() { return false; }); return canonicalizeImpl(key, data, detail::ReplaceClient{});
} }
template < template <
@@ -676,7 +735,7 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
sweepHelper( sweepHelper(
clock_type::time_point const& whenExpire, clock_type::time_point const& whenExpire,
[[maybe_unused]] clock_type::time_point const& now, [[maybe_unused]] clock_type::time_point const& now,
typename KeyValueCacheType::map_type& partition, KeyValueCacheType::map_type& partition,
SweptPointersVector& stuffToSweep, SweptPointersVector& stuffToSweep,
std::atomic<int>& allRemovals, std::atomic<int>& allRemovals,
std::scoped_lock<std::recursive_mutex> const&) std::scoped_lock<std::recursive_mutex> const&)
@@ -756,7 +815,7 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
sweepHelper( sweepHelper(
clock_type::time_point const& whenExpire, clock_type::time_point const& whenExpire,
clock_type::time_point const& now, clock_type::time_point const& now,
typename KeyOnlyCacheType::map_type& partition, KeyOnlyCacheType::map_type& partition,
SweptPointersVector&, SweptPointersVector&,
std::atomic<int>& allRemovals, std::atomic<int>& allRemovals,
std::scoped_lock<std::recursive_mutex> const&) std::scoped_lock<std::recursive_mutex> const&)

View File

@@ -36,6 +36,7 @@
#include <cstdint> #include <cstdint>
#include <string> #include <string>
#include <string_view>
namespace xrpl { namespace xrpl {
@@ -43,7 +44,7 @@ std::string
base64Encode(std::uint8_t const* data, std::size_t len); base64Encode(std::uint8_t const* data, std::size_t len);
inline std::string inline std::string
base64Encode(std::string const& s) base64Encode(std::string_view s)
{ {
return base64Encode(reinterpret_cast<std::uint8_t const*>(s.data()), s.size()); return base64Encode(reinterpret_cast<std::uint8_t const*>(s.data()), s.size());
} }

View File

@@ -5,7 +5,6 @@
#pragma once #pragma once
#include <xrpl/basics/Expected.h>
#include <xrpl/basics/Slice.h> #include <xrpl/basics/Slice.h>
#include <xrpl/basics/contract.h> #include <xrpl/basics/contract.h>
#include <xrpl/basics/hardened_hash.h> #include <xrpl/basics/hardened_hash.h>
@@ -20,6 +19,7 @@
#include <algorithm> #include <algorithm>
#include <array> #include <array>
#include <cstring> #include <cstring>
#include <expected>
#include <type_traits> #include <type_traits>
namespace xrpl { namespace xrpl {
@@ -177,7 +177,7 @@ private:
BadChar, BadChar,
}; };
constexpr Expected<decltype(data_), ParseResult> constexpr std::expected<decltype(data_), ParseResult>
parseFromStringView(std::string_view sv) noexcept parseFromStringView(std::string_view sv) noexcept
{ {
// Local lambda that converts a single hex char to four bits and // Local lambda that converts a single hex char to four bits and
@@ -216,7 +216,7 @@ private:
} }
if (sv.size() != size() * 2) if (sv.size() != size() * 2)
return Unexpected(ParseResult::BadLength); return std::unexpected(ParseResult::BadLength);
std::size_t i = 0u; std::size_t i = 0u;
auto in = sv.begin(); auto in = sv.begin();
@@ -227,7 +227,7 @@ private:
{ {
if (auto const result = hexCharToUInt(*in++, shift, accum); if (auto const result = hexCharToUInt(*in++, shift, accum);
result != ParseResult::Okay) result != ParseResult::Okay)
return Unexpected(result); return std::unexpected(result);
} }
ret[i++] = accum; ret[i++] = accum;
} }

View File

@@ -75,7 +75,7 @@ private:
detail::seed_pair seeds_{detail::makeSeedPair<>()}; detail::seed_pair seeds_{detail::makeSeedPair<>()};
public: public:
using result_type = typename HashAlgorithm::result_type; using result_type = HashAlgorithm::result_type;
HardenedHash() = default; HardenedHash() = default;

View File

@@ -1,12 +1,13 @@
#pragma once #pragma once
#include <string> #include <string>
#include <string_view>
namespace xrpl { namespace xrpl {
template <class Stream, class Iter> template <class Stream, class Iter>
Stream& Stream&
join(Stream& s, Iter iter, Iter end, std::string const& delimiter) join(Stream& s, Iter iter, Iter end, std::string_view delimiter)
{ {
if (iter == end) if (iter == end)
return s; return s;

View File

@@ -57,8 +57,8 @@ public:
{ {
using iterator_category = std::forward_iterator_tag; using iterator_category = std::forward_iterator_tag;
partition_map_type* map{nullptr}; partition_map_type* map{nullptr};
typename partition_map_type::iterator ait{}; partition_map_type::iterator ait{};
typename map_type::iterator mit; map_type::iterator mit;
Iterator() = default; Iterator() = default;
@@ -126,8 +126,8 @@ public:
using iterator_category = std::forward_iterator_tag; using iterator_category = std::forward_iterator_tag;
partition_map_type* map{nullptr}; partition_map_type* map{nullptr};
typename partition_map_type::iterator ait{}; partition_map_type::iterator ait{};
typename map_type::iterator mit; map_type::iterator mit;
ConstIterator() = default; ConstIterator() = default;

View File

@@ -29,6 +29,7 @@ static_assert(
namespace detail { namespace detail {
// Determines if a type can be called like an Engine // Determines if a type can be called like an Engine
// NOLINTNEXTLINE(readability-redundant-typename): typename required by MSVC
template <class Engine, class Result = typename Engine::result_type> template <class Engine, class Result = typename Engine::result_type>
using is_engine = std::is_invocable_r<Result, Engine>; using is_engine = std::is_invocable_r<Result, Engine>;
} // namespace detail } // namespace detail

View File

@@ -1,29 +0,0 @@
#pragma once
#if XRPL_ROCKSDB_AVAILABLE
// #include <rocksdb2/port/port_posix.h>
#include <rocksdb/cache.h>
#include <rocksdb/compaction_filter.h>
#include <rocksdb/comparator.h>
#include <rocksdb/convenience.h>
#include <rocksdb/db.h>
#include <rocksdb/env.h>
#include <rocksdb/filter_policy.h>
#include <rocksdb/flush_block_policy.h>
#include <rocksdb/iterator.h>
#include <rocksdb/memtablerep.h>
#include <rocksdb/merge_operator.h>
#include <rocksdb/options.h>
#include <rocksdb/perf_context.h>
#include <rocksdb/slice.h>
#include <rocksdb/slice_transform.h>
#include <rocksdb/statistics.h>
#include <rocksdb/status.h>
#include <rocksdb/table.h>
#include <rocksdb/table_properties.h>
#include <rocksdb/transaction_log.h>
#include <rocksdb/types.h>
#include <rocksdb/universal_compaction.h>
#include <rocksdb/write_batch.h>
#endif

View File

@@ -4,7 +4,7 @@
/* /*
ASAN flags some false positives with sudden jumps in control flow, like ASAN flags some false positives with sudden jumps in control flow, like
exceptions, or when encountering coroutine stack switches. This macro can be used to disable ASAN exceptions, or when encountering coroutine stack switches. This macro can be used to disable ASAN
intrumentation for specific functions. instrumentation for specific functions.
*/ */
#if defined(__GNUC__) || defined(__clang__) #if defined(__GNUC__) || defined(__clang__)
#define XRPL_NO_SANITIZE_ADDRESS __attribute__((no_sanitize("address", "hwaddress"))) #define XRPL_NO_SANITIZE_ADDRESS __attribute__((no_sanitize("address", "hwaddress")))

View File

@@ -18,8 +18,8 @@ template <class Clock>
class IOLatencyProbe class IOLatencyProbe
{ {
private: private:
using duration = typename Clock::duration; using duration = Clock::duration;
using time_point = typename Clock::time_point; using time_point = Clock::time_point;
std::recursive_mutex mutex_; std::recursive_mutex mutex_;
std::condition_variable_any cond_; std::condition_variable_any cond_;

View File

@@ -34,10 +34,10 @@ template <class Clock>
class AbstractClock class AbstractClock
{ {
public: public:
using rep = typename Clock::rep; using rep = Clock::rep;
using period = typename Clock::period; using period = Clock::period;
using duration = typename Clock::duration; using duration = Clock::duration;
using time_point = typename Clock::time_point; using time_point = Clock::time_point;
using clock_type = Clock; using clock_type = Clock;
static bool const is_steady = Clock::is_steady; // NOLINT(readability-identifier-naming) static bool const is_steady = Clock::is_steady; // NOLINT(readability-identifier-naming)

View File

@@ -20,10 +20,10 @@ public:
explicit BasicSecondsClock() = default; explicit BasicSecondsClock() = default;
using rep = typename Clock::rep; using rep = Clock::rep;
using period = typename Clock::period; using period = Clock::period;
using duration = typename Clock::duration; using duration = Clock::duration;
using time_point = typename Clock::time_point; using time_point = Clock::time_point;
static bool const is_steady = // NOLINT(readability-identifier-naming) static bool const is_steady = // NOLINT(readability-identifier-naming)
Clock::is_steady; Clock::is_steady;

View File

@@ -16,15 +16,15 @@ template <bool IsConst, class Iterator>
class AgedContainerIterator class AgedContainerIterator
{ {
public: public:
using iterator_category = typename std::iterator_traits<Iterator>::iterator_category; using iterator_category = std::iterator_traits<Iterator>::iterator_category;
using value_type = std::conditional_t< using value_type = std::conditional_t<
IsConst, IsConst,
typename Iterator::value_type::Stashed::value_type const, typename Iterator::value_type::Stashed::value_type const,
typename Iterator::value_type::Stashed::value_type>; typename Iterator::value_type::Stashed::value_type>;
using difference_type = typename std::iterator_traits<Iterator>::difference_type; using difference_type = std::iterator_traits<Iterator>::difference_type;
using pointer = value_type*; using pointer = value_type*;
using reference = value_type&; using reference = value_type&;
using time_point = typename Iterator::value_type::Stashed::time_point; using time_point = Iterator::value_type::Stashed::time_point;
AgedContainerIterator() = default; AgedContainerIterator() = default;

View File

@@ -62,8 +62,8 @@ class AgedOrderedContainer
{ {
public: public:
using clock_type = AbstractClock<Clock>; using clock_type = AbstractClock<Clock>;
using time_point = typename clock_type::time_point; using time_point = clock_type::time_point;
using duration = typename clock_type::duration; using duration = clock_type::duration;
using key_type = Key; using key_type = Key;
using mapped_type = T; using mapped_type = T;
using value_type = std::conditional_t<IsMap, std::pair<Key const, T>, Key>; using value_type = std::conditional_t<IsMap, std::pair<Key const, T>, Key>;
@@ -94,8 +94,8 @@ private:
{ {
explicit Stashed() = default; explicit Stashed() = default;
using value_type = typename AgedOrderedContainer::value_type; using value_type = AgedOrderedContainer::value_type;
using time_point = typename AgedOrderedContainer::time_point; using time_point = AgedOrderedContainer::time_point;
}; };
Element(time_point const& when, value_type const& value) : value(value), when(when) Element(time_point const& when, value_type const& value) : value(value), when(when)
@@ -192,8 +192,8 @@ private:
} }
}; };
using list_type = typename boost::intrusive:: using list_type =
make_list<Element, boost::intrusive::constant_time_size<false>>::type; boost::intrusive::make_list<Element, boost::intrusive::constant_time_size<false>>::type;
using cont_type = std::conditional_t< using cont_type = std::conditional_t<
IsMulti, IsMulti,
@@ -206,8 +206,7 @@ private:
boost::intrusive::constant_time_size<true>, boost::intrusive::constant_time_size<true>,
boost::intrusive::compare<KeyValueCompare>>::type>; boost::intrusive::compare<KeyValueCompare>>::type>;
using ElementAllocator = using ElementAllocator = std::allocator_traits<Allocator>::template rebind_alloc<Element>;
typename std::allocator_traits<Allocator>::template rebind_alloc<Element>;
using ElementAllocatorTraits = std::allocator_traits<ElementAllocator>; using ElementAllocatorTraits = std::allocator_traits<ElementAllocator>;
@@ -373,8 +372,8 @@ public:
using allocator_type = Allocator; using allocator_type = Allocator;
using reference = value_type&; using reference = value_type&;
using const_reference = value_type const&; using const_reference = value_type const&;
using pointer = typename std::allocator_traits<Allocator>::pointer; using pointer = std::allocator_traits<Allocator>::pointer;
using const_pointer = typename std::allocator_traits<Allocator>::const_pointer; using const_pointer = std::allocator_traits<Allocator>::const_pointer;
// A set iterator (IsMap==false) is always const // A set iterator (IsMap==false) is always const
// because the elements of a set are immutable. // because the elements of a set are immutable.
@@ -617,7 +616,7 @@ public:
bool MaybeMulti = IsMulti, bool MaybeMulti = IsMulti,
bool MaybeMap = IsMap, bool MaybeMap = IsMap,
class = std::enable_if_t<MaybeMap && !MaybeMulti>> class = std::enable_if_t<MaybeMap && !MaybeMulti>>
typename std::conditional<IsMap, T, void*>::type const& std::conditional<IsMap, T, void*>::type const&
at(K const& k) const; at(K const& k) const;
template < template <
@@ -1146,7 +1145,7 @@ private:
void void
touch( touch(
beast::detail::AgedContainerIterator<IsConst, Iterator> pos, beast::detail::AgedContainerIterator<IsConst, Iterator> pos,
typename clock_type::time_point const& now); clock_type::time_point const& now);
template < template <
bool MaybePropagate = std::allocator_traits<Allocator>::propagate_on_container_swap::value> bool MaybePropagate = std::allocator_traits<Allocator>::propagate_on_container_swap::value>
@@ -1393,7 +1392,7 @@ AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::at(K co
template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator> template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
template <class K, bool MaybeMulti, bool MaybeMap, class> template <class K, bool MaybeMulti, bool MaybeMap, class>
typename std::conditional<IsMap, T, void*>::type const& std::conditional<IsMap, T, void*>::type const&
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::at(K const& k) const AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::at(K const& k) const
{ {
auto const iter(cont_.find(k, std::cref(config_.keyCompare()))); auto const iter(cont_.find(k, std::cref(config_.keyCompare())));
@@ -1732,7 +1731,7 @@ AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::operato
cend(), cend(),
other.cbegin(), other.cbegin(),
other.cend(), other.cend(),
[&eq, &other](value_type const& lhs, typename Other::value_type const& rhs) { [&eq, &other](value_type const& lhs, Other::value_type const& rhs) {
return eq(extract(lhs), other.extract(rhs)); return eq(extract(lhs), other.extract(rhs));
}); });
} }
@@ -1744,7 +1743,7 @@ template <bool IsConst, class Iterator, class>
void void
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::touch( AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::touch(
beast::detail::AgedContainerIterator<IsConst, Iterator> pos, beast::detail::AgedContainerIterator<IsConst, Iterator> pos,
typename clock_type::time_point const& now) clock_type::time_point const& now)
{ {
auto& e(*pos.iterator()); auto& e(*pos.iterator());
e.when = now; e.when = now;

View File

@@ -67,8 +67,8 @@ class AgedUnorderedContainer
{ {
public: public:
using clock_type = AbstractClock<Clock>; using clock_type = AbstractClock<Clock>;
using time_point = typename clock_type::time_point; using time_point = clock_type::time_point;
using duration = typename clock_type::duration; using duration = clock_type::duration;
using key_type = Key; using key_type = Key;
using mapped_type = T; using mapped_type = T;
using value_type = std::conditional_t<IsMap, std::pair<Key const, T>, Key>; using value_type = std::conditional_t<IsMap, std::pair<Key const, T>, Key>;
@@ -99,8 +99,8 @@ private:
{ {
explicit Stashed() = default; explicit Stashed() = default;
using value_type = typename AgedUnorderedContainer::value_type; using value_type = AgedUnorderedContainer::value_type;
using time_point = typename AgedUnorderedContainer::time_point; using time_point = AgedUnorderedContainer::time_point;
}; };
Element(time_point const& when, value_type const& value) : value(value), when(when) Element(time_point const& when, value_type const& value) : value(value), when(when)
@@ -201,8 +201,8 @@ private:
} }
}; };
using list_type = typename boost::intrusive:: using list_type =
make_list<Element, boost::intrusive::constant_time_size<false>>::type; boost::intrusive::make_list<Element, boost::intrusive::constant_time_size<false>>::type;
using cont_type = std::conditional_t< using cont_type = std::conditional_t<
IsMulti, IsMulti,
@@ -219,16 +219,14 @@ private:
boost::intrusive::equal<KeyValueEqual>, boost::intrusive::equal<KeyValueEqual>,
boost::intrusive::cache_begin<true>>::type>; boost::intrusive::cache_begin<true>>::type>;
using bucket_type = typename cont_type::bucket_type; using bucket_type = cont_type::bucket_type;
using bucket_traits = typename cont_type::bucket_traits; using bucket_traits = cont_type::bucket_traits;
using ElementAllocator = using ElementAllocator = std::allocator_traits<Allocator>::template rebind_alloc<Element>;
typename std::allocator_traits<Allocator>::template rebind_alloc<Element>;
using ElementAllocatorTraits = std::allocator_traits<ElementAllocator>; using ElementAllocatorTraits = std::allocator_traits<ElementAllocator>;
using BucketAllocator = using BucketAllocator = std::allocator_traits<Allocator>::template rebind_alloc<Element>;
typename std::allocator_traits<Allocator>::template rebind_alloc<Element>;
using BucketAllocatorTraits = std::allocator_traits<BucketAllocator>; using BucketAllocatorTraits = std::allocator_traits<BucketAllocator>;
@@ -542,8 +540,8 @@ public:
using allocator_type = Allocator; using allocator_type = Allocator;
using reference = value_type&; using reference = value_type&;
using const_reference = value_type const&; using const_reference = value_type const&;
using pointer = typename std::allocator_traits<Allocator>::pointer; using pointer = std::allocator_traits<Allocator>::pointer;
using const_pointer = typename std::allocator_traits<Allocator>::const_pointer; using const_pointer = std::allocator_traits<Allocator>::const_pointer;
// A set iterator (IsMap==false) is always const // A set iterator (IsMap==false) is always const
// because the elements of a set are immutable. // because the elements of a set are immutable.
@@ -850,7 +848,7 @@ public:
bool MaybeMulti = IsMulti, bool MaybeMulti = IsMulti,
bool MaybeMap = IsMap, bool MaybeMap = IsMap,
class = std::enable_if_t<MaybeMap && !MaybeMulti>> class = std::enable_if_t<MaybeMap && !MaybeMulti>>
typename std::conditional<IsMap, T, void*>::type const& std::conditional<IsMap, T, void*>::type const&
at(K const& k) const; at(K const& k) const;
template < template <
@@ -1414,7 +1412,7 @@ private:
void void
touch( touch(
beast::detail::AgedContainerIterator<IsConst, Iterator> pos, beast::detail::AgedContainerIterator<IsConst, Iterator> pos,
typename clock_type::time_point const& now) clock_type::time_point const& now)
{ {
auto& e(*pos.iterator()); auto& e(*pos.iterator());
e.when = now; e.when = now;
@@ -2111,7 +2109,7 @@ template <
class KeyEqual, class KeyEqual,
class Allocator> class Allocator>
template <class K, bool MaybeMulti, bool MaybeMap, class> template <class K, bool MaybeMulti, bool MaybeMap, class>
typename std::conditional<IsMap, T, void*>::type const& std::conditional<IsMap, T, void*>::type const&
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::at( AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::at(
K const& k) const K const& k) const
{ {

View File

@@ -24,7 +24,7 @@ struct CopyConst<T const, U>
{ {
explicit CopyConst() = default; explicit CopyConst() = default;
using type = typename std::remove_const<U>::type const; using type = std::remove_const<U>::type const;
}; };
/** @} */ /** @} */
@@ -56,7 +56,7 @@ class ListIterator
{ {
public: public:
using iterator_category = std::bidirectional_iterator_tag; using iterator_category = std::bidirectional_iterator_tag;
using value_type = typename beast::detail::CopyConst<N, typename N::value_type>::type; using value_type = beast::detail::CopyConst<N, typename N::value_type>::type;
using difference_type = std::ptrdiff_t; using difference_type = std::ptrdiff_t;
using pointer = value_type*; using pointer = value_type*;
using reference = value_type&; using reference = value_type&;
@@ -259,7 +259,7 @@ template <typename T, typename Tag = void>
class List class List
{ {
public: public:
using Node = typename detail::ListNode<T, Tag>; using Node = detail::ListNode<T, Tag>;
using value_type = T; using value_type = T;
using pointer = value_type*; using pointer = value_type*;

View File

@@ -12,13 +12,13 @@ template <class Container, bool IsConst>
class LockFreeStackIterator class LockFreeStackIterator
{ {
protected: protected:
using Node = typename Container::Node; using Node = Container::Node;
using NodePtr = std::conditional_t<IsConst, Node const*, Node*>; using NodePtr = std::conditional_t<IsConst, Node const*, Node*>;
public: public:
using iterator_category = std::forward_iterator_tag; using iterator_category = std::forward_iterator_tag;
using value_type = typename Container::value_type; using value_type = Container::value_type;
using difference_type = typename Container::difference_type; using difference_type = Container::difference_type;
using pointer = using pointer =
std::conditional_t<IsConst, typename Container::const_pointer, typename Container::pointer>; std::conditional_t<IsConst, typename Container::const_pointer, typename Container::pointer>;
using reference = std:: using reference = std::

View File

@@ -11,7 +11,7 @@ struct Uhash
{ {
Uhash() = default; Uhash() = default;
using result_type = typename Hasher::result_type; using result_type = Hasher::result_type;
template <class T> template <class T>
result_type result_type

View File

@@ -7,8 +7,11 @@
#include <array> #include <array>
#include <cstddef> #include <cstddef>
#include <cstdint> #include <cstdint>
#include <cstring>
#include <new>
#include <optional> #include <optional>
#include <span> #include <span>
#include <type_traits>
namespace beast { namespace beast {

View File

@@ -3,6 +3,7 @@
#include <xrpl/beast/insight/CounterImpl.h> #include <xrpl/beast/insight/CounterImpl.h>
#include <memory> #include <memory>
#include <utility>
namespace beast::insight { namespace beast::insight {
@@ -29,7 +30,7 @@ public:
factory function in the Collector interface. factory function in the Collector interface.
@see Collector. @see Collector.
*/ */
explicit Counter(std::shared_ptr<CounterImpl> const& impl) : impl_(impl) explicit Counter(std::shared_ptr<CounterImpl> impl) : impl_(std::move(impl))
{ {
} }

View File

@@ -4,6 +4,7 @@
#include <chrono> #include <chrono>
#include <memory> #include <memory>
#include <utility>
namespace beast::insight { namespace beast::insight {
@@ -31,7 +32,7 @@ public:
factory function in the Collector interface. factory function in the Collector interface.
@see Collector. @see Collector.
*/ */
explicit Event(std::shared_ptr<EventImpl> const& impl) : impl_(impl) explicit Event(std::shared_ptr<EventImpl> impl) : impl_(std::move(impl))
{ {
} }

View File

@@ -3,6 +3,7 @@
#include <xrpl/beast/insight/GaugeImpl.h> #include <xrpl/beast/insight/GaugeImpl.h>
#include <memory> #include <memory>
#include <utility>
namespace beast::insight { namespace beast::insight {
@@ -31,7 +32,7 @@ public:
factory function in the Collector interface. factory function in the Collector interface.
@see Collector. @see Collector.
*/ */
explicit Gauge(std::shared_ptr<GaugeImpl> const& impl) : impl_(impl) explicit Gauge(std::shared_ptr<GaugeImpl> impl) : impl_(std::move(impl))
{ {
} }

View File

@@ -3,6 +3,7 @@
#include <xrpl/beast/insight/HookImpl.h> #include <xrpl/beast/insight/HookImpl.h>
#include <memory> #include <memory>
#include <utility>
namespace beast::insight { namespace beast::insight {
@@ -20,7 +21,7 @@ public:
factory function in the Collector interface. factory function in the Collector interface.
@see Collector. @see Collector.
*/ */
explicit Hook(std::shared_ptr<HookImpl> const& impl) : impl_(impl) explicit Hook(std::shared_ptr<HookImpl> impl) : impl_(std::move(impl))
{ {
} }

View File

@@ -3,6 +3,7 @@
#include <xrpl/beast/insight/MeterImpl.h> #include <xrpl/beast/insight/MeterImpl.h>
#include <memory> #include <memory>
#include <utility>
namespace beast::insight { namespace beast::insight {
@@ -28,7 +29,7 @@ public:
factory function in the Collector interface. factory function in the Collector interface.
@see Collector. @see Collector.
*/ */
explicit Meter(std::shared_ptr<MeterImpl> const& impl) : impl_(impl) explicit Meter(std::shared_ptr<MeterImpl> impl) : impl_(std::move(impl))
{ {
} }

View File

@@ -102,7 +102,7 @@ Result
split(FwdIt first, FwdIt last, Char delim) split(FwdIt first, FwdIt last, Char delim)
{ {
using namespace detail; using namespace detail;
using string = typename Result::value_type; using string = Result::value_type;
Result result; Result result;

View File

@@ -32,11 +32,11 @@ protected:
} }
public: public:
using value_type = typename cont_type::value_type; using value_type = cont_type::value_type;
using size_type = typename cont_type::size_type; using size_type = cont_type::size_type;
using difference_type = typename cont_type::difference_type; using difference_type = cont_type::difference_type;
using iterator = typename cont_type::const_iterator; using iterator = cont_type::const_iterator;
using const_iterator = typename cont_type::const_iterator; using const_iterator = cont_type::const_iterator;
/** Returns `true` if the container is empty. */ /** Returns `true` if the container is empty. */
[[nodiscard]] bool [[nodiscard]] bool

View File

@@ -41,7 +41,7 @@ private:
public: public:
template <class = void> template <class = void>
explicit Selector(ModeT mode, std::string const& pattern = ""); explicit Selector(ModeT mode, std::string pattern = "");
template <class = void> template <class = void>
bool bool
@@ -51,9 +51,9 @@ public:
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
template <class> template <class>
Selector::Selector(ModeT mode, std::string const& pattern) : mode_(mode), pat_(pattern) Selector::Selector(ModeT mode, std::string pattern) : mode_(mode), pat_(std::move(pattern))
{ {
if (mode_ == ModeT::Automatch && pattern.empty()) if (mode_ == ModeT::Automatch && pat_.empty())
mode_ = ModeT::All; mode_ = ModeT::All;
} }

View File

@@ -48,7 +48,7 @@ private:
std::size_t cases = 0; std::size_t cases = 0;
std::size_t total = 0; std::size_t total = 0;
std::size_t failed = 0; std::size_t failed = 0;
typename clock_type::time_point start = clock_type::now(); clock_type::time_point start = clock_type::now();
explicit SuiteResults(std::string name = "") : name(std::move(name)) explicit SuiteResults(std::string name = "") : name(std::move(name))
{ {
@@ -60,7 +60,7 @@ private:
struct Results struct Results
{ {
using run_time = std::pair<std::string, typename clock_type::duration>; using run_time = std::pair<std::string, clock_type::duration>;
static constexpr auto kMaxTop = 10; static constexpr auto kMaxTop = 10;
@@ -69,7 +69,7 @@ private:
std::size_t total = 0; std::size_t total = 0;
std::size_t failed = 0; std::size_t failed = 0;
std::vector<run_time> top; std::vector<run_time> top;
typename clock_type::time_point start = clock_type::now(); clock_type::time_point start = clock_type::now();
void void
add(SuiteResults const& r); add(SuiteResults const& r);
@@ -91,7 +91,7 @@ public:
private: private:
static std::string static std::string
fmtdur(typename clock_type::duration const& d); fmtdur(clock_type::duration const& d);
void void
onSuiteBegin(SuiteInfo const& info) override; onSuiteBegin(SuiteInfo const& info) override;
@@ -141,9 +141,7 @@ Reporter<Unused>::Results::add(SuiteResults const& r)
top.begin(), top.begin(),
top.end(), top.end(),
elapsed, elapsed,
[](run_time const& t1, typename clock_type::duration const& t2) { [](run_time const& t1, clock_type::duration const& t2) { return t1.second > t2; });
return t1.second > t2;
});
if (iter != top.end()) if (iter != top.end())
{ {
if (top.size() == kMaxTop) if (top.size() == kMaxTop)
@@ -181,7 +179,7 @@ Reporter<Unused>::~Reporter()
template <class Unused> template <class Unused>
std::string std::string
Reporter<Unused>::fmtdur(typename clock_type::duration const& d) Reporter<Unused>::fmtdur(clock_type::duration const& d)
{ {
using namespace std::chrono; using namespace std::chrono;
auto const ms = duration_cast<milliseconds>(d); auto const ms = duration_cast<milliseconds>(d);

View File

@@ -411,9 +411,9 @@ class BasicLogstream : public std::basic_ostream<CharT, Traits>
{ {
using char_type = CharT; using char_type = CharT;
using traits_type = Traits; using traits_type = Traits;
using int_type = typename traits_type::int_type; using int_type = traits_type::int_type;
using pos_type = typename traits_type::pos_type; using pos_type = traits_type::pos_type;
using off_type = typename traits_type::off_type; using off_type = traits_type::off_type;
detail::LogStreamBuf<CharT, Traits> buf_; detail::LogStreamBuf<CharT, Traits> buf_;

View File

@@ -11,6 +11,8 @@
// Macros below are copied from antithesis_sdk.h and slightly simplified // Macros below are copied from antithesis_sdk.h and slightly simplified
// The duplication is because Visual Studio 2019 cannot compile that header // The duplication is because Visual Studio 2019 cannot compile that header
// even with the option -Zc:__cplusplus added. // even with the option -Zc:__cplusplus added.
// NOTE: cond must not contain bare commas outside () or []. Commas inside {}
// are not protected by the preprocessor and would be parsed as extra arguments.
#define ALWAYS(cond, message, ...) assert((message) && (cond)) #define ALWAYS(cond, message, ...) assert((message) && (cond))
#define ALWAYS_OR_UNREACHABLE(cond, message) assert((message) && (cond)) #define ALWAYS_OR_UNREACHABLE(cond, message) assert((message) && (cond))
#define SOMETIMES(cond, message, ...) #define SOMETIMES(cond, message, ...)
@@ -22,6 +24,8 @@
#define XRPL_ASSERT_PARTS(cond, function, description, ...) \ #define XRPL_ASSERT_PARTS(cond, function, description, ...) \
XRPL_ASSERT(cond, function " : " description) XRPL_ASSERT(cond, function " : " description)
#define XRPL_ASSERT_IF(guard, cond, message) XRPL_ASSERT(!(guard) || (cond), message)
// How to use the instrumentation macros: // How to use the instrumentation macros:
// //
// * XRPL_ASSERT if cond must be true but the line might not be reached during // * XRPL_ASSERT if cond must be true but the line might not be reached during
@@ -29,6 +33,14 @@
// * XRPL_ASSERT_PARTS is for convenience, and works like XRPL_ASSERT, but // * XRPL_ASSERT_PARTS is for convenience, and works like XRPL_ASSERT, but
// splits the message param into "function" and "description", then joins // splits the message param into "function" and "description", then joins
// them with " : " before passing to XRPL_ASSERT. // them with " : " before passing to XRPL_ASSERT.
// * XRPL_ASSERT_IF(guard, cond, message) asserts the implication
// `guard => cond`: it can only fail when guard is true (e.g. an amendment
// is enabled) and cond is false. Unlike `if (guard) XRPL_ASSERT(...)`, the
// assertion site is always evaluated, so the fuzzer registers it
// unconditionally; cond itself is short-circuited and only evaluated when
// guard is true. NOTE: do not rely on side effects in guard — in release
// builds the assertion body is stripped, and the compiler may optimize away
// a side-effect-free guard entirely.
// * ALWAYS if cond must be true _and_ the line must be reached during fuzzing. // * ALWAYS if cond must be true _and_ the line must be reached during fuzzing.
// Same like `assert` in normal use. // Same like `assert` in normal use.
// * REACHABLE if the line must be reached during fuzzing // * REACHABLE if the line must be reached during fuzzing

View File

@@ -15,6 +15,6 @@ struct MaybeConst
/** Alias for omitting `typename`. */ /** Alias for omitting `typename`. */
template <bool IsConst, class T> template <bool IsConst, class T>
using maybe_const_t = typename MaybeConst<IsConst, T>::type; using maybe_const_t = MaybeConst<IsConst, T>::type;
} // namespace beast } // namespace beast

View File

@@ -13,7 +13,7 @@ template <class Generator>
void void
rngfill(void* const buffer, std::size_t const bytes, Generator& g) rngfill(void* const buffer, std::size_t const bytes, Generator& g)
{ {
using result_type = typename Generator::result_type; using result_type = Generator::result_type;
constexpr std::size_t kResultSize = sizeof(result_type); constexpr std::size_t kResultSize = sizeof(result_type);
std::uint8_t* const bufferStart = static_cast<std::uint8_t*>(buffer); std::uint8_t* const bufferStart = static_cast<std::uint8_t*>(buffer);
@@ -42,7 +42,7 @@ template <
void void
rngfill(std::array<std::uint8_t, N>& a, Generator& g) rngfill(std::array<std::uint8_t, N>& a, Generator& g)
{ {
using result_type = typename Generator::result_type; using result_type = Generator::result_type;
auto i = N / sizeof(result_type); auto i = N / sizeof(result_type);
result_type* p = reinterpret_cast<result_type*>(a.data()); result_type* p = reinterpret_cast<result_type*>(a.data());
while (i--) while (i--)

View File

@@ -0,0 +1,180 @@
#pragma once
namespace xrpl {
struct Sections
{
static constexpr auto kAmendments = "amendments";
static constexpr auto kAmendmentMajorityTime = "amendment_majority_time";
static constexpr auto kBetaRpcApi = "beta_rpc_api";
static constexpr auto kClusterNodes = "cluster_nodes";
static constexpr auto kCompression = "compression";
static constexpr auto kCrawl = "crawl";
static constexpr auto kDatabasePath = "database_path";
static constexpr auto kDebugLogfile = "debug_logfile";
static constexpr auto kElbSupport = "elb_support";
static constexpr auto kFeatures = "features";
static constexpr auto kFeeDefault = "fee_default";
static constexpr auto kFetchDepth = "fetch_depth";
static constexpr auto kHashrouter = "hashrouter";
static constexpr auto kImportNodeDatabase = "import_db";
static constexpr auto kInsight = "insight";
static constexpr auto kIoWorkers = "io_workers";
static constexpr auto kIps = "ips";
static constexpr auto kIpsFixed = "ips_fixed";
static constexpr auto kLedgerHistory = "ledger_history";
static constexpr auto kLedgerReplay = "ledger_replay";
static constexpr auto kLedgerTxTables = "ledger_tx_tables";
static constexpr auto kMaxTransactions = "max_transactions";
static constexpr auto kNetworkId = "network_id";
static constexpr auto kNetworkQuorum = "network_quorum";
static constexpr auto kNodeDatabase = "node_db";
static constexpr auto kNodeSeed = "node_seed";
static constexpr auto kNodeSize = "node_size";
static constexpr auto kOverlay = "overlay";
static constexpr auto kPathSearch = "path_search";
static constexpr auto kPathSearchFast = "path_search_fast";
static constexpr auto kPathSearchMax = "path_search_max";
static constexpr auto kPathSearchOld = "path_search_old";
static constexpr auto kPeerPrivate = "peer_private";
static constexpr auto kPeersInMax = "peers_in_max";
static constexpr auto kPeersMax = "peers_max";
static constexpr auto kPeersOutMax = "peers_out_max";
static constexpr auto kPerf = "perf";
static constexpr auto kPortGrpc = "port_grpc";
static constexpr auto kPortPeer = "port_peer";
static constexpr auto kPortRpc = "port_rpc";
static constexpr auto kPortWs = "port_ws";
static constexpr auto kPortWssAdmin = "port_wss_admin";
static constexpr auto kPrefetchWorkers = "prefetch_workers";
static constexpr auto kReduceRelay = "reduce_relay";
static constexpr auto kRelationalDb = "relational_db";
static constexpr auto kRelayProposals = "relay_proposals";
static constexpr auto kRelayValidations = "relay_validations";
static constexpr auto kRpcStartup = "rpc_startup";
static constexpr auto kServer = "server";
static constexpr auto kServerDomain = "server_domain";
static constexpr auto kSigningSupport = "signing_support";
static constexpr auto kSntp = "sntp_servers";
static constexpr auto kSqdb = "sqdb";
static constexpr auto kSqlite = "sqlite";
static constexpr auto kSslVerify = "ssl_verify";
static constexpr auto kSslVerifyDir = "ssl_verify_dir";
static constexpr auto kSslVerifyFile = "ssl_verify_file";
static constexpr auto kSweepInterval = "sweep_interval";
static constexpr auto kTransactionQueue = "transaction_queue";
static constexpr auto kValidationSeed = "validation_seed";
static constexpr auto kValidatorKeys = "validator_keys";
static constexpr auto kValidatorKeyRevocation = "validator_key_revocation";
static constexpr auto kValidatorListKeys = "validator_list_keys";
static constexpr auto kValidatorListSites = "validator_list_sites";
static constexpr auto kValidatorListThreshold = "validator_list_threshold";
static constexpr auto kValidatorToken = "validator_token";
static constexpr auto kValidators = "validators";
static constexpr auto kValidatorsFile = "validators_file";
static constexpr auto kVetoAmendments = "veto_amendments";
static constexpr auto kVl = "vl";
static constexpr auto kVoting = "voting";
static constexpr auto kWorkers = "workers";
};
struct Keys
{
static constexpr auto kAccountReserve = "account_reserve";
static constexpr auto kAddress = "address";
static constexpr auto kAdmin = "admin";
static constexpr auto kAdminPassword = "admin_password";
static constexpr auto kAdminUser = "admin_user";
static constexpr auto kAdvisoryDelete = "advisory_delete";
static constexpr auto kAgeThresholdSeconds = "age_threshold_seconds";
static constexpr auto kBackOff = "backOff";
static constexpr auto kBackOffMilliseconds = "back_off_milliseconds";
static constexpr auto kBackend = "backend";
static constexpr auto kBbtOptions = "bbt_options";
static constexpr auto kBgThreads = "bg_threads";
static constexpr auto kBlockSize = "block_size";
static constexpr auto kCacheAge = "cache_age";
static constexpr auto kCacheMb = "cache_mb";
static constexpr auto kCacheSize = "cache_size";
static constexpr auto kClientMaxWindowBits = "client_max_window_bits";
static constexpr auto kClientNoContextTakeover = "client_no_context_takeover";
static constexpr auto kCompressLevel = "compress_level";
static constexpr auto kCounts = "counts";
static constexpr auto kDeleteBatch = "delete_batch";
static constexpr auto kEarliestSeq = "earliest_seq";
static constexpr auto kFastLoad = "fast_load";
static constexpr auto kFileSizeMb = "file_size_mb";
static constexpr auto kFileSizeMult = "file_size_mult";
static constexpr auto kFilterBits = "filter_bits";
static constexpr auto kFilterFull = "filter_full";
static constexpr auto kHardSet = "hard_set";
static constexpr auto kHighThreads = "high_threads";
static constexpr auto kHoldTime = "hold_time";
static constexpr auto kIp = "ip";
static constexpr auto kJournalMode = "journal_mode";
static constexpr auto kJournalSizeLimit = "journal_size_limit";
static constexpr auto kLedgersInQueue = "ledgers_in_queue";
static constexpr auto kLimit = "limit";
static constexpr auto kLogInterval = "log_interval";
static constexpr auto kMaxDivergedTime = "max_diverged_time";
static constexpr auto kMaxLedgerCountsToStore = "max_ledger_counts_to_store";
static constexpr auto kMaxUnknownTime = "max_unknown_time";
static constexpr auto kMaximumTxnInLedger = "maximum_txn_in_ledger";
static constexpr auto kMaximumTxnPerAccount = "maximum_txn_per_account";
static constexpr auto kMemoryLevel = "memory_level";
static constexpr auto kMinLedgersToComputeSizeLimit = "min_ledgers_to_compute_size_limit";
static constexpr auto kMinimumEscalationMultiplier = "minimum_escalation_multiplier";
static constexpr auto kMinimumLastLedgerBuffer = "minimum_last_ledger_buffer";
static constexpr auto kMinimumQueueSize = "minimum_queue_size";
static constexpr auto kMinimumTxnInLedger = "minimum_txn_in_ledger";
static constexpr auto kMinimumTxnInLedgerStandalone = "minimum_txn_in_ledger_standalone";
static constexpr auto kNormalConsensusIncreasePercent = "normal_consensus_increase_percent";
static constexpr auto kNudbBlockSize = "nudb_block_size";
static constexpr auto kOnlineDelete = "online_delete";
static constexpr auto kOpenFiles = "open_files";
static constexpr auto kOptions = "options";
static constexpr auto kOverlay = "overlay";
static constexpr auto kOwnerReserve = "owner_reserve";
static constexpr auto kPageSize = "page_size";
static constexpr auto kPassword = "password";
static constexpr auto kPath = "path";
static constexpr auto kPermessageDeflate = "permessage_deflate";
static constexpr auto kPort = "port";
static constexpr auto kPrefix = "prefix";
static constexpr auto kProtocol = "protocol";
static constexpr auto kRecoveryWaitSeconds = "recovery_wait_seconds";
static constexpr auto kReferenceFee = "reference_fee";
static constexpr auto kRelayTime = "relay_time";
static constexpr auto kRetrySequencePercent = "retry_sequence_percent";
static constexpr auto kRqBundle = "rq_bundle";
static constexpr auto kSafetyLevel = "safety_level";
static constexpr auto kSecureGateway = "secure_gateway";
static constexpr auto kSendQueueLimit = "send_queue_limit";
static constexpr auto kServer = "server";
static constexpr auto kServerMaxWindowBits = "server_max_window_bits";
static constexpr auto kServerNoContextTakeover = "server_no_context_takeover";
static constexpr auto kSlowConsensusDecreasePercent = "slow_consensus_decrease_percent";
static constexpr auto kSslCert = "ssl_cert";
static constexpr auto kSslCertChain = "ssl_cert_chain";
static constexpr auto kSslChain = "ssl_chain";
static constexpr auto kSslCiphers = "ssl_ciphers";
static constexpr auto kSslClientCa = "ssl_client_ca";
static constexpr auto kSslKey = "ssl_key";
static constexpr auto kSynchronous = "synchronous";
static constexpr auto kTargetTxnInLedger = "target_txn_in_ledger";
static constexpr auto kTempStore = "temp_store";
static constexpr auto kTxEnable = "tx_enable";
static constexpr auto kTxMetrics = "tx_metrics";
static constexpr auto kTxMinPeers = "tx_min_peers";
static constexpr auto kTxRelayPercentage = "tx_relay_percentage";
static constexpr auto kType = "type";
static constexpr auto kUniversalCompaction = "universal_compaction";
static constexpr auto kUnl = "unl";
static constexpr auto kUseTxTables = "use_tx_tables";
static constexpr auto kUser = "user";
static constexpr auto kVpBaseSquelchEnable = "vp_base_squelch_enable";
static constexpr auto kVpBaseSquelchMaxSelectedPeers = "vp_base_squelch_max_selected_peers";
static constexpr auto kVpEnable = "vp_enable";
};
} // namespace xrpl

View File

@@ -1,6 +1,5 @@
#pragma once #pragma once
#include <xrpl/basics/BasicConfig.h>
#include <xrpl/core/JobTypes.h> #include <xrpl/core/JobTypes.h>
#include <xrpl/json/json_value.h> #include <xrpl/json/json_value.h>
@@ -18,6 +17,7 @@ class Journal;
namespace xrpl { namespace xrpl {
class Application; class Application;
class Section;
namespace perf { namespace perf {
/** /**

View File

@@ -1,6 +1,7 @@
#pragma once #pragma once
#include <string> #include <string>
#include <string_view>
#include <vector> #include <vector>
namespace xrpl { namespace xrpl {
@@ -34,7 +35,7 @@ private:
static void static void
standard(std::string& strWord); standard(std::string& strWord);
static int static int
wsrch(std::string const& strWord, int iMin, int iMax); wsrch(std::string_view strWord, int iMin, int iMax);
static int static int
etob(std::string& strData, std::vector<std::string> vsHuman); etob(std::string& strData, std::vector<std::string> vsHuman);

View File

@@ -566,6 +566,7 @@ public:
using SelfType = ValueConstIterator; using SelfType = ValueConstIterator;
ValueConstIterator() = default; ValueConstIterator() = default;
ValueConstIterator(ValueConstIterator const& other) = default;
private: private:
/*! \internal Use by Value to create an iterator. /*! \internal Use by Value to create an iterator.
@@ -574,12 +575,12 @@ private:
public: public:
SelfType& SelfType&
operator=(ValueIteratorBase const& other); operator=(SelfType const& other);
SelfType SelfType
operator++(int) operator++(int)
{ {
SelfType temp(*this); SelfType const temp(*this);
++*this; ++*this;
return temp; return temp;
} }
@@ -587,7 +588,7 @@ public:
SelfType SelfType
operator--(int) operator--(int)
{ {
SelfType temp(*this); SelfType const temp(*this);
--*this; --*this;
return temp; return temp;
} }

View File

@@ -1,49 +0,0 @@
#pragma once
#include <xrpl/protocol/MultiApiJson.h>
#include <xrpl/server/InfoSub.h>
#include <memory>
#include <mutex>
namespace xrpl {
/** Listen to public/subscribe messages from a book. */
class BookListeners
{
public:
using pointer = std::shared_ptr<BookListeners>;
BookListeners() = default;
/** Add a new subscription for this book
*/
void
addSubscriber(InfoSub::ref sub);
/** Stop publishing to a subscriber
*/
void
removeSubscriber(std::uint64_t sub);
/** Publish a transaction to subscribers
Publish a transaction to clients subscribed to changes on this book.
Uses havePublished to prevent sending duplicate transactions to clients
that have subscribed to multiple books.
@param jvObj JSON transaction data to publish
@param havePublished InfoSub sequence numbers that have already
published this transaction.
*/
void
publish(MultiApiJson const& jvObj, hash_set<std::uint64_t>& havePublished);
private:
std::recursive_mutex lock_;
hash_map<std::uint64_t, InfoSub::wptr> listeners_;
};
} // namespace xrpl

View File

@@ -93,7 +93,7 @@ public:
} }
void void
insert(std::shared_ptr<STTx const> const& txn); insert(std::shared_ptr<STTx const> txn);
// Pops the next transaction on account that follows seqProx in the // Pops the next transaction on account that follows seqProx in the
// sort order. Normally called when a transaction is successfully // sort order. Normally called when a transaction is successfully

View File

@@ -1,11 +1,11 @@
#pragma once #pragma once
#include <xrpl/basics/UnorderedContainers.h>
#include <xrpl/beast/utility/Journal.h>
#include <xrpl/ledger/AcceptedLedgerTx.h> #include <xrpl/ledger/AcceptedLedgerTx.h>
#include <xrpl/ledger/BookListeners.h>
#include <xrpl/ledger/ReadView.h> #include <xrpl/ledger/ReadView.h>
#include <xrpl/protocol/Asset.h> #include <xrpl/protocol/Asset.h>
#include <xrpl/protocol/Book.h> #include <xrpl/protocol/Book.h>
#include <xrpl/protocol/MultiApiJson.h>
#include <xrpl/protocol/UintTypes.h> #include <xrpl/protocol/UintTypes.h>
#include <memory> #include <memory>
@@ -77,34 +77,24 @@ public:
*/ */
virtual bool virtual bool
isBookToXRP(Asset const& asset, std::optional<Domain> const& domain = std::nullopt) = 0; isBookToXRP(Asset const& asset, std::optional<Domain> const& domain = std::nullopt) = 0;
/**
* Process a transaction for order book tracking.
* @param ledger The ledger the transaction was applied to
* @param alTx The transaction to process
* @param jvObj The JSON object of the transaction
*/
virtual void
processTxn(
std::shared_ptr<ReadView const> const& ledger,
AcceptedLedgerTx const& alTx,
MultiApiJson const& jvObj) = 0;
/**
* Get the book listeners for a book.
* @param book The book to get the listeners for
* @return The book listeners for the book
*/
virtual BookListeners::pointer
getBookListeners(Book const&) = 0;
/**
* Create a new book listeners for a book.
* @param book The book to create the listeners for
* @return The new book listeners for the book
*/
virtual BookListeners::pointer
makeBookListeners(Book const&) = 0;
}; };
/** Extract the set of books affected by a transaction.
*
* Walks the transaction's metadata nodes and collects every order book
* whose offers were created, modified, or deleted. Used by NetworkOPs to
* fan transaction notifications out to book subscribers.
*
* @param alTx The accepted ledger transaction to inspect.
* @param j Journal used to log per-node parsing failures. Inspecting an
* offer node can throw if a required field is missing; in that
* case the bad node is skipped and a warn-level message is
* emitted via @p j. Other affected books in the same transaction
* are still returned.
* @return The set of books whose offers were created, modified, or
* deleted. May be empty for non-offer transactions.
*/
hash_set<Book>
affectedBooks(AcceptedLedgerTx const& alTx, beast::Journal const& j);
} // namespace xrpl } // namespace xrpl

View File

@@ -1,6 +1,5 @@
#pragma once #pragma once
#include <xrpl/basics/Expected.h>
#include <xrpl/basics/Log.h> #include <xrpl/basics/Log.h>
#include <xrpl/basics/Number.h> #include <xrpl/basics/Number.h>
#include <xrpl/beast/utility/Journal.h> #include <xrpl/beast/utility/Journal.h>
@@ -18,6 +17,8 @@
#include <xrpl/protocol/STAmount.h> #include <xrpl/protocol/STAmount.h>
#include <xrpl/protocol/STLedgerEntry.h> #include <xrpl/protocol/STLedgerEntry.h>
#include <expected>
namespace xrpl { namespace xrpl {
namespace detail { namespace detail {
@@ -36,6 +37,8 @@ reduceOffer(auto const& amount)
enum class IsDeposit : bool { No = false, Yes = true }; enum class IsDeposit : bool { No = false, Yes = true };
inline Number const kAMMInvariantRelativeTolerance{1, -11};
/** Calculate LP Tokens given AMM pool reserves. /** Calculate LP Tokens given AMM pool reserves.
* @param asset1 AMM one side of the pool reserve * @param asset1 AMM one side of the pool reserve
* @param asset2 AMM another side of the pool reserve * @param asset2 AMM another side of the pool reserve
@@ -737,11 +740,35 @@ ammPoolHolds(
AuthHandling authHandling, AuthHandling authHandling,
beast::Journal const j); beast::Journal const j);
/** Check AMM pool product invariant after an AMM operation that changes LP tokens
* (deposit/withdraw/clawback) from an already calculated pool product mean.
* Returns tecPRECISION_LOSS if poolProductMean < newLPTokenBalance beyond the
* invariant tolerance,
* tesSUCCESS otherwise. Skips check when newLPTokenBalance is zero (last withdrawal).
*/
TER
checkAMMPrecisionLoss(Number const& poolProductMean, STAmount const& newLPTokenBalance);
/** Check AMM pool product invariant after an AMM operation that changes LP tokens
* (deposit/withdraw/clawback).
* Returns tecPRECISION_LOSS if sqrt(asset1 * asset2) < newLPTokenBalance beyond
* the invariant tolerance,
* tesSUCCESS otherwise. Skips check when newLPTokenBalance is zero (last withdrawal).
*/
TER
checkAMMPrecisionLoss(
ReadView const& view,
AccountID const& ammAccountID,
Asset const& asset1,
Asset const& asset2,
STAmount const& newLPTokenBalance,
beast::Journal const j);
/** Get AMM pool and LP token balances. If both optIssue are /** Get AMM pool and LP token balances. If both optIssue are
* provided then they are used as the AMM token pair issues. * provided then they are used as the AMM token pair issues.
* Otherwise the missing issues are fetched from ammSle. * Otherwise the missing issues are fetched from ammSle.
*/ */
Expected<std::tuple<STAmount, STAmount, STAmount>, TER> std::expected<std::tuple<STAmount, STAmount, STAmount>, TER>
ammHolds( ammHolds(
ReadView const& view, ReadView const& view,
SLE const& ammSle, SLE const& ammSle,
@@ -801,14 +828,14 @@ initializeFeeAuctionVote(
* otherwise. Return tecINTERNAL if encountered an unexpected condition, * otherwise. Return tecINTERNAL if encountered an unexpected condition,
* for instance Liquidity Provider has more than one LPToken trustline. * for instance Liquidity Provider has more than one LPToken trustline.
*/ */
Expected<bool, TER> std::expected<bool, TER>
isOnlyLiquidityProvider(ReadView const& view, Issue const& ammIssue, AccountID const& lpAccount); isOnlyLiquidityProvider(ReadView const& view, Issue const& ammIssue, AccountID const& lpAccount);
/** Due to rounding, the LPTokenBalance of the last LP might /** Due to rounding, the LPTokenBalance of the last LP might
* not match the LP's trustline balance. If it's within the tolerance, * not match the LP's trustline balance. If it's within the tolerance,
* update LPTokenBalance to match the LP's trustline balance. * update LPTokenBalance to match the LP's trustline balance.
*/ */
Expected<bool, TER> std::expected<bool, TER>
verifyAndAdjustLPTokenBalance( verifyAndAdjustLPTokenBalance(
Sandbox& sb, Sandbox& sb,
STAmount const& lpTokens, STAmount const& lpTokens,

View File

@@ -1,6 +1,5 @@
#pragma once #pragma once
#include <xrpl/basics/Expected.h>
#include <xrpl/beast/utility/Journal.h> #include <xrpl/beast/utility/Journal.h>
#include <xrpl/ledger/ApplyView.h> #include <xrpl/ledger/ApplyView.h>
#include <xrpl/ledger/ReadView.h> #include <xrpl/ledger/ReadView.h>
@@ -9,6 +8,7 @@
#include <xrpl/protocol/STLedgerEntry.h> #include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/TER.h> #include <xrpl/protocol/TER.h>
#include <expected>
#include <set> #include <set>
#include <vector> #include <vector>
@@ -91,7 +91,7 @@ isPseudoAccount(
* before using a field. The amendment check is **not** performed in * before using a field. The amendment check is **not** performed in
* createPseudoAccount. * createPseudoAccount.
*/ */
[[nodiscard]] Expected<SLE::pointer, TER> [[nodiscard]] std::expected<SLE::pointer, TER>
createPseudoAccount(ApplyView& view, uint256 const& pseudoOwnerKey, SField const& ownerField); createPseudoAccount(ApplyView& view, uint256 const& pseudoOwnerKey, SField const& ownerField);
/** Checks the destination and tag. /** Checks the destination and tag.

View File

@@ -36,13 +36,13 @@ checkFields(STTx const& tx, beast::Journal j);
TER TER
valid(STTx const& tx, ReadView const& view, AccountID const& src, beast::Journal j); valid(STTx const& tx, ReadView const& view, AccountID const& src, beast::Journal j);
// Check if subject has any credential maching the given domain. If you call it // Check if subject has any credential matching the given domain. If you call it
// in preclaim and it returns tecEXPIRED, you should call verifyValidDomain in // in preclaim and it returns tecEXPIRED, you should call verifyValidDomain in
// doApply. This will ensure that expired credentials are deleted. // doApply. This will ensure that expired credentials are deleted.
TER TER
validDomain(ReadView const& view, uint256 domainID, AccountID const& subject); validDomain(ReadView const& view, uint256 domainID, AccountID const& subject);
// This function is only called when we about to return tecNO_PERMISSION // This function is only called when we are about to return tecNO_PERMISSION
// because all the checks for the DepositPreauth authorization failed. // because all the checks for the DepositPreauth authorization failed.
TER TER
authorizedDepositPreauth(ReadView const& view, STVector256 const& ctx, AccountID const& dst); authorizedDepositPreauth(ReadView const& view, STVector256 const& ctx, AccountID const& dst);
@@ -58,7 +58,7 @@ checkArray(STArray const& credentials, unsigned maxSize, beast::Journal j);
} // namespace credentials } // namespace credentials
// Check expired credentials and for credentials maching DomainID of the ledger // Check expired credentials and for credentials matching DomainID of the ledger
// object // object
TER TER
verifyValidDomain(ApplyView& view, AccountID const& account, uint256 domainID, beast::Journal j); verifyValidDomain(ApplyView& view, AccountID const& account, uint256 domainID, beast::Journal j);

View File

@@ -23,13 +23,9 @@ checkTxPermission(SLE::const_ref delegate, STTx const& tx);
* @param delegate The delegate account. * @param delegate The delegate account.
* @param type Used to determine which granted granular permissions to load, * @param type Used to determine which granted granular permissions to load,
* based on the transaction type. * based on the transaction type.
* @param granularPermissions Granted granular permissions tied to the * @return the granted granular permissions tied to the transaction type.
* transaction type.
*/ */
void std::unordered_set<GranularPermissionType>
loadGranularPermission( getGranularPermission(SLE::const_ref delegate, TxType const& type);
SLE::const_ref delegate,
TxType const& type,
std::unordered_set<GranularPermissionType>& granularPermissions);
} // namespace xrpl } // namespace xrpl

Some files were not shown because too many files have changed in this diff Show More