Skip to content

Commit 4de1475

Browse files
LarryRuanebitschmidty
authored andcommitted
News268: Add review club n28165 (p2p v2 encrypted transport)
1 parent 30eb26c commit 4de1475

File tree

2 files changed

+90
-4
lines changed

2 files changed

+90
-4
lines changed

_posts/en/newsletters/2023-09-13-newsletter.md

Lines changed: 87 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,91 @@ Club][] meeting, highlighting some of the important questions and
6363
answers. Click on a question below to see a summary of the answer from
6464
the meeting.*
6565

66-
FIXME:LarryRuane
66+
[Transport abstraction][review club 28165] is a recently-merged PR by Pieter Wuille (sipa)
67+
that introduces a _transport_ abstraction (interface class). Concrete
68+
derivations of this class convert a (per-peer) connection's (already
69+
serialized) send and receive messages to and from wire format. This
70+
can be thought of as implementing a deeper level of serialization and
71+
deserialization. These classes do not do the actual sending and receiving.
72+
73+
The PR derives two concrete classes from the `Transport` class,
74+
`V1Transport` (what we have today) and `V2Transport` (encrypted on the
75+
wire). This PR is part of the
76+
[BIP324][topic v2 p2p transport]
77+
_Version 2 P2P Encrypted Transport Protocol_ [project][v2 p2p tracking pr].
6778

6879
{% include functions/details-list.md
69-
q0="FIXME"
70-
a0="FIXME"
71-
a0link="https://bitcoincore.reviews/28122#l-126FIXME"
80+
q0="What is the distinction between [*net*][net] and
81+
[*net_processing*][net_processing]?"
82+
a0="*Net* is at the bottom of the networking stack and handles
83+
low-level communication between peers, while *net_processing*
84+
builds on top of the *net* layer and handles the processing
85+
and validation of messages from *net* layer."
86+
a0link="https://bitcoincore.reviews/28165#l-22"
87+
88+
q1="More concretely, name examples of classes or functions that
89+
we'd associate with *net_processing*, and, in contrast,
90+
with *net*?"
91+
a1="*net_processing*: `PeerManager`, `ProcessMessage`.
92+
*net*: `CNode`, `ReceiveMsgBytes`, `CConnMan`."
93+
a1link="https://bitcoincore.reviews/28165#l-25"
94+
95+
q2="Does BIP324 require changes to the *net* layer, the
96+
*net_processing* layer, or both? Does it affect policy
97+
or consensus?"
98+
a2="These changes are only at the *net* layer; they don't affect consensus."
99+
a2link="https://bitcoincore.reviews/28165#l-37"
100+
101+
q3="What are examples of implementation bugs that could result in
102+
this PR being an (accidental) consensus change?"
103+
a3="A bug that restricts the maximum message size to less than
104+
4MB, which may cause the node to reject a block that other
105+
nodes consider valid; a bug in block
106+
deserialization that causes the node to reject a consensus-valid
107+
block."
108+
a3link="https://bitcoincore.reviews/28165#l-45"
109+
110+
q4="`CNetMsgMaker` and `Transport` both “serialize” messages.
111+
What is the difference in what they do?"
112+
a4="`CNetMsgMaker` performs the serialization of data structures
113+
into bytes; `Transport` receives these bytes, adds
114+
(serializes) the header, and actually sends it."
115+
a4link="https://bitcoincore.reviews/28165#l-60"
116+
117+
q5="In the process of turning an application object like a
118+
`CTransactionRef` (transaction) into bytes / network packets, what
119+
happens? Which data structures does it turn into in the process?"
120+
a5="`msgMaker.Make()` serializes the `CTransactionRef` message by
121+
calling `SerializeTransaction()`, then `PushMessage()` puts the
122+
serialized message into the `vSendMsg` queue, then `SocketSendData()`
123+
adds a header/checksum (after the changes from this PR) and asks the
124+
transport for the next packet to send, and finally calls `m_sock->Send()`."
125+
a5link="https://bitcoincore.reviews/28165#l-83"
126+
127+
q6="How many bytes are sent over the wire for the `sendtxrcncl`message
128+
(taking that message, used in [Erlay][topic erlay], as a simple example)?"
129+
a6="36 bytes: 24 for the header (magic 4 bytes, command 12 bytes,
130+
message size 4 bytes, checksum 4 bytes), then 12 bytes for the
131+
payload (version 4 bytes, salt 8 bytes)."
132+
a6link="https://bitcoincore.reviews/28165#l-86"
133+
134+
q7="After `PushMessage()` returns, have we sent the bytes corresponding
135+
to this message to the peer already (yes/no/maybe)? Why?"
136+
a7="All are possible. **Yes**: we (*net_processing*) don't have to do
137+
anything else to cause the message to be sent.
138+
**No**: it's extremely unlikely to have
139+
been received by the recipient by the time that function returns.
140+
**Maybe**: if all the queues are empty it will have made it to the
141+
kernel socket layer, but if some of the queues aren't, then it
142+
will still be waiting on those to drain further before getting
143+
to the OS."
144+
a7link="https://bitcoincore.reviews/28165#l-112"
145+
146+
q8="Which threads access `CNode::vSendMsg`?"
147+
a8="`ThreadMessageHandler` if the message is sent synchronously
148+
(\"optimistically\"); `ThreadSocketHandler` if it gets queued
149+
and picked up and sent later."
150+
a8link="https://bitcoincore.reviews/28165#l-120"
72151
%}
73152

74153
## Releases and release candidates
@@ -97,9 +176,13 @@ Proposals (BIPs)][bips repo], [Lightning BOLTs][bolts repo], and
97176
{% include references.md %}
98177
{% include linkers/issues.md v=2 issues="26567" %}
99178
[LND v0.17.0-beta.rc2]: https://github.com/lightningnetwork/lnd/releases/tag/v0.17.0-beta.rc2
179+
[net]: https://github.com/bitcoin/bitcoin/blob/master/src/net.h
180+
[net_processing]: https://github.com/bitcoin/bitcoin/blob/master/src/net_processing.h
100181
[news195 taro]: /en/newsletters/2022/04/13/#transferable-token-scheme
101182
[osuntokun bips]: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2023-September/021938.html
102183
[osuntokun blip post]: https://lists.linuxfoundation.org/pipermail/lightning-dev/2023-September/004089.html
103184
[osuntokun blip]: https://github.com/lightning/blips/pull/29
185+
[review club 28165]: https://bitcoincore.reviews/28165
104186
[sanders post]: https://lists.linuxfoundation.org/pipermail/lightning-dev/2023-September/004088.html
105187
[sanders ptlc]: https://gist.github.com/instagibbs/1d02d0251640c250ceea1c66665ec163
188+
[v2 p2p tracking pr]: https://github.com/bitcoin/bitcoin/issues/27634

_topics/en/v2-p2p-transport.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ optech_mentions:
5959
- title: "Bitcoin Core #28008 adds encryption and decryption routines for v2 transport protocol encryption"
6060
url: /en/newsletters/2023/08/16/#bitcoin-core-28008
6161

62+
- title: "Bitcoin Core PR Review Club summary about internal serialization changes for BIP324"
63+
url: /en/newsletters/2023/09/13/#bitcoin-core-pr-review-club
64+
6265
## Optional. Same format as "primary_sources" above
6366
see_also:
6467
- title: BIP151

0 commit comments

Comments
 (0)