Sponsored Content
Skip to content

fix: Fix regressions in server_definitions - #7008

Merged
bthomee merged 11 commits into
developfrom
mvadari/fix-defs
May 5, 2026
Merged

fix: Fix regressions in server_definitions#7008
bthomee merged 11 commits into
developfrom
mvadari/fix-defs

Conversation

@mvadari

@mvadari mvadari commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

High Level Overview of Change

This PR fixes regressions in the output of server_definitions, namely:

  • The FIELDS array was not sorted by field value
  • sfGeneric was listed twice in the FIELDS array

Context of Change

These regressions were missed in #5590, caught by @pdp2121.

API Impact

Only fixes, no API format change

Copilot AI review requested due to automatic review settings April 23, 2026 20:55
Comment thread src/libxrpl/protocol/SField.cpp Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This constructor is only used by sfGeneric and sfInvalid

@mvadari
mvadari requested review from godexsoft and ximinez April 23, 2026 20:57

@xrplf-ai-reviewer xrplf-ai-reviewer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues.

Review by Claude Opus 4.6 · Prompt: V15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to restore expected server_definitions output behavior by making the FIELDS section deterministic and removing a duplicate sfGeneric entry that was introduced in #5590.

Changes:

  • Remove the manual Generic insertion and prevent duplicates between manually-added fields and registered SFields.
  • Make FIELDS ordering deterministic by iterating over a sorted view of SField::getKnownCodeToField().
  • Update server_definitions unit tests to reflect the new ordering and add a duplicate-name check.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/xrpld/rpc/handlers/server_info/ServerDefinitions.cpp Switches FIELDS generation to a deterministic, sorted iteration and filters out manually-added field names to avoid duplicates.
src/test/rpc/ServerDefinitions_test.cpp Updates assertions for the new FIELDS ordering and adds a no-duplicates check.
src/libxrpl/protocol/SField.cpp Adjusts default signing-field behavior for the (fieldCode, name) SField constructor (affecting sfGeneric / sfInvalid).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/xrpld/rpc/handlers/server_info/ServerDefinitions.cpp
Comment on lines +52 to +56
auto const field = result[jss::result][jss::FIELDS][6u];
BEAST_EXPECT(field[0u].asString() == "LedgerEntryType");
BEAST_EXPECT(field[1][jss::isSerialized].asBool() == true);
BEAST_EXPECT(field[1][jss::isSigningField].asBool() == true);
BEAST_EXPECT(field[1][jss::isVLEncoded].asBool() == false);

Copilot AI Apr 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The assertion that FIELDS[6] is LedgerEntryType is brittle: adding any new SField with a smaller sort key will shift indices even if ordering is still correct. Consider locating the field by name (and then asserting its properties) and/or asserting the ordering property directly instead of relying on a hard-coded index.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's done on purpose. Everything below it is hard-coded.

@codecov

codecov Bot commented Apr 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.1%. Comparing base (d050073) to head (062d70c).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #7008     +/-   ##
=========================================
- Coverage     82.1%   82.1%   -0.0%     
=========================================
  Files         1010    1010             
  Lines        76033   76024      -9     
  Branches      7379    7373      -6     
=========================================
- Hits         62426   62392     -34     
- Misses       13607   13632     +25     
Files with missing lines Coverage Δ
...pld/rpc/handlers/server_info/ServerDefinitions.cpp 98.0% <100.0%> (-0.1%) ⬇️

... and 11 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@godexsoft godexsoft left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks alright to me. Please address copilot's concerns 👍

@xrplf-ai-reviewer xrplf-ai-reviewer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues.

Review by Claude Opus 4.6 · Prompt: V15

@ximinez ximinez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not super-familiar with ServerDefinitions, but the changes look right, aside from the couple of comments below.

Comment thread src/libxrpl/protocol/SField.cpp Outdated
, fieldMeta(sMD_Never)
, fieldNum(++num)
, signingField(IsSigning::yes)
, signingField(IsSigning::no)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been yes for 11 years (and true before that). I'm not entirely clear on why it needs to change. Could you explain what's going on?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sfGeneric also used to be labeled as IsSigning::no in the definitions.json output, so one of those is wrong then.

This constructor is only used for these two SFields, to clarify:

SField const sfInvalid(access, -1, "");
SField const sfGeneric(access, 0, "Generic");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sfGeneric also used to be labeled as IsSigning::no in the definitions.json output, so one of those is wrong then.

This constructor is only used for these two SFields, to clarify:

That makes sense.

However, it looks like the only reason sfGeneric was listed as non-signing is because it had been hard-coded. https://github.com/XRPLF/rippled/pull/7008/changes#diff-c9864c2527cd17eeac088af7a96edca5f1347208dc6b77a4317e3427cc2dca36L158-L160. This PR removes that hard-coding.

My concern is that even though these fields are only used as placeholders, and never intentionally used in transaction data, they may be ignored if they ever found their way into transaction data. E.g. through a bug, or perhaps a malicious injection into serialized data / protocol messages.

Please feel free to disagree, but I think the way forward here is to

  1. revert the change SField.cpp back to IsSigning::Yes,
  2. and then in ServerDefinitions.cpp either
    • Put the hard-coded "Generic" back, and skip over it when found in the loop (if (field->fieldName.empty() || field->fieldName == "Generic") continue;,
    • OR put an override in the assignment. innerObj[jss::isSigningField] = field->fieldName == "Generic" ? false : field->shouldInclude(false);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can skip step 2 if you're okay with labeling sfGeneric as isSigningField: true since it seems that that's more accurate.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can skip step 2 if you're okay with labeling sfGeneric as isSigningField: true since it seems that that's more accurate.

Yeah, I'm very happy with that! I didn't realize that was an acceptable outcome. 😀

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just assumed what was there before was the desired answer, based on this conversation that's not the case :)

Comment thread src/xrpld/rpc/handlers/server_info/ServerDefinitions.cpp
Copilot AI review requested due to automatic review settings April 30, 2026 18:56

@xrplf-ai-reviewer xrplf-ai-reviewer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a look at this

The static_assert introduced for STI_VECTOR256 uses 15U instead of 19U — this will fail to compile. See inline.


Review by ReviewBot 🤖

Review by Claude Opus 4.6 · Prompt: V15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/xrpld/rpc/handlers/server_info/ServerDefinitions.cpp Outdated

@xrplf-ai-reviewer xrplf-ai-reviewer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues.

Review by Claude Opus 4.6 · Prompt: V15

@github-actions

github-actions Bot commented May 3, 2026

Copy link
Copy Markdown

This PR has conflicts, please resolve them in order for the PR to be reviewed.

@godexsoft

Copy link
Copy Markdown
Contributor

We recently merged a refactor to develop that enables clang-tidy's readability-identifier-naming. Your branch now has heavy conflicts that are largely mechanical. Below is a workflow that aligns your branch's naming with develop before merging, which should minimize the merge conflicts.

One-time setup

If you don't already have clang-tidy working in your env, on macOS:

brew install llvm@21
# Follow brew's hint to put $(brew --prefix llvm@21)/bin on PATH so run-clang-tidy is found.

Workflow on your branch (before merging develop)

1. Grab the new .clang-tidy from develop without pulling anything else. Sync your fork on GitHub first, then:

git remote -v   # should show 'upstream' among others; if not:
# git remote set-url upstream git@github.com:XRPLF/rippled.git
git fetch upstream
git checkout upstream/develop -- .clang-tidy

2. Reconfigure conan/cmake so compile_commands.json is fresh.

3. Apply renames for the files modified in your PR:

git diff --name-only $(git merge-base HEAD upstream/develop) HEAD \
  | grep -E '\.(cpp|h|hpp|ipp)$' \
  | xargs run-clang-tidy -p build -fix -allow-no-checks
# or -p .build, or whatever your build dir is called

4. Build + test, then commit as a single dedicated commit:

cmake --build build -j8
git commit -am "refactor: Align identifier naming with develop"

5. Now merge develop:

git merge upstream/develop

Extra

Run clang-tidy once more after the merge to catch any stragglers introduced from develop's side:

run-clang-tidy -p build -fix -allow-no-checks src tests
# or -p .build, or whatever your build dir is called

Copilot AI review requested due to automatic review settings May 4, 2026 17:00
@github-actions

github-actions Bot commented May 4, 2026

Copy link
Copy Markdown

All conflicts have been resolved. Assigned reviewers can now start or resume their review.

@xrplf-ai-reviewer xrplf-ai-reviewer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues.

Review by Claude Opus 4.6 · Prompt: V15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

src/xrpld/rpc/handlers/server_info/ServerDefinitions.cpp:246

  • After removing the hard-coded "Generic" entry, the remaining "Generic" row will now be generated from kSF_GENERIC (which has fieldType == STI_UNKNOWN). With the current predicate (type < 10000 && name != "hash" && name != "index"), that makes Generic.isSerialized evaluate to true, which differs from the previous explicit isSerialized=false semantics for Generic and is likely misleading for an STI_UNKNOWN placeholder field. Consider excluding STI_UNKNOWN (and/or field->fieldCodeMem <= 0 / !field->isUseful()) from the isSerialized predicate, or reintroduce a dedicated exception entry for Generic and skip it in the loop to preserve the intended output contract.
        // whether the field is included in serialization
        innerObj[jss::isSerialized] =
            (type < 10000 && field->fieldName != "hash" &&
             field->fieldName !=
                 "index");  // hash, index, TRANSACTION, LEDGER_ENTRY, VALIDATION, METADATA


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@xrplf-ai-reviewer xrplf-ai-reviewer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues.

Review by Claude Opus 4.6 · Prompt: V15

@mvadari mvadari added the Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required. label May 5, 2026
Copilot AI review requested due to automatic review settings May 5, 2026 16:42

@xrplf-ai-reviewer xrplf-ai-reviewer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues.

Review by Claude Opus 4.6 · Prompt: V15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@bthomee bthomee changed the title fix: Regressions in server_definitions fix: Fix regressions in server_definitions May 5, 2026
@bthomee
bthomee added this pull request to the merge queue May 5, 2026
Merged via the queue into develop with commit 5e1c35f May 5, 2026
1 check passed
@bthomee
bthomee deleted the mvadari/fix-defs branch May 5, 2026 18:02
@mvadari mvadari added this to the 3.2.0 milestone May 20, 2026
beartec-jpg pushed a commit to beartec-jpg/FalconLedger that referenced this pull request Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants