Compare commits

..

75 Commits

Author SHA1 Message Date
Ed Hennis
7c933e06a0 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-11-18 22:39:10 -05:00
Ed Hennis
d94722e4d0 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-11-15 03:08:21 -05:00
Ed Hennis
059092d773 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-11-13 12:18:19 -05:00
Ed Hennis
1cb0887436 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-11-12 13:59:49 -05:00
Ed Hennis
b9e289df55 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-11-10 19:52:46 -05:00
Ed Hennis
fff08cb2b1 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-11-10 15:35:00 -05:00
Ed Hennis
d3842b3908 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-11-08 22:49:30 -05:00
Ed Hennis
759bd4d199 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-11-06 23:50:26 -05:00
Ed Hennis
4c88dfc384 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-11-05 22:23:11 -05:00
Ed Hennis
f241378e6e Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-11-04 18:02:34 -05:00
Ed Hennis
c8ff090d8e Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-11-03 18:04:00 -05:00
Ed Hennis
945c362559 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-11-03 12:41:52 -05:00
Ed Hennis
9546c52013 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-10-31 13:51:19 -04:00
Ed Hennis
3a099aeb64 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-10-31 12:51:28 -04:00
Ed Hennis
8567bd0d12 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-10-29 14:23:15 -04:00
Ed Hennis
3cb1851537 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-10-29 13:42:25 -04:00
Ed Hennis
55feea308e Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-10-29 12:54:20 -04:00
Ed Hennis
a6692af17a Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-10-28 17:38:25 -04:00
Ed Hennis
1d058a5d78 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-10-26 19:12:36 -04:00
Ed Hennis
a70821adc5 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-10-23 13:24:29 -04:00
Ed Hennis
bfeb60d3f5 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-10-22 11:38:53 -04:00
Ed Hennis
c86bfa32f7 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-10-21 22:20:09 -04:00
Ed Hennis
0f44d619b6 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-10-17 18:21:41 -04:00
Ed Hennis
2add6a7917 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-10-16 13:12:12 -04:00
Ed Hennis
d21c4f3218 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-10-16 10:48:48 -04:00
Ed Hennis
265a504301 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-10-10 13:01:37 -04:00
Ed Hennis
b1e576d3d1 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-10-09 15:14:51 -04:00
Ed Hennis
d2d3039ce6 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-10-08 14:21:37 -04:00
Ed Hennis
16e85a7b79 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-10-02 11:03:12 -04:00
Ed Hennis
4ae1c01e13 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-10-01 18:11:01 -04:00
Ed Hennis
8807afc074 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-10-01 13:14:26 -04:00
Ed Hennis
a4e13e07d5 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-09-30 22:28:57 -04:00
Ed Hennis
6067d59336 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-09-29 18:34:47 -04:00
Ed Hennis
e14aecee66 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-09-29 13:32:16 -04:00
Ed Hennis
0e4c3e3427 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-09-26 19:26:10 -04:00
Ed Hennis
da5c563426 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-09-26 13:41:39 -04:00
Ed Hennis
b9f5d8b1c5 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-09-26 12:09:21 -04:00
Ed Hennis
5ea7b562a2 Review feedback from @mvadari: Document test lambdas 2025-09-25 14:23:10 -04:00
Ed Hennis
8450970b80 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-09-25 13:27:21 -04:00
Ed Hennis
14d4cff530 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-09-24 15:50:03 -04:00
Ed Hennis
88ac659d86 Move the lambda to the top so that the parse functions stay alphabetical 2025-09-24 12:54:47 -04:00
Ed Hennis
43fdbf27b9 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-09-20 15:44:43 -04:00
Ed Hennis
1e33f8e868 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-09-18 14:08:38 -04:00
Ed Hennis
a6e30857df Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-09-18 12:26:54 -04:00
Ed Hennis
563f24edb0 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-09-17 10:49:24 -04:00
Ed Hennis
a89f6d5da2 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-09-16 11:15:08 -04:00
Ed Hennis
5b2e91986a Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-09-15 11:13:49 -04:00
Ed Hennis
fbc5056817 Gate the new "index: special_case" on the current beta apiVersion 3 2025-09-12 14:02:38 -04:00
Ed Hennis
b7cafed040 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-09-11 10:33:34 -04:00
Ed Hennis
b6ebd34b30 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-09-10 19:40:02 -04:00
Ed Hennis
74c2765159 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-09-09 17:14:37 -04:00
Ed Hennis
62c7fdadba Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-09-08 11:42:06 -04:00
Ed Hennis
372c66e684 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-09-05 17:44:24 -04:00
Ed Hennis
a2fab5bcaf Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-09-04 20:25:13 -04:00
Ed Hennis
2e4f41571c Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-09-04 16:44:07 -04:00
Ed Hennis
8799a6dbfd Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-09-04 12:36:56 -04:00
Ed Hennis
e655087027 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-09-03 14:04:19 -04:00
Ed Hennis
46bd2a4090 Merge remote-tracking branch 'upstream/develop' into ximinez/fixed-ledger-entries
* upstream/develop:
  Refactor `ledger_entry` RPC source code and tests (5237)
2025-08-29 17:55:45 -04:00
Ed Hennis
f3b8a8aef3 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-08-29 10:43:07 -04:00
Ed Hennis
ee0c917e95 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-08-28 18:17:43 -04:00
Ed Hennis
375aedd340 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-08-27 11:15:17 -04:00
Ed Hennis
95397a7710 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-08-25 19:51:08 -04:00
Ed Hennis
7af8a52d27 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-08-22 20:34:53 -04:00
Ed Hennis
326a8093c9 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-08-22 19:31:27 -04:00
Ed Hennis
9f0e159205 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-08-22 19:08:59 -04:00
Ed Hennis
2fda101b44 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-08-21 11:39:13 -04:00
Ed Hennis
e6e1e4f9dd Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-08-19 16:05:38 -04:00
Ed Hennis
70591265e5 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-08-18 12:26:01 -04:00
Ed Hennis
ed1d477a45 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-08-08 18:23:40 -04:00
Ed Hennis
cd58f636d3 Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-08-06 21:03:20 -04:00
Ed Hennis
3152f2233f Merge branch 'develop' into ximinez/fixed-ledger-entries 2025-08-05 21:17:03 -04:00
Ed Hennis
0c147a895c Restrict which values are valid for fixed types.
- True or a ledger index for those that can't parameters
- Number, true, or a ledger index for "hashes".
2025-08-04 19:23:59 -04:00
Ed Hennis
cf80710ef1 Refactor a little bit to reduce future conflicts
- Specifically #5237
2025-08-04 17:38:52 -04:00
Ed Hennis
fc929ab984 Add support for "index":"fixed type" lookups in ledger_entry
- For example "index":"amendments" will return the amendments object as
  if the request was
  "index":"7DB0788C020F02780A673DC74757F23823FA3014C1866E72CC4CD8B226CD6EF4"
- Works for amendments, fee, nunl, and hashes (for the recent history
  list only).
- Always returns the valid computed index, even if the object is not
  found.
2025-08-04 17:23:45 -04:00
Ed Hennis
145a8817dc Add ledger_entry options for fee, amendments, NUNL, and hashes
- Request format for fee, amendments, and nunl is
  "fieldName":<any valid json>, including null. Because these types
  have no inputs to the index computation, any value
  works.
- Request format for hashes is "hashes":<uint value or any valid
  json>. If the value is numeric, and evaluates to a uint, return the
  hashes history page for that ledger sequence. (AKA "long" skip list.)
  Any other valid json value will return the "short" skip list.
2025-08-04 17:23:43 -04:00
15 changed files with 589 additions and 617 deletions

View File

@@ -21,10 +21,6 @@ inputs:
description: "The logging verbosity." description: "The logging verbosity."
required: false required: false
default: "verbose" default: "verbose"
sanitizers:
description: "The sanitizers to enable ('None', 'Address', 'Thread')."
required: false
default: "None"
runs: runs:
using: composite using: composite
@@ -37,13 +33,11 @@ runs:
BUILD_OPTION: ${{ inputs.force_build == 'true' && '*' || 'missing' }} BUILD_OPTION: ${{ inputs.force_build == 'true' && '*' || 'missing' }}
BUILD_TYPE: ${{ inputs.build_type }} BUILD_TYPE: ${{ inputs.build_type }}
LOG_VERBOSITY: ${{ inputs.log_verbosity }} LOG_VERBOSITY: ${{ inputs.log_verbosity }}
SANITIZERS: ${{ inputs.sanitizers }}
run: | run: |
echo 'Installing dependencies.' echo 'Installing dependencies.'
mkdir -p "${BUILD_DIR}" mkdir -p "${BUILD_DIR}"
cd "${BUILD_DIR}" cd "${BUILD_DIR}"
conan install \ conan install \
--profile ci \
--output-folder . \ --output-folder . \
--build="${BUILD_OPTION}" \ --build="${BUILD_OPTION}" \
--options:host='&:tests=True' \ --options:host='&:tests=True' \

View File

@@ -28,7 +28,7 @@ runs:
shell: bash shell: bash
run: | run: |
echo 'Installing profile.' echo 'Installing profile.'
conan config install conan/profiles/ -tf $(conan config home)/profiles/ conan config install conan/profiles/default -tf $(conan config home)/profiles/
echo 'Conan profile:' echo 'Conan profile:'
conan profile show conan profile show

View File

@@ -57,18 +57,18 @@ def generate_strategy_matrix(all: bool, config: Config) -> list:
if os['distro_name'] == 'debian': if os['distro_name'] == 'debian':
skip = True skip = True
if os['distro_version'] == 'bookworm': if os['distro_version'] == 'bookworm':
if f'{os["compiler_name"]}-{os["compiler_version"]}' == 'gcc-13' and build_type == 'Release' and '-Dunity=ON' in cmake_args and architecture['platform'] == 'linux/amd64': if f'{os['compiler_name']}-{os['compiler_version']}' == 'gcc-13' and build_type == 'Release' and '-Dunity=ON' in cmake_args and architecture['platform'] == 'linux/amd64':
cmake_args = f'-DUNIT_TEST_REFERENCE_FEE=500 {cmake_args}' cmake_args = f'-DUNIT_TEST_REFERENCE_FEE=500 {cmake_args}'
skip = False skip = False
if f'{os["compiler_name"]}-{os["compiler_version"]}' == 'gcc-15' and build_type == 'Debug' and '-Dunity=OFF' in cmake_args and architecture['platform'] == 'linux/amd64': if f'{os['compiler_name']}-{os['compiler_version']}' == 'gcc-15' and build_type == 'Debug' and '-Dunity=OFF' in cmake_args and architecture['platform'] == 'linux/amd64':
skip = False skip = False
if f'{os["compiler_name"]}-{os["compiler_version"]}' == 'clang-16' and build_type == 'Debug' and '-Dunity=OFF' in cmake_args and architecture['platform'] == 'linux/arm64': if f'{os['compiler_name']}-{os['compiler_version']}' == 'clang-16' and build_type == 'Debug' and '-Dunity=OFF' in cmake_args and architecture['platform'] == 'linux/arm64':
cmake_args = f'-Dvoidstar=ON {cmake_args}' cmake_args = f'-Dvoidstar=ON {cmake_args}'
skip = False skip = False
if f'{os["compiler_name"]}-{os["compiler_version"]}' == 'clang-17' and build_type == 'Release' and '-Dunity=ON' in cmake_args and architecture['platform'] == 'linux/amd64': if f'{os['compiler_name']}-{os['compiler_version']}' == 'clang-17' and build_type == 'Release' and '-Dunity=ON' in cmake_args and architecture['platform'] == 'linux/amd64':
cmake_args = f'-DUNIT_TEST_REFERENCE_FEE=1000 {cmake_args}' cmake_args = f'-DUNIT_TEST_REFERENCE_FEE=1000 {cmake_args}'
skip = False skip = False
if f'{os["compiler_name"]}-{os["compiler_version"]}' == 'clang-20' and build_type == 'Debug' and '-Dunity=ON' in cmake_args and architecture['platform'] == 'linux/amd64': if f'{os['compiler_name']}-{os['compiler_version']}' == 'clang-20' and build_type == 'Debug' and '-Dunity=ON' in cmake_args and architecture['platform'] == 'linux/amd64':
skip = False skip = False
if skip: if skip:
continue continue
@@ -79,10 +79,10 @@ def generate_strategy_matrix(all: bool, config: Config) -> list:
if os['distro_name'] == 'rhel': if os['distro_name'] == 'rhel':
skip = True skip = True
if os['distro_version'] == '9': if os['distro_version'] == '9':
if f'{os["compiler_name"]}-{os["compiler_version"]}' == 'gcc-12' and build_type == 'Debug' and '-Dunity=ON' in cmake_args and architecture['platform'] == 'linux/amd64': if f'{os['compiler_name']}-{os['compiler_version']}' == 'gcc-12' and build_type == 'Debug' and '-Dunity=ON' in cmake_args and architecture['platform'] == 'linux/amd64':
skip = False skip = False
elif os['distro_version'] == '10': elif os['distro_version'] == '10':
if f'{os["compiler_name"]}-{os["compiler_version"]}' == 'clang-any' and build_type == 'Release' and '-Dunity=OFF' in cmake_args and architecture['platform'] == 'linux/amd64': if f'{os['compiler_name']}-{os['compiler_version']}' == 'clang-any' and build_type == 'Release' and '-Dunity=OFF' in cmake_args and architecture['platform'] == 'linux/amd64':
skip = False skip = False
if skip: if skip:
continue continue
@@ -95,14 +95,14 @@ def generate_strategy_matrix(all: bool, config: Config) -> list:
if os['distro_name'] == 'ubuntu': if os['distro_name'] == 'ubuntu':
skip = True skip = True
if os['distro_version'] == 'jammy': if os['distro_version'] == 'jammy':
if f'{os["compiler_name"]}-{os["compiler_version"]}' == 'gcc-12' and build_type == 'Debug' and '-Dunity=OFF' in cmake_args and architecture['platform'] == 'linux/arm64': if f'{os['compiler_name']}-{os['compiler_version']}' == 'gcc-12' and build_type == 'Debug' and '-Dunity=OFF' in cmake_args and architecture['platform'] == 'linux/arm64':
skip = False skip = False
elif os['distro_version'] == 'noble': elif os['distro_version'] == 'noble':
if f'{os["compiler_name"]}-{os["compiler_version"]}' == 'gcc-14' and build_type == 'Release' and '-Dunity=ON' in cmake_args and architecture['platform'] == 'linux/amd64': if f'{os['compiler_name']}-{os['compiler_version']}' == 'gcc-14' and build_type == 'Release' and '-Dunity=ON' in cmake_args and architecture['platform'] == 'linux/amd64':
skip = False skip = False
if f'{os["compiler_name"]}-{os["compiler_version"]}' == 'clang-18' and build_type == 'Debug' and '-Dunity=OFF' in cmake_args and architecture['platform'] == 'linux/amd64': if f'{os['compiler_name']}-{os['compiler_version']}' == 'clang-18' and build_type == 'Debug' and '-Dunity=OFF' in cmake_args and architecture['platform'] == 'linux/amd64':
skip = False skip = False
if f'{os["compiler_name"]}-{os["compiler_version"]}' == 'clang-19' and build_type == 'Release' and '-Dunity=ON' in cmake_args and architecture['platform'] == 'linux/arm64': if f'{os['compiler_name']}-{os['compiler_version']}' == 'clang-19' and build_type == 'Release' and '-Dunity=ON' in cmake_args and architecture['platform'] == 'linux/arm64':
skip = False skip = False
if skip: if skip:
continue continue
@@ -117,9 +117,10 @@ def generate_strategy_matrix(all: bool, config: Config) -> list:
if os['distro_name'] == 'windows' and not (build_type == 'Release' and '-Dunity=ON' in cmake_args and architecture['platform'] == 'windows/amd64'): if os['distro_name'] == 'windows' and not (build_type == 'Release' and '-Dunity=ON' in cmake_args and architecture['platform'] == 'windows/amd64'):
continue continue
# Additional CMake arguments. # Additional CMake arguments.
cmake_args = f'{cmake_args} -Dtests=ON -Dwerr=ON -Dxrpld=ON' cmake_args = f'{cmake_args} -Dtests=ON -Dwerr=ON -Dxrpld=ON'
if not f'{os["compiler_name"]}-{os["compiler_version"]}' in ['gcc-12', 'clang-16']: if not f'{os['compiler_name']}-{os['compiler_version']}' in ['gcc-12', 'clang-16']:
cmake_args = f'{cmake_args} -Dwextra=ON' cmake_args = f'{cmake_args} -Dwextra=ON'
if build_type == 'Release': if build_type == 'Release':
cmake_args = f'{cmake_args} -Dassert=ON' cmake_args = f'{cmake_args} -Dassert=ON'
@@ -130,15 +131,13 @@ def generate_strategy_matrix(all: bool, config: Config) -> list:
continue continue
# We skip all clang 20+ on arm64 due to Boost build error. # We skip all clang 20+ on arm64 due to Boost build error.
if f'{os["compiler_name"]}-{os["compiler_version"]}' in ['clang-20', 'clang-21'] and architecture['platform'] == 'linux/arm64': if f'{os['compiler_name']}-{os['compiler_version']}' in ['clang-20', 'clang-21'] and architecture['platform'] == 'linux/arm64':
continue continue
cxx_flags = '-g' # Enable code coverage for Debian Bookworm using GCC 15 in Debug and no
# Enable code coverage for Debian Bookworm using GCC 14 in Debug and no
# Unity on linux/amd64 # Unity on linux/amd64
if f'{os["compiler_name"]}-{os["compiler_version"]}' == 'gcc-14' and build_type == 'Debug' and '-Dunity=OFF' in cmake_args and architecture['platform'] == 'linux/amd64': if f'{os['compiler_name']}-{os['compiler_version']}' == 'gcc-15' and build_type == 'Debug' and '-Dunity=OFF' in cmake_args and architecture['platform'] == 'linux/amd64':
cmake_args = f'-Dcoverage=ON -Dcoverage_format=xml -DCODE_COVERAGE_VERBOSE=ON -DCMAKE_C_FLAGS=-O0 {cmake_args}' cmake_args = f'-Dcoverage=ON -Dcoverage_format=xml -DCODE_COVERAGE_VERBOSE=ON -DCMAKE_C_FLAGS=-O0 -DCMAKE_CXX_FLAGS=-O0 {cmake_args}'
cxx_flags = f'-O0 {cxx_flags}'
# Generate a unique name for the configuration, e.g. macos-arm64-debug # Generate a unique name for the configuration, e.g. macos-arm64-debug
# or debian-bookworm-gcc-12-amd64-release-unity. # or debian-bookworm-gcc-12-amd64-release-unity.
@@ -149,7 +148,7 @@ def generate_strategy_matrix(all: bool, config: Config) -> list:
config_name += f'-{n}' config_name += f'-{n}'
if (n := os['compiler_version']) != '': if (n := os['compiler_version']) != '':
config_name += f'-{n}' config_name += f'-{n}'
config_name += f'-{architecture["platform"][architecture["platform"].find("/")+1:]}' config_name += f'-{architecture['platform'][architecture['platform'].find('/')+1:]}'
config_name += f'-{build_type.lower()}' config_name += f'-{build_type.lower()}'
if '-Dunity=ON' in cmake_args: if '-Dunity=ON' in cmake_args:
config_name += '-unity' config_name += '-unity'
@@ -157,106 +156,15 @@ def generate_strategy_matrix(all: bool, config: Config) -> list:
# Add the configuration to the list, with the most unique fields first, # Add the configuration to the list, with the most unique fields first,
# so that they are easier to identify in the GitHub Actions UI, as long # so that they are easier to identify in the GitHub Actions UI, as long
# names get truncated. # names get truncated.
# Add Address and Thread (both coupled with UB) sanitizers when the distro is bookworm. configurations.append({
if os['distro_version'] == 'bookworm' and f'{os["compiler_name"]}-{os["compiler_version"]}' in {'gcc-15', 'clang-20'}: 'config_name': config_name,
extra_warning_flags = '' 'cmake_args': cmake_args,
linker_relocation_flags = '' 'cmake_target': cmake_target,
linker_flags = '' 'build_only': build_only,
'build_type': build_type,
# Use large code model to avoid relocation errors with large binaries 'os': os,
# Only for x86-64 (amd64) - ARM64 doesn't support -mcmodel=large 'architecture': architecture,
if architecture['platform'] == 'linux/amd64' and os['compiler_name'] == 'gcc': })
# Add -mcmodel=large and -fPIC to both compiler AND linker flags
# This is needed because sanitizers create very large binaries
# -fPIC enables position independent code to avoid relocation range issues
# large model removes the 2GB limitation that medium model has
cxx_flags += ' -mcmodel=large -fPIC -fno-pie'
linker_relocation_flags+=' -mcmodel=large -fPIC -fno-pie'
# Create default sanitizer flags
sanitizers_flags = 'undefined,float-divide-by-zero'
if os['compiler_name'] == 'gcc':
sanitizers_flags = f'{sanitizers_flags},signed-integer-overflow'
# Suppress false positive warnings in GCC with stringop-overflow
extra_warning_flags += ' -Wno-stringop-overflow'
# Disable mold, gold and lld linkers.
# Use default linker (bfd/ld) which is more lenient with mixed code models
cmake_args += ' -Duse_mold=OFF -Duse_gold=OFF -Duse_lld=OFF'
# Add linker flags for Sanitizers
linker_flags += f' -DCMAKE_EXE_LINKER_FLAGS="{linker_relocation_flags} -fsanitize=address,{sanitizers_flags}"'
linker_flags += f' -DCMAKE_SHARED_LINKER_FLAGS="{linker_relocation_flags} -fsanitize=address,{sanitizers_flags}"'
elif os['compiler_name'] == 'clang':
sanitizers_flags = f'{sanitizers_flags},signed-integer-overflow,unsigned-integer-overflow'
linker_flags += f' -DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address,{sanitizers_flags}"'
linker_flags += f' -DCMAKE_SHARED_LINKER_FLAGS="-fsanitize=address,{sanitizers_flags}"'
# Sanitizers recommend minimum of -O1 for reasonable performance
if "-O0" in cxx_flags:
cxx_flags = cxx_flags.replace("-O0", "-O1")
else:
cxx_flags += " -O1"
# First create config for asan
cmake_args_flags = f'{cmake_args} -DCMAKE_CXX_FLAGS="-fsanitize=address,{sanitizers_flags} -fno-omit-frame-pointer {cxx_flags} {extra_warning_flags}" {linker_flags}'
# Add config with asan
configurations.append({
'config_name': config_name + "_asan",
'cmake_args': cmake_args_flags,
'cmake_target': cmake_target,
'build_only': build_only,
'build_type': build_type,
'os': os,
'architecture': architecture,
'sanitizers': 'Address'
})
linker_flags = ''
# Update configs for tsan
# gcc doesn't supports atomic_thread_fence with tsan. Suppress warnings.
# Also tsan doesn't work well with mcmode=large and bfd linker
if os['compiler_name'] == 'gcc':
extra_warning_flags += ' -Wno-tsan'
cxx_flags = cxx_flags.replace('-mcmodel=large', '-mcmodel=medium')
linker_relocation_flags = linker_relocation_flags.replace('-mcmodel=large', '-mcmodel=medium')
# Add linker flags for Sanitizers
linker_flags += f' -DCMAKE_EXE_LINKER_FLAGS="{linker_relocation_flags} -fsanitize=thread,{sanitizers_flags}"'
linker_flags += f' -DCMAKE_SHARED_LINKER_FLAGS="{linker_relocation_flags} -fsanitize=thread,{sanitizers_flags}"'
elif os['compiler_name'] == 'clang':
cxx_flags += ' -fsanitize-blacklist=$GITHUB_WORKSPACE/external/sanitizer-blacklist.txt'
linker_flags += f' -DCMAKE_EXE_LINKER_FLAGS="-fsanitize=thread,{sanitizers_flags}"'
linker_flags += f' -DCMAKE_SHARED_LINKER_FLAGS="-fsanitize=thread,{sanitizers_flags}"'
# Note: We use $GITHUB_WORKSPACE environment variable which will be expanded by the shell
# before CMake processes it. This ensures the compiler receives an absolute path.
# CMAKE_SOURCE_DIR won't work here because it's inside CMAKE_CXX_FLAGS string.
cmake_args_flags = f'{cmake_args} -DCMAKE_CXX_FLAGS="-fsanitize=thread,{sanitizers_flags} -fno-omit-frame-pointer {cxx_flags} {extra_warning_flags}" {linker_flags}'
configurations.append({
'config_name': config_name+ "_tsan",
'cmake_args': cmake_args_flags,
'cmake_target': cmake_target,
'build_only': build_only,
'build_type': build_type,
'os': os,
'architecture': architecture,
'sanitizers': 'Thread'
})
else:
if cxx_flags:
cmake_args_flags = f'{cmake_args} -DCMAKE_CXX_FLAGS={cxx_flags}'
else:
cmake_args_flags = f'{cmake_args}'
configurations.append({
'config_name': config_name,
'cmake_args': cmake_args_flags,
'cmake_target': cmake_target,
'build_only': build_only,
'build_type': build_type,
'os': os,
'architecture': architecture
})
return configurations return configurations

View File

@@ -50,12 +50,6 @@ on:
type: number type: number
default: 2 default: 2
sanitizers:
description: "The sanitizers to enable ('Address+UndefinedBehaviour' or 'Thread+UndefinedBehaviour')."
required: false
type: string
default: "None"
secrets: secrets:
CODECOV_TOKEN: CODECOV_TOKEN:
description: "The Codecov token to use for uploading coverage reports." description: "The Codecov token to use for uploading coverage reports."
@@ -74,7 +68,6 @@ jobs:
env: env:
ENABLED_VOIDSTAR: ${{ contains(inputs.cmake_args, '-Dvoidstar=ON') }} ENABLED_VOIDSTAR: ${{ contains(inputs.cmake_args, '-Dvoidstar=ON') }}
ENABLED_COVERAGE: ${{ contains(inputs.cmake_args, '-Dcoverage=ON') }} ENABLED_COVERAGE: ${{ contains(inputs.cmake_args, '-Dcoverage=ON') }}
ENABLED_SANITIZERS: ${{ contains(inputs.cmake_args, '-fsanitize') }}
steps: steps:
- name: Cleanup workspace (macOS and Windows) - name: Cleanup workspace (macOS and Windows)
if: ${{ runner.os == 'macOS' || runner.os == 'Windows' }} if: ${{ runner.os == 'macOS' || runner.os == 'Windows' }}
@@ -109,18 +102,19 @@ jobs:
# Set the verbosity to "quiet" for Windows to avoid an excessive # Set the verbosity to "quiet" for Windows to avoid an excessive
# amount of logs. For other OSes, the "verbose" logs are more useful. # amount of logs. For other OSes, the "verbose" logs are more useful.
log_verbosity: ${{ runner.os == 'Windows' && 'quiet' || 'verbose' }} log_verbosity: ${{ runner.os == 'Windows' && 'quiet' || 'verbose' }}
sanitizers: ${{ inputs.sanitizers }}
- name: Configure CMake - name: Configure CMake
working-directory: ${{ inputs.build_dir }} working-directory: ${{ inputs.build_dir }}
env: env:
BUILD_TYPE: ${{ inputs.build_type }} BUILD_TYPE: ${{ inputs.build_type }}
CMAKE_ARGS: ${{ inputs.cmake_args }}
run: | run: |
cmake .. \ cmake \
-G '${{ runner.os == 'Windows' && 'Visual Studio 17 2022' || 'Ninja' }}' \ -G '${{ runner.os == 'Windows' && 'Visual Studio 17 2022' || '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}" \
${{ inputs.cmake_args }} ${CMAKE_ARGS} \
..
- name: Build the binary - name: Build the binary
working-directory: ${{ inputs.build_dir }} working-directory: ${{ inputs.build_dir }}
@@ -147,7 +141,7 @@ jobs:
if-no-files-found: error if-no-files-found: error
- name: Check linking (Linux) - name: Check linking (Linux)
if: ${{ runner.os == 'Linux' && env.ENABLED_SANITIZERS == 'false' }} if: ${{ runner.os == 'Linux' }}
working-directory: ${{ inputs.build_dir }} working-directory: ${{ inputs.build_dir }}
run: | run: |
ldd ./rippled ldd ./rippled
@@ -172,10 +166,6 @@ jobs:
BUILD_TYPE: ${{ inputs.build_type }} BUILD_TYPE: ${{ inputs.build_type }}
PARALLELISM: ${{ runner.os == 'Windows' && '1' || steps.nproc.outputs.nproc }} PARALLELISM: ${{ runner.os == 'Windows' && '1' || steps.nproc.outputs.nproc }}
run: | run: |
export ASAN_OPTIONS="suppressions=$GITHUB_WORKSPACE/external/asan.supp"
export TSAN_OPTIONS="second_deadlock_stack=1 halt_on_error=0 suppressions=$GITHUB_WORKSPACE/external/tsan.supp"
export UBSAN_OPTIONS="suppressions=$GITHUB_WORKSPACE/external/ubsan.supp"
export LSAN_OPTIONS="suppressions=$GITHUB_WORKSPACE/external/lsan.supp"
ctest \ ctest \
--output-on-failure \ --output-on-failure \
-C "${BUILD_TYPE}" \ -C "${BUILD_TYPE}" \
@@ -187,10 +177,6 @@ jobs:
env: env:
BUILD_NPROC: ${{ steps.nproc.outputs.nproc }} BUILD_NPROC: ${{ steps.nproc.outputs.nproc }}
run: | run: |
export ASAN_OPTIONS="suppressions=$GITHUB_WORKSPACE/external/asan.supp"
export TSAN_OPTIONS="second_deadlock_stack=1 halt_on_error=0 suppressions=$GITHUB_WORKSPACE/external/tsan.supp"
export UBSAN_OPTIONS="suppressions=$GITHUB_WORKSPACE/external/ubsan.supp"
export LSAN_OPTIONS="suppressions=$GITHUB_WORKSPACE/external/lsan.supp"
./rippled --unittest --unittest-jobs "${BUILD_NPROC}" ./rippled --unittest --unittest-jobs "${BUILD_NPROC}"
- name: Debug failure (Linux) - name: Debug failure (Linux)

View File

@@ -54,6 +54,5 @@ jobs:
runs_on: ${{ toJSON(matrix.architecture.runner) }} runs_on: ${{ toJSON(matrix.architecture.runner) }}
image: ${{ contains(matrix.architecture.platform, 'linux') && format('ghcr.io/xrplf/ci/{0}-{1}:{2}-{3}-sha-{4}', matrix.os.distro_name, matrix.os.distro_version, matrix.os.compiler_name, matrix.os.compiler_version, matrix.os.image_sha) || '' }} image: ${{ contains(matrix.architecture.platform, 'linux') && format('ghcr.io/xrplf/ci/{0}-{1}:{2}-{3}-sha-{4}', matrix.os.distro_name, matrix.os.distro_version, matrix.os.compiler_name, matrix.os.compiler_version, matrix.os.image_sha) || '' }}
config_name: ${{ matrix.config_name }} config_name: ${{ matrix.config_name }}
sanitizers: ${{ matrix.sanitizers }}
secrets: secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@@ -360,16 +360,6 @@ tools.build:cxxflags=['-DBOOST_ASIO_DISABLE_CONCEPTS']
conan install .. --output-folder . --build missing --settings build_type=Debug conan install .. --output-folder . --build missing --settings build_type=Debug
``` ```
If you would like to activate `asan+ubsan`(`Address`) or `tsan+ubsan`(`Thread`) for the build,
declare an env. variable as follows and simply use the `sanitizers`
profile in the `conan install` command.
```
SANITIZERS=Address conan install .. --output-folder . --profile sanitizers --build missing --settings build_type=Debug
```
Available options for SANITIZERS: `Address` and `Thread`
To build Debug, in the next step, be sure to set `-DCMAKE_BUILD_TYPE=Debug` To build Debug, in the next step, be sure to set `-DCMAKE_BUILD_TYPE=Debug`
For a single-configuration generator, e.g. `Unix Makefiles` or `Ninja`, For a single-configuration generator, e.g. `Unix Makefiles` or `Ninja`,

View File

@@ -1 +0,0 @@
include(./sanitizers)

View File

@@ -1,50 +0,0 @@
include(./default)
{% set compiler, version, compiler_exe = detect_api.detect_default_compiler() %}
{% set default_sanitizer_flags = "undefined,float-divide-by-zero,signed-integer-overflow" %}
{% set sanitizers = os.getenv("SANITIZERS") %}
[settings]
{% if sanitizers == "Address" or sanitizers == "Thread" %}
user.package:sanitizers={{ sanitizers }}
tools.info.package_ids:confs+=["user.package:sanitizers"]
{% endif %}
[conf]
{% if compiler == "gcc" %}
{% set asan_sanitizer_flags = "-fsanitize=address,"~default_sanitizer_flags~" -mcmodel=large -fPIC" %}
{% set tsan_sanitizer_flags = "-fsanitize=thread,"~default_sanitizer_flags~" -mcmodel=medium -fPIC" %}
{% if sanitizers == "Address" %}
tools.build:cxxflags+=['{{asan_sanitizer_flags}} -fno-omit-frame-pointer -O1 -Wno-stringop-overflow']
tools.build:sharedlinkflags+=['{{asan_sanitizer_flags}}']
tools.build:exelinkflags+=['{{asan_sanitizer_flags}}']
tools.cmake.cmaketoolchain:extra_variables={"use_mold": "OFF", "use_gold": "OFF", "use_lld": "OFF"}
{% elif sanitizers == "Thread" %}
tools.build:cxxflags+=['{{tsan_sanitizer_flags}} -fno-omit-frame-pointer -O1 -Wno-stringop-overflow -Wno-tsan']
tools.build:sharedlinkflags+=['{{tsan_sanitizer_flags}}']
tools.build:exelinkflags+=['{{tsan_sanitizer_flags}}']
{% endif %}
{% elif compiler == "apple-clang" or compiler == "clang" %}
{% set asan_sanitizer_flags = "-fsanitize=address,"~default_sanitizer_flags~",unsigned-integer-overflow -fPIC" %}
{% set tsan_sanitizer_flags = "-fsanitize=thread,"~default_sanitizer_flags~",unsigned-integer-overflow -fPIC" %}
{% if sanitizers == "Address" %}
tools.build:cxxflags+=['{{asan_sanitizer_flags}} -fno-omit-frame-pointer -O1']
tools.build:sharedlinkflags+=['{{asan_sanitizer_flags}}']
tools.build:exelinkflags+=['{{asan_sanitizer_flags}}']
{% elif sanitizers == "Thread" %}
tools.build:cxxflags+=['{{tsan_sanitizer_flags}} -fno-omit-frame-pointer -O1']
tools.build:sharedlinkflags+=['{{tsan_sanitizer_flags}}']
tools.build:exelinkflags+=['{{tsan_sanitizer_flags}}']
{% endif %}
{% endif %}

16
external/asan.supp vendored
View File

@@ -1,16 +0,0 @@
# Suppress voilations in Boost libraries
interceptor_via_lib:^libboost_.*
# Suprpress voilations in external code
interceptor_name:^external/.*
# Boost
interceptor_name:.*/boost/asio/.*
# Leaks in Doctests
interceptor_name:.*/src/libxrpl/net/HTTPClient.cpp
interceptor_name:.*/src/libxrpl/net/RegisterSSLCerts.cpp
interceptor_name:.*/src/tests/libxrpl/net/HTTPClient.cpp
interceptor_name:.*/xrpl/net/AutoSocket.h
interceptor_name:.*/xrpl/net/HTTPClient.h
interceptor_name:.*/xrpl/net/HTTPClientSSLContext.h
interceptor_name:.*/xrpl/net/RegisterSSLCerts.h

12
external/lsan.supp vendored
View File

@@ -1,12 +0,0 @@
leak:.*/src/libxrpl/net/HTTPClient.cpp
leak:.*/src/libxrpl/net/RegisterSSLCerts.cpp
leak:.*/src/tests/libxrpl/net/HTTPClient.cpp
leak:.*/xrpl/net/AutoSocket.h
leak:.*/xrpl/net/HTTPClient.h
leak:.*/xrpl/net/HTTPClientSSLContext.h
leak:.*/xrpl/net/RegisterSSLCerts.h
leak:ripple::HTTPClient
leak:ripple::HTTPClientImp
leak:.*boost::asio::.*
leak:.*/boost/asio/.*

View File

@@ -1,26 +0,0 @@
[thread]
signal:libxrpl/beast/utility/beast_Journal.cpp
signal:libxrpl/beast/utility/beast_PropertyStream.cpp
signal:test/beast/beast_PropertyStream_test.cpp
signal:libxrpl/beast/utility/beast_Journal.cpp
signal:xrpld/core/detail/Workers.cpp
signal:xrpld/core/JobQueue.cpp
race:libxrpl/beast/utility/beast_Journal.cpp
race:libxrpl/beast/utility/beast_PropertyStream.cpp
race:test/beast/beast_PropertyStream_test.cpp
race:libxrpl/beast/utility/beast_Journal.cpp
race:xrpld/core/detail/Workers.cpp
race:xrpld/core/JobQueue.cpp
deadlock:libxrpl/beast/utility/beast_Journal.cpp
deadlock:libxrpl/beast/utility/beast_PropertyStream.cpp
deadlock:test/beast/beast_PropertyStream_test.cpp
deadlock:libxrpl/beast/utility/beast_Journal.cpp
deadlock:xrpld/core/detail/Workers.cpp
deadlock:xrpld/core/JobQueue.cpp
[tsan]
src:beast/utility/beast_Journal.cpp
src:beast/utility/beast_PropertyStream.cpp
src:test/beast/beast_PropertyStream_test.cpp
src:core/detail/Workers.cpp
src:core/JobQueue.cpp

112
external/tsan.supp vendored
View File

@@ -1,112 +0,0 @@
# Suppress race in Boost ASIO scheduler detected by GCC-15
# This is a false positive in Boost's internal pipe() synchronization
race:boost/asio/
race:boost/context/
race:boost/asio/executor.hpp
race:boost::asio
race:src/libxrpl/basics/make_SSLContext.cpp
race:src/libxrpl/basics/Number.cpp
race:src/libxrpl/json/json_value.cpp
race:src/libxrpl/json/to_string.cpp
race:src/libxrpl/ledger/OpenView.cpp
race:src/libxrpl/net/HTTPClient.cpp
race:src/libxrpl/nodestore/backend/NuDBFactory.cpp
race:src/libxrpl/protocol/InnerObjectFormats.cpp
race:src/libxrpl/protocol/STParsedJSON.cpp
race:src/libxrpl/resource/ResourceManager.cpp
race:src/test/app/Flow_test.cpp
race:src/test/app/LedgerReplay_test.cpp
race:src/test/app/NFToken_test.cpp
race:src/test/app/Offer_test.cpp
race:src/test/app/ValidatorSite_test.cpp
race:src/test/consensus/NegativeUNL_test.cpp
race:src/test/jtx/impl/Env.cpp
race:src/test/jtx/impl/JSONRPCClient.cpp
race:src/test/jtx/impl/pay.cpp
race:src/test/jtx/impl/token.cpp
race:src/test/rpc/Book_test.cpp
race:src/xrpld/app/ledger/detail/InboundTransactions.cpp
race:src/xrpld/app/main/Application.cpp
race:src/xrpld/app/main/BasicApp.cpp
race:src/xrpld/app/main/GRPCServer.cpp
race:src/xrpld/app/misc/detail/AmendmentTable.cpp
race:src/xrpld/app/misc/FeeVoteImpl.cpp
race:src/xrpld/app/rdb/detail/Wallet.cpp
race:src/xrpld/overlay/detail/OverlayImpl.cpp
race:src/xrpld/peerfinder/detail/PeerfinderManager.cpp
race:src/xrpld/peerfinder/detail/SourceStrings.cpp
race:src/xrpld/rpc/detail/ServerHandler.cpp
race:xrpl/server/detail/Door.h
race:xrpl/server/detail/Spawn.h
race:xrpl/server/detail/ServerImpl.h
race:xrpl/nodestore/detail/DatabaseNodeImp.h
race:src/libxrpl/beast/utility/beast_Journal.cpp
race:src/test/beast/LexicalCast_test.cpp
race:crtstuff.c
race:pipe
race:ripple::ServerHandler
# Deadlock / lock-order-inversion suppressions
# Note: GCC's TSAN may not fully support all deadlock suppression patterns
deadlock:src/libxrpl/beast/utility/beast_Journal.cpp
deadlock:src/libxrpl/beast/utility/beast_PropertyStream.cpp
deadlock:src/test/beast/beast_PropertyStream_test.cpp
deadlock:src/xrpld/core/detail/Workers.cpp
# Suppress lock-order-inversion in recursive_mutex operations
deadlock:std::recursive_mutex::lock
deadlock:__gthread_recursive_mutex_lock
deadlock:pthread_mutex_lock
# Aggressive suppressing of deadlock tsan errors
deadlock:pthread_create
deadlock:pthread_rwlock_rdlock
deadlock:boost::asio
deadlock:src/xrpld/app/misc/detail/Manifest.cpp
deadlock:src/xrpld/app/misc/detail/ValidatorList.cpp
deadlock:src/xrpld/app/misc/detail/ValidatorSite.cpp
signal:src/libxrpl/beast/utility/beast_Journal.cpp
signal:src/xrpld/core/detail/Workers.cpp
signal:src/xrpld/core/JobQueue.cpp
signal:ripple::Workers::Worker
# Suppress SEGV crashes in TSAN itself during stringbuf operations
# This appears to be a GCC-15 TSAN instrumentation issue with basic_stringbuf::str()
# Commonly triggered in beast::Journal::ScopedStream destructor
signal:std::__cxx11::basic_stringbuf
signal:basic_stringbuf
signal:basic_ostringstream
called_from_lib:libclang_rt
race:ostreambuf_iterator
race:basic_ostream
#called_from_lib:libc++.1.dylib
#called_from_lib:libc++.abi.dylib
# Suppress SEGV in TSAN during operator new called from stringbuf
signal:operator new
# Suppress SEGV in Boost ASIO memory allocation with GCC-15 TSAN
signal:boost::asio::aligned_new
signal:boost::asio::detail::memory
# Suppress SEGV in execute_native_thread_routine
signal:execute_native_thread_routine
# Suppress nested TSAN bugs (TSAN crashing while handling a crash)
signal:nested bug in the same thread
# Suppress data race in Boost Context fiber management
# This is a false positive in Boost's exception state management during fiber context switching
race:__cxxabiv1::manage_exception_state
race:boost::context::fiber::resume
race:boost::asio::detail::spawned_fiber_thread
race:boost::asio::detail::spawned_fiber_thread::suspend_with
race:boost::asio::detail::spawned_fiber_thread::destroy
# Suppress data race in __tsan_memcpy called from Boost fiber operations
race:__tsan_memcpy

167
external/ubsan.supp vendored
View File

@@ -1,167 +0,0 @@
# Suppress UBSan errors in external code by source file path
# This matches any source file under the external/ directory
alignment:external
bool:external
bounds:external
cfi:external
enum:external
float-cast-overflow:external
float-divide-by-zero:external
function:external
implicit-integer-sign-change:external
implicit-signed-integer-truncation::external
implicit-signed-integer-truncation:external
implicit-unsigned-integer-truncation:external
integer-divide-by-zero:external
invalid-builtin-use:external
invalid-objc-cast:external
nonnull-attribute:external
null:external
nullability-arg:external
nullability-assign:external
nullability-return:external
object-size:external
pointer-overflow:external
return:external
returns-nonnull-attribute:external
shift-base:external
shift-exponent:external
signed-integer-overflow:external
undefined:external
unreachable:external
unsigned-integer-overflow:external
vla-bound:external
vptr_check:external
vptr:external
# Suppress all UBSan errors in Boost libraries
# This matches any files containing "boost" in its path or name
alignment:boost
bool:boost
bounds:boost
cfi:boost
enum:boost
float-cast-overflow:boost
float-divide-by-zero:boost
function:boost
implicit-integer-sign-change:boost
implicit-signed-integer-truncation:boost
implicit-unsigned-integer-truncation:boost
integer-divide-by-zero:boost
invalid-builtin-use:boost
invalid-objc-cast:boost
nonnull-attribute:boost
null:boost
nullability-arg:boost
nullability-assign:boost
nullability-return:boost
object-size:boost
pointer-overflow:boost
return:boost
returns-nonnull-attribute:boost
shift-base:boost
shift-exponent:boost
signed-integer-overflow:boost
undefined:boost
unreachable:boost
unsigned-integer-overflow:boost
vla-bound:boost
vptr_check:boost
vptr:boost
undefined:src/libxrpl/basics/base64.cpp
undefined:src/libxrpl/basics/Number.cpp
undefined:src/libxrpl/beast/utility/beast_Journal.cpp
undefined:src/libxrpl/crypto/RFC1751.cpp
undefined:src/libxrpl/ledger/ApplyView.cpp
undefined:src/libxrpl/ledger/View.cpp
undefined:src/libxrpl/protocol/Permissions.cpp
undefined:src/libxrpl/protocol/STAmount.cpp
undefined:src/libxrpl/protocol/STPathSet.cpp
undefined:src/libxrpl/protocol/tokens.cpp
undefined:src/libxrpl/shamap/SHAMap.cpp
undefined:src/test/app/Batch_test.cpp
undefined:src/test/app/Invariants_test.cpp
undefined:src/test/app/NFToken_test.cpp
undefined:src/test/app/Offer_test.cpp
undefined:src/test/app/Path_test.cpp
undefined:src/test/basics/XRPAmount_test.cpp
undefined:src/test/beast/LexicalCast_test.cpp
undefined:src/test/jtx/impl/acctdelete.cpp
undefined:src/test/ledger/SkipList_test.cpp
undefined:src/test/rpc/Subscribe_test.cpp
undefined:src/tests/libxrpl/basics/RangeSet.cpp
undefined:src/xrpld/app/main/BasicApp.cpp
undefined:src/xrpld/app/main/BasicApp.cpp
undefined:src/xrpld/app/misc/detail/AmendmentTable.cpp
undefined:src/xrpld/app/misc/NetworkOPs.cpp
undefined:src/libxrpl/json/json_value.cpp
undefined:src/xrpld/app/paths/detail/StrandFlow.h
undefined:src/xrpld/app/tx/detail/NFTokenMint.cpp
undefined:src/xrpld/app/tx/detail/SetOracle.cpp
undefined:src/xrpld/core/detail/JobQueue.cpp
undefined:src/xrpld/core/detail/Workers.cpp
undefined:src/xrpld/rpc/detail/Role.cpp
undefined:src/xrpld/rpc/handlers/GetAggregatePrice.cpp
undefined:xrpl/basics/base_uint.h
undefined:xrpl/basics/DecayingSample.h
undefined:xrpl/beast/test/yield_to.h
undefined:xrpl/beast/xor_shift_engine.h
undefined:xrpl/nodestore/detail/varint.h
undefined:xrpl/peerfinder/detail/Counts.h
undefined:xrpl/protocol/nft.h
# basic_string.h:483:51: runtime error: unsigned integer overflow
unsigned-integer-overflow:basic_string.h
unsigned-integer-overflow:bits/chrono.h
unsigned-integer-overflow:bits/random.h
unsigned-integer-overflow:bits/random.tcc
unsigned-integer-overflow:bits/stl_algobase.h
unsigned-integer-overflow:bits/uniform_int_dist.h
unsigned-integer-overflow:string_view
# runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'std::size_t' (aka 'unsigned long')
unsigned-integer-overflow:src/libxrpl/basics/base64.cpp
unsigned-integer-overflow:src/libxrpl/basics/Number.cpp
unsigned-integer-overflow:src/libxrpl/crypto/RFC1751.cpp
unsigned-integer-overflow:rc/libxrpl/json/json_value.cpp
unsigned-integer-overflow:src/libxrpl/ledger/ApplyView.cpp
unsigned-integer-overflow:src/libxrpl/ledger/View.cpp
unsigned-integer-overflow:src/libxrpl/protocol/Permissions.cpp
unsigned-integer-overflow:src/libxrpl/protocol/STAmount.cpp
unsigned-integer-overflow:src/libxrpl/protocol/STPathSet.cpp
unsigned-integer-overflow:src/libxrpl/protocol/tokens.cpp
unsigned-integer-overflow:src/libxrpl/shamap/SHAMap.cpp
unsigned-integer-overflow:src/test/app/Batch_test.cpp
unsigned-integer-overflow:src/test/app/Invariants_test.cpp
unsigned-integer-overflow:src/test/app/NFToken_test.cpp
unsigned-integer-overflow:src/test/app/Offer_test.cpp
unsigned-integer-overflow:src/test/app/Path_test.cpp
unsigned-integer-overflow:src/test/basics/XRPAmount_test.cpp
unsigned-integer-overflow:src/test/beast/LexicalCast_test.cpp
unsigned-integer-overflow:src/test/jtx/impl/acctdelete.cpp
unsigned-integer-overflow:src/test/ledger/SkipList_test.cpp
unsigned-integer-overflow:src/test/rpc/Subscribe_test.cpp
unsigned-integer-overflow:src/tests/libxrpl/basics/RangeSet.cpp
unsigned-integer-overflow:src/xrpld/app/main/BasicApp.cpp
unsigned-integer-overflow:src/xrpld/app/misc/detail/AmendmentTable.cpp
unsigned-integer-overflow:src/xrpld/app/misc/NetworkOPs.cpp
unsigned-integer-overflow:src/xrpld/app/paths/detail/StrandFlow.h
unsigned-integer-overflow:src/xrpld/app/tx/detail/NFTokenMint.cpp
unsigned-integer-overflow:src/xrpld/app/tx/detail/SetOracle.cpp
unsigned-integer-overflow:src/xrpld/rpc/detail/Role.cpp
unsigned-integer-overflow:src/xrpld/rpc/handlers/GetAggregatePrice.cpp
unsigned-integer-overflow:xrpl/basics/base_uint.h
unsigned-integer-overflow:xrpl/basics/DecayingSample.h
unsigned-integer-overflow:xrpl/beast/test/yield_to.h
unsigned-integer-overflow:xrpl/beast/xor_shift_engine.h
unsigned-integer-overflow:xrpl/nodestore/detail/varint.h
unsigned-integer-overflow:xrpl/peerfinder/detail/Counts.h
unsigned-integer-overflow:xrpl/protocol/nft.h
# Signed integer overflow suppressions
signed-integer-overflow:src/test/beast/LexicalCast_test.cpp
# External library suppressions
unsigned-integer-overflow:nudb/detail/xxhash.hpp

View File

@@ -5,6 +5,8 @@
#include <test/jtx/multisign.h> #include <test/jtx/multisign.h>
#include <test/jtx/xchain_bridge.h> #include <test/jtx/xchain_bridge.h>
#include <xrpld/app/tx/apply.h>
#include <xrpl/beast/unit_test.h> #include <xrpl/beast/unit_test.h>
#include <xrpl/json/json_value.h> #include <xrpl/json/json_value.h>
#include <xrpl/protocol/AccountID.h> #include <xrpl/protocol/AccountID.h>
@@ -1103,7 +1105,7 @@ class LedgerEntry_test : public beast::unit_test::suite
checkErrorValue( checkErrorValue(
jrr[jss::result], jrr[jss::result],
"malformedAuthorizedCredentials", "malformedAuthorizedCredentials",
"Invalid field 'authorized_credentials', array empty."); "Invalid field 'authorized_credentials', not array.");
} }
{ {
@@ -1144,7 +1146,7 @@ class LedgerEntry_test : public beast::unit_test::suite
checkErrorValue( checkErrorValue(
jrr[jss::result], jrr[jss::result],
"malformedAuthorizedCredentials", "malformedAuthorizedCredentials",
"Invalid field 'authorized_credentials', array too long."); "Invalid field 'authorized_credentials', not array.");
} }
} }
@@ -2008,6 +2010,370 @@ class LedgerEntry_test : public beast::unit_test::suite
} }
} }
/// Test the ledger entry types that don't take parameters
void
testLedgerEntryFixed()
{
using namespace test::jtx;
Account const alice{"alice"};
Account const bob{"bob"};
Env env{*this, envconfig([](auto cfg) {
cfg->START_UP = Config::FRESH;
return cfg;
})};
env.close();
/** Verifies that the RPC result has the expected data
*
* @param good: Indicates that the request should have succeeded
* and returned a ledger object of `expectedType` type.
* @param jv: The RPC result Json value
* @param expectedType: The type that the ledger object should
* have if "good".
* @param expectedError: Optional. The expected error if not
* good. Defaults to "entryNotFound".
*/
auto checkResult =
[&](bool good,
Json::Value const& jv,
Json::StaticString const& expectedType,
std::optional<std::string> const& expectedError = {}) {
if (good)
{
BEAST_EXPECTS(
jv.isObject() && jv.isMember(jss::result) &&
!jv[jss::result].isMember(jss::error) &&
jv[jss::result].isMember(jss::node) &&
jv[jss::result][jss::node].isMember(
sfLedgerEntryType.jsonName) &&
jv[jss::result][jss::node]
[sfLedgerEntryType.jsonName] == expectedType,
to_string(jv));
}
else
{
BEAST_EXPECTS(
jv.isObject() && jv.isMember(jss::result) &&
jv[jss::result].isMember(jss::error) &&
!jv[jss::result].isMember(jss::node) &&
jv[jss::result][jss::error] ==
expectedError.value_or("entryNotFound"),
to_string(jv));
}
};
/** Runs a series of tests for a given fixed-position ledger
* entry.
*
* @param field: The Json request field to use.
* @param expectedType: The type that the ledger object should
* have if "good".
* @param expectedKey: The keylet of the fixed object.
* @param good: Indicates whether the object is expected to
* exist.
*/
auto test = [&](Json::StaticString const& field,
Json::StaticString const& expectedType,
Keylet const& expectedKey,
bool good) {
testcase << "ledger_entry " << expectedType.c_str()
<< (good ? "" : " not") << " found";
auto const hexKey = strHex(expectedKey.key);
// Test bad values
// "field":null
Json::Value params;
params[jss::ledger_index] = jss::validated;
params[field] = Json::nullValue;
auto jv = env.rpc("json", "ledger_entry", to_string(params));
checkResult(false, jv, expectedType, "malformedRequest");
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
// "field":"string"
params.clear();
params[jss::ledger_index] = jss::validated;
params[field] = "arbitrary string";
jv = env.rpc("json", "ledger_entry", to_string(params));
checkResult(false, jv, expectedType, "malformedRequest");
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
// "field":false
params.clear();
params[jss::ledger_index] = jss::validated;
params[field] = false;
jv = env.rpc("json", "ledger_entry", to_string(params));
checkResult(false, jv, expectedType, "invalidParams");
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
{
// "field":[incorrect index hash]
auto const badKey = strHex(expectedKey.key + uint256{1});
params.clear();
params[jss::ledger_index] = jss::validated;
params[field] = badKey;
jv = env.rpc("json", "ledger_entry", to_string(params));
checkResult(false, jv, expectedType, "entryNotFound");
BEAST_EXPECTS(
jv[jss::result][jss::index] == badKey, to_string(jv));
}
// "index":"field" using API 2
params.clear();
params[jss::ledger_index] = jss::validated;
params[jss::index] = field;
params[jss::api_version] = 2;
jv = env.rpc("json", "ledger_entry", to_string(params));
checkResult(false, jv, expectedType, "malformedRequest");
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
// Test good values
// Use the "field":true notation
params.clear();
params[jss::ledger_index] = jss::validated;
params[field] = true;
jv = env.rpc("json", "ledger_entry", to_string(params));
// Index will always be returned for valid parameters.
std::string const pdIdx = jv[jss::result][jss::index].asString();
BEAST_EXPECTS(hexKey == pdIdx, to_string(jv));
checkResult(good, jv, expectedType);
// "field":"[index hash]"
params.clear();
params[jss::ledger_index] = jss::validated;
params[field] = hexKey;
jv = env.rpc("json", "ledger_entry", to_string(params));
checkResult(good, jv, expectedType);
BEAST_EXPECT(jv[jss::result][jss::index].asString() == hexKey);
// Use the "index":"field" notation with API 3
params.clear();
params[jss::ledger_index] = jss::validated;
params[jss::index] = field;
params[jss::api_version] = 3;
jv = env.rpc("json", "ledger_entry", to_string(params));
// Index is correct either way
BEAST_EXPECT(jv[jss::result][jss::index].asString() == hexKey);
checkResult(good, jv, expectedType);
// Use the "index":"[index hash]" notation
params.clear();
params[jss::ledger_index] = jss::validated;
params[jss::index] = pdIdx;
jv = env.rpc("json", "ledger_entry", to_string(params));
// Index is correct either way
BEAST_EXPECT(jv[jss::result][jss::index].asString() == hexKey);
checkResult(good, jv, expectedType);
};
test(jss::amendments, jss::Amendments, keylet::amendments(), true);
test(jss::fee, jss::FeeSettings, keylet::fees(), true);
// There won't be an nunl
test(jss::nunl, jss::NegativeUNL, keylet::negativeUNL(), false);
// Can only get the short skip list this way
test(jss::hashes, jss::LedgerHashes, keylet::skip(), true);
}
void
testLedgerEntryHashes()
{
using namespace test::jtx;
Account const alice{"alice"};
Account const bob{"bob"};
Env env{*this, envconfig([](auto cfg) {
cfg->START_UP = Config::FRESH;
return cfg;
})};
env.close();
/** Verifies that the RPC result has the expected data
*
* @param good: Indicates that the request should have succeeded
* and returned a ledger object of `expectedType` type.
* @param jv: The RPC result Json value
* @param expectedCount: The number of Hashes expected in the
* object if "good".
* @param expectedError: Optional. The expected error if not
* good. Defaults to "entryNotFound".
*/
auto checkResult =
[&](bool good,
Json::Value const& jv,
int expectedCount,
std::optional<std::string> const& expectedError = {}) {
if (good)
{
BEAST_EXPECTS(
jv.isObject() && jv.isMember(jss::result) &&
!jv[jss::result].isMember(jss::error) &&
jv[jss::result].isMember(jss::node) &&
jv[jss::result][jss::node].isMember(
sfLedgerEntryType.jsonName) &&
jv[jss::result][jss::node]
[sfLedgerEntryType.jsonName] == jss::LedgerHashes,
to_string(jv));
BEAST_EXPECTS(
jv[jss::result].isMember(jss::node) &&
jv[jss::result][jss::node].isMember("Hashes") &&
jv[jss::result][jss::node]["Hashes"].size() ==
expectedCount,
to_string(jv[jss::result][jss::node]["Hashes"].size()));
}
else
{
BEAST_EXPECTS(
jv.isObject() && jv.isMember(jss::result) &&
jv[jss::result].isMember(jss::error) &&
!jv[jss::result].isMember(jss::node) &&
jv[jss::result][jss::error] ==
expectedError.value_or("entryNotFound"),
to_string(jv));
}
};
/** Runs a series of tests for a given ledger index.
*
* @param ledger: The ledger index value of the "hashes" request
* parameter. May not necessarily be a number.
* @param expectedKey: The expected keylet of the object.
* @param good: Indicates whether the object is expected to
* exist.
* @param expectedCount: The number of Hashes expected in the
* object if "good".
*/
auto test = [&](Json::Value ledger,
Keylet const& expectedKey,
bool good,
int expectedCount = 0) {
testcase << "ledger_entry LedgerHashes: seq: "
<< env.current()->info().seq
<< " \"hashes\":" << to_string(ledger)
<< (good ? "" : " not") << " found";
auto const hexKey = strHex(expectedKey.key);
// Test bad values
// "hashes":null
Json::Value params;
params[jss::ledger_index] = jss::validated;
params[jss::hashes] = Json::nullValue;
auto jv = env.rpc("json", "ledger_entry", to_string(params));
checkResult(false, jv, 0, "malformedRequest");
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
// "hashes":"non-uint string"
params.clear();
params[jss::ledger_index] = jss::validated;
params[jss::hashes] = "arbitrary string";
jv = env.rpc("json", "ledger_entry", to_string(params));
checkResult(false, jv, 0, "malformedRequest");
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
// "hashes":"uint string" is invalid, too
params.clear();
params[jss::ledger_index] = jss::validated;
params[jss::hashes] = "10";
jv = env.rpc("json", "ledger_entry", to_string(params));
checkResult(false, jv, 0, "malformedRequest");
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
// "hashes":false
params.clear();
params[jss::ledger_index] = jss::validated;
params[jss::hashes] = false;
jv = env.rpc("json", "ledger_entry", to_string(params));
checkResult(false, jv, 0, "invalidParams");
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
// "hashes":-1
params.clear();
params[jss::ledger_index] = jss::validated;
params[jss::hashes] = -1;
jv = env.rpc("json", "ledger_entry", to_string(params));
checkResult(false, jv, 0, "internal");
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
// "hashes":[incorrect index hash]
{
auto const badKey = strHex(expectedKey.key + uint256{1});
params.clear();
params[jss::ledger_index] = jss::validated;
params[jss::hashes] = badKey;
jv = env.rpc("json", "ledger_entry", to_string(params));
checkResult(false, jv, 0, "entryNotFound");
BEAST_EXPECT(jv[jss::result][jss::index] == badKey);
}
// Test good values
// Use the "hashes":ledger notation
params.clear();
params[jss::ledger_index] = jss::validated;
params[jss::hashes] = ledger;
jv = env.rpc("json", "ledger_entry", to_string(params));
checkResult(good, jv, expectedCount);
// Index will always be returned for valid parameters.
std::string const pdIdx = jv[jss::result][jss::index].asString();
BEAST_EXPECTS(hexKey == pdIdx, strHex(pdIdx));
// "hashes":"[index hash]"
params.clear();
params[jss::ledger_index] = jss::validated;
params[jss::hashes] = hexKey;
jv = env.rpc("json", "ledger_entry", to_string(params));
checkResult(good, jv, expectedCount);
// Index is correct either way
BEAST_EXPECTS(
hexKey == jv[jss::result][jss::index].asString(),
strHex(jv[jss::result][jss::index].asString()));
// Use the "index":"[index hash]" notation
params.clear();
params[jss::ledger_index] = jss::validated;
params[jss::index] = hexKey;
jv = env.rpc("json", "ledger_entry", to_string(params));
checkResult(good, jv, expectedCount);
// Index is correct either way
BEAST_EXPECTS(
hexKey == jv[jss::result][jss::index].asString(),
strHex(jv[jss::result][jss::index].asString()));
};
// short skip list
test(true, keylet::skip(), true, 2);
// long skip list at index 0
test(1, keylet::skip(1), false);
// long skip list at index 1
test(1 << 17, keylet::skip(1 << 17), false);
// Close more ledgers, but stop short of the flag ledger
for (auto i = env.current()->seq(); i <= 250; ++i)
env.close();
// short skip list
test(true, keylet::skip(), true, 249);
// long skip list at index 0
test(1, keylet::skip(1), false);
// long skip list at index 1
test(1 << 17, keylet::skip(1 << 17), false);
// Close a flag ledger so the first "long" skip list is created
for (auto i = env.current()->seq(); i <= 260; ++i)
env.close();
// short skip list
test(true, keylet::skip(), true, 256);
// long skip list at index 0
test(1, keylet::skip(1), true, 1);
// long skip list at index 1
test(1 << 17, keylet::skip(1 << 17), false);
}
void void
testLedgerEntryCLI() testLedgerEntryCLI()
{ {
@@ -2057,6 +2423,8 @@ public:
testOracleLedgerEntry(); testOracleLedgerEntry();
testLedgerEntryMPT(); testLedgerEntryMPT();
testLedgerEntryPermissionedDomain(); testLedgerEntryPermissionedDomain();
testLedgerEntryFixed();
testLedgerEntryHashes();
testLedgerEntryCLI(); testLedgerEntryCLI();
} }
}; };

View File

@@ -16,8 +16,36 @@
#include <xrpl/protocol/STXChainBridge.h> #include <xrpl/protocol/STXChainBridge.h>
#include <xrpl/protocol/jss.h> #include <xrpl/protocol/jss.h>
#include <functional>
namespace ripple { namespace ripple {
using FunctionType = std::function<Expected<uint256, Json::Value>(
Json::Value const&,
Json::StaticString const,
unsigned apiVersion)>;
static Expected<uint256, Json::Value>
parseFixed(
Keylet const& keylet,
Json::Value const& params,
Json::StaticString const& fieldName,
unsigned apiVersion);
// Helper function to return FunctionType for objects that have a fixed
// location. That is, they don't take parameters to compute the index.
// e.g. amendments, fees, negative UNL, etc.
static FunctionType
fixed(Keylet const& keylet)
{
return [&keylet](
Json::Value const& params,
Json::StaticString const fieldName,
unsigned apiVersion) -> Expected<uint256, Json::Value> {
return parseFixed(keylet, params, fieldName, apiVersion);
};
}
static Expected<uint256, Json::Value> static Expected<uint256, Json::Value>
parseObjectID( parseObjectID(
Json::Value const& params, Json::Value const& params,
@@ -33,13 +61,33 @@ parseObjectID(
} }
static Expected<uint256, Json::Value> static Expected<uint256, Json::Value>
parseIndex(Json::Value const& params, Json::StaticString const fieldName) parseIndex(
Json::Value const& params,
Json::StaticString const fieldName,
unsigned apiVersion)
{ {
if (apiVersion > 2u && params.isString())
{
std::string const index = params.asString();
if (index == jss::amendments.c_str())
return keylet::amendments().key;
if (index == jss::fee.c_str())
return keylet::fees().key;
if (index == jss::nunl)
return keylet::negativeUNL().key;
if (index == jss::hashes)
// Note this only finds the "short" skip list. Use "hashes":index to
// get the long list.
return keylet::skip().key;
}
return parseObjectID(params, fieldName, "hex string"); return parseObjectID(params, fieldName, "hex string");
} }
static Expected<uint256, Json::Value> static Expected<uint256, Json::Value>
parseAccountRoot(Json::Value const& params, Json::StaticString const fieldName) parseAccountRoot(
Json::Value const& params,
Json::StaticString const fieldName,
unsigned apiVersion)
{ {
if (auto const account = LedgerEntryHelpers::parse<AccountID>(params)) if (auto const account = LedgerEntryHelpers::parse<AccountID>(params))
{ {
@@ -50,14 +98,13 @@ parseAccountRoot(Json::Value const& params, Json::StaticString const fieldName)
"malformedAddress", fieldName, "AccountID"); "malformedAddress", fieldName, "AccountID");
} }
static Expected<uint256, Json::Value> auto const parseAmendments = fixed(keylet::amendments());
parseAmendments(Json::Value const& params, Json::StaticString const fieldName)
{
return parseObjectID(params, fieldName, "hex string");
}
static Expected<uint256, Json::Value> static Expected<uint256, Json::Value>
parseAMM(Json::Value const& params, Json::StaticString const fieldName) parseAMM(
Json::Value const& params,
Json::StaticString const fieldName,
unsigned apiVersion)
{ {
if (!params.isObject()) if (!params.isObject())
{ {
@@ -84,7 +131,10 @@ parseAMM(Json::Value const& params, Json::StaticString const fieldName)
} }
static Expected<uint256, Json::Value> static Expected<uint256, Json::Value>
parseBridge(Json::Value const& params, Json::StaticString const fieldName) parseBridge(
Json::Value const& params,
Json::StaticString const fieldName,
unsigned apiVersion)
{ {
if (!params.isMember(jss::bridge)) if (!params.isMember(jss::bridge))
{ {
@@ -115,13 +165,19 @@ parseBridge(Json::Value const& params, Json::StaticString const fieldName)
} }
static Expected<uint256, Json::Value> static Expected<uint256, Json::Value>
parseCheck(Json::Value const& params, Json::StaticString const fieldName) parseCheck(
Json::Value const& params,
Json::StaticString const fieldName,
unsigned apiVersion)
{ {
return parseObjectID(params, fieldName, "hex string"); return parseObjectID(params, fieldName, "hex string");
} }
static Expected<uint256, Json::Value> static Expected<uint256, Json::Value>
parseCredential(Json::Value const& cred, Json::StaticString const fieldName) parseCredential(
Json::Value const& cred,
Json::StaticString const fieldName,
unsigned apiVersion)
{ {
if (!cred.isObject()) if (!cred.isObject())
{ {
@@ -152,7 +208,10 @@ parseCredential(Json::Value const& cred, Json::StaticString const fieldName)
} }
static Expected<uint256, Json::Value> static Expected<uint256, Json::Value>
parseDelegate(Json::Value const& params, Json::StaticString const fieldName) parseDelegate(
Json::Value const& params,
Json::StaticString const fieldName,
unsigned apiVersion)
{ {
if (!params.isObject()) if (!params.isObject())
{ {
@@ -176,41 +235,18 @@ static Expected<STArray, Json::Value>
parseAuthorizeCredentials(Json::Value const& jv) parseAuthorizeCredentials(Json::Value const& jv)
{ {
if (!jv.isArray()) if (!jv.isArray())
{
return LedgerEntryHelpers::invalidFieldError( return LedgerEntryHelpers::invalidFieldError(
"malformedAuthorizedCredentials", "malformedAuthorizedCredentials",
jss::authorized_credentials, jss::authorized_credentials,
"array"); "array");
} STArray arr(sfAuthorizeCredentials, jv.size());
std::uint32_t const n = jv.size();
if (n > maxCredentialsArraySize)
{
return Unexpected(LedgerEntryHelpers::malformedError(
"malformedAuthorizedCredentials",
"Invalid field '" + std::string(jss::authorized_credentials) +
"', array too long."));
}
if (n == 0)
{
return Unexpected(LedgerEntryHelpers::malformedError(
"malformedAuthorizedCredentials",
"Invalid field '" + std::string(jss::authorized_credentials) +
"', array empty."));
}
STArray arr(sfAuthorizeCredentials, n);
for (auto const& jo : jv) for (auto const& jo : jv)
{ {
if (!jo.isObject()) if (!jo.isObject())
{
return LedgerEntryHelpers::invalidFieldError( return LedgerEntryHelpers::invalidFieldError(
"malformedAuthorizedCredentials", "malformedAuthorizedCredentials",
jss::authorized_credentials, jss::authorized_credentials,
"array"); "array");
}
if (auto const value = LedgerEntryHelpers::hasRequired( if (auto const value = LedgerEntryHelpers::hasRequired(
jo, jo,
{jss::issuer, jss::credential_type}, {jss::issuer, jss::credential_type},
@@ -243,7 +279,10 @@ parseAuthorizeCredentials(Json::Value const& jv)
} }
static Expected<uint256, Json::Value> static Expected<uint256, Json::Value>
parseDepositPreauth(Json::Value const& dp, Json::StaticString const fieldName) parseDepositPreauth(
Json::Value const& dp,
Json::StaticString const fieldName,
unsigned apiVersion)
{ {
if (!dp.isObject()) if (!dp.isObject())
{ {
@@ -281,6 +320,13 @@ parseDepositPreauth(Json::Value const& dp, Json::StaticString const fieldName)
auto const arr = parseAuthorizeCredentials(ac); auto const arr = parseAuthorizeCredentials(ac);
if (!arr.has_value()) if (!arr.has_value())
return Unexpected(arr.error()); return Unexpected(arr.error());
if (arr->empty() || (arr->size() > maxCredentialsArraySize))
{
return LedgerEntryHelpers::invalidFieldError(
"malformedAuthorizedCredentials",
jss::authorized_credentials,
"array");
}
auto const& sorted = credentials::makeSorted(arr.value()); auto const& sorted = credentials::makeSorted(arr.value());
if (sorted.empty()) if (sorted.empty())
@@ -296,7 +342,10 @@ parseDepositPreauth(Json::Value const& dp, Json::StaticString const fieldName)
} }
static Expected<uint256, Json::Value> static Expected<uint256, Json::Value>
parseDID(Json::Value const& params, Json::StaticString const fieldName) parseDID(
Json::Value const& params,
Json::StaticString const fieldName,
unsigned apiVersion)
{ {
auto const account = LedgerEntryHelpers::parse<AccountID>(params); auto const account = LedgerEntryHelpers::parse<AccountID>(params);
if (!account) if (!account)
@@ -311,7 +360,8 @@ parseDID(Json::Value const& params, Json::StaticString const fieldName)
static Expected<uint256, Json::Value> static Expected<uint256, Json::Value>
parseDirectoryNode( parseDirectoryNode(
Json::Value const& params, Json::Value const& params,
Json::StaticString const fieldName) Json::StaticString const fieldName,
unsigned apiVersion)
{ {
if (!params.isObject()) if (!params.isObject())
{ {
@@ -364,7 +414,10 @@ parseDirectoryNode(
} }
static Expected<uint256, Json::Value> static Expected<uint256, Json::Value>
parseEscrow(Json::Value const& params, Json::StaticString const fieldName) parseEscrow(
Json::Value const& params,
Json::StaticString const fieldName,
unsigned apiVersion)
{ {
if (!params.isObject()) if (!params.isObject())
{ {
@@ -383,20 +436,53 @@ parseEscrow(Json::Value const& params, Json::StaticString const fieldName)
return keylet::escrow(*id, *seq).key; return keylet::escrow(*id, *seq).key;
} }
auto const parseFeeSettings = fixed(keylet::fees());
static Expected<uint256, Json::Value> static Expected<uint256, Json::Value>
parseFeeSettings(Json::Value const& params, Json::StaticString const fieldName) parseFixed(
Keylet const& keylet,
Json::Value const& params,
Json::StaticString const& fieldName,
unsigned apiVersion)
{ {
return parseObjectID(params, fieldName, "hex string"); if (!params.isBool())
{
return parseObjectID(params, fieldName, "hex string");
}
if (!params.asBool())
{
return LedgerEntryHelpers::invalidFieldError(
"invalidParams", fieldName, "true");
}
return keylet.key;
} }
static Expected<uint256, Json::Value> static Expected<uint256, Json::Value>
parseLedgerHashes(Json::Value const& params, Json::StaticString const fieldName) parseLedgerHashes(
Json::Value const& params,
Json::StaticString const fieldName,
unsigned apiVersion)
{ {
return parseObjectID(params, fieldName, "hex string"); if (params.isUInt() || params.isInt())
{
// If the index doesn't parse as a UInt, throw
auto const index = params.asUInt();
// Return the "long" skip list for the given ledger index.
auto const keylet = keylet::skip(index);
return keylet.key;
}
// Return the key in `params` or the "short" skip list, which contains
// hashes since the last flag ledger.
return parseFixed(keylet::skip(), params, fieldName, apiVersion);
} }
static Expected<uint256, Json::Value> static Expected<uint256, Json::Value>
parseMPToken(Json::Value const& params, Json::StaticString const fieldName) parseMPToken(
Json::Value const& params,
Json::StaticString const fieldName,
unsigned apiVersion)
{ {
if (!params.isObject()) if (!params.isObject())
{ {
@@ -419,7 +505,8 @@ parseMPToken(Json::Value const& params, Json::StaticString const fieldName)
static Expected<uint256, Json::Value> static Expected<uint256, Json::Value>
parseMPTokenIssuance( parseMPTokenIssuance(
Json::Value const& params, Json::Value const& params,
Json::StaticString const fieldName) Json::StaticString const fieldName,
unsigned apiVersion)
{ {
auto const mptIssuanceID = LedgerEntryHelpers::parse<uint192>(params); auto const mptIssuanceID = LedgerEntryHelpers::parse<uint192>(params);
if (!mptIssuanceID) if (!mptIssuanceID)
@@ -430,25 +517,30 @@ parseMPTokenIssuance(
} }
static Expected<uint256, Json::Value> static Expected<uint256, Json::Value>
parseNFTokenOffer(Json::Value const& params, Json::StaticString const fieldName) parseNFTokenOffer(
Json::Value const& params,
Json::StaticString const fieldName,
unsigned apiVersion)
{ {
return parseObjectID(params, fieldName, "hex string"); return parseObjectID(params, fieldName, "hex string");
} }
static Expected<uint256, Json::Value> static Expected<uint256, Json::Value>
parseNFTokenPage(Json::Value const& params, Json::StaticString const fieldName) parseNFTokenPage(
Json::Value const& params,
Json::StaticString const fieldName,
unsigned apiVersion)
{ {
return parseObjectID(params, fieldName, "hex string"); return parseObjectID(params, fieldName, "hex string");
} }
static Expected<uint256, Json::Value> auto const parseNegativeUNL = fixed(keylet::negativeUNL());
parseNegativeUNL(Json::Value const& params, Json::StaticString const fieldName)
{
return parseObjectID(params, fieldName, "hex string");
}
static Expected<uint256, Json::Value> static Expected<uint256, Json::Value>
parseOffer(Json::Value const& params, Json::StaticString const fieldName) parseOffer(
Json::Value const& params,
Json::StaticString const fieldName,
unsigned apiVersion)
{ {
if (!params.isObject()) if (!params.isObject())
{ {
@@ -469,7 +561,10 @@ parseOffer(Json::Value const& params, Json::StaticString const fieldName)
} }
static Expected<uint256, Json::Value> static Expected<uint256, Json::Value>
parseOracle(Json::Value const& params, Json::StaticString const fieldName) parseOracle(
Json::Value const& params,
Json::StaticString const fieldName,
unsigned apiVersion)
{ {
if (!params.isObject()) if (!params.isObject())
{ {
@@ -490,7 +585,10 @@ parseOracle(Json::Value const& params, Json::StaticString const fieldName)
} }
static Expected<uint256, Json::Value> static Expected<uint256, Json::Value>
parsePayChannel(Json::Value const& params, Json::StaticString const fieldName) parsePayChannel(
Json::Value const& params,
Json::StaticString const fieldName,
unsigned apiVersion)
{ {
return parseObjectID(params, fieldName, "hex string"); return parseObjectID(params, fieldName, "hex string");
} }
@@ -498,7 +596,8 @@ parsePayChannel(Json::Value const& params, Json::StaticString const fieldName)
static Expected<uint256, Json::Value> static Expected<uint256, Json::Value>
parsePermissionedDomain( parsePermissionedDomain(
Json::Value const& pd, Json::Value const& pd,
Json::StaticString const fieldName) Json::StaticString const fieldName,
unsigned apiVersion)
{ {
if (pd.isString()) if (pd.isString())
{ {
@@ -527,7 +626,8 @@ parsePermissionedDomain(
static Expected<uint256, Json::Value> static Expected<uint256, Json::Value>
parseRippleState( parseRippleState(
Json::Value const& jvRippleState, Json::Value const& jvRippleState,
Json::StaticString const fieldName) Json::StaticString const fieldName,
unsigned apiVersion)
{ {
Currency uCurrency; Currency uCurrency;
@@ -577,13 +677,19 @@ parseRippleState(
} }
static Expected<uint256, Json::Value> static Expected<uint256, Json::Value>
parseSignerList(Json::Value const& params, Json::StaticString const fieldName) parseSignerList(
Json::Value const& params,
Json::StaticString const fieldName,
unsigned apiVersion)
{ {
return parseObjectID(params, fieldName, "hex string"); return parseObjectID(params, fieldName, "hex string");
} }
static Expected<uint256, Json::Value> static Expected<uint256, Json::Value>
parseTicket(Json::Value const& params, Json::StaticString const fieldName) parseTicket(
Json::Value const& params,
Json::StaticString const fieldName,
unsigned apiVersion)
{ {
if (!params.isObject()) if (!params.isObject())
{ {
@@ -604,7 +710,10 @@ parseTicket(Json::Value const& params, Json::StaticString const fieldName)
} }
static Expected<uint256, Json::Value> static Expected<uint256, Json::Value>
parseVault(Json::Value const& params, Json::StaticString const fieldName) parseVault(
Json::Value const& params,
Json::StaticString const fieldName,
unsigned apiVersion)
{ {
if (!params.isObject()) if (!params.isObject())
{ {
@@ -627,7 +736,8 @@ parseVault(Json::Value const& params, Json::StaticString const fieldName)
static Expected<uint256, Json::Value> static Expected<uint256, Json::Value>
parseXChainOwnedClaimID( parseXChainOwnedClaimID(
Json::Value const& claim_id, Json::Value const& claim_id,
Json::StaticString const fieldName) Json::StaticString const fieldName,
unsigned apiVersion)
{ {
if (!claim_id.isObject()) if (!claim_id.isObject())
{ {
@@ -652,7 +762,8 @@ parseXChainOwnedClaimID(
static Expected<uint256, Json::Value> static Expected<uint256, Json::Value>
parseXChainOwnedCreateAccountClaimID( parseXChainOwnedCreateAccountClaimID(
Json::Value const& claim_id, Json::Value const& claim_id,
Json::StaticString const fieldName) Json::StaticString const fieldName,
unsigned apiVersion)
{ {
if (!claim_id.isObject()) if (!claim_id.isObject())
{ {
@@ -676,10 +787,6 @@ parseXChainOwnedCreateAccountClaimID(
return keylet.key; return keylet.key;
} }
using FunctionType = Expected<uint256, Json::Value> (*)(
Json::Value const&,
Json::StaticString const);
struct LedgerEntry struct LedgerEntry
{ {
Json::StaticString fieldName; Json::StaticString fieldName;
@@ -712,7 +819,7 @@ doLedgerEntry(RPC::JsonContext& context)
{jss::ripple_state, parseRippleState, ltRIPPLE_STATE}, {jss::ripple_state, parseRippleState, ltRIPPLE_STATE},
}); });
auto hasMoreThanOneMember = [&]() { auto const hasMoreThanOneMember = [&]() {
int count = 0; int count = 0;
for (auto const& ledgerEntry : ledgerEntryParsers) for (auto const& ledgerEntry : ledgerEntryParsers)
@@ -756,8 +863,8 @@ doLedgerEntry(RPC::JsonContext& context)
Json::Value const& params = ledgerEntry.fieldName == jss::bridge Json::Value const& params = ledgerEntry.fieldName == jss::bridge
? context.params ? context.params
: context.params[ledgerEntry.fieldName]; : context.params[ledgerEntry.fieldName];
auto const result = auto const result = ledgerEntry.parseFunction(
ledgerEntry.parseFunction(params, ledgerEntry.fieldName); params, ledgerEntry.fieldName, context.apiVersion);
if (!result) if (!result)
return result.error(); return result.error();
@@ -788,9 +895,13 @@ doLedgerEntry(RPC::JsonContext& context)
throw; throw;
} }
// Return the computed index regardless of whether the node exists.
jvResult[jss::index] = to_string(uNodeIndex);
if (uNodeIndex.isZero()) if (uNodeIndex.isZero())
{ {
return RPC::make_error(rpcENTRY_NOT_FOUND); RPC::inject_error(rpcENTRY_NOT_FOUND, jvResult);
return jvResult;
} }
auto const sleNode = lpLedger->read(keylet::unchecked(uNodeIndex)); auto const sleNode = lpLedger->read(keylet::unchecked(uNodeIndex));
@@ -802,12 +913,14 @@ doLedgerEntry(RPC::JsonContext& context)
if (!sleNode) if (!sleNode)
{ {
// Not found. // Not found.
return RPC::make_error(rpcENTRY_NOT_FOUND); RPC::inject_error(rpcENTRY_NOT_FOUND, jvResult);
return jvResult;
} }
if ((expectedType != ltANY) && (expectedType != sleNode->getType())) if ((expectedType != ltANY) && (expectedType != sleNode->getType()))
{ {
return RPC::make_error(rpcUNEXPECTED_LEDGER_TYPE); RPC::inject_error(rpcUNEXPECTED_LEDGER_TYPE, jvResult);
return jvResult;
} }
if (bNodeBinary) if (bNodeBinary)
@@ -817,12 +930,10 @@ doLedgerEntry(RPC::JsonContext& context)
sleNode->add(s); sleNode->add(s);
jvResult[jss::node_binary] = strHex(s.peekData()); jvResult[jss::node_binary] = strHex(s.peekData());
jvResult[jss::index] = to_string(uNodeIndex);
} }
else else
{ {
jvResult[jss::node] = sleNode->getJson(JsonOptions::none); jvResult[jss::node] = sleNode->getJson(JsonOptions::none);
jvResult[jss::index] = to_string(uNodeIndex);
} }
return jvResult; return jvResult;