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

backport: merge bitcoin#22778, #25156, #26497, #27213, #28189, #28155, #28895, partial bitcoin#26396 (networking backports: part 9) #6365

Merged
merged 10 commits into from
Oct 27, 2024

Conversation

kwvg
Copy link
Collaborator

@kwvg kwvg commented Oct 26, 2024

Additional Information

  • Dependency for backport: merge bitcoin#23496, #26272, #23443, #26381, #26396, #26448, #26359, #26686, #23670, partial bitcoin#19953 (Erlay support) #6333

  • When backporting bitcoin#22778, the m_tx_inventory_known_filter.insert() call in queueAndMaybePushInv() had to be moved out as EXCLUSIVE_LOCKS_REQUIRED does not seem to work with lambda parameters list (though it does work with capture list, source), see error below

    Compiler error:
    net_processing.cpp:5895:21: note: found near match 'tx_relay->m_tx_inventory_mutex'
    net_processing.cpp:5955:21: error: calling function 'operator()' requires holding mutex 'queueAndMaybePushInv.m_tx_inventory_mutex' exclusively [-Werror,-Wthread-safety-precise]
                        queueAndMaybePushInv(tx_relay, CInv(nInvType, hash));
                        ^
    net_processing.cpp:5955:21: note: found near match 'tx_relay->m_tx_inventory_mutex'
    net_processing.cpp:5977:17: error: calling function 'operator()' requires holding mutex 'queueAndMaybePushInv.m_tx_inventory_mutex' exclusively [-Werror,-Wthread-safety-precise]
                    queueAndMaybePushInv(inv_relay, inv);
                    ^
    
    • Attempting to remove the EXCLUSIVE_LOCKS_REQUIRED or the AssertLockHeld are not options due to stricter thread sanitization checks being applied since dash#6319 (and in general, removing annotations being inadvisable regardless)

    • We cannot simply lock peer->GetInvRelay()->m_tx_inventory_mutex as a) the caller already has a copy of the relay pointer (which means that m_tx_relay_mutex was already held) that b) they used to lock m_tx_inventory_mutex (which we were already asserting) so c) we cannot simply re-lock m_tx_inventory_mutex as it's already already held, just through a less circuitous path.

      • The reason locking is mentioned instead of asserting is that the compiler treats peer->GetInvRelay()->m_tx_inventory_mutex and tx_relay->m_tx_inventory_mutex as separate locks (despite being different ways of accessing the same thing) and would complain similarly to the error above if attempting to assert the former while holding the latter.
  • As m_tx_relay is always initialized for Dash, to mimic the behaviour expected upstream, in bitcoin#22778, SetTxRelay() will allow GetTxRelay() to return m_can_tx_relay (while Dash code that demands unconditional access can use GetInvRelay() instead) with the lack of SetTxRelay() resulting in GetTxRelay() feigning the absence of m_can_tx_relay.

    This allows us to retain the same style of checks used upstream instead of using proxies like !CNode::IsBlockOnlyConn() to determined if we should use m_tx_relay.

  • Speaking of proxies, being a block-only connection is now no longer the only reason not to relay transactions

    In preparation for bitcoin#26396, proxy usage of !CNode::IsBlockOnlyConn() and !Peer::m_block_relay_only was replaced with the more explicit Peer::m_can_tx_relay before being used to gate the result of GetTxRelay(), to help it mimic upstream semantics.

Breaking Changes

None expected

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas (note: N/A)
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation
  • I have assigned this pull request to a milestone (for repository code-owners and collaborators only)

kwvg added 3 commits October 26, 2024 09:07
The true purpose of `m_block_relay_only` is to use it in place of
`m_tx_relay == nullptr`, used to indicate if the node is permitted
to relay transactions.

In upcoming commits, being a block-relay-only node will not be the only
reason to not relay transactions, so let's rename the variable to what
we actually use it for.
Right now, it's not immediately obvious which checks are to see if we
are looking for block-relay-only status or are using that status as a
proxy to see if we can relay transactions. Let's fix that.
…ly connections

continuation of 60b5392 in dash#6276

excludes:
- 42e3250 (Dash does not have FEEFILTER support)
Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

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

utACK 09504bd

@PastaPastaPasta PastaPastaPasta merged commit 25c3355 into dashpay:develop Oct 27, 2024
35 checks passed
PastaPastaPasta added a commit that referenced this pull request Oct 28, 2024
, bitcoin#26381, bitcoin#26396, bitcoin#26448, bitcoin#26359, bitcoin#26686, bitcoin#23670, partial bitcoin#19953 (Erlay support)

cc98f9e merge bitcoin#23670: Build minisketch test in make check, not in make (Kittywhiskers Van Gogh)
606a444 merge bitcoin#26686: Enable erlay setting in process_message(s) targets (Kittywhiskers Van Gogh)
38a16a2 merge bitcoin#26359: Erlay support signaling follow-ups (Kittywhiskers Van Gogh)
b55a6f7 merge bitcoin#26448: fix intermittent failure in p2p_sendtxrcncl.py (Kittywhiskers Van Gogh)
36be978 merge bitcoin#26396: Avoid SetTxRelay for feeler connections (Kittywhiskers Van Gogh)
62dc9cb merge bitcoin#26381: Fix intermittent issue in p2p_sendtxrcncl.py (Kittywhiskers Van Gogh)
6a7868d merge bitcoin#23443: Erlay support signaling (Kittywhiskers Van Gogh)
fdc3c07 partial bitcoin#19953: Implement BIP 340-342 validation (Kittywhiskers Van Gogh)
477157d merge bitcoin#26272: Prevent UB in `minisketch_tests.cpp` (Kittywhiskers Van Gogh)
0cf7401 merge bitcoin#23496: Add minisketch fuzz test (Kittywhiskers Van Gogh)
49ef53c merge bitcoin#23491: Move minisketchwrapper to src/node (Kittywhiskers Van Gogh)

Pull request description:

  ## Additional Information

  * Dependent on #6332
  * Dependent on #6365
  * Erlay requires nodes to be `WTXIDRELAY` (as defined by BIP-339, [source](https://github.com/bitcoin/bips/blob/17c04f9fa1ecae173d6864b65717e13dfc1880af/bip-0339.mediawiki))-capable ([source](https://github.com/bitcoin/bips/blob/17c04f9fa1ecae173d6864b65717e13dfc1880af/bip-0330.mediawiki#sendtxrcncl)) as prior to `WTXIDRELAY` adoption, TXIDs of SegWit transactions didn't include the witness data in the hash, which meant, the witness data was malleable ([source](https://bitcoin.stackexchange.com/a/107394)), which would be a relevant factor when you are building out a reconciliation system where you need TXIDs to authoritatively identify a transaction's contents.

    As Dash _doesn't_ support SegWit, this requirement can be dispensed with. It has instead been replaced with checking if the node is running Dash Core v22 or above to retain the underlying test logic (but this can also be dispensed with as `SENDTXRCNCL`  will simply be ignored by older nodes and major releases are _generally_ mandatory upgrades anyways)

  ## Breaking Changes

  None expected.

  ## Checklist

  - [x] I have performed a self-review of my own code
  - [x] I have commented my code, particularly in hard-to-understand areas **(note: N/A)**
  - [x] I have added or updated relevant unit/integration/functional/e2e tests
  - [x] I have made corresponding changes to the documentation **(note: N/A)**
  - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

ACKs for top commit:
  PastaPastaPasta:
    utACK cc98f9e
  UdjinM6:
    utACK cc98f9e

Tree-SHA512: fe985f4df6c96c0a7b984882815a1bce7f23c54370198d099e41a59ac4c46c283a2b8dd95f5c8fc12eb1dc1330c4e5c21626b76d33d83d395326e8eb19d564ce
PastaPastaPasta added a commit that referenced this pull request Jan 15, 2025
, bitcoin#24468, bitcoin#25119, bitcoin#25176, bitcoin#25421, bitcoin#26248, bitcoin#26199, bitcoin#27036, bitcoin#27270, partial bitcoin#27106 (networking backports: part 10)

3260f2c partial bitcoin#27106: remove orphaned CSubNet::SanityCheck() (Kittywhiskers Van Gogh)
75cc94e merge bitcoin#27270: Avoid CNode::m_relays_txs usage (Kittywhiskers Van Gogh)
f961903 merge bitcoin#27036: Remove last uses of snprintf and simplify (Kittywhiskers Van Gogh)
d80bbe9 merge bitcoin#26199: Don't self-advertise during version processing (Kittywhiskers Van Gogh)
4b17baf merge bitcoin#26248: Set relay in version msg to peers with relay permission in -blocksonly mode (Kittywhiskers Van Gogh)
18738f5 merge bitcoin#25421: convert standalone IsSelectableSocket() and SetSocketNonBlocking() to Sock methods (Kittywhiskers Van Gogh)
8782575 merge bitcoin#25176: Fix frequent -netinfo JSON errors from missing getpeerinfo#relaytxes (Kittywhiskers Van Gogh)
1d96a47 merge bitcoin#25119: move StartExtraBlockRelayPeers() from header to implementation (Kittywhiskers Van Gogh)
37e0c58 merge bitcoin#24468: improve -onlynet help and related tor/i2p documentation (Kittywhiskers Van Gogh)
52c3b03 merge bitcoin#23542: open p2p connections to nodes that listen on non-default ports (Kittywhiskers Van Gogh)
8e2a12a merge bitcoin#22732: use m_client_interface rather than uiInterface (Kittywhiskers Van Gogh)
06a8e9c merge bitcoin#21845: Don't require locking cs_main before calling RelayTransactions() (Kittywhiskers Van Gogh)

Pull request description:

  ## Additional Information

  * Due to changes introduced in [bitcoin#21845](bitcoin#21845), a `LOCK(cs_main)` had to be added to `PeerManagerImpl::ReattemptInitialBroadcast()` ([source](06a8e9c#diff-6875de769e90cec84d2e8a9c1b962cdbcda44d870d42e4215827e599e11e90e3R1634)). This addition is in line with upstream ([source](https://github.com/bitcoin/bitcoin/blob/39e19713cd6594f93db835e8ef7eef5824a9ba02/src/net_processing.cpp#L1021)).

  * While nodes have been allowed to connect to non-default ports since [dash#2168](#2168), [bitcoin#23542](bitcoin#23542) also adds a list of ports considered "bad" that while not outright prohibited, are heavily discouraged from use as they are considered _de facto_ prohibited.

    In combination with port restrictions for masternodes (connections only permitted if matching listening port), port validation logic was better served by implementing it in a lambda block that's immediately executed (see `is_prohibited_port` for more information, [source](https://github.com/dashpay/dash/blob/01975fba32b8fcd8bccb0ce293b217c07b522c53/src/net.cpp#L3551-L3567)).

  * In [bitcoin#25176](bitcoin#25176), `is_block_relay` is renamed to `is_tx_relay` as the block relay-only = not transaction-relay assumption no longer holds true (see [dash#6365](#6365) for more information). One use of `is_block_relay` which relied on this now-obsolete assumption is incrementing `m_block_relay_peers_count`. It has been replaced with checking for a `block-relay-only` `conn_type`, matching upstream ([source](https://github.com/bitcoin/bitcoin/blob/a17c5e96b602fed65166037b78d98605e915206b/src/bitcoin-cli.cpp#L486)).

  ## Breaking Changes

  None expected.

  ## Checklist

  - [x] I have performed a self-review of my own code
  - [x] I have commented my code, particularly in hard-to-understand areas
  - [x] I have added or updated relevant unit/integration/functional/e2e tests
  - [x] I have made corresponding changes to the documentation
  - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

ACKs for top commit:
  UdjinM6:
    utACK 3260f2c
  PastaPastaPasta:
    utACK 3260f2c

Tree-SHA512: 2bb50deb77ffaf7f7c4b396a8efe03f8bbfa605b49b75eace5fbc9d9813d4de8b72b086c50fbb0c23b97237c1f4c1b30b68f4b456bb74875308a4fcaa82deb08
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.

3 participants