Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support canonical ledger entry names #5271

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

bthomee
Copy link
Collaborator

@bthomee bthomee commented Feb 1, 2025

High Level Overview of Change

This change implements #4393, which enhances the filtering in the ledger, ledger_data, and account_objects methods by also supporting filtering by the canonical name of the LedgerEntryType using case-insensitive matching.

Context of Change

Currently the mapping between the RPC name to provide as filter and the LedgerEntryType is inconsistent and sometimes surprising. For example, to match the DirectoryNode the provided RPC name is directory, while for PayChannel it is payment_channel.

This change enables filtering on the canonical name as well to make the mapping consistent and unsurprising. For instance, to filter on PayChannel it is still possible to specify payment_channel, but now it's also possible to specify PayChannel and paychannel (or any variant thereof using different casing).

Type of Change

  • New feature (non-breaking change which adds functionality)

API Impact

  • Public API: New feature (new methods and/or new fields)

Before / After

See #4393 for an excellent description.

Copy link

codecov bot commented Feb 1, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.1%. Comparing base (33e1c42) to head (9b501bd).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           develop   #5271   +/-   ##
=======================================
  Coverage     78.1%   78.1%           
=======================================
  Files          790     790           
  Lines        67556   67557    +1     
  Branches      8158    8155    -3     
=======================================
+ Hits         52785   52793    +8     
+ Misses       14771   14764    -7     
Files with missing lines Coverage Δ
src/xrpld/rpc/detail/RPCHelpers.cpp 82.8% <100.0%> (+<0.1%) ⬆️

... and 3 files with indirect coverage changes

Impacted file tree graph

@mvadari
Copy link
Collaborator

mvadari commented Feb 3, 2025

Why deprecate the old filter names? Why not support both?

@bthomee
Copy link
Collaborator Author

bthomee commented Feb 3, 2025

Why deprecate the old filter names? Why not support both?

@mDuo13 can you respond? In the issue you had raised you mentioned "For backwards compatibility, continue to also support the existing short names (but mark them deprecated in the documentation)." - are there requests from the community to deprecate that field to reduce confusion, or is there another reason?

@mDuo13
Copy link
Collaborator

mDuo13 commented Feb 3, 2025

The reason to mark it deprecated is so that we can move away from needing a short name for new ledger entries (a dev task that was often forgotten in the past anyway). There should be one preferred way to look up ledger entry types, by their canonical name (case-insensitive).

It's fine if the existing, "deprecated" shortcut names are supported indefinitely too.

@bthomee bthomee requested a review from godexsoft February 4, 2025 18:18
@mvadari
Copy link
Collaborator

mvadari commented Feb 5, 2025

Maybe this is an unpopular opinion but I actually like the lower-case names, and think we should keep them.

note: I have no objection to adding additional filter names, just to deprecating/replacing the existing setup.

@bthomee
Copy link
Collaborator Author

bthomee commented Feb 5, 2025

Maybe this is an unpopular opinion but I actually like the lower-case names, and think we should keep them.

note: I have no objection to adding additional filter names, just to deprecating/replacing the existing setup.

I have no particular opinion here or sufficient background to know how people use this API, but do note that this PR explicitly adds support for case-insensitive filtering; so lowercase names are definitely possible.

Copy link
Collaborator

@godexsoft godexsoft left a comment

Choose a reason for hiding this comment

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

Just leaving a suggestion. Looks good overall 👍

static constexpr auto types =
std::to_array<std::pair<char const*, LedgerEntryType>>({
static constexpr auto types = std::to_array<
std::tuple<char const*, char const*, LedgerEntryType>>({
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: For readability, consider a small struct instead of the tuple.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I figured that if we're going to deprecate the current way of referencing ledger entries, then the next release we can return to using a std::pair - which would be preferred over a dedicated struct.

@bthomee
Copy link
Collaborator Author

bthomee commented Feb 7, 2025

Maybe this is an unpopular opinion but I actually like the lower-case names, and think we should keep them.
note: I have no objection to adding additional filter names, just to deprecating/replacing the existing setup.

I have no particular opinion here or sufficient background to know how people use this API, but do note that this PR explicitly adds support for case-insensitive filtering; so lowercase names are definitely possible.

@mDuo13 & @mvadari, let's discuss whether or not to deprecate the existing setup. In particular, @mDuo13 raised some good points, so @mvadari do you feel strongly about that we should keep the existing, frequently odd, naming convention & the increased burden in remembering to add such a separate name for each new ledger entry type?

@mvadari
Copy link
Collaborator

mvadari commented Feb 7, 2025

Maybe this is an unpopular opinion but I actually like the lower-case names, and think we should keep them.
note: I have no objection to adding additional filter names, just to deprecating/replacing the existing setup.

I have no particular opinion here or sufficient background to know how people use this API, but do note that this PR explicitly adds support for case-insensitive filtering; so lowercase names are definitely possible.

@mDuo13 & @mvadari, let's discuss whether or not to deprecate the existing setup. In particular, @mDuo13 raised some good points, so @mvadari do you feel strongly about that we should keep the existing, frequently odd, naming convention & the increased burden in remembering to add such a separate name for each new ledger entry type?

The rpcName got added to the ledger entry macro in #5202, so that should make it much easier to keep everything aligned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants