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

Chunk /gettransactions to avoid hitting restricted RPC limit #8388

Merged
merged 1 commit into from
Jul 6, 2022

Conversation

tobtoht
Copy link
Contributor

@tobtoht tobtoht commented Jun 15, 2022

Fixes the following issue when mempool contains more than 100 new transactions when connected to a restricted node:

Error calling gettransactions daemon RPC: r 1, status Too many transactions requested in restricted mode

@selsta

// get those txes
if (!txids.empty())
// get_transaction_pool_hashes.bin may return more transactions than we're allowed to request in restricted mode
const size_t SLICE_SIZE = 100; // RESTRICTED_TRANSACTIONS_COUNT as defined in rpc/core_rpc_server.cpp
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we detect if the daemon is in restricted mode and chunk accordingly, as opposed to defaulting to the (rather low) value of 100?

Copy link
Contributor

@plowsof plowsof Jun 16, 2022

Choose a reason for hiding this comment

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

i think this is what happens already here (on the server side at least)

if (restricted && req.txs_hashes.size() > RESTRICTED_TRANSACTIONS_COUNT)

Copy link
Contributor

@jeffro256 jeffro256 Jun 16, 2022

Choose a reason for hiding this comment

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

Right, but I mean but if the daemon is in unrestricted mode, then we can ask for more at once (what the old code was doing), which would definitely reduce overhead if/when the mempool gets to be the size of (for example) Bitcoin's with >1000 txs per block

@selsta
Copy link
Collaborator

selsta commented Jun 20, 2022

LOG_PRINT_L0("Expected " << txids.size() << " tx(es), got " << res.txs.size());

should this log message be updated? Maybe to something like

LOG_PRINT_L0("Expected " << n_txids << " out of " << txids.size() << " tx(es), got " << res.txs.size());

Because otherwise the log is a bit confusing.

2022-06-20 13:47:25.050	     0x1051b8580	DEBUG	wallet.wallet2	src/wallet/wallet2.cpp:3173	asking for 5 transactions
2022-06-20 13:47:25.098	     0x1051b8580	TRACE	net	contrib/epee/include/net/net_helper.h:460	READ ENDS: Success. bytes_tr: 5134
2022-06-20 13:47:25.098	     0x1051b8580	TRACE	net.http	contrib/epee/include/net/http_client.h:648	http_stream_filter::parse_cached_header(*)
2022-06-20 13:47:25.098	     0x1051b8580	DEBUG	wallet.wallet2	src/wallet/wallet2.cpp:3187	Got 1 and OK
2022-06-20 13:47:25.098	     0x1051b8580	WARNING	wallet.wallet2	src/wallet/wallet2.cpp:3226	Expected 59 tx(es), got 5

Adding the remaining tx count would also be nice but might make the log message too complicated.

@jeffro256
Copy link
Contributor

jeffro256 commented Jun 20, 2022

In reply to @selsa:

To piggyback off of this, should this log statement be put inside the loop now since there are now multiple requests which could each individually go wrong?

@selsta
Copy link
Collaborator

selsta commented Jun 20, 2022

@jeffro256 it is already in the loop, or am I misunderstanding your suggestion?

@jeffro256
Copy link
Contributor

Oh you're right, I read my brackets wrong, it is inside the for loop

Copy link
Collaborator

@selsta selsta left a comment

Choose a reason for hiding this comment

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

Code reviewed and tested.

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.

5 participants