-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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#21594, #21843, #22306, #22211, #22387, #21528, #22616, #22604, #22960, #23218 (networking backports: part 3) #5978
Conversation
src/rpc/net.cpp
Outdated
@@ -104,6 +104,7 @@ static RPCHelpMan getpeerinfo() | |||
{RPCResult::Type::STR, "addr", "(host:port) The IP address and port of the peer"}, | |||
{RPCResult::Type::STR, "addrbind", "(ip:port) Bind address of the connection to the peer"}, | |||
{RPCResult::Type::STR, "addrlocal", "(ip:port) Local address as reported by the peer"}, | |||
{RPCResult::Type::BOOL, "addr_relay_enabled", "Whether we participate in address relay with this peer"}, |
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.
21528 - please include backport bitcoin#22618 which has release notes for this changes
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.
Resolved in latest push!
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.
Generally looks good
if (RelayAddrsWithPeer(*peer)) { | ||
if (!pto->IsBlockOnlyConn()) { |
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.
this feels wrong; 21528 doesn't introduce any usage of IsBlockOnlyConn? why not use peer->m_addr_relay_enabled?
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.
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
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.
LGTM
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.
utACK
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.
utACK 1fedf47
, 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
Additional Information
ADDRS
inp2p_addr
(v2
)_relay
in 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.mocktime
instead of Bitcoin, which will work with simply sampling current time (time.time()
).ADDRS
outside the test object. That, alongside with other considerations, resulted in dash#5967 and a discussion (source)ADDRS
was defined outside but setup within the test object. This worked just fine (build) but displeased the linter (build) becauseADDRS
type could not be implicitly determined solely on usage in the global scope.ADDRS
has been annotated as aList[CAddress]
(which involved importingList
but 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_relay
usage 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_only
is introduced to be the counterpart toPeer::m_addr_relay_enabled
(source) to account for someCConnman
logic being moved intoPeerManager
(source), which, in a way, reverts dash#5339 but also, doesn't, since it moves the information intoPeer
instead 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: