From 7936bc049e3812532f8fe4cf480c995e582ae20c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Tue, 19 Dec 2023 15:14:53 -0300 Subject: [PATCH] docs: add `GetMetadata` example (#538) --- docs/snappy.md | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 docs/snappy.md diff --git a/docs/snappy.md b/docs/snappy.md new file mode 100644 index 000000000..ea72c8540 --- /dev/null +++ b/docs/snappy.md @@ -0,0 +1,55 @@ +# Metadata request example + +After sending a *GetMetadata* request to a peer, I get as a response: + +`0011ff060000734e6150705901150000cd11e7d53a03000000000000ffffffffffffffff0f` + +## *GetMetadata* request header + +Decoding it with the protocol described in the consensus specs (**Req/Resp interaction**), we get: + +```elixir +# Status (success) +"00" +# Optional header (uncompressed length: 17) +"11" +# Encoded data +"ff060000734e6150705901150000cd11e7d53a03000000000000ffffffffffffffff0f" +``` + +## *Snappy* framing format + +We can interpret the encoded data with the Snappy framing format described in [google/snappy](https://github.com/google/snappy/blob/main/framing_format.txt). +Then we get: + +```elixir +### Chunk start ### +# Chunk type (stream identifier) +"ff" +# Chunk size in LE (6) +"060000" +# Chunk data ("sNaPpY" in ASCII) +"734e61507059" + +### Chunk start ### +# Chunk type (uncompressed data) +"01" +# Chunk size in LE (21) +"150000" +# CRC-32C checksum (4 bytes; little-endian) +"cd11e7d5" +# SSZ encoded payload (uncompressed) +"3a03000000000000ffffffffffffffff0f" +``` + +## *SSZ* + +Decoding the payload with [simpleserialize.com](https://simpleserialize.com/), we find the received message: + +```json +{ + "seq_number": "826", + "attnets": "0xffffffffffffffff", + "syncnets": "0x0f" +} +```