aboutsummaryrefslogtreecommitdiff
path: root/test/functional/p2p_addr_relay.py
AgeCommit message (Collapse)Author
2021-12-16test: Combine addr generation helper functionsMartin Zumsande
This combines the addr generation helper functions setup_addr_msg and setup_rand_addr_msg. It also changes the way addr.time is filled to random, because before, if too many addresses (>600) were created in a batch, they would stop being relayed because their timestamp would be too far in the future.
2021-12-16test: Fix intermittent issue in p2p_addr_relay.pyMartin Zumsande
by increasing the mocktime bump for m_next_addr_send, which is on a Poisson timer, and explain why. Closes #22449
2021-11-10scripted-diff: Bump copyright headersMarcoFalke
The previous diff touched most files in ./test/, so bump the headers to avoid having to touch them again for a bump later. -BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./test/ -END VERIFY SCRIPT-
2021-10-28[addrman] Add Add_() inner function, fix Add() return semanticsJohn Newbery
Previously, Add() would return true if the function created a new AddressInfo object, even if that object could not be successfully entered into the new table and was deleted. That would happen if the new table position was already taken and the existing entry could not be removed. Instead, return true if the new AddressInfo object is successfully entered into the new table. This fixes a bug in the "Added %i addresses" log, which would not always accurately log how many addresses had been added. p2p_addrv2_relay.py and p2p_addr_relay.py need to be updated since they were incorrectly asserting on the buggy log (assuming that addresses are added to addrman, when there could in fact be new table position collisions that prevent some of those address records from being added).
2021-09-19test: use test_framework.p2p P2P_SERVICES in functional testsJon Atack
2021-08-14Merge bitcoin/bitcoin#22604: p2p, rpc, test: address rate-limiting follow-upsfanquake
d930c7f5b091687eb4208a5ffe8a2abe311d8054 p2p, rpc, test: address rate-limiting follow-ups (Jon Atack) Pull request description: Incorporates review feedback in #22387. Edit, could be considered separately: should a release note (or two) be added for 22.0? e.g. the new getpeerinfo fields in `Updated RPCs` and the rate-limiting itself in `P2P and network changes`. ACKs for top commit: MarcoFalke: review ACK d930c7f5b091687eb4208a5ffe8a2abe311d8054 theStack: re-ACK d930c7f5b091687eb4208a5ffe8a2abe311d8054 🌮 Zero-1729: crACK d930c7f Tree-SHA512: b2101cad87f59c238603f38bd8e8df7a4d48929794e4de9e0e0ff2afa935a68475c2d369aa669d124a0bec2f50280fb47e8b980bde6ad812db08cf67b71c066a
2021-08-04[docs] Add release notes for #21528Amiti Uttarwar
And fix a typo in the test.
2021-08-04p2p, rpc, test: address rate-limiting follow-upsJon Atack
2021-07-29[test] Use the new endpoint to improve testsAmiti Uttarwar
2021-07-29[test] Test that we intentionally select addr relay peers.Amiti Uttarwar
This test checks that we only relay addresses with inbound peers who have sent us an addr related message. Uses a combination of GETADDR and ADDR to verify when peers are eligible.
2021-07-29[net_processing] Defer initializing m_addr_knownAmiti Uttarwar
Use SetupAddressRelay to only initialize `m_addr_known` as needed. For outbound peers, we initialize the filter before sending our self announcement (not applicable for block-relay-only connections). For inbound peers, we initialize the filter when we get an addr related message (ADDR, ADDRV2, GETADDR). These changes intend to mitigate address blackholes. Since an inbound peer has to send us an addr related message to become eligible as a candidate for addr relay, this should reduce our likelihood of sending them self-announcements.
2021-07-29[test] Update p2p_addr_relay test to prepareAmiti Uttarwar
Use an init param to make clear whether a getaddr message should be sent when the P2PConnection receives a version message. These changes are in preparation for upcoming commits that modify the behavior of a bitcoind node and the test framework.
2021-07-15Improve tests using statisticsJohn Newbery
2021-07-15Functional tests for addr rate limitingPieter Wuille
2021-07-15Rate limit the processing of incoming addr messagesPieter Wuille
While limitations on the influence of attackers on addrman already exist (affected buckets are restricted to a subset based on incoming IP / network group), there is no reason to permit them to let them feed us addresses at more than a multiple of the normal network rate. This commit introduces a "token bucket" rate limiter for the processing of addresses in incoming ADDR and ADDRV2 messages. Every connection gets an associated token bucket. Processing an address in an ADDR or ADDRV2 message from non-whitelisted peers consumes a token from the bucket. If the bucket is empty, the address is ignored (it is not forwarded or processed). The token counter increases at a rate of 0.1 tokens per second, and will accrue up to a maximum of 1000 tokens (the maximum we accept in a single ADDR or ADDRV2). When a GETADDR is sent to a peer, it immediately gets 1000 additional tokens, as we actively desire many addresses from such peers (this may temporarily cause the token count to exceed 1000). The rate limit of 0.1 addr/s was chosen based on observation of honest nodes on the network. Activity in general from most nodes is either 0, or up to a maximum around 0.025 addr/s for recent Bitcoin Core nodes. A few (self-identified, through subver) crawler nodes occasionally exceed 0.1 addr/s.
2021-06-21[test] Prevent intermittent issueAmiti Uttarwar
Since m_next_addr_send is on a Poisson distribution, increase the mocktime bump to ensure we don't experience flakiness in the tests. Closes #22243.
2021-06-21[test] Remove GetAddrStore classAmiti Uttarwar
2021-06-21[test] Update GetAddrStore callers to use AddrReceiverAmiti Uttarwar
2021-06-21[test] Add functionality to AddrReceiverAmiti Uttarwar
Add two simple helper functions to `AddrReceiver` to support callers currently using `GetAddrStore` [used in next commit].
2021-06-21[test] Allow AddrReceiver to be used more generallyAmiti Uttarwar
The `on_addr` functionality of `AddrReceiver` tests logic specific to how the addr messages are set up in the test bodies. To allow other callers to also use `AddrReceiver`, only apply the assertion logic if the caller indicates desirability by setting `test_addr_contents` to true when initializing the class.
2021-04-28test: Fix intermittent issue in p2p_addr_relay.pyMarcoFalke
2021-04-28test: Use self.send_addr_msgMarcoFalke
2021-04-21[test] Add tests for addr relay in -blocksonly modeAmiti Uttarwar
Co-Authored-By: Martin Zumsande <mzumsande@gmail.com>
2021-04-21[test] Add address relay tests involving outbound peersMartin Zumsande
Co-authored-by: Amiti Uttarwar <amiti@uttarwar.org>
2021-04-21[test] Add tests for getaddr behaviorMartin Zumsande
Co-authored-by: Amiti Uttarwar <amiti@uttarwar.org>
2021-04-21[test] Extract sending an addr message into a helperAmiti Uttarwar
Also reduces mocktime to prevent idle disconnects Co-Authored-By: Martin Zumsande <mzumsande@gmail.com>
2021-04-21[test] Refactor the addr relay test to prepare for new testsAmiti Uttarwar
Moves setting up the addr message into a repeatable function, and breaks up the existing tests into separate functions for legibility.
2021-02-01scripted-diff: Remove setup_clean_chain if default is not changedFabian Jahr
-BEGIN VERIFY SCRIPT- git grep -l "self.setup_clean_chain = False" test/functional/*.py | xargs sed -i "/self.setup_clean_chain = False/d"; -END VERIFY SCRIPT-
2020-12-10net: don't relay to the address' originatorVasil Dimov
For each address to be relayed we "randomly" pick 2 nodes to send the address to (in `RelayAddress()`). However we do not take into consideration that it does not make sense to relay the address back to its originator (`CNode::PushAddress()` will do nothing in that case). This means that if the originator is among the "randomly" picked nodes, then we will relay to one node less than intended. Fix this by skipping the originating node when choosing candidates to relay to.
2020-08-21test: resort importsJohn Newbery
2020-08-21scripted-diff: Rename mininode to p2pJohn Newbery
-BEGIN VERIFY SCRIPT- sed -i 's/\.mininode/\.p2p/g' $(git grep -l "mininode") git mv test/functional/test_framework/mininode.py test/functional/test_framework/p2p.py -END VERIFY SCRIPT-
2020-06-19net: update misbehavior logging for oversized messagesJon Atack
so that oversized ADDR, GETDATA, HEADERS and INV messages print the same consistent debug logs.
2020-04-02test: Add basic addr relay testMarcoFalke