Skip to content
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

TorV3 Backport ZIP155: For test purposes only #5366

Draft
wants to merge 134 commits into
base: master
Choose a base branch
from

Conversation

zancas
Copy link
Contributor

@zancas zancas commented Oct 28, 2021

This builds, and passes the full test suite tests. It's almost completely composed of code cherry-picked from bitcoin's implementation of BIP155 and subsequent Torv3 support.

NOTE: It's likely that it will need commit-history modifying refactor (among many other things).

The next step is to attempt to establish communication between two nodes using torv3.

luke-jr and others added 30 commits October 28, 2021 10:31
…n be shared and reused

(cherry picked from commit 5e10922)
To make it clear where DNS resolves are happening

(cherry picked from commit e9fc71e)
Note: Some seeds aren't actually returning an IP for their name entries, so
they're being added to addrman with a source of [::].

This commit shouldn't change that behavior, for better or worse.

(cherry picked from commit a98cd1f)
Rather than allowing CNetAddr/CService/CSubNet to launch DNS queries, require
that addresses are already resolved.

This greatly simplifies async resolve logic, and makes it harder to
accidentally leak DNS queries.

(cherry picked from commit 3675699)
CNetAddr/CService/CSubnet can no longer resolve DNS.

(cherry picked from commit d39f5b4)
(cherry picked from commit b6c3ff3)
Net functionality is no longer needed for CAddress/CAddrman/etc. now that
CNetAddr/CService/CSubNet are dumb storage classes.

(cherry picked from commit 21ba407)
Also fix up a few small issues:
- Lookup with "badip:port" now sets the port to 0
- Don't allow assert to have side-effects

(cherry picked from commit 8945384)
(cherry picked from commit 9e9d644)
-BEGIN VERIFY SCRIPT-

sed --in-place'' --expression='s/NET_TOR/NET_ONION/g' $(git grep -I --files-with-matches 'NET_TOR')

-END VERIFY SCRIPT-

The --in-place'' hack is required for sed on macOS to edit files in-place without passing a backup extension.

(cherry picked from commit 07c493f)
Do not access `CNetAddr::ip` directly from `CService` methods.

This improvement will help later when we change the type of
`CNetAddr::ip` (in the BIP155 implementation).

Co-authored-by: Carl Dong <contact@carldong.me>
(cherry picked from commit bc74a40)
(cherry picked from commit 100c64a)
We currently do two resolves for dns seeds: one for the results, and one to
serve in addrman as the source for those addresses.

There's no requirement that the source hostname resolves to the stored
identifier, only that the mapping is unique. So rather than incurring the
second lookup, combine a private subnet with a hash of the hostname.

The resulting v6 ip is guaranteed not to be publicy routable, and has only a
negligible chance of colliding with a user's internal network (which would be
of no consequence anyway).

(cherry picked from commit 7f31762)
(cherry picked from commit 100c64a)
zancas and others added 24 commits October 28, 2021 10:31
FastRandomContext now provides all functionality that the real Rand* functions
provide.

(cherry picked from commit 37e864e)
Note this doesn't build, missing identifier: SHA256D64
(cherry picked from commit e549bf8)
This is needed when we want to encode an arbitrary number as CompactSize
like node service flags, which is a bitmask and could be bigger than the
usual size of an object.

(cherry picked from commit 1d3ec2a)
(cherry picked from commit e86ce4e)
(cherry picked from commit 92beff1)
Change the serialization of `CAddrMan` to serialize its addresses
in ADDRv2/BIP155 format by default. Introduce a new `CAddrMan` format
version (3).

Add support for ADDRv2 format in `CAddress` (un)serialization.

Co-authored-by: Carl Dong <contact@carldong.me>
(cherry picked from commit 201a459)
(cherry picked from commit bd2c485)
(cherry picked from commit 857baca)
(cherry picked from commit 5c34bff)
CVectorWriter is useful for overwriting or appending an existing byte vector.

CNetMsgMaker is a shortcut for creating messages on-the-fly which are suitable
for pushing to CConnman.

(cherry picked from commit 2ec935d)
(cherry picked from commit 878e63c)
minimally change net_processing by adding "addrv2" as a strCommand
minimally change net.h with addition of m_wants_addrv2

(cherry picked from commit 353a3fd)
(cherry picked from commit d2d5557)
 (cherry picked from commit 353a3fd)

(cherry picked from commit 19ee7cf)
  (cherry picked from commit dcf0cb4)

(cherry picked from commit 796c30a)
@zancas zancas marked this pull request as draft October 28, 2021 18:47
@zancas zancas changed the title For test purposes only TorV3 Backport ZIP155: For test purposes only Oct 28, 2021
@str4d
Copy link
Contributor

str4d commented Jul 18, 2022

I've been through every commit in this PR in order, and mapped the cherry-picked commits to their respective PRs.

List is ordered by the earliest a commit from the PR appears in the GitHub commit ordering of this PR (I did not check the exact ordering in the git branch, but this PR has never been rebased or force-pushed, so GitHub shouldn't yet be confused by the out-of-order dates).

"Local commits" are (ranges of) commits in this PR that have no cherry-pick information. Some of these I could omit because their commit messages indicated they were obvious fixups to the prior cherry-picked commits, but many appeared to be new or pulled from somewhere else we will have to figure out.

@str4d
Copy link
Contributor

str4d commented Jul 18, 2022

Here is the same list of PRs, in the order they were merged upstream (and thus the order of least merge conflicts), and with their associated Zcash issue if any (eventually all will have one, once I've turned this list into a graph):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.