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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/rpc/mempool.cpp
Expand Up @@ -677,6 +677,8 @@ UniValue MempoolInfoToJSON(const CTxMemPool& pool)
ret.pushKV("incrementalrelayfee", ValueFromAmount(pool.m_opts.incremental_relay_feerate.GetFeePerK()));
ret.pushKV("unbroadcastcount", uint64_t{pool.GetUnbroadcastTxs().size()});
ret.pushKV("fullrbf", pool.m_opts.full_rbf);
ret.pushKV("permitbaremultisig", pool.m_opts.permit_bare_multisig);
ret.pushKV("maxdatacarriersize", (pool.m_opts.max_datacarrier_bytes ? *pool.m_opts.max_datacarrier_bytes : 0));
return ret;
}

Expand All @@ -699,6 +701,8 @@ static RPCHelpMan getmempoolinfo()
{RPCResult::Type::NUM, "incrementalrelayfee", "minimum fee rate increment for mempool limiting or replacement in " + CURRENCY_UNIT + "/kvB"},
{RPCResult::Type::NUM, "unbroadcastcount", "Current number of transactions that haven't passed initial broadcast yet"},
{RPCResult::Type::BOOL, "fullrbf", "True if the mempool accepts RBF without replaceability signaling inspection"},
{RPCResult::Type::BOOL, "permitbaremultisig", "True if the mempool accepts transactions with bare multisig outputs"},
{RPCResult::Type::NUM, "maxdatacarriersize", "Maximum number of bytes that can be used by OP_RETURN outputs in the mempool"},
}},
RPCExamples{
HelpExampleCli("getmempoolinfo", "")
Expand Down
2 changes: 2 additions & 0 deletions test/functional/mempool_accept.py
Expand Up @@ -72,6 +72,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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just adding the true check in mempool_datacarrier seems like it would be easy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ajtowns Good idea, can add test simple way without adding much more code. 84e03ab


self.log.info('Start with empty mempool, and 200 blocks')
self.mempool_size = 0
assert_equal(node.getblockcount(), 200)
Expand Down
10 changes: 9 additions & 1 deletion test/functional/mempool_datacarrier.py
Expand Up @@ -13,7 +13,7 @@
)
from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_node import TestNode
from test_framework.util import assert_raises_rpc_error
from test_framework.util import assert_equal, assert_raises_rpc_error
from test_framework.wallet import MiniWallet

from random import randbytes
Expand Down Expand Up @@ -46,6 +46,14 @@ def test_null_data_transaction(self, node: TestNode, data, success: bool) -> Non
def run_test(self):
self.wallet = MiniWallet(self.nodes[0])

assert_equal(self.nodes[0].getmempoolinfo()["maxdatacarriersize"], MAX_OP_RETURN_RELAY)
assert_equal(self.nodes[1].getmempoolinfo()["maxdatacarriersize"], 0)
assert_equal(self.nodes[2].getmempoolinfo()["maxdatacarriersize"], MAX_OP_RETURN_RELAY - 1)
assert_equal(self.nodes[3].getmempoolinfo()["maxdatacarriersize"], 2)

# Test that bare multisig is allowed by default.
assert_equal(self.nodes[0].getmempoolinfo()["permitbaremultisig"], True)

# By default, only 80 bytes are used for data (+1 for OP_RETURN, +2 for the pushdata opcodes).
default_size_data = randbytes(MAX_OP_RETURN_RELAY - 3)
too_long_data = randbytes(MAX_OP_RETURN_RELAY - 2)
Expand Down