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

RPC: Return permitbaremultisig and maxdatacarriersize in getmempoolinfo #29954

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

Conversation

kristapsk
Copy link
Contributor

Other node relay settings like fullrbf and minrelaytxfee are already returned, makes sense to add these two too.

@DrahtBot
Copy link
Contributor

DrahtBot commented Apr 24, 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.

Type Reviewers
Concept ACK tdb3

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #29086 (refactor: Simply include CTxMemPool::Options in CTxMemPool directly rather than duplicating definition by luke-jr)
  • #28676 ([WIP] Cluster mempool implementation by sdaftuar)

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.

src/rpc/mempool.cpp Outdated Show resolved Hide resolved
@@ -70,6 +70,8 @@ def run_test(self):
node = self.nodes[0]
self.wallet = MiniWallet(node)

assert_equal(node.getmempoolinfo()['permitbaremultisig'], False)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could have a test with the True case?

Copy link
Contributor

@tdb3 tdb3 Apr 28, 2024

Choose a reason for hiding this comment

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

I second this. It would add value to have tests that cover:

  1. permitbaremultisig disabled
  2. permitbaremultisig enabled

This might be accomplished through the use of a second node (self.num_nodes) or perhaps through stopping the node, modifying configuration with replace_in_config(), and restarting it. Typically num_nodes is to be minimized and start/stops avoided when possible, but I do not immediately see how different permitbaremultisig states could be tested without doing one of the two (see https://github.com/bitcoin/bitcoin/blob/master/test/functional/README.md#general-test-writing-advice). Maybe it's a bit overkill, but we would want to know that the code behind the RPC on bitcoind still works if there are changes in the future.

Co-authored-by: Andrew Toth <andrewstoth@gmail.com>
Copy link
Contributor

@tdb3 tdb3 left a comment

Choose a reason for hiding this comment

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

Concept ACK.
Thank you. Appears to work well. Seems helpful to me for clients to have this information provided through RPC. I took a quick look at other RPC calls (in https://bitcoincore.org/en/doc/27.0.0/), but didn't see any that had permitbaremultisig and maxdatacarriersize.

Recently, Issue #29912 was opened, which discusses implementing a formal specification for the RPC API. RPC API changes have the potential to adjust the meaning, fields/types, and/or values used in or returned by the API (see also #29845 (comment) for a recent discussion on a type change). Overall, it's a reasonable idea to be very careful when changing the RPC API, as there is a ripple effect to downstream clients and can cause issues/bugs for them.

That being said, the specific change in this PR seems pretty low risk to me, since it is adding two items to the existing result object returned, rather than changing the type returned, the meaning/value, or the other fields. Per https://github.com/bitcoin/bitcoin/blob/master/doc/JSON-RPC-interface.md#versioning, we already declare that RPC can change in major releases. I wrote this comment to increase awareness in case others have input.

This PR:

$ src/bitcoin-cli getmempoolinfo
{
  "loaded": true,
  "size": 0,
  "bytes": 0,
  "usage": 32,
  "total_fee": 0.00000000,
  "maxmempool": 300000000,
  "mempoolminfee": 0.00001000,
  "minrelaytxfee": 0.00001000,
  "incrementalrelayfee": 0.00001000,
  "unbroadcastcount": 0,
  "fullrbf": false,
  "permitbaremultisig": true,
  "maxdatacarriersize": 83
}
$ curl --user __cookie__ --data-binary '{"id": "curltest", "method": "getmempoolinfo", "params": []}' -H 'content-type: text/plain;' http://127.0.0.1:38332/
Enter host password for user '__cookie__':
{"result":{"loaded":true,"size":0,"bytes":0,"usage":32,"total_fee":0.00000000,"maxmempool":300000000,"mempoolminfee":0.00001000,"minrelaytxfee":0.00001000,"incrementalrelayfee":0.00001000,"unbroadcastcount":0,"fullrbf":false,"permitbaremultisig":true,"maxdatacarriersize":83},"error":null,"id":"curltest"}

Master branch (3aaf732 at the the time):

$ src/bitcoin-cli getmempoolinfo
{
  "loaded": true,
  "size": 0,
  "bytes": 0,
  "usage": 32,
  "total_fee": 0.00000000,
  "maxmempool": 300000000,
  "mempoolminfee": 0.00001000,
  "minrelaytxfee": 0.00001000,
  "incrementalrelayfee": 0.00001000,
  "unbroadcastcount": 0,
  "fullrbf": false
}
$ curl --user __cookie__ --data-binary '{"id": "curltest", "method": "getmempoolinfo", "params": []}' -H 'content-type: text/plain;' http://127.0.0.1:38332/
Enter host password for user '__cookie__':
{"result":{"loaded":true,"size":0,"bytes":0,"usage":32,"total_fee":0.00000000,"maxmempool":300000000,"mempoolminfee":0.00001000,"minrelaytxfee":0.00001000,"incrementalrelayfee":0.00001000,"unbroadcastcount":0,"fullrbf":false},"error":null,"id":"curltest"}

Also left some inline comments/suggestions.

@@ -70,6 +70,8 @@ def run_test(self):
node = self.nodes[0]
self.wallet = MiniWallet(node)

assert_equal(node.getmempoolinfo()['permitbaremultisig'], False)
Copy link
Contributor

@tdb3 tdb3 Apr 28, 2024

Choose a reason for hiding this comment

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

I second this. It would add value to have tests that cover:

  1. permitbaremultisig disabled
  2. permitbaremultisig enabled

This might be accomplished through the use of a second node (self.num_nodes) or perhaps through stopping the node, modifying configuration with replace_in_config(), and restarting it. Typically num_nodes is to be minimized and start/stops avoided when possible, but I do not immediately see how different permitbaremultisig states could be tested without doing one of the two (see https://github.com/bitcoin/bitcoin/blob/master/test/functional/README.md#general-test-writing-advice). Maybe it's a bit overkill, but we would want to know that the code behind the RPC on bitcoind still works if there are changes in the future.

@@ -677,6 +677,8 @@ UniValue MempoolInfoToJSON(const CTxMemPool& pool)
ret.pushKV("incrementalrelayfee", ValueFromAmount(pool.m_incremental_relay_feerate.GetFeePerK()));
ret.pushKV("unbroadcastcount", uint64_t{pool.GetUnbroadcastTxs().size()});
ret.pushKV("fullrbf", pool.m_full_rbf);
ret.pushKV("permitbaremultisig", pool.m_permit_bare_multisig);
ret.pushKV("maxdatacarriersize", (pool.m_max_datacarrier_bytes ? *pool.m_max_datacarrier_bytes : 0));
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason to name it something different here? Especially while the option is still broken and doesn't actually limit datacarriers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was expecting this comment from you. :)

Named it same way as existing startup / config option (-datacarriersize), but I'm open to other names, as in fact it only limits OP_RETURN. What name seems to be good from Knots perspective? It would be good to not unnecessary break compatibility between Core and Knots.

Copy link
Member

Choose a reason for hiding this comment

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

Well, you added "max" in front. I guess it makes sense, but might be surprising.

It's not clear what compatibility would mean before Core has fixed it to actually work.

Copy link
Member

Choose a reason for hiding this comment

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

I slightly prefer it being called datacarriersize to match the config option, but don't feel strongly

@luke-jr
Copy link
Member

luke-jr commented May 8, 2024

I wonder if a sub-object would be a good idea before we start adding more settings here. There's at least also m_expiry that would make sense to add too.

@luke-jr
Copy link
Member

luke-jr commented May 8, 2024

Actually, since these don't change on their own... maybe a separate RPC altogether? (later extended to allow some changes?)

Copy link
Member

@glozow glozow left a comment

Choose a reason for hiding this comment

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

This seems useful, and makes sense as a field of getmempoolinfo like the others

@@ -677,6 +677,8 @@ UniValue MempoolInfoToJSON(const CTxMemPool& pool)
ret.pushKV("incrementalrelayfee", ValueFromAmount(pool.m_incremental_relay_feerate.GetFeePerK()));
ret.pushKV("unbroadcastcount", uint64_t{pool.GetUnbroadcastTxs().size()});
ret.pushKV("fullrbf", pool.m_full_rbf);
ret.pushKV("permitbaremultisig", pool.m_permit_bare_multisig);
ret.pushKV("maxdatacarriersize", (pool.m_max_datacarrier_bytes ? *pool.m_max_datacarrier_bytes : 0));
Copy link
Member

Choose a reason for hiding this comment

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

I slightly prefer it being called datacarriersize to match the config option, but don't feel strongly

@tdb3
Copy link
Contributor

tdb3 commented May 10, 2024

I wonder if a sub-object would be a good idea before we start adding more settings here. There's at least also m_expiry that would make sense to add too.

Implementing as a sub-object makes sense to me as well. If it is decided to adjust this RPC, then I'm thinking we'd also need a -deprecatedrpc option to retain the existing behavior, so we don't break RPC for downstream clients.

See also: #29845 (comment)

@tdb3
Copy link
Contributor

tdb3 commented May 10, 2024

Actually, since these don't change on their own... maybe a separate RPC altogether? (later extended to allow some changes?)

This option also makes sense to me. Maybe something like getmempoolpolicy or similar?

@kristapsk
Copy link
Contributor Author

IMHO #29086 should be merged first, it's a good refactor, I will rebase then, so please review that one.

@kristapsk
Copy link
Contributor Author

Actually, since these don't change on their own... maybe a separate RPC altogether? (later extended to allow some changes?)

I'm not sure it's worth breaking compatibility here. Stuff like minrelaytxfee and mempoolminfee is checked by a lots of wallet software, Lightning nodes, etc.

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.

None yet

6 participants