From 896b8c3b54a22b0497cb0d1ce95e1095f9a227ce Mon Sep 17 00:00:00 2001 From: Bart Date: Fri, 22 Aug 2025 10:02:56 -0400 Subject: [PATCH 1/7] chore: Fix file formatting (#5718) --- .github/actions/build-deps/action.yml | 18 ++--- .github/actions/build-test/action.yml | 14 ++-- .github/scripts/levelization/README.md | 2 +- .github/workflows/build-test.yml | 20 ++--- .github/workflows/check-missing-commits.yml | 78 +++++++++---------- .github/workflows/notify-clio.yml | 10 +-- .github/workflows/on-pr.yml | 40 +++++----- .github/workflows/on-trigger.yml | 44 +++++------ .github/workflows/publish-docs.yml | 16 ++-- bin/git/setup-upstreams.sh | 3 +- bin/git/squash-branches.sh | 3 +- cfg/rippled-example.cfg | 8 +- cmake/RippledCore.cmake | 2 +- .../negativeUNLSqDiagram.puml | 20 ++--- .../ledger_replay_classes.puml | 36 ++++----- .../ledger_replay_sequence.puml | 6 +- include/xrpl/protocol/Batch.h | 2 +- include/xrpl/protocol/TxFlags.h | 4 +- .../xrpl/protocol/detail/ledger_entries.macro | 1 - src/libxrpl/protocol/Permissions.cpp | 2 +- src/test/app/Delegate_test.cpp | 2 +- src/test/app/NFTokenAuth_test.cpp | 2 +- src/test/csf/collectors.h | 2 +- src/test/jtx/delegate.h | 2 +- src/test/jtx/impl/delegate.cpp | 2 +- src/xrpld/app/tx/detail/DelegateSet.cpp | 2 +- src/xrpld/app/tx/detail/DelegateSet.h | 2 +- 27 files changed, 170 insertions(+), 173 deletions(-) diff --git a/.github/actions/build-deps/action.yml b/.github/actions/build-deps/action.yml index 272af0f97d..ba4f4e9e2f 100644 --- a/.github/actions/build-deps/action.yml +++ b/.github/actions/build-deps/action.yml @@ -7,33 +7,33 @@ name: Build Conan dependencies # https://docs.github.com/en/actions/reference/workflows-and-actions/metadata-syntax#inputs. inputs: build_dir: - description: 'The directory where to build.' + description: "The directory where to build." required: true build_type: description: 'The build type to use ("Debug", "Release").' required: true conan_remote_name: - description: 'The name of the Conan remote to use.' + description: "The name of the Conan remote to use." required: true conan_remote_url: - description: 'The URL of the Conan endpoint to use.' + description: "The URL of the Conan endpoint to use." required: true conan_remote_username: - description: 'The username for logging into the Conan remote. If not provided, the dependencies will not be uploaded.' + description: "The username for logging into the Conan remote. If not provided, the dependencies will not be uploaded." required: false - default: '' + default: "" conan_remote_password: - description: 'The password for logging into the Conan remote. If not provided, the dependencies will not be uploaded.' + description: "The password for logging into the Conan remote. If not provided, the dependencies will not be uploaded." required: false - default: '' + default: "" force_build: description: 'Force building of all dependencies ("true", "false").' required: false - default: 'false' + default: "false" force_upload: description: 'Force uploading of all dependencies ("true", "false").' required: false - default: 'false' + default: "false" runs: using: composite diff --git a/.github/actions/build-test/action.yml b/.github/actions/build-test/action.yml index 44292e7318..d68f302698 100644 --- a/.github/actions/build-test/action.yml +++ b/.github/actions/build-test/action.yml @@ -6,26 +6,26 @@ name: Build and Test # https://docs.github.com/en/actions/reference/workflows-and-actions/metadata-syntax#inputs. inputs: build_dir: - description: 'The directory where to build.' + description: "The directory where to build." required: true build_only: description: 'Whether to only build or to build and test the code ("true", "false").' required: false - default: 'false' + default: "false" build_type: description: 'The build type to use ("Debug", "Release").' required: true cmake_args: - description: 'Additional arguments to pass to CMake.' + description: "Additional arguments to pass to CMake." required: false - default: '' + default: "" cmake_target: - description: 'The CMake target to build.' + description: "The CMake target to build." required: true codecov_token: - description: 'The Codecov token to use for uploading coverage reports.' + description: "The Codecov token to use for uploading coverage reports." required: false - default: '' + default: "" os: description: 'The operating system to use for the build ("linux", "macos", "windows").' required: true diff --git a/.github/scripts/levelization/README.md b/.github/scripts/levelization/README.md index ec41a021cc..31c6d34b6b 100644 --- a/.github/scripts/levelization/README.md +++ b/.github/scripts/levelization/README.md @@ -111,4 +111,4 @@ get those details locally. 1. Run `levelization.sh` 2. Grep the modules in `paths.txt`. - For example, if a cycle is found `A ~= B`, simply `grep -w - A .github/scripts/levelization/results/paths.txt | grep -w B` +A .github/scripts/levelization/results/paths.txt | grep -w B` diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index e06ff9abab..36145479e1 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -9,25 +9,25 @@ on: workflow_call: inputs: build_dir: - description: 'The directory where to build.' + description: "The directory where to build." required: false type: string - default: '.build' + default: ".build" conan_remote_name: - description: 'The name of the Conan remote to use.' + description: "The name of the Conan remote to use." required: true type: string conan_remote_url: - description: 'The URL of the Conan endpoint to use.' + description: "The URL of the Conan endpoint to use." required: true type: string dependencies_force_build: - description: 'Force building of all dependencies.' + description: "Force building of all dependencies." required: false type: boolean default: false dependencies_force_upload: - description: 'Force uploading of all dependencies.' + description: "Force uploading of all dependencies." required: false type: boolean default: false @@ -40,16 +40,16 @@ on: description: 'The strategy matrix to use for generating the configurations ("minimal", "all").' required: false type: string - default: 'minimal' + default: "minimal" secrets: codecov_token: - description: 'The Codecov token to use for uploading coverage reports.' + description: "The Codecov token to use for uploading coverage reports." required: false conan_remote_username: - description: 'The username for logging into the Conan remote. If not provided, the dependencies will not be uploaded.' + description: "The username for logging into the Conan remote. If not provided, the dependencies will not be uploaded." required: false conan_remote_password: - description: 'The password for logging into the Conan remote. If not provided, the dependencies will not be uploaded.' + description: "The password for logging into the Conan remote. If not provided, the dependencies will not be uploaded." required: false concurrency: diff --git a/.github/workflows/check-missing-commits.yml b/.github/workflows/check-missing-commits.yml index da0e296e70..07d29174d8 100644 --- a/.github/workflows/check-missing-commits.yml +++ b/.github/workflows/check-missing-commits.yml @@ -18,45 +18,45 @@ jobs: check: runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 - with: - fetch-depth: 0 - - name: Check for missing commits - env: - MESSAGE: | + - name: Checkout repository + uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 + with: + fetch-depth: 0 + - name: Check for missing commits + env: + MESSAGE: | - If you are reading this, then the commits indicated above are missing - from the "develop" and/or "release" branch. Do a reverse-merge as soon - as possible. See CONTRIBUTING.md for instructions. - run: | - set -o pipefail - # Branches are ordered by how "canonical" they are. Every commit in one - # branch should be in all the branches behind it. - order=(master release develop) - branches=() - for branch in "${order[@]}"; do - # Check that the branches exist so that this job will work on forked - # repos, which don't necessarily have master and release branches. - echo "Checking if ${branch} exists." - if git ls-remote --exit-code --heads origin \ - refs/heads/${branch} > /dev/null; then - branches+=(origin/${branch}) - fi - done + If you are reading this, then the commits indicated above are missing + from the "develop" and/or "release" branch. Do a reverse-merge as soon + as possible. See CONTRIBUTING.md for instructions. + run: | + set -o pipefail + # Branches are ordered by how "canonical" they are. Every commit in one + # branch should be in all the branches behind it. + order=(master release develop) + branches=() + for branch in "${order[@]}"; do + # Check that the branches exist so that this job will work on forked + # repos, which don't necessarily have master and release branches. + echo "Checking if ${branch} exists." + if git ls-remote --exit-code --heads origin \ + refs/heads/${branch} > /dev/null; then + branches+=(origin/${branch}) + fi + done - prior=() - for branch in "${branches[@]}"; do - if [[ ${#prior[@]} -ne 0 ]]; then - echo "Checking ${prior[@]} for commits missing from ${branch}." - git log --oneline --no-merges "${prior[@]}" \ - ^$branch | tee -a "missing-commits.txt" - echo + prior=() + for branch in "${branches[@]}"; do + if [[ ${#prior[@]} -ne 0 ]]; then + echo "Checking ${prior[@]} for commits missing from ${branch}." + git log --oneline --no-merges "${prior[@]}" \ + ^$branch | tee -a "missing-commits.txt" + echo + fi + prior+=("${branch}") + done + + if [[ $(cat missing-commits.txt | wc -l) -ne 0 ]]; then + echo "${MESSAGE}" + exit 1 fi - prior+=("${branch}") - done - - if [[ $(cat missing-commits.txt | wc -l) -ne 0 ]]; then - echo "${MESSAGE}" - exit 1 - fi diff --git a/.github/workflows/notify-clio.yml b/.github/workflows/notify-clio.yml index b92dea65e2..f7e10de7af 100644 --- a/.github/workflows/notify-clio.yml +++ b/.github/workflows/notify-clio.yml @@ -8,22 +8,22 @@ on: workflow_call: inputs: conan_remote_name: - description: 'The name of the Conan remote to use.' + description: "The name of the Conan remote to use." required: true type: string conan_remote_url: - description: 'The URL of the Conan endpoint to use.' + description: "The URL of the Conan endpoint to use." required: true type: string secrets: clio_notify_token: - description: 'The GitHub token to notify Clio about new versions.' + description: "The GitHub token to notify Clio about new versions." required: true conan_remote_username: - description: 'The username for logging into the Conan remote.' + description: "The username for logging into the Conan remote." required: true conan_remote_password: - description: 'The password for logging into the Conan remote.' + description: "The password for logging into the Conan remote." required: true concurrency: diff --git a/.github/workflows/on-pr.yml b/.github/workflows/on-pr.yml index 9d7bbbf89c..f3811c4ea4 100644 --- a/.github/workflows/on-pr.yml +++ b/.github/workflows/on-pr.yml @@ -7,28 +7,28 @@ name: PR on: pull_request: paths: - - '.github/actions/build-deps/**' - - '.github/actions/build-test/**' - - '.github/scripts/levelization/**' - - '.github/scripts/strategy-matrix/**' - - '.github/workflows/build-test.yml' - - '.github/workflows/check-format.yml' - - '.github/workflows/check-levelization.yml' - - '.github/workflows/notify-clio.yml' - - '.github/workflows/on-pr.yml' + - ".github/actions/build-deps/**" + - ".github/actions/build-test/**" + - ".github/scripts/levelization/**" + - ".github/scripts/strategy-matrix/**" + - ".github/workflows/build-test.yml" + - ".github/workflows/check-format.yml" + - ".github/workflows/check-levelization.yml" + - ".github/workflows/notify-clio.yml" + - ".github/workflows/on-pr.yml" # Keep the list of paths below in sync with those in the `on-trigger.yml` # file. - - 'cmake/**' - - 'conan/**' - - 'external/**' - - 'include/**' - - 'src/**' - - 'tests/**' - - '.clang-format' - - '.codecov.yml' - - '.pre-commit-config.yaml' - - 'CMakeLists.txt' - - 'conanfile.py' + - "cmake/**" + - "conan/**" + - "external/**" + - "include/**" + - "src/**" + - "tests/**" + - ".clang-format" + - ".codecov.yml" + - ".pre-commit-config.yaml" + - "CMakeLists.txt" + - "conanfile.py" types: - opened - synchronize diff --git a/.github/workflows/on-trigger.yml b/.github/workflows/on-trigger.yml index ed9a794985..55e93b9866 100644 --- a/.github/workflows/on-trigger.yml +++ b/.github/workflows/on-trigger.yml @@ -13,31 +13,31 @@ on: - release - master paths: - - '.github/actions/build-deps/**' - - '.github/actions/build-test/**' - - '.github/scripts/strategy-matrix/**' - - '.github/workflows/build-test.yml' - - '.github/workflows/check-missing-commits.yml' - - '.github/workflows/on-trigger.yml' - - '.github/workflows/publish-docs.yml' + - ".github/actions/build-deps/**" + - ".github/actions/build-test/**" + - ".github/scripts/strategy-matrix/**" + - ".github/workflows/build-test.yml" + - ".github/workflows/check-missing-commits.yml" + - ".github/workflows/on-trigger.yml" + - ".github/workflows/publish-docs.yml" # Keep the list of paths below in sync with those in `on-pr.yml`. - - 'cmake/**' - - 'conan/**' - - 'external/**' - - 'include/**' - - 'src/**' - - 'tests/**' - - '.clang-format' - - '.codecov.yml' - - '.pre-commit-config.yaml' - - 'CMakeLists.txt' - - 'conanfile.py' + - "cmake/**" + - "conan/**" + - "external/**" + - "include/**" + - "src/**" + - "tests/**" + - ".clang-format" + - ".codecov.yml" + - ".pre-commit-config.yaml" + - "CMakeLists.txt" + - "conanfile.py" # Run at 06:32 UTC on every day of the week from Monday through Friday. This # will force all dependencies to be rebuilt, which is useful to verify that # all dependencies can be built successfully. Only the dependencies that # are actually missing from the remote will be uploaded. schedule: - - cron: '32 6 * * 1-5' + - cron: "32 6 * * 1-5" # Run when manually triggered via the GitHub UI or API. If `force_upload` is # true, then the dependencies that were missing (`force_rebuild` is false) or # rebuilt (`force_rebuild` is true) will be uploaded, overwriting existing @@ -45,12 +45,12 @@ on: workflow_dispatch: inputs: dependencies_force_build: - description: 'Force building of all dependencies.' + description: "Force building of all dependencies." required: false type: boolean default: false dependencies_force_upload: - description: 'Force uploading of all dependencies.' + description: "Force uploading of all dependencies." required: false type: boolean default: false @@ -109,7 +109,7 @@ jobs: dependencies_force_build: ${{ needs.generate-outputs.outputs.dependencies_force_build == 'true' }} dependencies_force_upload: ${{ needs.generate-outputs.outputs.dependencies_force_upload == 'true' }} os: ${{ matrix.os }} - strategy_matrix: 'all' + strategy_matrix: "all" secrets: conan_remote_username: ${{ secrets.CONAN_REMOTE_USERNAME }} conan_remote_password: ${{ secrets.CONAN_REMOTE_PASSWORD }} diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index 509644e6b5..2fcdd581d1 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -5,13 +5,13 @@ name: Build and publish documentation on: push: paths: - - '.github/workflows/publish-docs.yml' - - '*.md' - - '**/*.md' - - 'docs/**' - - 'include/**' - - 'src/libxrpl/**' - - 'src/xrpld/**' + - ".github/workflows/publish-docs.yml" + - "*.md" + - "**/*.md" + - "docs/**" + - "include/**" + - "src/libxrpl/**" + - "src/xrpld/**" concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -22,7 +22,7 @@ defaults: shell: bash env: - BUILD_DIR: .build + BUILD_DIR: .build jobs: publish: diff --git a/bin/git/setup-upstreams.sh b/bin/git/setup-upstreams.sh index cdf3f37f37..61d8171569 100755 --- a/bin/git/setup-upstreams.sh +++ b/bin/git/setup-upstreams.sh @@ -5,7 +5,7 @@ then name=$( basename $0 ) cat <<- USAGE Usage: $name - + Where is the Github username of the upstream repo. e.g. XRPLF USAGE exit 0 @@ -83,4 +83,3 @@ fi _run git fetch --jobs=$(nproc) upstreams exit 0 - diff --git a/bin/git/squash-branches.sh b/bin/git/squash-branches.sh index 66f1a2d715..4dcbf5aaa1 100755 --- a/bin/git/squash-branches.sh +++ b/bin/git/squash-branches.sh @@ -5,7 +5,7 @@ then name=$( basename $0 ) cat <<- USAGE Usage: $name workbranch base/branch user/branch [user/branch [...]] - + * workbranch will be created locally from base/branch * base/branch and user/branch may be specified as user:branch to allow easy copying from Github PRs @@ -66,4 +66,3 @@ git push $push HEAD:$b git fetch $repo ------------------------------------------------------------------- PUSH - diff --git a/cfg/rippled-example.cfg b/cfg/rippled-example.cfg index 8fb7d00875..8bffc150c1 100644 --- a/cfg/rippled-example.cfg +++ b/cfg/rippled-example.cfg @@ -396,8 +396,8 @@ # true - enables compression # false - disables compression [default]. # -# The rippled server can save bandwidth by compressing its peer-to-peer communications, -# at a cost of greater CPU usage. If you enable link compression, +# The rippled server can save bandwidth by compressing its peer-to-peer communications, +# at a cost of greater CPU usage. If you enable link compression, # the server automatically compresses communications with peer servers # that also have link compression enabled. # https://xrpl.org/enable-link-compression.html @@ -1011,7 +1011,7 @@ # that rippled is still in sync with the network, # and that the validated ledger is less than # 'age_threshold_seconds' old. If not, then continue -# sleeping for this number of seconds and +# sleeping for this number of seconds and # checking until healthy. # Default is 5. # @@ -1113,7 +1113,7 @@ # page_size Valid values: integer (MUST be power of 2 between 512 and 65536) # The default is 4096 bytes. This setting determines # the size of a page in the transaction.db file. -# See https://www.sqlite.org/pragma.html#pragma_page_size +# See https://www.sqlite.org/pragma.html#pragma_page_size # for more details about the available options. # # journal_size_limit Valid values: integer diff --git a/cmake/RippledCore.cmake b/cmake/RippledCore.cmake index 83b27e6c4f..7d3561675a 100644 --- a/cmake/RippledCore.cmake +++ b/cmake/RippledCore.cmake @@ -101,7 +101,7 @@ target_link_libraries(xrpl.libxrpl.resource PUBLIC xrpl.libxrpl.protocol) # Level 06 add_module(xrpl net) -target_link_libraries(xrpl.libxrpl.net PUBLIC +target_link_libraries(xrpl.libxrpl.net PUBLIC xrpl.libxrpl.basics xrpl.libxrpl.json xrpl.libxrpl.protocol diff --git a/docs/0001-negative-unl/negativeUNLSqDiagram.puml b/docs/0001-negative-unl/negativeUNLSqDiagram.puml index 8cb491af6a..9f37d43903 100644 --- a/docs/0001-negative-unl/negativeUNLSqDiagram.puml +++ b/docs/0001-negative-unl/negativeUNLSqDiagram.puml @@ -5,8 +5,8 @@ skinparam roundcorner 20 skinparam maxmessagesize 160 actor "Rippled Start" as RS -participant "Timer" as T -participant "NetworkOPs" as NOP +participant "Timer" as T +participant "NetworkOPs" as NOP participant "ValidatorList" as VL #lightgreen participant "Consensus" as GC participant "ConsensusAdaptor" as CA #lightgreen @@ -20,7 +20,7 @@ VL -> NOP NOP -> VL: update trusted validators activate VL VL -> VL: re-calculate quorum -hnote over VL#lightgreen: ignore negative listed validators\nwhen calculate quorum +hnote over VL#lightgreen: ignore negative listed validators\nwhen calculate quorum VL -> NOP deactivate VL NOP -> GC: start round @@ -36,14 +36,14 @@ activate GC end alt phase == OPEN - alt should close ledger + alt should close ledger GC -> GC: phase = ESTABLISH GC -> CA: onClose activate CA - alt sqn%256==0 + alt sqn%256==0 CA -[#green]> RM: getValidations - CA -[#green]> CA: create UNLModify Tx - hnote over CA#lightgreen: use validatations of the last 256 ledgers\nto figure out UNLModify Tx candidates.\nIf any, create UNLModify Tx, and add to TxSet. + CA -[#green]> CA: create UNLModify Tx + hnote over CA#lightgreen: use validatations of the last 256 ledgers\nto figure out UNLModify Tx candidates.\nIf any, create UNLModify Tx, and add to TxSet. end CA -> GC GC -> CA: propose @@ -61,14 +61,14 @@ else phase == ESTABLISH CA -> CA : build LCL hnote over CA #lightgreen: copy negative UNL from parent ledger alt sqn%256==0 - CA -[#green]> CA: Adjust negative UNL + CA -[#green]> CA: Adjust negative UNL CA -[#green]> CA: apply UNLModify Tx end CA -> CA : validate and send validation message activate NOP CA -> NOP : end consensus and\nbegin next consensus round deactivate NOP - deactivate CA + deactivate CA hnote over RM: receive validations end else phase == ACCEPTED @@ -76,4 +76,4 @@ else phase == ACCEPTED end deactivate GC -@enduml \ No newline at end of file +@enduml diff --git a/docs/0010-ledger-replay/ledger_replay_classes.puml b/docs/0010-ledger-replay/ledger_replay_classes.puml index 4c90ef2511..f98cfbe231 100644 --- a/docs/0010-ledger-replay/ledger_replay_classes.puml +++ b/docs/0010-ledger-replay/ledger_replay_classes.puml @@ -4,7 +4,7 @@ class TimeoutCounter { #app_ : Application& } -TimeoutCounter o-- "1" Application +TimeoutCounter o-- "1" Application ': app_ Stoppable <.. Application @@ -14,13 +14,13 @@ class Application { -m_inboundLedgers : uptr } -Application *-- "1" LedgerReplayer +Application *-- "1" LedgerReplayer ': m_ledgerReplayer -Application *-- "1" InboundLedgers +Application *-- "1" InboundLedgers ': m_inboundLedgers Stoppable <.. InboundLedgers -Application "1" --o InboundLedgers +Application "1" --o InboundLedgers ': app_ class InboundLedgers { @@ -28,9 +28,9 @@ class InboundLedgers { } Stoppable <.. LedgerReplayer -InboundLedgers "1" --o LedgerReplayer +InboundLedgers "1" --o LedgerReplayer ': inboundLedgers_ -Application "1" --o LedgerReplayer +Application "1" --o LedgerReplayer ': app_ class LedgerReplayer { @@ -42,17 +42,17 @@ class LedgerReplayer { -skipLists_ : hash_map> } -LedgerReplayer *-- LedgerReplayTask +LedgerReplayer *-- LedgerReplayTask ': tasks_ -LedgerReplayer o-- LedgerDeltaAcquire +LedgerReplayer o-- LedgerDeltaAcquire ': deltas_ -LedgerReplayer o-- SkipListAcquire +LedgerReplayer o-- SkipListAcquire ': skipLists_ TimeoutCounter <.. LedgerReplayTask -InboundLedgers "1" --o LedgerReplayTask +InboundLedgers "1" --o LedgerReplayTask ': inboundLedgers_ -LedgerReplayer "1" --o LedgerReplayTask +LedgerReplayer "1" --o LedgerReplayTask ': replayer_ class LedgerReplayTask { @@ -63,15 +63,15 @@ class LedgerReplayTask { +addDelta(sptr) } -LedgerReplayTask *-- "1" SkipListAcquire +LedgerReplayTask *-- "1" SkipListAcquire ': skipListAcquirer_ -LedgerReplayTask *-- LedgerDeltaAcquire +LedgerReplayTask *-- LedgerDeltaAcquire ': deltas_ TimeoutCounter <.. SkipListAcquire -InboundLedgers "1" --o SkipListAcquire +InboundLedgers "1" --o SkipListAcquire ': inboundLedgers_ -LedgerReplayer "1" --o SkipListAcquire +LedgerReplayer "1" --o SkipListAcquire ': replayer_ LedgerReplayTask --o SkipListAcquire : implicit via callback @@ -83,9 +83,9 @@ class SkipListAcquire { } TimeoutCounter <.. LedgerDeltaAcquire -InboundLedgers "1" --o LedgerDeltaAcquire +InboundLedgers "1" --o LedgerDeltaAcquire ': inboundLedgers_ -LedgerReplayer "1" --o LedgerDeltaAcquire +LedgerReplayer "1" --o LedgerDeltaAcquire ': replayer_ LedgerReplayTask --o LedgerDeltaAcquire : implicit via callback @@ -95,4 +95,4 @@ class LedgerDeltaAcquire { -replayer_ : LedgerReplayer& -dataReadyCallbacks_ : vector } -@enduml \ No newline at end of file +@enduml diff --git a/docs/0010-ledger-replay/ledger_replay_sequence.puml b/docs/0010-ledger-replay/ledger_replay_sequence.puml index 481819b5e8..603b09157b 100644 --- a/docs/0010-ledger-replay/ledger_replay_sequence.puml +++ b/docs/0010-ledger-replay/ledger_replay_sequence.puml @@ -38,7 +38,7 @@ deactivate lr loop lr -> lda : make_shared(ledgerId, ledgerSeq) return delta - lr -> lrt : addDelta(delta) + lr -> lrt : addDelta(delta) lrt -> lda : addDataCallback(callback) return return @@ -62,7 +62,7 @@ deactivate peer lr -> lda : processData(ledgerHeader, txns) lda -> lda : notify() note over lda: call the callbacks added by\naddDataCallback(callback). - lda -> lrt : callback(ledgerId) + lda -> lrt : callback(ledgerId) lrt -> lrt : deltaReady(ledgerId) lrt -> lrt : tryAdvance() loop as long as child can be built @@ -82,4 +82,4 @@ deactivate peer deactivate peer -@enduml \ No newline at end of file +@enduml diff --git a/include/xrpl/protocol/Batch.h b/include/xrpl/protocol/Batch.h index 1388bbd2f1..1307ea0978 100644 --- a/include/xrpl/protocol/Batch.h +++ b/include/xrpl/protocol/Batch.h @@ -34,4 +34,4 @@ serializeBatch( msg.addBitString(txid); } -} // namespace ripple \ No newline at end of file +} // namespace ripple diff --git a/include/xrpl/protocol/TxFlags.h b/include/xrpl/protocol/TxFlags.h index 2831933afb..a37474b780 100644 --- a/include/xrpl/protocol/TxFlags.h +++ b/include/xrpl/protocol/TxFlags.h @@ -141,7 +141,7 @@ constexpr std::uint32_t const tfTransferable = 0x00000008; constexpr std::uint32_t const tfMutable = 0x00000010; // MPTokenIssuanceCreate flags: -// NOTE - there is intentionally no flag here for lsfMPTLocked, which this transaction cannot mutate. +// NOTE - there is intentionally no flag here for lsfMPTLocked, which this transaction cannot mutate. constexpr std::uint32_t const tfMPTCanLock = lsfMPTCanLock; constexpr std::uint32_t const tfMPTRequireAuth = lsfMPTRequireAuth; constexpr std::uint32_t const tfMPTCanEscrow = lsfMPTCanEscrow; @@ -243,7 +243,7 @@ constexpr std::uint32_t tfUntilFailure = 0x00040000; constexpr std::uint32_t tfIndependent = 0x00080000; /** * @note If nested Batch transactions are supported in the future, the tfInnerBatchTxn flag - * will need to be removed from this mask to allow Batch transaction to be inside + * will need to be removed from this mask to allow Batch transaction to be inside * the sfRawTransactions array. */ constexpr std::uint32_t const tfBatchMask = diff --git a/include/xrpl/protocol/detail/ledger_entries.macro b/include/xrpl/protocol/detail/ledger_entries.macro index 11306ee0f5..967fb37b94 100644 --- a/include/xrpl/protocol/detail/ledger_entries.macro +++ b/include/xrpl/protocol/detail/ledger_entries.macro @@ -505,4 +505,3 @@ LEDGER_ENTRY(ltVAULT, 0x0084, Vault, vault, ({ #undef EXPAND #undef LEDGER_ENTRY_DUPLICATE - diff --git a/src/libxrpl/protocol/Permissions.cpp b/src/libxrpl/protocol/Permissions.cpp index dbe5325a4e..ca8cb26f36 100644 --- a/src/libxrpl/protocol/Permissions.cpp +++ b/src/libxrpl/protocol/Permissions.cpp @@ -145,4 +145,4 @@ Permission::permissionToTxType(uint32_t const& value) const return static_cast(value - 1); } -} // namespace ripple \ No newline at end of file +} // namespace ripple diff --git a/src/test/app/Delegate_test.cpp b/src/test/app/Delegate_test.cpp index 179532140d..44cb6a54b6 100644 --- a/src/test/app/Delegate_test.cpp +++ b/src/test/app/Delegate_test.cpp @@ -1499,4 +1499,4 @@ class Delegate_test : public beast::unit_test::suite }; BEAST_DEFINE_TESTSUITE(Delegate, app, ripple); } // namespace test -} // namespace ripple \ No newline at end of file +} // namespace ripple diff --git a/src/test/app/NFTokenAuth_test.cpp b/src/test/app/NFTokenAuth_test.cpp index f5eedfce77..f0d7cc3700 100644 --- a/src/test/app/NFTokenAuth_test.cpp +++ b/src/test/app/NFTokenAuth_test.cpp @@ -621,4 +621,4 @@ public: BEAST_DEFINE_TESTSUITE_PRIO(NFTokenAuth, app, ripple, 2); -} // namespace ripple \ No newline at end of file +} // namespace ripple diff --git a/src/test/csf/collectors.h b/src/test/csf/collectors.h index 7b91863cbd..0494178ae9 100644 --- a/src/test/csf/collectors.h +++ b/src/test/csf/collectors.h @@ -720,4 +720,4 @@ struct JumpCollector } // namespace test } // namespace ripple -#endif \ No newline at end of file +#endif diff --git a/src/test/jtx/delegate.h b/src/test/jtx/delegate.h index 9e8850fbe2..ea368557b8 100644 --- a/src/test/jtx/delegate.h +++ b/src/test/jtx/delegate.h @@ -59,4 +59,4 @@ public: } // namespace delegate } // namespace jtx } // namespace test -} // namespace ripple \ No newline at end of file +} // namespace ripple diff --git a/src/test/jtx/impl/delegate.cpp b/src/test/jtx/impl/delegate.cpp index 3ceedff190..8ef2fac13d 100644 --- a/src/test/jtx/impl/delegate.cpp +++ b/src/test/jtx/impl/delegate.cpp @@ -64,4 +64,4 @@ entry(jtx::Env& env, jtx::Account const& account, jtx::Account const& authorize) } // namespace delegate } // namespace jtx } // namespace test -} // namespace ripple \ No newline at end of file +} // namespace ripple diff --git a/src/xrpld/app/tx/detail/DelegateSet.cpp b/src/xrpld/app/tx/detail/DelegateSet.cpp index 34e1c3afd3..708cdf0dc2 100644 --- a/src/xrpld/app/tx/detail/DelegateSet.cpp +++ b/src/xrpld/app/tx/detail/DelegateSet.cpp @@ -159,4 +159,4 @@ DelegateSet::deleteDelegate( return tesSUCCESS; } -} // namespace ripple \ No newline at end of file +} // namespace ripple diff --git a/src/xrpld/app/tx/detail/DelegateSet.h b/src/xrpld/app/tx/detail/DelegateSet.h index 6b01d63281..c72b1e3c58 100644 --- a/src/xrpld/app/tx/detail/DelegateSet.h +++ b/src/xrpld/app/tx/detail/DelegateSet.h @@ -53,4 +53,4 @@ public: } // namespace ripple -#endif \ No newline at end of file +#endif From 2e255812ae8fcd8b0da6acf0281c5f286c2827ed Mon Sep 17 00:00:00 2001 From: Bronek Kozicki Date: Fri, 22 Aug 2025 15:58:36 +0100 Subject: [PATCH 2/7] chore: Workaround for CI build errors on arm64 (#5717) CI builds with `clang-20` on `linux/arm64` are failing due to boost 1.86. This is hopefully fixed in version 1.88. --- .github/scripts/strategy-matrix/generate.py | 4 ++++ .gitignore | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/scripts/strategy-matrix/generate.py b/.github/scripts/strategy-matrix/generate.py index 0acdca8d4f..652cb8871f 100644 --- a/.github/scripts/strategy-matrix/generate.py +++ b/.github/scripts/strategy-matrix/generate.py @@ -123,6 +123,10 @@ def generate_strategy_matrix(all: bool, architecture: list[dict], os: list[dict] if os['distro_name'] == 'rhel' and architecture['platform'] == 'linux/arm64': continue + # We skip all clang-20 on arm64 due to boost 1.86 build error + if f'{os['compiler_name']}-{os['compiler_version']}' == 'clang-20' and architecture['platform'] == 'linux/arm64': + continue + # Generate a unique name for the configuration, e.g. macos-arm64-debug # or debian-bookworm-gcc-12-amd64-release-unity. config_name = os['distro_name'] diff --git a/.gitignore b/.gitignore index ab54adba74..5476f21a41 100644 --- a/.gitignore +++ b/.gitignore @@ -110,4 +110,4 @@ bld.rippled/ .vscode # Suggested in-tree build directory -/.build/ +/.build*/ From 095dc4d9cc89f96aaf82940e822a753bff4b96af Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Fri, 22 Aug 2025 12:15:03 -0400 Subject: [PATCH 3/7] fix(test): handle null metadata for unvalidated tx in Env::meta (#5715) This change handles errors better when calling `env.meta`. It prints some debug help and throws an error if `env.meta` is going to return a `nullptr`. --- src/test/jtx/impl/Env.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/test/jtx/impl/Env.cpp b/src/test/jtx/impl/Env.cpp index 46558a188a..d6956b30c7 100644 --- a/src/test/jtx/impl/Env.cpp +++ b/src/test/jtx/impl/Env.cpp @@ -499,7 +499,16 @@ Env::meta() close(); } auto const item = closed()->txRead(txid_); - return item.second; + auto const result = item.second; + if (result == nullptr) + { + test.log << "Env::meta: no metadata for txid: " << txid_ << std::endl; + test.log << "This is probably because the transaction failed with a " + "non-tec error." + << std::endl; + Throw("Env::meta: no metadata for txid"); + } + return result; } std::shared_ptr From c14ce956adeabe476ad73c18d73103f347c9c613 Mon Sep 17 00:00:00 2001 From: Bart Date: Fri, 22 Aug 2025 13:37:11 -0400 Subject: [PATCH 4/7] chore: Update clang-format and prettier with pre-commit (#5709) The change updates how clang-format is called in CI and locally, and adds prettier to the pre-commit hook. Proto files are now also formatted, while external files are excluded. --- .clang-format | 36 +++++------ .git-blame-ignore-revs | 2 + .github/scripts/strategy-matrix/linux.json | 24 ++------ .github/scripts/strategy-matrix/macos.json | 12 +--- .github/scripts/strategy-matrix/windows.json | 14 +---- .github/workflows/check-format.yml | 63 ++++--------------- .github/workflows/on-pr.yml | 4 +- .pre-commit-config.yaml | 64 +++++++++++++++++++- .prettierignore | 1 - 9 files changed, 103 insertions(+), 117 deletions(-) diff --git a/.clang-format b/.clang-format index 9c3820a6bf..bd446022df 100644 --- a/.clang-format +++ b/.clang-format @@ -1,4 +1,20 @@ --- +BreakBeforeBraces: Custom +BraceWrapping: + AfterClass: true + AfterControlStatement: true + AfterEnum: false + AfterFunction: true + AfterNamespace: false + AfterObjCDeclaration: true + AfterStruct: true + AfterUnion: true + BeforeCatch: true + BeforeElse: true + IndentBraces: false +KeepEmptyLinesAtTheStartOfBlocks: false +MaxEmptyLinesToKeep: 1 +--- Language: Cpp AccessModifierOffset: -4 AlignAfterOpenBracket: AlwaysBreak @@ -18,20 +34,7 @@ AlwaysBreakBeforeMultilineStrings: true AlwaysBreakTemplateDeclarations: true BinPackArguments: false BinPackParameters: false -BraceWrapping: - AfterClass: true - AfterControlStatement: true - AfterEnum: false - AfterFunction: true - AfterNamespace: false - AfterObjCDeclaration: true - AfterStruct: true - AfterUnion: true - BeforeCatch: true - BeforeElse: true - IndentBraces: false BreakBeforeBinaryOperators: false -BreakBeforeBraces: Custom BreakBeforeTernaryOperators: true BreakConstructorInitializersBeforeComma: true ColumnLimit: 80 @@ -66,8 +69,6 @@ IndentFunctionDeclarationAfterType: false IndentRequiresClause: true IndentWidth: 4 IndentWrappedFunctionNames: false -KeepEmptyLinesAtTheStartOfBlocks: false -MaxEmptyLinesToKeep: 1 NamespaceIndentation: None ObjCSpaceAfterProperty: false ObjCSpaceBeforeProtocolList: false @@ -96,11 +97,6 @@ TabWidth: 8 UseTab: Never QualifierAlignment: Right --- -Language: JavaScript ---- -Language: Json -IndentWidth: 2 ---- Language: Proto BasedOnStyle: Google ColumnLimit: 0 diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index a9805e705c..cf50d48f95 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -12,3 +12,5 @@ fe9a5365b8a52d4acc42eb27369247e6f238a4f9 9a93577314e6a8d4b4a8368cc9d2b15a5d8303e8 552377c76f55b403a1c876df873a23d780fcc81c 97f0747e103f13e26e45b731731059b32f7679ac +b13370ac0d207217354f1fc1c29aef87769fb8a1 +896b8c3b54a22b0497cb0d1ce95e1095f9a227ce diff --git a/.github/scripts/strategy-matrix/linux.json b/.github/scripts/strategy-matrix/linux.json index d8f176273d..44eaebd074 100644 --- a/.github/scripts/strategy-matrix/linux.json +++ b/.github/scripts/strategy-matrix/linux.json @@ -2,21 +2,11 @@ "architecture": [ { "platform": "linux/amd64", - "runner": [ - "self-hosted", - "Linux", - "X64", - "heavy" - ] + "runner": ["self-hosted", "Linux", "X64", "heavy"] }, { "platform": "linux/arm64", - "runner": [ - "self-hosted", - "Linux", - "ARM64", - "heavy-arm64" - ] + "runner": ["self-hosted", "Linux", "ARM64", "heavy-arm64"] } ], "os": [ @@ -159,12 +149,6 @@ "compiler_version": "19" } ], - "build_type": [ - "Debug", - "Release" - ], - "cmake_args": [ - "-Dunity=OFF", - "-Dunity=ON" - ] + "build_type": ["Debug", "Release"], + "cmake_args": ["-Dunity=OFF", "-Dunity=ON"] } diff --git a/.github/scripts/strategy-matrix/macos.json b/.github/scripts/strategy-matrix/macos.json index a6ffdf14b7..de37639ddd 100644 --- a/.github/scripts/strategy-matrix/macos.json +++ b/.github/scripts/strategy-matrix/macos.json @@ -2,12 +2,7 @@ "architecture": [ { "platform": "macos/arm64", - "runner": [ - "self-hosted", - "macOS", - "ARM64", - "mac-runner-m1" - ] + "runner": ["self-hosted", "macOS", "ARM64", "mac-runner-m1"] } ], "os": [ @@ -18,10 +13,7 @@ "compiler_version": "" } ], - "build_type": [ - "Debug", - "Release" - ], + "build_type": ["Debug", "Release"], "cmake_args": [ "-Dunity=OFF -DCMAKE_POLICY_VERSION_MINIMUM=3.5", "-Dunity=ON -DCMAKE_POLICY_VERSION_MINIMUM=3.5" diff --git a/.github/scripts/strategy-matrix/windows.json b/.github/scripts/strategy-matrix/windows.json index aaa8c94411..5e6e536750 100644 --- a/.github/scripts/strategy-matrix/windows.json +++ b/.github/scripts/strategy-matrix/windows.json @@ -2,9 +2,7 @@ "architecture": [ { "platform": "windows/amd64", - "runner": [ - "windows-latest" - ] + "runner": ["windows-latest"] } ], "os": [ @@ -15,12 +13,6 @@ "compiler_version": "" } ], - "build_type": [ - "Debug", - "Release" - ], - "cmake_args": [ - "-Dunity=OFF", - "-Dunity=ON" - ] + "build_type": ["Debug", "Release"], + "cmake_args": ["-Dunity=OFF", "-Dunity=ON"] } diff --git a/.github/workflows/check-format.yml b/.github/workflows/check-format.yml index 5e3da10028..359e3e634b 100644 --- a/.github/workflows/check-format.yml +++ b/.github/workflows/check-format.yml @@ -13,9 +13,9 @@ defaults: shell: bash jobs: - clang-format: + pre-commit: runs-on: ubuntu-latest - container: ghcr.io/xrplf/ci/tools-rippled-clang-format + container: ghcr.io/xrplf/ci/tools-rippled-pre-commit steps: # The $GITHUB_WORKSPACE and ${{ github.workspace }} might not point to the # same directory for jobs running in containers. The actions/checkout step @@ -38,48 +38,11 @@ jobs: echo 'Checking environment variables.' env | sort + echo 'Checking pre-commit version.' + pre-commit --version + echo 'Checking clang-format version.' clang-format --version - - name: Format code - run: find include src tests -type f \( -name '*.cpp' -o -name '*.hpp' -o -name '*.h' -o -name '*.ipp' \) -exec clang-format -i {} + - - name: Check for differences - env: - MESSAGE: | - One or more files did not conform to the formatting specified in - .clang-format. Maybe you did not run 'git-clang-format' or - 'clang-format' before committing, or your version of clang-format - has an incompatibility with the one used here (see the "Check - configuration" step above). - - Run 'git-clang-format --extensions cpp,h,hpp,ipp develop' in your - repo, and then commit and push the changes. - run: | - DIFF=$(git status --porcelain) - if [ -n "${DIFF}" ]; then - # Print the files that changed to give the contributor a hint about - # what to expect when running git-clang-format on their own machine. - git status - echo "${MESSAGE}" - exit 1 - fi - - prettier: - runs-on: ubuntu-latest - container: ghcr.io/xrplf/ci/tools-rippled-prettier - steps: - - name: Configure git safe.directory - run: | - git config --global --add safe.directory $GITHUB_WORKSPACE - git config --global --add safe.directory ${{ github.workspace }} - - name: Checkout repository - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - - name: Check configuration - run: | - echo 'Checking path.' - echo ${PATH} | tr ':' '\n' - - echo 'Checking environment variables.' - env | sort echo 'Checking NPM version.' npm --version @@ -90,22 +53,22 @@ jobs: echo 'Checking prettier version.' prettier --version - name: Format code - run: prettier --check . + run: pre-commit run --show-diff-on-failure --color=always --all-files - name: Check for differences env: MESSAGE: | - One or more files did not conform to the formatting rules specified - by Prettier. Maybe you did not run 'prettier' before committing, or - your version of prettier has an incompatibility with the one used - here (see the "Check configuration" step above). + One or more files did not conform to the formatting. Maybe you did + not run 'pre-commit' before committing, or your version of + 'clang-format' or 'prettier' has an incompatibility with the ones + used here (see the "Check configuration" step above). - Run 'prettier --check .' in your repo, and then commit and push the - changes. + Run 'pre-commit run --all-files' in your repo, and then commit and + push the changes. run: | DIFF=$(git status --porcelain) if [ -n "${DIFF}" ]; then # Print the files that changed to give the contributor a hint about - # what to expect when running prettier on their own machine. + # what to expect when running pre-commit on their own machine. git status echo "${MESSAGE}" exit 1 diff --git a/.github/workflows/on-pr.yml b/.github/workflows/on-pr.yml index f3811c4ea4..d1623874ac 100644 --- a/.github/workflows/on-pr.yml +++ b/.github/workflows/on-pr.yml @@ -69,7 +69,7 @@ jobs: runs-on: ubuntu-latest steps: - name: No-op - run: echo '' + run: true check-format: needs: should-run @@ -86,7 +86,7 @@ jobs: runs-on: ubuntu-latest steps: - name: No-op - run: echo '' + run: true outputs: conan_remote_name: ${{ env.CONAN_REMOTE_NAME }} conan_remote_url: ${{ env.CONAN_REMOTE_URL }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7daecdb5ec..3bd60b76d0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,64 @@ -# .pre-commit-config.yaml +# To run pre-commit hooks, first install pre-commit: +# - `pip install pre-commit==${PRE_COMMIT_VERSION}` +# - `pip install pre-commit-hooks==${PRE_COMMIT_HOOKS_VERSION}` +# +# Depending on your system, you can use `brew install` or `apt install` as well +# for installing the pre-commit package, but `pip` is needed to install the +# hooks; you can also use `pipx` if you prefer. +# Next, install the required formatters: +# - `pip install clang-format==${CLANG_VERSION}` +# - `npm install prettier@${PRETTIER_VERSION}` +# +# See https://github.com/XRPLF/ci/blob/main/.github/workflows/tools-rippled.yml +# for the versions used in the CI pipeline. You will need to have the exact same +# versions of the tools installed on your system to produce the same results as +# the pipeline. +# +# Then, run the following command to install the git hook scripts: +# - `pre-commit install` +# You can run all configured hooks against all files with: +# - `pre-commit run --all-files` +# To manually run a specific hook, use: +# - `pre-commit run --all-files` +# To run the hooks against only the files changed in the current commit, use: +# - `pre-commit run` repos: - - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v18.1.8 + - repo: local hooks: - id: clang-format + name: clang-format + language: system + entry: clang-format -i + files: '\.(cpp|hpp|h|ipp|proto)$' + - id: trailing-whitespace + name: trailing-whitespace + entry: trailing-whitespace-fixer + language: system + types: [text] + - id: end-of-file + name: end-of-file + entry: end-of-file-fixer + language: system + types: [text] + - id: mixed-line-ending + name: mixed-line-ending + entry: mixed-line-ending + language: system + types: [text] + - id: check-merge-conflict + name: check-merge-conflict + entry: check-merge-conflict --assume-in-merge + language: system + types: [text] + - repo: local + hooks: + - id: prettier + name: prettier + language: system + entry: prettier --ignore-unknown --write + +exclude: | + (?x)^( + external/.*| + .github/scripts/levelization/results/.*\.txt + )$ diff --git a/.prettierignore b/.prettierignore index 477120ade1..5446323fad 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,2 +1 @@ external -.* From c57cd8b23ead8a092ff28a7be67c23d610e29c46 Mon Sep 17 00:00:00 2001 From: Ed Hennis Date: Fri, 22 Aug 2025 17:30:08 -0400 Subject: [PATCH 5/7] Revert "perf: Move mutex to the partition level (#5486)" This reverts commit 94decc753b515e7499808ca0d5b9e24d172c691e. --- include/xrpl/basics/SHAMapHash.h | 1 + include/xrpl/basics/TaggedCache.h | 26 ++- include/xrpl/basics/TaggedCache.ipp | 197 +++++++++--------- .../xrpl/basics/partitioned_unordered_map.h | 12 -- include/xrpl/protocol/Protocol.h | 1 + src/test/basics/TaggedCache_test.cpp | 24 +-- src/xrpld/app/ledger/LedgerHistory.cpp | 15 +- src/xrpld/rpc/handlers/GetCounts.cpp | 2 +- 8 files changed, 143 insertions(+), 135 deletions(-) diff --git a/include/xrpl/basics/SHAMapHash.h b/include/xrpl/basics/SHAMapHash.h index 1ec326409c..2d2dcdc3ef 100644 --- a/include/xrpl/basics/SHAMapHash.h +++ b/include/xrpl/basics/SHAMapHash.h @@ -21,6 +21,7 @@ #define RIPPLE_BASICS_SHAMAP_HASH_H_INCLUDED #include +#include #include diff --git a/include/xrpl/basics/TaggedCache.h b/include/xrpl/basics/TaggedCache.h index 7eace6fe72..99c91fe393 100644 --- a/include/xrpl/basics/TaggedCache.h +++ b/include/xrpl/basics/TaggedCache.h @@ -90,6 +90,9 @@ public: int getCacheSize() const; + int + getTrackSize() const; + float getHitRate(); @@ -167,6 +170,9 @@ public: bool retrieve(key_type const& key, T& data); + mutex_type& + peekMutex(); + std::vector getKeys() const; @@ -187,14 +193,11 @@ public: private: SharedPointerType - initialFetch(key_type const& key); + initialFetch(key_type const& key, std::lock_guard const& l); void collect_metrics(); - Mutex& - lockPartition(key_type const& key) const; - private: struct Stats { @@ -297,8 +300,8 @@ private: [[maybe_unused]] clock_type::time_point const& now, typename KeyValueCacheType::map_type& partition, SweptPointersVector& stuffToSweep, - std::atomic& allRemoval, - Mutex& partitionLock); + std::atomic& allRemovals, + std::lock_guard const&); [[nodiscard]] std::thread sweepHelper( @@ -307,12 +310,14 @@ private: typename KeyOnlyCacheType::map_type& partition, SweptPointersVector&, std::atomic& allRemovals, - Mutex& partitionLock); + std::lock_guard const&); beast::Journal m_journal; clock_type& m_clock; Stats m_stats; + mutex_type mutable m_mutex; + // Used for logging std::string m_name; @@ -323,11 +328,10 @@ private: clock_type::duration const m_target_age; // Number of items cached - std::atomic m_cache_count; + int m_cache_count; cache_type m_cache; // Hold strong reference to recent objects - std::atomic m_hits; - std::atomic m_misses; - mutable std::vector partitionLocks_; + std::uint64_t m_hits; + std::uint64_t m_misses; }; } // namespace ripple diff --git a/include/xrpl/basics/TaggedCache.ipp b/include/xrpl/basics/TaggedCache.ipp index c909ec6ad1..16a3f7587a 100644 --- a/include/xrpl/basics/TaggedCache.ipp +++ b/include/xrpl/basics/TaggedCache.ipp @@ -22,7 +22,6 @@ #include #include -#include namespace ripple { @@ -61,7 +60,6 @@ inline TaggedCache< , m_hits(0) , m_misses(0) { - partitionLocks_ = std::vector(m_cache.partitions()); } template < @@ -107,13 +105,8 @@ TaggedCache< KeyEqual, Mutex>::size() const { - std::size_t totalSize = 0; - for (size_t i = 0; i < partitionLocks_.size(); ++i) - { - std::lock_guard lock(partitionLocks_[i]); - totalSize += m_cache.map()[i].size(); - } - return totalSize; + std::lock_guard lock(m_mutex); + return m_cache.size(); } template < @@ -136,7 +129,32 @@ TaggedCache< KeyEqual, Mutex>::getCacheSize() const { - return m_cache_count.load(std::memory_order_relaxed); + std::lock_guard lock(m_mutex); + return m_cache_count; +} + +template < + class Key, + class T, + bool IsKeyCache, + class SharedWeakUnionPointer, + class SharedPointerType, + class Hash, + class KeyEqual, + class Mutex> +inline int +TaggedCache< + Key, + T, + IsKeyCache, + SharedWeakUnionPointer, + SharedPointerType, + Hash, + KeyEqual, + Mutex>::getTrackSize() const +{ + std::lock_guard lock(m_mutex); + return m_cache.size(); } template < @@ -159,10 +177,9 @@ TaggedCache< KeyEqual, Mutex>::getHitRate() { - auto const hits = m_hits.load(std::memory_order_relaxed); - auto const misses = m_misses.load(std::memory_order_relaxed); - float const total = float(hits + misses); - return hits * (100.0f / std::max(1.0f, total)); + std::lock_guard lock(m_mutex); + auto const total = static_cast(m_hits + m_misses); + return m_hits * (100.0f / std::max(1.0f, total)); } template < @@ -185,12 +202,9 @@ TaggedCache< KeyEqual, Mutex>::clear() { - for (auto& mutex : partitionLocks_) - mutex.lock(); + std::lock_guard lock(m_mutex); m_cache.clear(); - for (auto& mutex : partitionLocks_) - mutex.unlock(); - m_cache_count.store(0, std::memory_order_relaxed); + m_cache_count = 0; } template < @@ -213,9 +227,11 @@ TaggedCache< KeyEqual, Mutex>::reset() { - clear(); - m_hits.store(0, std::memory_order_relaxed); - m_misses.store(0, std::memory_order_relaxed); + std::lock_guard lock(m_mutex); + m_cache.clear(); + m_cache_count = 0; + m_hits = 0; + m_misses = 0; } template < @@ -239,7 +255,7 @@ TaggedCache< KeyEqual, Mutex>::touch_if_exists(KeyComparable const& key) { - std::lock_guard lock(lockPartition(key)); + std::lock_guard lock(m_mutex); auto const iter(m_cache.find(key)); if (iter == m_cache.end()) { @@ -281,6 +297,8 @@ TaggedCache< auto const start = std::chrono::steady_clock::now(); { + std::lock_guard lock(m_mutex); + if (m_target_size == 0 || (static_cast(m_cache.size()) <= m_target_size)) { @@ -312,13 +330,12 @@ TaggedCache< m_cache.map()[p], allStuffToSweep[p], allRemovals, - partitionLocks_[p])); + lock)); } for (std::thread& worker : workers) worker.join(); - int removals = allRemovals.load(std::memory_order_relaxed); - m_cache_count.fetch_sub(removals, std::memory_order_relaxed); + m_cache_count -= allRemovals; } // At this point allStuffToSweep will go out of scope outside the lock // and decrement the reference count on each strong pointer. @@ -352,8 +369,7 @@ TaggedCache< { // Remove from cache, if !valid, remove from map too. Returns true if // removed from cache - - std::lock_guard lock(lockPartition(key)); + std::lock_guard lock(m_mutex); auto cit = m_cache.find(key); @@ -366,7 +382,7 @@ TaggedCache< if (entry.isCached()) { - m_cache_count.fetch_sub(1, std::memory_order_relaxed); + --m_cache_count; entry.ptr.convertToWeak(); ret = true; } @@ -404,16 +420,17 @@ TaggedCache< { // Return canonical value, store if needed, refresh in cache // Return values: true=we had the data already + std::lock_guard lock(m_mutex); - std::lock_guard lock(lockPartition(key)); auto cit = m_cache.find(key); + if (cit == m_cache.end()) { m_cache.emplace( std::piecewise_construct, std::forward_as_tuple(key), std::forward_as_tuple(m_clock.now(), data)); - m_cache_count.fetch_add(1, std::memory_order_relaxed); + ++m_cache_count; return false; } @@ -462,12 +479,12 @@ TaggedCache< data = cachedData; } - m_cache_count.fetch_add(1, std::memory_order_relaxed); + ++m_cache_count; return true; } entry.ptr = data; - m_cache_count.fetch_add(1, std::memory_order_relaxed); + ++m_cache_count; return false; } @@ -543,11 +560,10 @@ TaggedCache< KeyEqual, Mutex>::fetch(key_type const& key) { - std::lock_guard lock(lockPartition(key)); - - auto ret = initialFetch(key); + std::lock_guard l(m_mutex); + auto ret = initialFetch(key, l); if (!ret) - m_misses.fetch_add(1, std::memory_order_relaxed); + ++m_misses; return ret; } @@ -611,8 +627,8 @@ TaggedCache< Mutex>::insert(key_type const& key) -> std::enable_if_t { + std::lock_guard lock(m_mutex); clock_type::time_point const now(m_clock.now()); - std::lock_guard lock(lockPartition(key)); auto [it, inserted] = m_cache.emplace( std::piecewise_construct, std::forward_as_tuple(key), @@ -652,6 +668,29 @@ TaggedCache< return true; } +template < + class Key, + class T, + bool IsKeyCache, + class SharedWeakUnionPointer, + class SharedPointerType, + class Hash, + class KeyEqual, + class Mutex> +inline auto +TaggedCache< + Key, + T, + IsKeyCache, + SharedWeakUnionPointer, + SharedPointerType, + Hash, + KeyEqual, + Mutex>::peekMutex() -> mutex_type& +{ + return m_mutex; +} + template < class Key, class T, @@ -675,13 +714,10 @@ TaggedCache< std::vector v; { + std::lock_guard lock(m_mutex); v.reserve(m_cache.size()); - for (std::size_t i = 0; i < partitionLocks_.size(); ++i) - { - std::lock_guard lock(partitionLocks_[i]); - for (auto const& entry : m_cache.map()[i]) - v.push_back(entry.first); - } + for (auto const& _ : m_cache) + v.push_back(_.first); } return v; @@ -707,12 +743,11 @@ TaggedCache< KeyEqual, Mutex>::rate() const { - auto const hits = m_hits.load(std::memory_order_relaxed); - auto const misses = m_misses.load(std::memory_order_relaxed); - auto const tot = hits + misses; + std::lock_guard lock(m_mutex); + auto const tot = m_hits + m_misses; if (tot == 0) - return 0.0; - return double(hits) / tot; + return 0; + return double(m_hits) / tot; } template < @@ -736,16 +771,18 @@ TaggedCache< KeyEqual, Mutex>::fetch(key_type const& digest, Handler const& h) { - std::lock_guard lock(lockPartition(digest)); - - if (auto ret = initialFetch(digest)) - return ret; + { + std::lock_guard l(m_mutex); + if (auto ret = initialFetch(digest, l)) + return ret; + } auto sle = h(); if (!sle) return {}; - m_misses.fetch_add(1, std::memory_order_relaxed); + std::lock_guard l(m_mutex); + ++m_misses; auto const [it, inserted] = m_cache.emplace(digest, Entry(m_clock.now(), std::move(sle))); if (!inserted) @@ -772,10 +809,9 @@ TaggedCache< SharedPointerType, Hash, KeyEqual, - Mutex>::initialFetch(key_type const& key) + Mutex>:: + initialFetch(key_type const& key, std::lock_guard const& l) { - std::lock_guard lock(lockPartition(key)); - auto cit = m_cache.find(key); if (cit == m_cache.end()) return {}; @@ -783,7 +819,7 @@ TaggedCache< Entry& entry = cit->second; if (entry.isCached()) { - m_hits.fetch_add(1, std::memory_order_relaxed); + ++m_hits; entry.touch(m_clock.now()); return entry.ptr.getStrong(); } @@ -791,13 +827,12 @@ TaggedCache< if (entry.isCached()) { // independent of cache size, so not counted as a hit - m_cache_count.fetch_add(1, std::memory_order_relaxed); + ++m_cache_count; entry.touch(m_clock.now()); return entry.ptr.getStrong(); } m_cache.erase(cit); - return {}; } @@ -826,11 +861,10 @@ TaggedCache< { beast::insight::Gauge::value_type hit_rate(0); { - auto const hits = m_hits.load(std::memory_order_relaxed); - auto const misses = m_misses.load(std::memory_order_relaxed); - auto const total = hits + misses; + std::lock_guard lock(m_mutex); + auto const total(m_hits + m_misses); if (total != 0) - hit_rate = (hits * 100) / total; + hit_rate = (m_hits * 100) / total; } m_stats.hit_rate.set(hit_rate); } @@ -861,16 +895,12 @@ TaggedCache< typename KeyValueCacheType::map_type& partition, SweptPointersVector& stuffToSweep, std::atomic& allRemovals, - Mutex& partitionLock) + std::lock_guard const&) { return std::thread([&, this]() { - beast::setCurrentThreadName("sweep-KVCache"); - int cacheRemovals = 0; int mapRemovals = 0; - std::lock_guard lock(partitionLock); - // Keep references to all the stuff we sweep // so that we can destroy them outside the lock. stuffToSweep.reserve(partition.size()); @@ -954,16 +984,12 @@ TaggedCache< typename KeyOnlyCacheType::map_type& partition, SweptPointersVector&, std::atomic& allRemovals, - Mutex& partitionLock) + std::lock_guard const&) { return std::thread([&, this]() { - beast::setCurrentThreadName("sweep-KCache"); - int cacheRemovals = 0; int mapRemovals = 0; - std::lock_guard lock(partitionLock); - // Keep references to all the stuff we sweep // so that we can destroy them outside the lock. { @@ -998,29 +1024,6 @@ TaggedCache< }); } -template < - class Key, - class T, - bool IsKeyCache, - class SharedWeakUnionPointer, - class SharedPointerType, - class Hash, - class KeyEqual, - class Mutex> -inline Mutex& -TaggedCache< - Key, - T, - IsKeyCache, - SharedWeakUnionPointer, - SharedPointerType, - Hash, - KeyEqual, - Mutex>::lockPartition(key_type const& key) const -{ - return partitionLocks_[m_cache.partition_index(key)]; -} - } // namespace ripple #endif diff --git a/include/xrpl/basics/partitioned_unordered_map.h b/include/xrpl/basics/partitioned_unordered_map.h index ecaf16a47e..4e503ad0fa 100644 --- a/include/xrpl/basics/partitioned_unordered_map.h +++ b/include/xrpl/basics/partitioned_unordered_map.h @@ -277,12 +277,6 @@ public: return map_; } - partition_map_type const& - map() const - { - return map_; - } - iterator begin() { @@ -327,12 +321,6 @@ public: return cend(); } - std::size_t - partition_index(key_type const& key) const - { - return partitioner(key); - } - private: template void diff --git a/include/xrpl/protocol/Protocol.h b/include/xrpl/protocol/Protocol.h index bd39233cca..898fd06fbd 100644 --- a/include/xrpl/protocol/Protocol.h +++ b/include/xrpl/protocol/Protocol.h @@ -22,6 +22,7 @@ #include #include +#include #include diff --git a/src/test/basics/TaggedCache_test.cpp b/src/test/basics/TaggedCache_test.cpp index ec450e46dd..3d3dba698d 100644 --- a/src/test/basics/TaggedCache_test.cpp +++ b/src/test/basics/TaggedCache_test.cpp @@ -58,10 +58,10 @@ public: // Insert an item, retrieve it, and age it so it gets purged. { BEAST_EXPECT(c.getCacheSize() == 0); - BEAST_EXPECT(c.size() == 0); + BEAST_EXPECT(c.getTrackSize() == 0); BEAST_EXPECT(!c.insert(1, "one")); BEAST_EXPECT(c.getCacheSize() == 1); - BEAST_EXPECT(c.size() == 1); + BEAST_EXPECT(c.getTrackSize() == 1); { std::string s; @@ -72,7 +72,7 @@ public: ++clock; c.sweep(); BEAST_EXPECT(c.getCacheSize() == 0); - BEAST_EXPECT(c.size() == 0); + BEAST_EXPECT(c.getTrackSize() == 0); } // Insert an item, maintain a strong pointer, age it, and @@ -80,7 +80,7 @@ public: { BEAST_EXPECT(!c.insert(2, "two")); BEAST_EXPECT(c.getCacheSize() == 1); - BEAST_EXPECT(c.size() == 1); + BEAST_EXPECT(c.getTrackSize() == 1); { auto p = c.fetch(2); @@ -88,14 +88,14 @@ public: ++clock; c.sweep(); BEAST_EXPECT(c.getCacheSize() == 0); - BEAST_EXPECT(c.size() == 1); + BEAST_EXPECT(c.getTrackSize() == 1); } // Make sure its gone now that our reference is gone ++clock; c.sweep(); BEAST_EXPECT(c.getCacheSize() == 0); - BEAST_EXPECT(c.size() == 0); + BEAST_EXPECT(c.getTrackSize() == 0); } // Insert the same key/value pair and make sure we get the same result @@ -111,7 +111,7 @@ public: ++clock; c.sweep(); BEAST_EXPECT(c.getCacheSize() == 0); - BEAST_EXPECT(c.size() == 0); + BEAST_EXPECT(c.getTrackSize() == 0); } // Put an object in but keep a strong pointer to it, advance the clock a @@ -121,24 +121,24 @@ public: // Put an object in BEAST_EXPECT(!c.insert(4, "four")); BEAST_EXPECT(c.getCacheSize() == 1); - BEAST_EXPECT(c.size() == 1); + BEAST_EXPECT(c.getTrackSize() == 1); { // Keep a strong pointer to it auto const p1 = c.fetch(4); BEAST_EXPECT(p1 != nullptr); BEAST_EXPECT(c.getCacheSize() == 1); - BEAST_EXPECT(c.size() == 1); + BEAST_EXPECT(c.getTrackSize() == 1); // Advance the clock a lot ++clock; c.sweep(); BEAST_EXPECT(c.getCacheSize() == 0); - BEAST_EXPECT(c.size() == 1); + BEAST_EXPECT(c.getTrackSize() == 1); // Canonicalize a new object with the same key auto p2 = std::make_shared("four"); BEAST_EXPECT(c.canonicalize_replace_client(4, p2)); BEAST_EXPECT(c.getCacheSize() == 1); - BEAST_EXPECT(c.size() == 1); + BEAST_EXPECT(c.getTrackSize() == 1); // Make sure we get the original object BEAST_EXPECT(p1.get() == p2.get()); } @@ -146,7 +146,7 @@ public: ++clock; c.sweep(); BEAST_EXPECT(c.getCacheSize() == 0); - BEAST_EXPECT(c.size() == 0); + BEAST_EXPECT(c.getTrackSize() == 0); } } }; diff --git a/src/xrpld/app/ledger/LedgerHistory.cpp b/src/xrpld/app/ledger/LedgerHistory.cpp index dcbd722120..ccec209bd4 100644 --- a/src/xrpld/app/ledger/LedgerHistory.cpp +++ b/src/xrpld/app/ledger/LedgerHistory.cpp @@ -63,6 +63,8 @@ LedgerHistory::insert( ledger->stateMap().getHash().isNonZero(), "ripple::LedgerHistory::insert : nonzero hash"); + std::unique_lock sl(m_ledgers_by_hash.peekMutex()); + bool const alreadyHad = m_ledgers_by_hash.canonicalize_replace_cache( ledger->info().hash, ledger); if (validated) @@ -74,6 +76,7 @@ LedgerHistory::insert( LedgerHash LedgerHistory::getLedgerHash(LedgerIndex index) { + std::unique_lock sl(m_ledgers_by_hash.peekMutex()); if (auto it = mLedgersByIndex.find(index); it != mLedgersByIndex.end()) return it->second; return {}; @@ -83,11 +86,13 @@ std::shared_ptr LedgerHistory::getLedgerBySeq(LedgerIndex index) { { + std::unique_lock sl(m_ledgers_by_hash.peekMutex()); auto it = mLedgersByIndex.find(index); if (it != mLedgersByIndex.end()) { uint256 hash = it->second; + sl.unlock(); return getLedgerByHash(hash); } } @@ -103,6 +108,7 @@ LedgerHistory::getLedgerBySeq(LedgerIndex index) { // Add this ledger to the local tracking by index + std::unique_lock sl(m_ledgers_by_hash.peekMutex()); XRPL_ASSERT( ret->isImmutable(), @@ -452,6 +458,8 @@ LedgerHistory::builtLedger( XRPL_ASSERT( !hash.isZero(), "ripple::LedgerHistory::builtLedger : nonzero hash"); + std::unique_lock sl(m_consensus_validated.peekMutex()); + auto entry = std::make_shared(); m_consensus_validated.canonicalize_replace_client(index, entry); @@ -492,6 +500,8 @@ LedgerHistory::validatedLedger( !hash.isZero(), "ripple::LedgerHistory::validatedLedger : nonzero hash"); + std::unique_lock sl(m_consensus_validated.peekMutex()); + auto entry = std::make_shared(); m_consensus_validated.canonicalize_replace_client(index, entry); @@ -525,9 +535,10 @@ LedgerHistory::validatedLedger( bool LedgerHistory::fixIndex(LedgerIndex ledgerIndex, LedgerHash const& ledgerHash) { - auto ledger = m_ledgers_by_hash.fetch(ledgerHash); + std::unique_lock sl(m_ledgers_by_hash.peekMutex()); auto it = mLedgersByIndex.find(ledgerIndex); - if (ledger && (it != mLedgersByIndex.end()) && (it->second != ledgerHash)) + + if ((it != mLedgersByIndex.end()) && (it->second != ledgerHash)) { it->second = ledgerHash; return false; diff --git a/src/xrpld/rpc/handlers/GetCounts.cpp b/src/xrpld/rpc/handlers/GetCounts.cpp index 2987da46d5..3c1d8cccdd 100644 --- a/src/xrpld/rpc/handlers/GetCounts.cpp +++ b/src/xrpld/rpc/handlers/GetCounts.cpp @@ -114,7 +114,7 @@ getCountsJson(Application& app, int minObjectCount) ret[jss::treenode_cache_size] = app.getNodeFamily().getTreeNodeCache()->getCacheSize(); ret[jss::treenode_track_size] = - static_cast(app.getNodeFamily().getTreeNodeCache()->size()); + app.getNodeFamily().getTreeNodeCache()->getTrackSize(); std::string uptime; auto s = UptimeClock::now(); From c5fe97064678ff8cdf2762acc69b814142db0757 Mon Sep 17 00:00:00 2001 From: Ed Hennis Date: Fri, 22 Aug 2025 17:32:31 -0400 Subject: [PATCH 6/7] Set version to 2.6.0-rc3 --- src/libxrpl/protocol/BuildInfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libxrpl/protocol/BuildInfo.cpp b/src/libxrpl/protocol/BuildInfo.cpp index 0d7ea1a7ca..4b55f82f49 100644 --- a/src/libxrpl/protocol/BuildInfo.cpp +++ b/src/libxrpl/protocol/BuildInfo.cpp @@ -36,7 +36,7 @@ namespace BuildInfo { // and follow the format described at http://semver.org/ //------------------------------------------------------------------------------ // clang-format off -char const* const versionString = "2.6.0-rc2" +char const* const versionString = "2.6.0-rc3" // clang-format on #if defined(DEBUG) || defined(SANITIZER) From c61096239c5d672b40e1da08c778cbb9e9d9189c Mon Sep 17 00:00:00 2001 From: Bart Date: Fri, 22 Aug 2025 19:31:01 -0400 Subject: [PATCH 7/7] chore: Remove codecov token check to support tokenless uploads on forks (#5722) --- .github/actions/build-test/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/build-test/action.yml b/.github/actions/build-test/action.yml index d68f302698..ee945dcf38 100644 --- a/.github/actions/build-test/action.yml +++ b/.github/actions/build-test/action.yml @@ -83,7 +83,7 @@ runs: ./rippled --unittest --unittest-jobs $(nproc) ctest -j $(nproc) --output-on-failure - name: Upload coverage report - if: ${{ inputs.cmake_target == 'coverage' && inputs.codecov_token }} + if: ${{ inputs.cmake_target == 'coverage' }} uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3 with: disable_search: true