backport: merge bitcoin#21594, #21843, #22306, #22211, #22387, #21528, #22616, #22604, #22960, #23218 (networking backports: part 3)#5978
Merged
PastaPastaPasta merged 13 commits intodashpay:developfrom Apr 15, 2024
Conversation
Merged
5 tasks
knst
reviewed
Apr 12, 2024
src/rpc/net.cpp
Outdated
Collaborator
There was a problem hiding this comment.
21528 - please include backport bitcoin#22618 which has release notes for this changes
Collaborator
Author
There was a problem hiding this comment.
Resolved in latest push!
src/net_processing.cpp
Outdated
Comment on lines
5339
to
5385
Member
There was a problem hiding this comment.
this feels wrong; 21528 doesn't introduce any usage of IsBlockOnlyConn? why not use peer->m_addr_relay_enabled?
Collaborator
Author
There was a problem hiding this comment.
This has already been explained in the PR description but the switchover to IsBlockOnlyConn has been split into a separate commit to avoid association with changes from the backport.
In bitcoin#21528, the value of `m_addr_relay_enabled` isn't determined until the first ADDR/ADDRV2/GETADDR call. Until then, it'll always default to `false`. This creates a false-negative where a term equivalent to "not a block connection" no longer reliably means that. Therefore we need to switch to directly querying "not a block-only connection".
Required to avoid unhappy python linter[1] result. Have to use annotation instead of re-aligning with upstream (where ADDRS is populated in the global state) due to reliance on `self.mocktime`, without which, the test fails[2] [1] - https://gitlab.com/dashpay/dash/-/jobs/6594035886 [2] - https://gitlab.com/dashpay/dash/-/jobs/6597322548
PastaPastaPasta
added a commit
that referenced
this pull request
Apr 28, 2024
, bitcoin#23695, bitcoin#21160, bitcoin#24692, partial bitcoin#20196, bitcoin#25176, merge bitcoin-core/gui#526 (networking backports: part 4) ab7ac1b partial bitcoin#25176: Fix frequent -netinfo JSON errors from null getpeerinfo#relaytxes (Kittywhiskers Van Gogh) c89799d merge bitcoin#24692: Follow-ups to bitcoin#21160 (Kittywhiskers Van Gogh) 33098ae merge bitcoin#21160: Move tx inventory into net_processing (Kittywhiskers Van Gogh) 24205d9 partial bitcoin#20196: fix GetListenPort() to derive the proper port (Kittywhiskers Van Gogh) 7f72009 merge bitcoin-core/gui#526: Add address relay/processed/rate-limited fields to peer details (Kittywhiskers Van Gogh) a9114f1 merge bitcoin#23695: Always serialize local timestamp for version msg (Kittywhiskers Van Gogh) d936c28 merge bitcoin#23575: Rework FillNode (Kittywhiskers Van Gogh) 6f8c730 merge bitcoin#19499: Make timeout mockable and type safe, speed up test (Kittywhiskers Van Gogh) 43a82bd merge bitcoin#20769: fixes "advertised address where nobody is listening" (Kittywhiskers Van Gogh) Pull request description: ## Additional Information * Dependent on #5978 * Dependent on #5977 ## Breaking Changes None observed. ## 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 ab7ac1b Tree-SHA512: 87bf5108bb80576c5bff8cd577add7800044da252fd18590e06a727f0bf70de94e2e9294b4412cdd9f1f6676472b0359902af361aaffc4c9ee299ad07d6af009
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Additional Information
ADDRSinp2p_addr(v2)_relayin Dash is done in the test object (source) as opposed to upstream, where it is done in the global state (source). This is because Dash specifically relies onself.mocktimeinstead of Bitcoin, which will work with simply sampling current time (time.time()).ADDRSoutside the test object. That, alongside with other considerations, resulted in dash#5967 and a discussion (source)ADDRSwas defined outside but setup within the test object. This worked just fine (build) but displeased the linter (build) becauseADDRStype could not be implicitly determined solely on usage in the global scope.ADDRShas been annotated as aList[CAddress](which involved importingListbut that's fine) (commit)m_tx_relay(source) and can always check if transaction relaying is permitted by checking if it's initialized (source).RelayAddrsWithPeer()(source), which, to be noted, is determined by the initialization status ofPeer::m_addr_known(source), which, so far, was pegged to not block-relay connection status (source).RelayAddrsWithPeer()and replaced it withPeer::m_addr_relay_enabled(source), which is setup usingPeer::SetupAddressRelay()(source). This means, rather than defining the address relay status during construction, it is setup during the first address-related message (i.e.ADDR,ADDRV2,GETADDR) (source).Meaning, until the first addr-related message happens, the state is has not been determined and defaults to
false. Because somem_tx_relayusage still piggybacked on addr-relay permission to determine tx-relay, if a transaction message is processed before an address message is processed, there will be a false-negative condition.The transaction relay logic won't run since it's expecting that if transactions can be relayed, so can addresses and checks for address relaying but believes that it cannot do address relaying, borrowing that state for transaction relaying, despite address relaying permissions actually being indeterminate since it hasn't had a chance to validate its eligibility.
There were two approaches, run
SetupAddressRelay()as early in the connection as possible to substitute for the "determine at construction" behaviour and change no other conditional statements... and break address-related tests or move the remaining conditional transaction relay logic to use not block-only connection checks instead.We've gone with the latter, resulting in some changes where the condition only changes form but is the same (
RelayAddrsWithPeer()>Peer::m_addr_relay_enabled) (source) but other changes where the condition itself has been changed (RelayAddrsWithPeer()>!CNode::IsBlockOnlyConn()) (source)Peer::m_block_relay_onlyis introduced to be the counterpart toPeer::m_addr_relay_enabled(source) to account for someCConnmanlogic being moved intoPeerManager(source), which, in a way, reverts dash#5339 but also, doesn't, since it moves the information intoPeerinstead of reinstating it intoCNode.CNode::IsAddrRelayPeer() == !CNode::IsBlockOnlyConn()no longer holds true (also becauseCNode::IsAddrRelayPeer()doesn't exist anymore).Special thanks to @UdjinM6 for help with understanding Dash-specifics with respect to functional tests through help on dash#5964 and dash#5967
Breaking Changes
None expected.
RPC changes have been introduced in
getnodeaddresses, where a new inputnetwork, can filter addresses based on desired network and a new output, alsonetwork, will associate the address with the origin network. This change is expected to be backwards-compatible.Checklist: