Skip to content

Conversation

str4d and others added 4 commits August 13, 2021 03:58
This brings the code more closely in line with upstream, and prepares
for subsequent performance improvements.
… req.

The ability to GETDATA a transaction which has not (yet) been relayed
 is a privacy loss vector.

The use of the mempool for this was added as part of the mempool p2p
 message and is only needed to fetch transactions returned by it.

(cherry picked from commit bitcoin/bitcoin@7e908c7)
This reduces the rate of not founds by better matching the far
 end expectations, it also improves privacy by removing the
 ability to use getdata to probe for a node having a txn before
 it has been relayed.

(cherry picked from commit bitcoin/bitcoin@4d8993b)
@str4d str4d added C-upstream-port Category: Changes that are ported from the Bitcoin Core codebase. A-networking Area: Networking code NU5 Network upgrade: NU5-specific tasks labels Aug 13, 2021
@str4d str4d added this to the Core Sprint 2021-30 milestone Aug 13, 2021
@str4d
Copy link
Contributor Author

str4d commented Aug 13, 2021

@zkbot try

@zkbot
Copy link
Contributor

zkbot commented Aug 13, 2021

⌛ Trying commit 57cf4c271cc68d6c5e8a64e73cf42470519589f7 with merge 1d7ed0617499d3c6377e763eeeeeeea7fb0279b5...

@str4d str4d added the A-mempool Area: Mempool label Aug 13, 2021
@zkbot
Copy link
Contributor

zkbot commented Aug 13, 2021

💔 Test failed - pr-try

@str4d
Copy link
Contributor Author

str4d commented Aug 13, 2021

RPC test failures are reproducible (though mempool_nu_activation.py appears intermittent). I'll investigate tomorrow (which is technically today, as I haven't slept yet).

@mdr0id mdr0id added the safe-to-build Used to send PR to prod CI environment label Aug 13, 2021
sipa and others added 13 commits August 13, 2021 15:42
* Switch mapRelay to use shared_ptr<CTransaction>
* Switch the relay code to copy mempool shared_ptr's, rather than copying
  the transaction itself.
* Change vRelayExpiration to store mapRelay iterators rather than hashes
  (smaller and faster).

(cherry picked from commit bitcoin/bitcoin@dbfb426)
(cherry picked from commit sipa/bitcoin@adb1c09)
In principle, the checksums of P2P packets are simply 4-byte blobs which
are the first four bytes of SHA256(SHA256(payload)).

Currently they are handled as little-endian 32-bit integers half of the
time, as blobs the other half, sometimes copying the one to the other,
resulting in somewhat confused code.

This PR changes the handling to be consistent both at packet creation
and receiving, making it (I think) easier to understand.

(cherry picked from commit bitcoin/bitcoin@41e58fa)
The P2P network uses a fixed protocol, these sizes shouldn't change
based on what happens to be the architecture.

(cherry picked from commit bitcoin/bitcoin@305087b)
Also move the enum to the top, and remove a deceptive TODO
comment.

(cherry picked from commit bitcoin/bitcoin@2c09a52)
This concretizes the numbers and adds a comment to make it clear that
these numbers are fixed by the protocol, and may avoid people forgetting
to claim numbers in the future (e.g. issue #8500).

Also gets rid of a weird unused `MSG_TYPE_MAX` in the middle of the
enumeration (thanks @paveljanik for noticing).

(cherry picked from commit bitcoin/bitcoin@1df3111)
PushInventory() is currently called with a CInv object, which can be a
MSG_TX or MSG_BLOCK. PushInventory() only uses the type to determine
whether to add the hash to setInventoryTxToSend or
vInventoryBlockToSend.

Since the caller always knows what type of inventory they're pushing,
the CInv is wastefully constructed and thrown away, and tx/block relay
is being split out, we split the function into PushTxInventory() and
PushBlockInventory().

(cherry picked from commit bitcoin/bitcoin@f52d403)

Zcash: Adjusted to account for bitcoin/bitcoin#15759 not having been
backported.
@str4d
Copy link
Contributor Author

str4d commented Aug 13, 2021

RPC test failures were due to me originally trying to backport bitcoin/bitcoin#8126 before a needed commit (adding score-based sorting) from bitcoin/bitcoin#6898, and then once the latter was backported in #5269 I mis-rebased this branch so that the score-based sorting was inconsistent across two APIs, which resulted in the node segfaulting somewhere in the depths of walletdb.cpp. The fix:

diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index bdf14e7eb7..25b0d37cbc 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -699,7 +699,7 @@ public:
         // As of https://github.com/bitcoin/bitcoin/pull/8126 this comparator
         // duplicates that function (as it doesn't need to hold a dependency
         // on the mempool).
-        return CompareTxMemPoolEntryByFee()(*a, *b);
+        return CompareTxMemPoolEntryByScore()(*a, *b);
     }
 };
 }

Copy link
Contributor

@nuttycom nuttycom left a comment

Choose a reason for hiding this comment

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

utACK; verified against the upstream changes.

@str4d
Copy link
Contributor Author

str4d commented Aug 17, 2021

@zkbot r+

@zkbot
Copy link
Contributor

zkbot commented Aug 17, 2021

📌 Commit 8469683 has been approved by str4d

@zkbot
Copy link
Contributor

zkbot commented Aug 17, 2021

⌛ Testing commit 8469683 with merge 56b5f95...

@zkbot
Copy link
Contributor

zkbot commented Aug 17, 2021

☀️ Test successful - pr-merge
Approved by: str4d
Pushing 56b5f95 to master...

@zkbot zkbot merged commit 56b5f95 into zcash:master Aug 17, 2021
@str4d str4d deleted the zip-239-prep-3 branch August 17, 2021 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-mempool Area: Mempool A-networking Area: Networking code C-upstream-port Category: Changes that are ported from the Bitcoin Core codebase. NU5 Network upgrade: NU5-specific tasks safe-to-build Used to send PR to prod CI environment

Projects

None yet

Development

Successfully merging this pull request may close these issues.