Skip to content

Conversation

naumenkogs
Copy link
Member

@naumenkogs naumenkogs commented Oct 21, 2022

Non-trivial changes include:

  • Getting rid of roles in sendtxrcncl message (summarized in the BIP PR);
  • Disconnect the peer if it send sendtxrcncl although we are in blocksonly and notified the peer with fRelay=0;
  • Don't send sendtxrcncl to feeler connections.

@DrahtBot
Copy link
Contributor

DrahtBot commented Oct 21, 2022

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK vasild, ariard, mzumsande

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #26283 (p2p: Fill reconciliation sets and request reconciliation (Erlay) by naumenkogs)
  • #25572 (refactor: Introduce EvictionManager and use it for the inbound eviction logic by dergoegge)
  • #25268 (refactor: Introduce EvictionManager by dergoegge)
  • #21515 (Erlay: bandwidth-efficient transaction relay protocol by naumenkogs)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

Copy link
Contributor

@vasild vasild left a comment

Choose a reason for hiding this comment

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

Approach ACK 2b9cd5f

Copy link
Contributor

@mzumsande mzumsande left a comment

Choose a reason for hiding this comment

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

Approach ACK

I reviewed the code, and all points I found were already mentioned by others, so I'd be happy to ACK after the oustanding comments are addressed.

Copy link
Contributor

@vasild vasild left a comment

Choose a reason for hiding this comment

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

ACK 2193344 modulo the failing test which seems to need some tweaking and the comment below wrt assert().

@@ -3273,17 +3273,14 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,

if (greatest_common_version >= WTXID_RELAY_VERSION && m_txreconciliation) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if that is better, just an idea, feel free to ignore:

diff --git i/src/net_processing.cpp w/src/net_processing.cpp
index 376a263183..0ed7781b2c 100644
--- i/src/net_processing.cpp
+++ w/src/net_processing.cpp
@@ -3265,26 +3265,27 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
             (fRelay || (peer->m_our_services & NODE_BLOOM))) {
             auto* const tx_relay = peer->SetTxRelay();
             {
                 LOCK(tx_relay->m_bloom_filter_mutex);
                 tx_relay->m_relay_txs = fRelay; // set to true after we get the first filter* message
             }
-            if (fRelay) pfrom.m_relays_txs = true;
-        }
-
-        if (greatest_common_version >= WTXID_RELAY_VERSION && m_txreconciliation) {
-            // Per BIP-330, we announce txreconciliation support if:
-            // - protocol version per the peer's VERSION message supports WTXID_RELAY;
-            // - transaction relay is supported per the peer's VERSION message (see m_relays_txs);
-            // - this is not a block-relay-only connection and not a feeler (see m_relays_txs);
-            // - this is not an addr fetch connection;
-            // - we are not in -blocksonly mode.
-            if (pfrom.m_relays_txs && !pfrom.IsAddrFetchConn() && !m_ignore_incoming_txs) {
-                const uint64_t recon_salt = m_txreconciliation->PreRegisterPeer(pfrom.GetId());
-                m_connman.PushMessage(&pfrom, msg_maker.Make(NetMsgType::SENDTXRCNCL,
-                                                             TXRECONCILIATION_VERSION, recon_salt));
+            if (fRelay) {
+                pfrom.m_relays_txs = true;
+
+                if (greatest_common_version >= WTXID_RELAY_VERSION &&
+                    m_txreconciliation &&
+                    !pfrom.IsAddrFetchConn() && !m_ignore_incoming_txs) {
+                    // Per BIP-330, we announce txreconciliation support if:
+                    // - protocol version per the peer's VERSION message supports WTXID_RELAY;
+                    // - transaction relay is supported per the peer's VERSION message (see m_relays_txs);
+                    // - this is not a block-relay-only connection and not a feeler (see m_relays_txs);
+                    // - this is not an addr fetch connection;
+                    // - we are not in -blocksonly mode.
+                    const uint64_t recon_salt = m_txreconciliation->PreRegisterPeer(pfrom.GetId());
+                    m_connman.PushMessage(&pfrom, msg_maker.Make(NetMsgType::SENDTXRCNCL, TXRECONCILIATION_VERSION, recon_salt));
+                }
             }
         }
 
         m_connman.PushMessage(&pfrom, msg_maker.Make(NetMsgType::VERACK));
 
         // Potentially mark this peer as a preferred download peer.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure about this — it's kinda difficult either way :) Will see what others say.

@naumenkogs naumenkogs force-pushed the 2021-11-erlay1_followup branch from 2193344 to 1597210 Compare November 8, 2022 10:19
@maflcko maflcko changed the title p2p, refactor: #23443 (Erlay support signaling) follow-ups p2p: Erlay support signaling follow-ups Nov 8, 2022
Copy link
Contributor

@vasild vasild left a comment

Choose a reason for hiding this comment

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

ACK 1597210

@naumenkogs naumenkogs force-pushed the 2021-11-erlay1_followup branch from 1597210 to 58786a1 Compare November 9, 2022 08:08
Copy link
Contributor

@mzumsande mzumsande left a comment

Choose a reason for hiding this comment

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

Code Review ACK 58786a1

// - we are not in -blocksonly mode.
if (pfrom.m_relays_txs && !m_ignore_incoming_txs) {
if (pfrom.m_relays_txs && !pfrom.IsAddrFetchConn() && !m_ignore_incoming_txs) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a big fan of special casing behavior for AddrFetch without any tangible benefits (or are there any?) - I'd like to think of them as normal outbound connections, where we just happen to disconnect after we get the GETADDR answer, and while I admit that concerns such as #26396 (comment) aren't super strong, I think it's also easier mental model and less complicated code not to special-case for each message whether AddrFetch connections need it.

Copy link

@ariard ariard left a comment

Choose a reason for hiding this comment

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

ACK 58786a1

Verified the test coverage updates in removal of initiator/responder and after defining better sendtxrcncl policy.

@@ -39,7 +39,8 @@ class TxReconciliationState
* the following commits.
*
* Reconciliation protocol assumes using one role consistently: either a reconciliation
* initiator (requesting sketches), or responder (sending sketches). This defines our role.
* initiator (requesting sketches), or responder (sending sketches). This defines our role,
* based on the direction of the p2p connection.
Copy link

Choose a reason for hiding this comment

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

Note you have a bunch of references to the term initiator left in reconciatliation.{h,cpp}:

src/node/txreconciliation.cpp:     * initiator (requesting sketches), or responder (sending sketches). This defines our role,
src/node/txreconciliation.h: * 2.  At regular intervals, a txreconciliation initiator requests a sketch from a peer, where a
src/node/txreconciliation.h: * 3.  Once the initiator received a sketch from the peer, the initiator computes a local sketch,
src/node/txreconciliation.h: * 4b. If the difference was larger than estimated, initial txreconciliation fails. The initiator
src/node/txreconciliation.h: * SUCCESS. The initiator knows full symmetrical difference and can request what the initiator is
src/node/txreconciliation.h: * FAILURE. The initiator notifies the peer about the failure and announces all transactions from

It's minor, I think they can be addressed in its own commit here or in #26283 to avoid another review round.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it makes sense to keep using the more abstract terms initiator / receiver within the txreconciliation module, even after removing it from the sendtxrcncl message.

This feature was currently redundant (although could have provided
more flexibility in the future), and already been causing confusion.
@naumenkogs naumenkogs force-pushed the 2021-11-erlay1_followup branch from 58786a1 to d44438c Compare November 10, 2022 07:26
@naumenkogs
Copy link
Member Author

Applied clang-format everywhere.

Copy link

@ariard ariard left a comment

Choose a reason for hiding this comment

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

ACK d44438c

Note the new commit d44438c reodering functional tests for readability.

@vasild
Copy link
Contributor

vasild commented Nov 12, 2022

The cumulative diff as of d44438c looks ok, but the individual commits seem somewhat messed up:

  • d7239b5 test: Expand unit and functional tests for txreconciliation
    contains non-test changes related to the return value of RegisterPeer().

  • 9cb6b33 p2p, refactor: Switch to enum class for ReconciliationRegisterResult
    has some indentation changes, and not the enum class changes

  • 29df2d7 p2p, refactor: Minor code improvements
    has some adverse indentation changes and introduces the unnecessary { }

  • 5a183dd p2p, refactor: Extend logs for unexpected sendtxrcncl
    fixes the adverse indentation from 29df2d7 but not the unnecessary { }

@naumenkogs naumenkogs force-pushed the 2021-11-erlay1_followup branch from d44438c to 46339d2 Compare November 14, 2022 10:04
@naumenkogs
Copy link
Member Author

@vasild sorry for that mess, addressed everything without introducing behavior changes.

Copy link
Contributor

@vasild vasild left a comment

Choose a reason for hiding this comment

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

ACK 46339d2

🌞

Copy link

@ariard ariard left a comment

Choose a reason for hiding this comment

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

ACK 46339d2

Did another parse of the code changes to verify there wasn't functional modification.

peer_txreconcl_version, remote_salt);
switch (result) {
case ReconciliationRegisterResult::NOT_FOUND:
LogPrintLevel(BCLog::NET, BCLog::Level::Debug, "Ignore unexpected txreconciliation signal from peer=%d\n", pfrom.GetId());
Copy link

Choose a reason for hiding this comment

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

nit: The message could be clearer saying "Ignore sendtxrcncl received from peer". "txreconciliation signal" is a bit hand-wawy.

@fanquake fanquake requested a review from mzumsande November 16, 2022 10:07
Copy link
Contributor

@mzumsande mzumsande left a comment

Choose a reason for hiding this comment

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

Code Review ACK 46339d2

@fanquake fanquake merged commit bcee94d into bitcoin:master Nov 30, 2022
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Dec 1, 2022
46339d2 test, refactor: Reorder sendtxrcncl tests for better readability (Gleb Naumenko)
14263c1 p2p, refactor: Extend logs for unexpected sendtxrcncl (Gleb Naumenko)
87493e1 p2p, test, refactor: Minor code improvements (Gleb Naumenko)
00c5dec p2p: Clarify sendtxrcncl policies (Gleb Naumenko)
ac6ee5b test: Expand unit and functional tests for txreconciliation (Gleb Naumenko)
bc84e24 p2p, refactor: Switch to enum class for ReconciliationRegisterResult (Gleb Naumenko)
a60f729 p2p: Drop roles from sendtxrcncl (Gleb Naumenko)
6772cbf tests: stabilize sendtxrcncl test (Gleb Naumenko)

Pull request description:

  Non-trivial changes include:
  - Getting rid of roles in `sendtxrcncl` message (summarized in the [BIP PR](bitcoin/bips#1376));
  - Disconnect the peer if it send `sendtxrcncl` although we are in `blocksonly` and notified the peer with `fRelay=0`;
  - Don't send `sendtxrcncl` to feeler connections.

ACKs for top commit:
  vasild:
    ACK 46339d2
  ariard:
    ACK 46339d2
  mzumsande:
    Code Review ACK 46339d2

Tree-SHA512: b5cc6934b4670c12b7dbb3189e739ef747ee542ec56678bf4e4355bfb481b746d32363c173635685b71969b3fe4bd52b1c8ebd3ea3b35c82044bba69220f6417
@naumenkogs naumenkogs mentioned this pull request Oct 13, 2023
17 tasks
@bitcoin bitcoin locked and limited conversation to collaborators Nov 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants