Skip to content

Conversation

@kristapsk
Copy link
Contributor

Taken from #19443. There two additional arguments paginatebypointer and nextpagepointer were added and @luke-jr proposed that they could be united with existing skip argument into single options JSON argument. This is better approach than continue adding more and more different arguments for different output options. #22775 proposes to add sorting order as additional argument, I think it's better to use the same approach there too. Having this as a separate PR will make reviews and testing simpler.

Tests for old and new way of providing skip argument should be added, but didn't do it here as functional tests currently don't have tests for skip at all. I plan to add them later in a separate PR.

@ryanofsky
Copy link
Contributor

I think #19762 is a better solution to the problem of supporting large numbers of optional arguments. #19762 allows options to be specified without having to quote JSON on the command line and provides a more natural calling interface for languages like python that support named arguments. Unlike this PR, it is fully generic and does not require adding and maintaining confusing backwards compatibility code inside individual RPC method implementations.

#19762 can also be a foundation for supporting future usability improvements like being able to declare individual arguments keyword-only (only allowed to be passed by name and not position).

@luke-jr
Copy link
Member

luke-jr commented Aug 26, 2021

Concept ACK

I think #19762 is a better solution to the problem of supporting large numbers of optional arguments.

It's a good idea, but non-standard and IMO complimentary.

#19762 can also be a foundation for supporting future usability improvements like being able to declare individual arguments keyword-only (only allowed to be passed by name and not position).

This would make sense if positional use was deprecated, which it is not (and should not be sabotaged by making poor parameter positions or options unavailable).

Copy link
Member

@luke-jr luke-jr left a comment

Choose a reason for hiding this comment

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

utACK, a few minor nits

@ryanofsky
Copy link
Contributor

Concept ACK

I think #19762 is a better solution to the problem of supporting large numbers of optional arguments.

It's a good idea

Great, review is welcome.

, but non-standard

non-standard != not standardized

The "args" parameter added by #19762 is documented, but not standardized, in the exact same way the "options" parameter added by this PR is documented, but not standardized

and IMO complimentary.

Complimentary to what? It is not complimentary to this PR. It is incompatible with this PR.

#19762 can also be a foundation for supporting future usability improvements like being able to declare individual arguments keyword-only (only allowed to be passed by name and not position).

This would make sense if positional use was deprecated, which it is not

It makes sense in combination with #19762, period.

@kristapsk
Copy link
Contributor Author

functional tests currently don't have tests for skip at all

I was wrong, skip is covered by test/functional/wallet_coinbase_category.py.

@kristapsk kristapsk force-pushed the listtransactions-options branch from aab6389 to c2c53d9 Compare August 27, 2021 10:36
@kristapsk
Copy link
Contributor Author

Addressed review suggestions from @luke-jr.

@kristapsk
Copy link
Contributor Author

Removed unnecessary extra blank line inside RPCHelpMan() added by accident.

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

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

NACK 3e8b4dd220b2ddf8ae7f10808d529e4b09058180, why not just append options argument? Or in #19443 just append new arguments.

@kristapsk
Copy link
Contributor Author

kristapsk commented Aug 30, 2021

@promag That was initial way it was done, to add new positional arguments, see #14898. It was @luke-jr idea to add it instead in place of existing skip and I think it makes sense. Together skip, paginatebypointer, nextpagepointer and ascending_order can be seen as analogue to MySQL's ORDER BY x LIMIT y,z and they will be used most likely rarely, so not adding four additional positional arguments IMHO is better approach.

@promag
Copy link
Contributor

promag commented Sep 3, 2021

@kristapsk I think it's mixing 2 different things: add options parameter VS allow shorter -cli calls. If we want to simplify/improve -cli usage then I think we should try @ryanofsky approach first before "hijacking" one argument to support the other on the server-side.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure here, but previous reviews on questions like this and doc/developer-notes.md generally seemed to discourage mixing types / overloading:

- Try not to overload methods on argument type. E.g. don't make `getblock(true)`
  and `getblock("hash")` do different things.

Copy link
Member

Choose a reason for hiding this comment

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

That's about supported use, not deprecation compatibility...

Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't the old use be deprecated with planned removal then?

@DrahtBot
Copy link
Contributor

DrahtBot commented Dec 2, 2021

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.

Type Reviewers
Concept NACK promag
Concept ACK luke-jr

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

No conflicts as of last run.

@kristapsk
Copy link
Contributor Author

Could this be reopened? Will rebase.

@glozow glozow reopened this Sep 26, 2022
@kristapsk kristapsk force-pushed the listtransactions-options branch from 3e8b4dd to 29d9743 Compare September 26, 2022 19:57
@kristapsk
Copy link
Contributor Author

Rebased

@fanquake
Copy link
Member

fanquake commented Dec 6, 2022

Note that #19762, which is mentioned in the early commentary on this PR, has now recently been merged.

@maflcko
Copy link
Member

maflcko commented Jan 12, 2023

wallet/rpc/transactions.cpp:555:5: error: no matching function for call to ‘RPCHelpMan::RPCHelpMan(<brace-enclosed initializer list>)’

@kristapsk
Copy link
Contributor Author

@MarcoFalke I cannot reproduce that compiler error. Try make clean?

@maflcko
Copy link
Member

maflcko commented Jan 12, 2023

Did you run git rebase bitcoin-core/master?

@kristapsk
Copy link
Contributor Author

Did you run git rebase bitcoin-core/master?

Ok, seeing error after rebase. Will look at this.

@kristapsk kristapsk force-pushed the listtransactions-options branch from 29d9743 to c739834 Compare January 15, 2023 15:40
@kristapsk
Copy link
Contributor Author

Rebased

@kristapsk kristapsk force-pushed the listtransactions-options branch from c739834 to 500010d Compare April 12, 2023 16:21
@kristapsk
Copy link
Contributor Author

Rebased

@maflcko
Copy link
Member

maflcko commented Jul 11, 2023

I think you'll still need to rebase and fix the compile error

@kristapsk kristapsk force-pushed the listtransactions-options branch from 500010d to 7701d95 Compare July 12, 2023 20:57
Copy link
Member

Choose a reason for hiding this comment

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

wallet/rpc/transactions.cpp:441:75: error: no member named 'OMITTED_NAMED_ARG' in 'RPCArg::Optional'
                    {"options|skip", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED_NAMED_ARG, "for backward compatibility: passing in a number instead of an object will result in {\"skip\":nnn}",
                                                        ~~~~~~~~~~~~~~~~~~^
wallet/rpc/transactions.cpp:508:9: error: use of undeclared identifier 'RPCTypeCheckArgument'
        RPCTypeCheckArgument(options, UniValue::VOBJ);
        ^
2 errors generated.

@kristapsk kristapsk force-pushed the listtransactions-options branch from 7701d95 to 3a88c29 Compare July 13, 2023 13:30
@kristapsk
Copy link
Contributor Author

Now it builds, but backwards compatibility with passing number instead of object as a third parameter is broken, will look at it later.

@maflcko
Copy link
Member

maflcko commented Jul 21, 2023

Maybe mark as draft/WIP for as long as this is still WIP?

@kristapsk kristapsk marked this pull request as draft July 21, 2023 09:34
@maflcko
Copy link
Member

maflcko commented Sep 20, 2023

Are you still working on this? If not, maybe close for now

@kristapsk
Copy link
Contributor Author

Are you still working on this? If not, maybe close for now

Will try to look at this. There was bug after rebase (see comment above), need to go through other code changes to understand properly what has changed and what causes the issue.

@glozow
Copy link
Member

glozow commented Dec 20, 2023

Are you still working on this?

@kristapsk
Copy link
Contributor Author

Are you still working on this?

Not at the moment. Feel free to close. Will open a new PR in future if will get back to this.

@maflcko maflcko closed this Dec 20, 2023
@bitcoin bitcoin locked and limited conversation to collaborators Dec 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants