Skip to content

Conversation

Prabhat1308
Copy link
Contributor

followup of #29007 , implements adding of test-only RPC options in -test as discussed here

Currently a general user has access to test-only RPCs , where user might accidentally use it in production. This PR splits off test-only RPCs to be included in -test flag with additional restrictions of use in regtest segregating the user facing and testing RPCs . These test-only RPCs are split off from args and have their own method to extract arguments .

Current implementation of test-only RPCs follow this convention
-test=<command>=<argument> .
The test-only rpcs with ArgsManager::DEBUG_ONLY with OptionsCategory::DEBUG_TEST options have been added.

Additional info

Two more test-only arguments -checkpoints and -deprecatedrpc=<method> are excluded from this PR because of the requirement of their tests to be run on either testnet or testnet3.

This adds the test-only rpcs that require bool arguments to
`test-option-doc`
Adds helper function to extract bool arguments from test-only rpc
included in the `-test` flags. Adds one implementation for CI
passing
Adds test-only rpcs involving integer arguments to the `test-option-doc`
Adds helper function to extract int arguments from the test-only
rpcs included in the `-test` flag. Added one function implementation
for CI passing
Adds test-only RPCs to `test=<option>` involving Boolean arguments.
Uses `HasTestOptionBool()` to extract boolean arguments
Refactors the test-only RPCs to be included in the
`test=<option>` flag. Uses `HasTestOptionInt>` to
extract integer arguments from the flags
Adds Helper function `HasTestOptionString` to extract string
argument from test-only RPCs under `-test=<option>`.

Removes the redundant check for chain in `acceptstalefeeestimates` as
there is a similar check when passing this RPC using `-test` flag
@DrahtBot
Copy link
Contributor

DrahtBot commented Aug 26, 2024

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.
A summary of reviews will appear here.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #30712 (fuzz: Add missing fuzz targets to cmake build by maflcko)
  • #30592 (Remove mempoolfullrbf by instagibbs)
  • #30454 (build: Introduce CMake-based build system by hebasto)
  • #30232 (refactor: policy: Pass kernel::MemPoolOptions to IsStandard[Tx] rather than long list of individual options by luke-jr)
  • #29553 (assumeutxo: Add dumptxoutset height param, remove shell scripts by fjahr)
  • #28802 (ArgsManager: support subcommand-specific options by ajtowns)
  • #26022 (Add util::ResultPtr class by ryanofsky)
  • #25665 (refactor: Add util::Result failure values, multiple error and warning messages by ryanofsky)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

Copy link
Contributor

@murchandamus murchandamus left a comment

Choose a reason for hiding this comment

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

Looking at the discussion in #29007, I had the impression that it was suggested to move some RPC options to a "test-only" grouping, so I’m a bit surprised that this PR also moves a number of startup options to "test-only". At least a few from that list appear to be used in production, e.g. by people operating mempool explorers.

Comment on lines +695 to +701
"deprecatedrpc (Allows deprecated RPC method(s) to be used)",
"stopafterblockimport (Stop running after importing blocks from disk )",
"stopatheight (Stop running after reaching the given height in the main chain)",
"limitancestorcount (Do not accept transactions if number of in-mempool ancestors is <n> or more)",
"limitancestorsize (Do not accept transactions whose size with all in-mempool ancestors exceeds <n> kilobytes)",
"limitdescendantcount (Do not accept transactions if any ancestor would have <n> or more in-mempool descendants)",
"limitdescendantsize (Do not accept transactions if any ancestor would have descendants exceeding <n> kilobytes)",
Copy link
Contributor

@murchandamus murchandamus Aug 26, 2024

Choose a reason for hiding this comment

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

From what I understand, at least the startup options deprecatedrpc, stopatheight, limitancestorcount, limitancestorsize, limitdescendantcount, and limitdescendantsize are used in production by some users.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the arguments description in init.cpp they are categorised as DEBUG_ONLY AND DEBUG_TEST which is where I picked them up to be "test-only". There was not much documentation elsewhere to decide otherwise.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. What’s the overarching intent here: is the purpose just to label them more explicitly as being for testing, or is the intent to restrict their use to test networks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are restricting its use in test networks only specifically to regtest only . the -test flag has a check to assert use of regtest.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I have to withdraw limitancestorcount, limitancestorsize, limitdescendantcount, and limitdescendantsize. Both parties that I suspected to use these startup options, in fact, do not use them. We definitely used stopatheight at a prior employer while indexing the blockchain, and my understanding was that deprecatedrpc was meant to give users a heads-up that an RPC would be going away with the next release, but not completely requiring an immediate transitioning away from it.

Copy link
Contributor

Choose a reason for hiding this comment

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

stopatheight is also frequently used for benchmarks on mainnet, most recently in #28280. The -checkXYZ startup options that can help debug issues on all networks and I've run some of them on several occasions on mainnet and signet.

Many of the options are debug-only because they are meant to only be used by devs testing new things, but that doesn't mean they can only be useful regtest - often it's helpful to test things on other networks too.

I think that restricting to regtest should only be done with options specifically introduced for the test suite that don't make sense anywhere else.

Copy link
Contributor

Choose a reason for hiding this comment

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

makes sense. moving regtest only options to -test=<opt> would make the interface(dev-testing/more-debug-info vs regtest-only) less confusing. (other than test=addrman), regtest-only would include: fastprune, mocktime, acceptstalefeeestimates.
I think peertimeout and rpcdoccheck are only used in tests, so you could include them too

@DrahtBot
Copy link
Contributor

🚧 At least one of the CI tasks failed.
Debug: https://github.com/bitcoin/bitcoin/runs/29266802249

Hints

Make sure to run all tests locally, according to the documentation.

The failure may happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

@DrahtBot
Copy link
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

@achow101
Copy link
Member

This PR does not seem to have attracted much attention from reviewers. As such, it does not seem important enough right now to keep it sitting idle in the list of open PRs.

Closing due to lack of interest.

@achow101 achow101 closed this Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants