Skip to content

Conversation

dhruv
Copy link
Contributor

@dhruv dhruv commented Mar 12, 2022

This PR brings together all other BIP324 PRs and enables v2 encrypted P2P transport.

Builds on top of PRs: #25361, #23233, #23561, #23432. It looks like there's a lot of commits, but only the last 12 commits belong in this PR. The rest will be merged with upstream PRs.

The dependency tree for BIP324 PRs is here.

BIP324 is here.

Running a v2 node

Get the code

git remote add bip324 git@github.com:dhruv/bitcoin.git
git fetch bip324
git checkout bip324/bip324-enable

Build for your OS

Follow the appropriate instructions here

Run the node

src/bitcoind -conf=CONFIG_FILE -v2transport=1

Connect with a friend's v2 node

src/bitcoin-cli -conf=CONFIG_FILE addnode "FRIEND_IP:FRIEND_PORT" "add" true

The last parameter(p2p_v2:true) signals to your node that the peer is running a v2 supportive client and we should attempt to make an encrypted P2P connection (you're simulating the NODE_P2P_V2 service flag advertisement manually). Should that fail however (say because the peer told you mistakenly, lied, etc.), this code will downgrade the connection to unencrypted v1 transport.

Things you are helpful to test

  • If your friend's node is a v2 node, you can see with wireshark that the bytes are pseudorandom (the easiest way to confirm this is that with a v1 connection, wireshark will tell you it has detected a Bitcoin connection and it'll even parse out the metadata like message type, etc; with v2, wireshark has no idea -- of course that could be because wireshark does simply not know v2, but it is because the bytestream is pseudorandom)
  • Compare the v2 encrypted session id exposed via getpeerinfo as v2_session_id with your friend.
  • Add another peer that is actually v1, but try addnode still indicating v2 support. You should see with wireshark that after a failed attempt at a v2 handshake, the connection is downgraded to unencrypted v1 and wireshark can parse it.

I've been told there are v2 nodes running at (happy to update the list as more people run persistent v2 nodes; message me and I'll add it here):

be.anyone.eu.org
rp7k2go3s5lyj3fnj6zn62ktarlrsft2ohlsxkyd7v3e3idqyptvread.onion:8333
jdcoysubtxazi7dketpyb5rnjorvxad4onftveohash2pdwkgw4bvnqd.onion:8333
xci6cphki2pdb5qe7axzrcxcxabkbm24z4zlv2hn4ziy6grquqco2kyd.onion:8333
slvtesfgg3mkksqqzh67al4sq6dx3rhlzqepa4ny7jonzuckg6msf3id.onion:8333
gifm4fnj3vua664xhgeanx5fnpco3txkqy4amr4txbfsciiyrkxpf2qd.onion:8333
300:5ecb:6b8a:d837::3:8333
300:5ecb:6b8a:d837::a6d6:8333
2001:470:1f1a:365::2:8333
2001:470:1f1b:365:aa20:66ff:fe3f:1909:8333
184.74.240.157:8533
95.179.145.232:8333

@fanquake fanquake added the P2P label Mar 12, 2022
@DrahtBot
Copy link
Contributor

DrahtBot commented Mar 12, 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
Concept ACK jonatack, dergoegge

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:

  • #27294 (refactor: Move chain names to the kernel namespace by TheCharlatan)
  • #27257 (refactor, net: End friendship of CNode, CConnman and ConnmanTestMsg by dergoegge)
  • #27254 (refactor: Extract util/fs from util/system by TheCharlatan)
  • #27114 (p2p: Allow whitelisting outgoing connections by brunoerg)
  • #26728 (wallet: Have the wallet store the key for automatically generated descriptors by achow101)
  • #26684 (bench: add readblock benchmark by andrewtoth)
  • #26621 (refactor: Continue moving application data from CNode to Peer by dergoegge)
  • #26593 (tracing: Only prepare tracepoint arguments when actually tracing by 0xB10C)
  • #26366 (p2p, rpc, test: getpeerinfo improv + add test coverage for invalid command by brunoerg)
  • #26283 (p2p: Fill reconciliation sets and request reconciliation (Erlay) by naumenkogs)
  • #26261 (p2p: cleanup LookupIntern, Lookup and LookupHost by brunoerg)
  • #25907 (wallet: rpc to add automatically generated descriptors by achow101)
  • #25832 (tracing: network connection tracepoints by 0xB10C)
  • #25572 (refactor: Introduce EvictionManager and use it for the inbound eviction logic by dergoegge)
  • #25390 (sync: introduce a thread-safe generic container and use it to remove a bunch of "GlobalMutex"es by vasild)
  • #25284 (net: Use serialization parameters for CAddress serialization by MarcoFalke)
  • #25268 (refactor: Introduce EvictionManager by dergoegge)
  • #23352 (test: Extend stale_tip_peer_management test by MarcoFalke)
  • #22341 (rpc: add getxpub by Sjors)
  • #18470 (test: Extend stale tip test by MarcoFalke)
  • #10102 (Multiprocess bitcoin by ryanofsky)

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.

@dhruv
Copy link
Contributor Author

dhruv commented Mar 21, 2022

Bringing in upstream changes from #20962. Ready for further review.

@dhruv
Copy link
Contributor Author

dhruv commented Mar 30, 2022

Rebased to resolve conflicts with #21160.

Addressed comments from @mzumsande and @kallewoof in #23900.

Ready for further review.

git range-diff 171f6f269 4a38f3e be9a830

@dhruv
Copy link
Contributor Author

dhruv commented Mar 30, 2022

Rebased. Ready for further review.

git range-diff 171f6f269 be9a830 f7cae59

@jonatack
Copy link
Member

jonatack commented Apr 4, 2022

Concept ACK

@dhruv
Copy link
Contributor Author

dhruv commented Mar 21, 2023

Rebased.

@DrahtBot
Copy link
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

@fanquake
Copy link
Member

fanquake commented May 6, 2023

Closing for now. This will be picked up again later. BIP324 review attention should be directed towards #27479 and bitcoin-core/secp256k1#1129.

@fanquake fanquake closed this May 6, 2023
@sipa sipa mentioned this pull request May 12, 2023
43 tasks
sipa added a commit to sipa/bitcoin-seeder that referenced this pull request Aug 29, 2023
b9c64db Add NODE_P2P_V2 to filters (Sjors Provoost)

Pull request description:

  Perhaps premature since bitcoin/bitcoin#24545 hasn't been merged yet, but I figured it would be handy if at least one seed supports it. Mine does now, only on mainnet:

  * `xc08.seed.bitcoin.sprovoost.nl` all SegWit enabled nodes including pruned ones
  * `x809.seed.bitcoin.sprovoost.nl` all SegWit enabled full archive nodes (needed for IBD)
  * for compact filters use `x849` for full archive nodes (or `xc48`, but Bitcoin Core only serves these filters on pruned nodes if they've been enabled since IBD, see bitcoin/bitcoin#21726)

  So far it's found one reachable node on IPv4.

  Usage (IPv4 vs IPv6, results under `ANSWER SECTION`):

  ```
  dig -t A xc08.seed.bitcoin.sprovoost.nl
  dig -t AAAA xc08.seed.bitcoin.sprovoost.nl
  ```

  Assuming modern node software won't need pre-segwit peers or bloom filters, these combinations have been omitted.

  Someone should sanity check the hex values.

ACKs for top commit:
  sipa:
    ACK b9c64db

Tree-SHA512: f6f8525e3ad997a2500a2b5f83273a328af53ddbd277c48dc7ea04f8a676189c1143cccb162c9e74a0ae7c3108996fa5acfd9472b8b58b1a64bb0c3b9eafa312
@bitcoin bitcoin locked and limited conversation to collaborators Sep 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Status: Needs review
Development

Successfully merging this pull request may close these issues.