Skip to content

Commit 43e3983

Browse files
authored
Merge pull request #2086 from ajtowns/202512-bip324-shortid-alias
BIP 324: Clarify equivalence between 1 and 13 byte message types
2 parents e169a61 + 40e6634 commit 43e3983

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

bip-0324.mediawiki

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
Type: Specification
1111
Assigned: 2019-03-08
1212
License: BSD-3-Clause
13+
Version: 1.0.1
1314
Replaces: 151
1415
</pre>
1516

@@ -530,7 +531,9 @@ v2 Bitcoin P2P transport layer packets use the encrypted message structure shown
530531
531532
If the first byte of <code>message_type</code> is <code>b'\x00'</code>, the following 12 bytes are interpreted as an ASCII message type (as in the v1 P2P protocol), trailing padded with <code>b'\x00'</code> as necessary. If the first byte of <code>message_type</code> is in the range ''1..255'', it is interpreted as a message type ID. This structure results in smaller messages than the v1 protocol, as most messages sent/received will have a message type ID. We recommend reserving 1-byte type IDs for message types that are sent more than once per direction per connection.<ref name="smaller_messages">'''How do the lengths between v1 and v2 compare?''' For messages that use the 1-byte short message type ID, v2 packets use 3 bytes less per message than v1.</ref><ref name"fixed_length_long_ids">'''Why not allow variable length long message type IDs?''' Allowing for variable length long IDs reduces the available 1-byte ID space by 12 (to encode the length itself) and incentivizes less descriptive message types. In addition, limiting message types to fixed lengths of 1 or 13 hampers traffic analysis.</ref>
532533
533-
The following table lists currently defined message type IDs:
534+
The value of <code>message_length</code> is '''length''' minus the size of the <code>message_type</code>.
535+
536+
The following table lists currently defined message type IDs and the 12-byte ASCII message type (trimmed of trailing padding) that they are treated as equivalent to:
534537
535538
{| class="wikitable"
536539
|-
@@ -541,35 +544,36 @@ The following table lists currently defined message type IDs:
541544
!3
542545
|-
543546
!+0
544-
|(12 bytes follow)||<code>ADDR</code>||<code>BLOCK</code>||<code>BLOCKTXN</code>
547+
|(12 bytes follow)||<code>addr</code>||<code>block</code>||<code>blocktxn</code>
545548
|-
546549
!+4
547-
|<code>CMPCTBLOCK</code>||<code>FEEFILTER</code>||<code>FILTERADD</code>||<code>FILTERCLEAR</code>
550+
|<code>cmpctblock</code>||<code>feefilter</code>||<code>filteradd</code>||<code>filterclear</code>
548551
|-
549552
!+8
550-
|<code>FILTERLOAD</code>||<code>GETBLOCKS</code>||<code>GETBLOCKTXN</code>||<code>GETDATA</code>
553+
|<code>filterload</code>||<code>getblocks</code>||<code>getblocktxn</code>||<code>getdata</code>
551554
|-
552555
!+12
553-
|<code>GETHEADERS</code>||<code>HEADERS</code>||<code>INV</code>||<code>MEMPOOL</code>
556+
|<code>getheaders</code>||<code>headers</code>||<code>inv</code>||<code>mempool</code>
554557
|-
555558
!+16
556-
|<code>MERKLEBLOCK</code>||<code>NOTFOUND</code>||<code>PING</code>||<code>PONG</code>
559+
|<code>merkleblock</code>||<code>notfound</code>||<code>ping</code>||<code>pong</code>
557560
|-
558561
!+20
559-
|<code>SENDCMPCT</code>||<code>TX</code>||<code>GETCFILTERS</code>||<code>CFILTER</code>
562+
|<code>sendcmpct</code>||<code>tx</code>||<code>getcfilters</code>||<code>cfilter</code>
560563
|-
561564
!+24
562-
|<code>GETCFHEADERS</code>||<code>CFHEADERS</code>||<code>GETCFCHECKPT</code>||<code>CFCHECKPT</code>
565+
|<code>getcfheaders</code>||<code>cfheaders</code>||<code>getcfcheckpt</code>||<code>cfcheckpt</code>
563566
|-
564567
!+28
565-
|<code>ADDRV2</code>
568+
|<code>addrv2</code>
566569
|-
567570
!&geq;29
568571
|| colspan="4" | (undefined)
569572
|}
570573
574+
When a message type has both a 1-byte encoding and a 13-byte encoding defined, peers that support receiving that message type should accept messages using either encoding (e.g., if the "getblocktxn" message type is supported, then both the 1-byte <code>b'\x0a'</code> encoding and the 13-byte <code>b'\x00getblocktxn\x00'</code> should be supported, and behavior should not depend on which of the two encodings is received).
571575
572-
Additional message types may be added separately after BIP finalization.
576+
Additional message type IDs may be added separately after BIP finalization.
573577
574578
=== Signaling specification ===
575579
==== Signaling v2 support ====
@@ -583,6 +587,13 @@ For development and testing purposes, we provide a collection of test vectors in
583587
* [[bip-0324/xswiftec_inv_test_vectors.csv|XSwiftECInv vectors]] provide examples of ''(u, x)'' pairs, and the various ''t'' values that ''xswiftec_inv'' maps them to.
584588
* [[bip-0324/packet_encoding_test_vectors.csv|Packet encoding vectors]] illustrate the lifecycle of the authenticated encryption scheme proposed in this document.
585589
590+
== Changelog ==
591+
592+
* 1.0.1 (2026-01-16)
593+
* Specify equivalence of 1-byte and 13-byte `message_type`
594+
* 1.0.0 (2024-07-10)
595+
* Marked as Final
596+
586597
== Rationale and References ==
587598
<references/>
588599

0 commit comments

Comments
 (0)