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] Allow RPC to fetch all addrman records and add records to addrman #19658
Conversation
cc @naumenkogs |
I think this is a move in the right direction: GetAddr() should be more dynamic. Concept ACK. |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
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. |
Concept ACK, I think more control over addrman via RPC is a good thing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK, the getaddr limits only make sense for P2P, not for RPC.
c7e165d
to
5bff6fd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a bit of testing via console, and everything worked as expected (after adding addpeeraddress
to vRPCConvertParams
).
Added some minor issues/nits.
5bff6fd
to
81cbe5e
Compare
Thanks for the review @mzumsande . All comments have been addressed. |
CAddrMan.GetAddr() would previously limit the number and percentage of addresses returned (to ADDRMAN_GETADDR_MAX (1000) and ADDRMAN_GETADDR_MAX_PCT (23) respectively). Instead, make it the callers responsibility to specify the maximum addresses and percentage they want returned. For net_processing, the maximums are MAX_ADDR_TO_SEND (1000) and MAX_PCT_ADDR_TO_SEND (23). For rpc/net, the maximum is specified by the client.
Allows addresses to be added to Address Manager for testing.
Thanks for the review @luke-jr . I've addressed all of your comments. |
81cbe5e
to
37a480e
Compare
utACK 37a480e You updated rpc_net.py test, but there's also p2p_getaddr_cache.py and p2p_addr_relay.py which may benefit from new methods? |
Of course. Those can be done in a follow-up. |
Code review and lightly manually tested ACK 37a480e |
Thanks @laanwj
Yeah, I agree it's a bit confusing, but I didn't want to change the default in this PR. |
e9d28da [Doc] Document getnodeaddresses in release notes (Fuzzbawls) ebe2a46 test: improve getnodeaddresses coverage, test by network (Fuzzbawls) 91ac5c7 rpc: enable filtering getnodeaddresses by network (Fuzzbawls) badfc49 p2p: allow CConnman::GetAddresses() by network, add doxygen (Fuzzbawls) fa78233 p2p: allow CAddrMan::GetAddr() by network, add doxygen (Fuzzbawls) a4d2733 p2p: pull time call out of loop in CAddrMan::GetAddr_() (Fuzzbawls) d5c1250 p2p: enable CAddrMan::GetAddr_() by network, add doxygen (Fuzzbawls) 67e2c2f [RPC] add network field to getnodeaddresses (Fuzzbawls) b4832b2 [Net] Add addpeeraddress RPC method (Fuzzbawls) 1a31b67 [test] Test that getnodeaddresses() can return all known addresses (Fuzzbawls) e83fd0e [Addrman] Specify max addresses and pct when calling GetAddresses() (Fuzzbawls) 792655d [RPC] Add getnodeaddresses RPC command (chris-belcher) Pull request description: Implement a new RPC command (`getnodeaddresses`) that provides RPC access to the node's addrman. It may be useful for PIVX wallets to broadcast their transactions over tor for improved privacy without using the centralized DNS seeds. I've included upstream improvements to this feature here as well, and this RPC command was used to scrape the Tor v3 hardcoded seed nodes added in #2502 --------- Based on the following upstream PRs: * bitcoin#13152 * bitcoin#19658 * bitcoin#21594 * bitcoin#21843 ACKs for top commit: furszy: all good, tested ACK e9d28da. random-zebra: utACK e9d28da and merging... Tree-SHA512: 2e50108504ac8e172c2e31eb64813d6aae6b6819cf197eace2e4e15686906708b2f82262909faad00ce64af0f61945089a36b857064d3ce2398b3acb14e4ad7d
Summary: Commit description: > CAddrMan.GetAddr() would previously limit the number and percentage of > addresses returned (to ADDRMAN_GETADDR_MAX (1000) and > ADDRMAN_GETADDR_MAX_PCT (23) respectively). Instead, make it the callers > responsibility to specify the maximum addresses and percentage they want > returned. > > For net_processing, the maximums are MAX_ADDR_TO_SEND (1000) and > MAX_PCT_ADDR_TO_SEND (23). For rpc/net, the maximum is specified by the > client. > PR description: > Currently addrman only allows a maximum of 1000 records or 23% of all records to be returned in a call to GetAddr(). Relax this limit and have the client specify the max records they want. For p2p, behaviour is unchanged (but the rate limiting is set inside net_processing, where it belongs). For RPC, getnodeaddresses can now return the complete addrman, which is helpful for testing and monitoring. > > Also add a test-only RPC addpeeraddress, which adds an IP address:port to addrman. This is helpful for testing (eg #18991). This is a backport of [[bitcoin/bitcoin#19658 | core#19658]] [1/3] bitcoin/bitcoin@f26502e Test Plan: `ninja all check-all` ``` ./src/bitcoin-cli getnodeaddresses 0 ``` Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D10069
Summary: This is a backport of [[bitcoin/bitcoin#19658 | core#19658]] [2/3] bitcoin/bitcoin@ae8051b Depends on D10069 Test Plan: `ninja check-functional` Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Subscribers: majcosta Differential Revision: https://reviews.bitcoinabc.org/D10070
Summary: Allows addresses to be added to Address Manager for testing. This is a backport of [[bitcoin/bitcoin#19658 | core#19658]] [3/3] bitcoin/bitcoin@37a480e Depends on D10070 Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D10071
Currently addrman only allows a maximum of 1000 records or 23% of all records to be returned in a call to
GetAddr()
. Relax this limit and have the client specify the max records they want. For p2p, behaviour is unchanged (but the rate limiting is set inside net_processing, where it belongs). For RPC,getnodeaddresses
can now return the complete addrman, which is helpful for testing and monitoring.Also add a test-only RPC
addpeeraddress
, which adds an IP address:port to addrman. This is helpful for testing (eg #18991).