refactor: Fix sfGeneric and sfInvalid field names - #7300
Conversation
There was a problem hiding this comment.
Pull request overview
This PR reverts the special SField globals kSfGeneric/kSfInvalid back to their historical names sfGeneric/sfInvalid, updating all internal call sites accordingly.
Changes:
- Rename all usages of
kSfGeneric→sfGenericandkSfInvalid→sfInvalidacross core code and tests. - Update
SFielddefinitions andSField::getField(...)fallbacks to returnsfInvalid. - Update public header declarations (and
STBlobdefault parameter) to usesfGeneric/sfInvalid.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/xrpld/rpc/handlers/transaction/Simulate.cpp | Uses sfGeneric when deserializing tx blob into an STObject. |
| src/tests/libxrpl/protocol_autogen/TestHelpers.h | Updates autogen test helper to construct STObject{sfGeneric}. |
| src/test/rpc/Simulate_test.cpp | Updates simulate RPC tests to deserialize with sfGeneric. |
| src/test/protocol/STTx_test.cpp | Updates test-created STObject to use sfGeneric. |
| src/test/protocol/STObject_test.cpp | Updates tests to reference sfGeneric/sfInvalid. |
| src/test/protocol/STAmount_test.cpp | Updates STAmount deserialization to use sfGeneric. |
| src/test/protocol/Hooks_test.cpp | Updates dummy STObject creation to use sfGeneric. |
| src/test/overlay/compression_test.cpp | Updates STObject creation to use sfGeneric. |
| src/test/jtx/TrustedPublisherServer.h | Updates manifest-ish object construction to use sfGeneric. |
| src/test/jtx/impl/TestHelpers.cpp | Updates amountFromJson calls to use sfGeneric. |
| src/test/app/ValidatorList_test.cpp | Updates validator list object construction to use sfGeneric. |
| src/test/app/Path_test.cpp | Updates amountFromJson calls to use sfGeneric. |
| src/test/app/Manifest_test.cpp | Updates manifest-related object construction to use sfGeneric. |
| src/libxrpl/server/Manifest.cpp | Uses sfGeneric for manifest deserialization and hashing/verification helpers. |
| src/libxrpl/protocol/XChainAttestations.cpp | Uses sfGeneric for attestation message STObject construction. |
| src/libxrpl/protocol/STParsedJSON.cpp | Updates comparisons/entrypoints to use sfGeneric/sfInvalid. |
| src/libxrpl/protocol/STBase.cpp | Sets default STBase field name pointer to sfGeneric. |
| src/libxrpl/protocol/STAmount.cpp | Updates amountFromJsonNoThrow to call amountFromJson(sfGeneric, ...). |
| src/libxrpl/protocol/SField.cpp | Renames the special global SField instances and updates invalid-field fallbacks. |
| include/xrpl/protocol/STBlob.h | Changes default SerialIter ctor param from kSfGeneric to sfGeneric. |
| include/xrpl/protocol/SField.h | Exports sfInvalid/sfGeneric instead of kSfInvalid/kSfGeneric. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| SField const sfInvalid(access, -1, ""); | ||
| SField const sfGeneric(access, 0, "Generic"); |
| #define TYPED_SFIELD(sfName, stiSuffix, fieldValue, ...) extern SF_##stiSuffix const sfName; | ||
|
|
||
| extern SField const kSfInvalid; | ||
| extern SField const kSfGeneric; | ||
| extern SField const sfInvalid; // NOLINT(readability-identifier-naming) | ||
| extern SField const sfGeneric; // NOLINT(readability-identifier-naming) |
godexsoft
left a comment
There was a problem hiding this comment.
Thanks for changing them back. We should maybe change them all to what clang-tidy dictates in the future. I did not do it because of python scripts using them iirc.. but we can make it all work later on 👍
I mostly care about consistency across all sfields, we should change them all of we want to change them. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #7300 +/- ##
=========================================
- Coverage 82.1% 82.1% -0.0%
=========================================
Files 1010 1010
Lines 76167 76167
Branches 7423 7413 -10
=========================================
- Hits 62514 62506 -8
- Misses 13653 13661 +8
🚀 New features to boost your workflow:
|
High Level Overview of Change
This PR re-renames the
kSfGenericandkSfInvalidfields back tosfGenericandsfInvalid.Context of Change
#7120 renamed them
API Impact
N/A