42 Commits
Author SHA1 Message Date
Gleb Naumenko 72e8ffd7f8 p2p: Account for MANUAL conns when diversifying persistent outbound conns
Previously, we would make connections to peer from the netgroups to which
our MANUAL outbound connections belong.
However, they should be seen as regular connections from Addrman when it comes to netgroup diversity check, since the same rationale can be applied.

Note, this has nothing to do with how we connect to MANUAL connections:
we connect to them unconditionally.
2023-03-15 20:12:05 +05:30
Gleb Naumenko 3faae99c3d p2p: Diversify connections only w.r.t *persistent* outbound peers
ADDR_FETCH and FEELER are short-lived connections,
and they should not affect our choice of peers.

Also, improve comments.
2023-03-15 20:12:03 +05:30
Gleb Naumenko 46339d29b1 test, refactor: Reorder sendtxrcncl tests for better readability 2022-11-14 12:04:08 +02:00
Gleb Naumenko 14263c13f1 p2p, refactor: Extend logs for unexpected sendtxrcncl 2022-11-14 12:04:07 +02:00
Gleb Naumenko 87493e112e p2p, test, refactor: Minor code improvements 2022-11-14 11:49:49 +02:00
Gleb Naumenko 00c5dec818 p2p: Clarify sendtxrcncl policies 2022-11-14 11:40:17 +02:00
Gleb Naumenko ac6ee5ba21 test: Expand unit and functional tests for txreconciliation 2022-11-14 11:40:15 +02:00
Gleb Naumenko bc84e24a4f p2p, refactor: Switch to enum class for ReconciliationRegisterResult
While doing this, add a new value: ALREADY_REGISTERED.
2022-11-14 11:37:28 +02:00
Gleb Naumenko a60f729e29 p2p: Drop roles from sendtxrcncl
This feature was currently redundant (although could have provided
more flexibility in the future), and already been causing confusion.
2022-11-10 09:21:57 +02:00
Gleb Naumenko 6772cbf69c tests: stabilize sendtxrcncl test 2022-11-08 12:18:48 +02:00
Gleb Naumenko e56d1d2afd test: Add functional tests for sendtxrcncl message from outbound 2022-10-17 12:36:14 +03:00
Gleb Naumenko cfcef60779 test: Add functional tests for sendtxrcncl from inbound 2022-10-17 12:36:13 +03:00
Gleb Naumenko b99ee9d22d test: Add unit tests for reconciliation negotiation 2022-10-17 12:35:44 +03:00
Gleb Naumenko f63f1d3f4b p2p: clear txreconciliation state for non-wtxid peers
We optimistically pre-register a peer for txreconciliations
upon sending txreconciliation support announcement.
But if, at VERACK, we realize that the peer never sent
WTXIDRELAY message, we should unregister the peer
from txreconciliations, because txreconciliations rely on wtxids.
2022-10-17 12:35:44 +03:00
Gleb Naumenko 88d326c8e3 p2p: Finish negotiating reconciliation support
Once we received a reconciliation announcement support
message from a peer and it doesn't violate our protocol,
we store the negotiated parameters which will be used
for future reconciliations.
2022-10-17 12:35:44 +03:00
Gleb Naumenko 36cf6bf216 Add helper to see if a peer is registered for reconciliations 2022-10-17 12:35:44 +03:00
Gleb Naumenko 4470acf076 p2p: Forget peer's reconciliation state on disconnect 2022-10-17 12:35:44 +03:00
Gleb Naumenko 3fcf78ee6a p2p: Announce reconciliation support
If we're connecting to the peer which might support
transaction reconciliation, we announce we want to reconcile
with them.

We store the reconciliation salt so that when the peer
responds with their salt, we are able to compute the
full reconciliation salt.

This behavior is enabled with a CLI flag.
2022-10-17 12:35:43 +03:00
Gleb Naumenko 24e36fac0a log: Add tx reconciliation log category 2022-10-17 12:00:59 +03:00
Gleb NaumenkoandMartin Zumsande 3c43d9db1e p2p: Don't self-advertise during VERSION processing
Previously, we would prepare to self-announce to a new peer while
parsing a VERSION message from that peer. This is redundant, because we
do something very similar in MaybeSendAddr(), which is called from
SendMessages() after the version handshake is finished.

There are a couple of differences:

1) MaybeSendAddr() self-advertises to all peers we do address relay with,
   not just outbound ones.
2) GetLocalAddrForPeer() called from MaybeSendAddr() makes a
   probabilistic decision to either advertise
   what they think we are or what we think we are, while
   PushAddress(self) on VERSION deterministically only does
   the former if the address from the latter is unroutable.
3) During VERSION processing, we haven't received a potential sendaddrv2 message
   from our peer yet, so self-advertisements with addresses from addrV2-only networks
   would always be dropped in PushAddress().

Since it's confusing to have two slightly different mechanisms for self-advertising,
and the one in MaybeSendAddr() is better, remove the one in VERSION.

Co-authored-by: Martin Zumsande <mzumsande@gmail.com>
2022-09-28 17:41:56 -04:00
Gleb NaumenkoandJon Atack 2ff8f4dd81 Add tests for addr destination rotation
Check that within 24h addr of a given node is forwarded
to the same peer(s), and then the destination is
rotated every 24h.

Co-authored-by: Jon Atack <jon@atack.com>
2022-03-13 16:54:43 +01:00
Gleb Naumenko 77ccb7fce1 Use std::chrono for salting when randomizing ADDR destination 2022-03-13 16:40:36 +01:00
Gleb Naumenko 0659f12b13 Add minisketch dependency 2021-10-21 09:38:55 +08:00
Gleb Naumenko 2ea62cae48 Improve docs about feeler connections 2020-09-24 08:52:25 +03:00
Gleb Naumenko 0d04784af1 Refactor the functional test 2020-09-02 10:33:18 +03:00
Gleb Naumenko 83ad65f31b Address nits in ADDR caching 2020-09-02 10:33:17 +03:00
Gleb Naumenko 81b00f8780 Add indexing ADDR cache by local socket addr 2020-08-27 10:51:56 +03:00
Gleb Naumenko 42ec558542 Justify the choice of ADDR cache lifetime 2020-08-27 10:51:56 +03:00
Gleb Naumenko 3bd67ba5a4 Test addr response caching 2020-07-30 14:38:50 +03:00
Gleb Naumenko cf1569e074 Add addr permission flag enabling non-cached addr sharing 2020-07-30 14:38:50 +03:00
Gleb Naumenko acd6135b43 Cache responses to addr requests
Prevents a spy from scraping victim's AddrMan by
reconnecting and re-requesting addrs.
2020-07-30 14:38:48 +03:00
Gleb Naumenko 7cc0e8101f Remove useless 2500 limit on AddrMan queries 2020-07-24 18:02:20 +03:00
Gleb Naumenko ded742bc5b Move filtering banned addrs inside GetAddresses() 2020-07-24 18:02:20 +03:00
Gleb Naumenko 3c1bc40205 Add extra logging of asmap use and bucketing 2020-01-23 14:23:06 -05:00
Gleb Naumenko e4658aa8ea Return mapped AS in RPC call getpeerinfo
If ASN bucketing is used, return a corresponding AS
used in bucketing for a given peer.
2020-01-23 14:22:56 -05:00
Gleb Naumenko ec45646de9 Integrate ASN bucketing in Addrman and add tests
Instead of using /16 netgroups to bucket nodes in Addrman for connection
diversification, ASN, which better represents an actor in terms
of network-layer infrastructure, is used.
For testing, asmap.raw is used. It represents a minimal
asmap needed for testing purposes.
2019-12-25 08:59:08 -05:00
Gleb NaumenkoandPieter Wuille 8feb4e4b66 Add asmap utility which queries a mapping
The scripts for creating a compact IP->ASN mapping are here:
https://github.com/sipa/asmap

Co-authored-by: Pieter Wuille <pieter.wuille@gmail.com>
2019-12-18 14:27:03 -05:00
UserandMarcoFalke b6d2183858 Minor refactoring to remove implied m_addr_relay_peer.
Co-authored-by: MarcoFalke <falke.marco@gmail.com>
2019-10-31 13:42:02 -04:00
User a552e8477c added asserts to check m_addr_known when it's used 2019-10-25 16:28:14 -04:00
User 090b75c14b p2p: Avoid allocating memory for addrKnown where we don't need it 2019-10-16 17:06:20 -04:00
Gleb NaumenkoandSuhas Daftuar 1cff3d6cb0 Change in transaction pull scheduling to prevent InvBlock-related attacks
Co-authored-by: Suhas Daftuar <sdaftuar@gmail.com>
2019-02-06 20:25:27 -08:00
Gleb d45b344ffd Bucket for inbound when scheduling invs to hide tx time 2018-07-13 23:14:35 -07:00