You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: update packet-format.md to the 128-bit NodeId wire layout (closes the 2.4 doc gap)
The NodeId widening (2.4) doubled every on-the-wire NodeId from 8 to 16 bytes but
packet-format.md still documented the u64/8-byte layout. Updated throughout:
- NodeId is 16 raw bytes (not a u64); header is 17 B (was 9); sender/originator/
event.creator and breadcrumb NodeIds are 16 B each.
- Recomputed every size: clock notification 89->97 B; chain request base 89->113
(+16.h breadcrumb); chain response 21->37 + 16.h + EventChain; EventReference
44->52 B; Event 64+d+44r -> 72+d+52r; ClockEvent 76+44r -> 84+52r; and the hash
preimage's ref-creator is now 16 B.
These match the empirical sim run (packet bytes +~14%, e.g. every clock notification +8 B).
Copy file name to clipboardExpand all lines: doc/packet-format.md
+50-49Lines changed: 50 additions & 49 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,7 +48,8 @@ All multi-byte integers are **big-endian (network byte order)**.
48
48
| --- | --- | --- |
49
49
|`u8`| 1 byte | Used for the message type tag. |
50
50
|`u32`| 4 bytes, big-endian | Used only as a length / count prefix. |
51
-
|`u64`| 8 bytes, big-endian | All identifiers, salts, timestamps. |
51
+
|`u64`| 8 bytes, big-endian | Salts and timestamps. |
52
+
|`NodeId`| 16 raw bytes (fixed) | A node's 128-bit identity — written as 16 bytes, not an integer. |
52
53
|`blob`|`u32 length` then *length* raw bytes | Any variable-length byte string (hashes, content, signatures). A zero-length blob is 4 bytes (`length = 0`). |
53
54
|`array<T>`|`u32 count` then *count* × `T`| Repeated elements, each encoded in turn. |
54
55
@@ -62,7 +63,7 @@ How each logical field type maps onto the primitives above:
62
63
63
64
| Field type | Wire encoding | Typical size | Meaning |
64
65
| --- | --- | --- | --- |
65
-
|`NodeId`|`u64`| 8 B | A node's identity. |
66
+
|`NodeId`|16 raw bytes | 16 B | A node's **128-bit**identity — the first 16 bytes of `SHA-256(pubkey)`. |
66
67
|`Salt`|`u64`| 8 B | Random salt folded into a hash. |
67
68
|`Timestamp`|`u64`| 8 B | A raw clock tick (nanoseconds in production), signed 64-bit reinterpreted as `u64`. |
68
69
|`TimeRange`| two `u64` (`lo`, `hi`) | 16 B | A closed `[lo, hi]` window of `Timestamp` ticks — a discovery's estimated time window. |
@@ -78,24 +79,24 @@ How each logical field type maps onto the primitives above:
78
79
79
80
## Datagram header
80
81
81
-
**Every** datagram begins with the same 9-byte header (`write_header` in
82
+
**Every** datagram begins with the same 17-byte header (`write_header` in
82
83
[`packets.cpp`](../src/core/wire/packets.cpp)):
83
84
84
85
| Offset | Size | Field | Encoding | Meaning |
85
86
| --- | --- | --- | --- | --- |
86
87
| 0 | 1 B |`type`|`u8`| Message type: `0` = clock notification, `1` = chain request, `2` = chain response. Selects how the rest of the datagram is parsed. |
87
-
| 1 |8 B |`sender`|`u64`| The **sender's** own `NodeId`. Lets the receiver identify the neighbor; the payload that follows never repeats it. |
88
+
| 1 |16 B |`sender`|`NodeId`| The **sender's** own `NodeId`. Lets the receiver identify the neighbor; the payload that follows never repeats it. |
**Header size: 9 bytes** (fixed, on every datagram).
99
+
**Header size: 17 bytes** (fixed, on every datagram).
99
100
100
101
The three `type` values and their payloads:
101
102
@@ -115,7 +116,7 @@ node's clock DAG. A node runs several independent, geometrically-spaced clock ch
115
116
[implementation.md](implementation.md#multi-resolution-clock-chains)), so the notification
116
117
carries a `chain` id alongside the two hashes — never the clock event's contents.
117
118
118
-
Payload after the 9-byte header:
119
+
Payload after the 17-byte header:
119
120
120
121
| Field | Encoding | Meaning |
121
122
| --- | --- | --- |
@@ -124,13 +125,13 @@ Payload after the 9-byte header:
124
125
|`neighbor_last_clock_event_hash`|`blob` (EventHash) | Hash of the newest clock event the sender has heard **from this neighbor on that chain** — the back-reference that stitches the two DAGs together. |
is the breadcrumb length (one entry per hop travelled so far). Variable — one 16-byte `NodeId` is
169
+
appended to the breadcrumb at each hop.
169
170
170
171
Routing: if `event.creator` is this node, it builds the enclosing chain locally and replies with a
171
172
chain response. Otherwise it appends itself to `path` and forwards a copy to **each** next hop its
@@ -182,22 +183,22 @@ way back, **extends** the chain with its own clock-event bounds before forwardin
182
183
to the originator — **along the reverse-path breadcrumb the request recorded**, not via a routing
183
184
table (the response never re-routes).
184
185
185
-
Payload after the 9-byte header:
186
+
Payload after the 17-byte header:
186
187
187
188
| Field | Encoding | Meaning |
188
189
| --- | --- | --- |
189
-
|`originator`|`u64` (NodeId) | Copied from the request; identifies the discovery. The response is *home* when it reaches this node. |
190
+
|`originator`|`NodeId` (16 B) | Copied from the request; identifies the discovery. The response is *home* when it reaches this node. |
190
191
|`chain`|`EventChain` (see below) | The accreting proof: the target event plus a lower- and upper-bound run of clock events. Grows at each hop. |
191
192
|`path`|`array<NodeId>`| The **remaining** reverse-path breadcrumb toward the originator: the next hop is `path.back()`, popped at each hop; empty once the response reaches the originator. |
0 commit comments