Skip to content

ZIP 239 preparations 1#5265

Merged
zkbot merged 7 commits into
zcash:masterfrom
str4d:zip-239-prep-1
Aug 10, 2021
Merged

ZIP 239 preparations 1#5265
zkbot merged 7 commits into
zcash:masterfrom
str4d:zip-239-prep-1

Conversation

@str4d

@str4d str4d commented Aug 4, 2021

Copy link
Copy Markdown
Contributor

This is the first of several backports to prepare for ZIP 239. The primary
change is altering mapRelay to store CTransactions, which we need
because ZIP 239 requires changing Inv messages based on transaction
versions. The other changes are mainly for conflict removal but are also
independently useful.

Backports the following upstream PRs:

jonasschnelli and others added 4 commits August 4, 2021 17:12
Current master crashes on OSX with an exception: "boost: mutex lock failed in pthread_mutex_lock: Invalid argument"

(cherry picked from commit 0d699fc)

Zcash: Also adds the `clear` call that this was fixing. Upstream added it
in bitcoin/bitcoin#6722 which we never backported
(instead implementing our own mempool limiting logic).
We used to have a trickle node, a node which was chosen in each iteration of
the send loop that was privileged and allowed to send out queued up non-time
critical messages. Since the removal of the fixed sleeps in the network code,
this resulted in fast and attackable treatment of such broadcasts.

This pull request changes the 3 remaining trickle use cases by random delays:
* Local address broadcast (while also removing the the wiping of the seen filter)
* Address relay
* Inv relay (for transactions; blocks are always relayed immediately)

The code is based on older commits by Patrick Strateman.

(cherry picked from commit 5400ef6)
Previously we used the CInv that would be sent to the peer announcing the
transaction as the key, but using the txid instead allows us to decouple the
p2p layer from the application logic (which relies on this map to avoid
duplicate tx requests).

(cherry picked from commit 7e91f63)
@str4d str4d added the C-upstream-port Category: Changes that are ported from the Bitcoin Core codebase. label Aug 4, 2021
@str4d str4d added this to the Core Sprint 2021-30 milestone Aug 4, 2021
@str4d str4d requested a review from daira August 4, 2021 16:22
@str4d

str4d commented Aug 4, 2021

Copy link
Copy Markdown
Contributor Author

@zkbot try

@zkbot

zkbot commented Aug 4, 2021

Copy link
Copy Markdown
Contributor

⌛ Trying commit ad8abd6 with merge 65dff18...

zkbot added a commit that referenced this pull request Aug 4, 2021
ZIP 239 preparations 1

This is the first of several backports to prepare for ZIP 239. The primary
change is altering `mapRelay` to store `CTransaction`s, which we need
because ZIP 239 requires changing `Inv` messages based on transaction
versions. The other changes are mainly for conflict removal but are also
independently useful.

Backports the following upstream PRs:
- bitcoin/bitcoin#6889
- bitcoin/bitcoin#7125
- bitcoin/bitcoin#7862
- bitcoin/bitcoin#7877
Comment thread src/txmempool.cpp Outdated
Comment thread src/txmempool.h Outdated
Comment thread src/main.h
Comment thread src/net.cpp
}

int64_t PoissonNextSend(int64_t nNow, int average_interval_seconds) {
return nNow + (int64_t)(log1p(GetRand(1ULL << 48) * -0.0000000000000035527136788 /* -1/2^48 */) * average_interval_seconds * -1000000.0 + 0.5);

@daira daira Aug 4, 2021

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I checked that this formula is correct for inverse transform sampling of an exponential distribution.

(I would call it ExponentialNextSend, but I guess it doesn't matter.)

@zkbot

zkbot commented Aug 4, 2021

Copy link
Copy Markdown
Contributor

💔 Test failed - pr-try

@str4d

str4d commented Aug 5, 2021

Copy link
Copy Markdown
Contributor Author

CI failures were transient; this PR doesn't cause any hard test failures.

@daira daira left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

utACK

@daira

daira commented Aug 5, 2021

Copy link
Copy Markdown
Contributor

@zkbot r+

@zkbot

zkbot commented Aug 5, 2021

Copy link
Copy Markdown
Contributor

📌 Commit 465c249 has been approved by daira

@zkbot

zkbot commented Aug 5, 2021

Copy link
Copy Markdown
Contributor

⌛ Testing commit 465c249 with merge 6f389625778a56ace5bb9a28f376f3d0e8d54e9b...

@zkbot

zkbot commented Aug 5, 2021

Copy link
Copy Markdown
Contributor

💔 Test failed - pr-merge

This was previously a transient test failure, that started reliably
failing after the move to Poisson delays.
@str4d

str4d commented Aug 5, 2021

Copy link
Copy Markdown
Contributor Author

This PR caused a transient failure to become reliable, enabling me to find the cause: we weren't calling sync_all() to ensure a transaction propagated from the node that created it to the node mining the block.

@zkbot r+

@zkbot

zkbot commented Aug 5, 2021

Copy link
Copy Markdown
Contributor

📌 Commit 6be1a2a has been approved by str4d

@zkbot

zkbot commented Aug 5, 2021

Copy link
Copy Markdown
Contributor

⌛ Testing commit 6be1a2a with merge 1aa59fd...

zkbot added a commit that referenced this pull request Aug 5, 2021
ZIP 239 preparations 1

This is the first of several backports to prepare for ZIP 239. The primary
change is altering `mapRelay` to store `CTransaction`s, which we need
because ZIP 239 requires changing `Inv` messages based on transaction
versions. The other changes are mainly for conflict removal but are also
independently useful.

Backports the following upstream PRs:
- bitcoin/bitcoin#6889
- bitcoin/bitcoin#7125
- bitcoin/bitcoin#7862
- bitcoin/bitcoin#7877
@zkbot

zkbot commented Aug 5, 2021

Copy link
Copy Markdown
Contributor

💔 Test failed - pr-merge

@daira daira left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

utACK 6be1a2a. Looks like there's still a race condition in p2p_txexpiringsoon.py, though.

@str4d

str4d commented Aug 9, 2021

Copy link
Copy Markdown
Contributor Author

The race isn't reliable; I can't reproduce it locally.

@zkbot retry

@zkbot

zkbot commented Aug 9, 2021

Copy link
Copy Markdown
Contributor

⌛ Testing commit 6be1a2a with merge 8c3d670c8a39eda55a72dd99d8694ad50e6bf82f...

@zkbot

zkbot commented Aug 9, 2021

Copy link
Copy Markdown
Contributor

💔 Test failed - pr-merge

The recent changes to mempool inv logic mean that nodes are much less
likely to immediately return an `inv` message in response to a `mempool`
message. The `p2p_txexpiringsoon` RPC test was relying on the prior
behaviour.

`TestNode.sync_with_ping` now takes an optional `waiting_for` closure
that allows the caller to require that a specific message kind is
received prior to the timeout.
@str4d

str4d commented Aug 9, 2021

Copy link
Copy Markdown
Contributor Author

Did some digging, and I think I've figured out the race condition in p2p_txexpiringsoon. Given how frequently it is occuring in CI, we should know soon enough!

@zkbot r+

@zkbot

zkbot commented Aug 9, 2021

Copy link
Copy Markdown
Contributor

📌 Commit 75b9fc4 has been approved by str4d

@zkbot

zkbot commented Aug 9, 2021

Copy link
Copy Markdown
Contributor

⌛ Testing commit 75b9fc4 with merge 1dc1ababa970f633616d0c1fc60c65fb9a9231ef...

@zkbot

zkbot commented Aug 9, 2021

Copy link
Copy Markdown
Contributor

💔 Test failed - pr-merge

@str4d

str4d commented Aug 9, 2021

Copy link
Copy Markdown
Contributor Author

Transient failure that I'm going to try and fix in a separate PR. For now I'll just hope this works.

@zkbot retry

@zkbot

zkbot commented Aug 9, 2021

Copy link
Copy Markdown
Contributor

⌛ Testing commit 75b9fc4 with merge 18fe0a377bc66e3b0f8735624be8958ef93b75be...

@zkbot

zkbot commented Aug 9, 2021

Copy link
Copy Markdown
Contributor

💔 Test failed - pr-merge

@str4d

str4d commented Aug 9, 2021

Copy link
Copy Markdown
Contributor Author

Failed again. We need to merge #5268 before this PR.

@str4d

str4d commented Aug 10, 2021

Copy link
Copy Markdown
Contributor Author

Okay, next attempt:

@zkbot retry

@zkbot

zkbot commented Aug 10, 2021

Copy link
Copy Markdown
Contributor

⌛ Testing commit 75b9fc4 with merge 1cb1ed2...

@zkbot

zkbot commented Aug 10, 2021

Copy link
Copy Markdown
Contributor

☀️ Test successful - pr-merge
Approved by: str4d
Pushing 1cb1ed2 to master...

@zkbot zkbot merged commit 1cb1ed2 into zcash:master Aug 10, 2021
@zkbot zkbot mentioned this pull request Aug 10, 2021
@str4d str4d deleted the zip-239-prep-1 branch August 10, 2021 04:11
This was referenced Aug 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-upstream-port Category: Changes that are ported from the Bitcoin Core codebase.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants