Pieter Wuille [ARCHIVE] on Nostr: 📅 Original date posted:2022-11-10 📝 Original message:Hi, Thanks for the ...
📅 Original date posted:2022-11-10
📝 Original message:Hi,
Thanks for the comments so far. I think these are all reasonable ideas.
Comments inline below.
On Thursday, November 3rd, 2022 at 1:53 PM, Murch wrote:
> From what I understand we'll have about 35 message types on the network
> with the addition of BIP324. 256 possible IDs sounds like plenty room to
> grow, but perhaps we can be a bit more conservative:
>
> We could use the first bit to signal a 2-byte message ID. That allows us
> to express 128 IDs with 1 byte, but if we need more, we get a total of
> 2^15 IDs across 2 bytes.
Yeah, effectively treating the first 1 or 2 bytes as a simple variable
length integer is a nice way of increasing the space at low cost.
This also doesn't need to be decided now. The initial approach could just
be avoiding allocating bytes in the 128-255 range until the need for more
space arises. If and when that is the case, the choice could be to:
* Just continue treating the first byte as the command.
* Start treating the first upper bit as a sign that another command byte
follows.
* Switch to some form of explicit signalling (option 3 is my earlier
mail).
On Thursday, November 3rd, 2022 at 6:26 PM, Jonas Schnelli wrote:
> There would be an alternative to preserve more 1 byte IDs on the cost
> of a (much) smaller 2 byte ID space: Reserve the short ID 0xFF as an
> indication for a 2 bytes short ID (additional 256 short IDs with 2 bytes).
I don't think this is needed, because we arguably already have that! If the
first byte is 0x01, then 1 more command byte follows in the current BIP324
draft. That mechanism is designed for alphabetic 1-character commands, but
nothing prevents it from also being used for other things (by using a
non-alphabetic byte there).
> Maybe the BIP should state that only frequent sent messages should reserve
> a short ID, though, the BIP itself assigns short IDs to all(?) message
> types (including low frequent messages like SENDHEADERS).
>
> Maybe exclude message types that expected to be only sent once from
> assigning a short ID?
I think that makes sense. Especially in combination with the idea avoiding
bytes with the upper bit set there is a bit more pressure on the 1-byte
space. Rarely-sent or at-most-once-sent commands don't really provide much
benefit. I'd suggest scrapping from the list:
* Version messages: version, verack
* Negotiation messages: sendaddrv2, sendheaders, sendcmpct, wtxidrelay
* Rarely-sent messages: mempool
I'm not sure to what extent filteradd/filterload/filterclear/merkleblock
are still actually used; perhaps they could be removed too?
On Monday, November 7th, 2022 at 10:20 PM, Anthony Towns wrote:
> I guess I think it would make sense to not start using a novel 1-byte
> message unless you've done something to introduce that message first;
> whether that's via approach (3) ("I'm going to use 0xE9 to mean pkgtxns")
> or via a multibyte feature support message ("I sent sendaddrv3 as a
> 10-byte message, that implies 0xA3 means addrv3 from now on").
That's fair, but I don't think it matters too much for allocation purposes;
protocol designs should still not assign overlapping values, unless the
protocols are known to never be used simultaneously?
Unless... the assignment works like "whenever the sendaddrv3 is sent, the
next available byte in range 48..127 gets allocated for addrv3". That means
no explicit mapping is needed, as long as the total number of messages from
simultaneously-active extensions isn't too large.
> I do still think it'd be better to recommend against reserving a byte for
> one-shot messages, and not do it for existing one-shot messages though.
Agree.
FWIW, if anyone was wondering about how much is actually saved by having
1-byte commands vs 12-byte commands, I've gathered statistics from two nodes
(one with many inbound connections, one only outbound) for two weeks. This is
obviously very dependent on network topology and local implementation choices,
but it may still give an idea:
* Outbound-only node:
* Around 4.5% of sent bytes are bytes 2-12 of the command.
* Sent 979.98 MiB in total.
* Outbound and inbound node:
* Around 1.6% of sent bytes are bytes 2-12 of the command.
* Sent 124.14 GiB in total.
Cheers,
--
Pieter
Published at
2023-06-07 23:16:41Event JSON
{
"id": "efc66f08de0d5b6f92b77d96fe95e92d8ecab17f41856fc0440f6ea865695bb5",
"pubkey": "5cb21bf5d7f25a9d46879713cbd32433bbc10e40ef813a3c28fe7355f49854d6",
"created_at": 1686179801,
"kind": 1,
"tags": [
[
"e",
"0b6976e30325aea9b669739427371b54a6cc5a5d15b03cbe62f2441b51dd9a2e",
"",
"root"
],
[
"e",
"cd31c9338991f403c72c6dd136714f32631fc0490f90b6ce09680219aae56c43",
"",
"reply"
],
[
"p",
"f0feda6ad58ea9f486e469f87b3b9996494363a26982b864667c5d8acb0542ab"
]
],
"content": "📅 Original date posted:2022-11-10\n📝 Original message:Hi,\n\nThanks for the comments so far. I think these are all reasonable ideas.\nComments inline below.\n\nOn Thursday, November 3rd, 2022 at 1:53 PM, Murch wrote:\n\n\u003e From what I understand we'll have about 35 message types on the network\n\u003e with the addition of BIP324. 256 possible IDs sounds like plenty room to\n\u003e grow, but perhaps we can be a bit more conservative:\n\u003e \n\u003e We could use the first bit to signal a 2-byte message ID. That allows us\n\u003e to express 128 IDs with 1 byte, but if we need more, we get a total of\n\u003e 2^15 IDs across 2 bytes.\n\nYeah, effectively treating the first 1 or 2 bytes as a simple variable\nlength integer is a nice way of increasing the space at low cost.\n\nThis also doesn't need to be decided now. The initial approach could just\nbe avoiding allocating bytes in the 128-255 range until the need for more\nspace arises. If and when that is the case, the choice could be to:\n* Just continue treating the first byte as the command.\n* Start treating the first upper bit as a sign that another command byte\n follows.\n* Switch to some form of explicit signalling (option 3 is my earlier\n mail).\n\nOn Thursday, November 3rd, 2022 at 6:26 PM, Jonas Schnelli wrote:\n\n\u003e There would be an alternative to preserve more 1 byte IDs on the cost\n\u003e of a (much) smaller 2 byte ID space: Reserve the short ID 0xFF as an\n\u003e indication for a 2 bytes short ID (additional 256 short IDs with 2 bytes).\n\nI don't think this is needed, because we arguably already have that! If the\nfirst byte is 0x01, then 1 more command byte follows in the current BIP324\ndraft. That mechanism is designed for alphabetic 1-character commands, but\nnothing prevents it from also being used for other things (by using a\nnon-alphabetic byte there).\n\n\u003e Maybe the BIP should state that only frequent sent messages should reserve\n\u003e a short ID, though, the BIP itself assigns short IDs to all(?) message\n\u003e types (including low frequent messages like SENDHEADERS).\n\u003e \n\u003e Maybe exclude message types that expected to be only sent once from\n\u003e assigning a short ID?\n\nI think that makes sense. Especially in combination with the idea avoiding\nbytes with the upper bit set there is a bit more pressure on the 1-byte\nspace. Rarely-sent or at-most-once-sent commands don't really provide much\nbenefit. I'd suggest scrapping from the list:\n* Version messages: version, verack\n* Negotiation messages: sendaddrv2, sendheaders, sendcmpct, wtxidrelay\n* Rarely-sent messages: mempool\n\nI'm not sure to what extent filteradd/filterload/filterclear/merkleblock\nare still actually used; perhaps they could be removed too?\n\nOn Monday, November 7th, 2022 at 10:20 PM, Anthony Towns wrote:\n\n\u003e I guess I think it would make sense to not start using a novel 1-byte\n\u003e message unless you've done something to introduce that message first;\n\u003e whether that's via approach (3) (\"I'm going to use 0xE9 to mean pkgtxns\")\n\u003e or via a multibyte feature support message (\"I sent sendaddrv3 as a\n\u003e 10-byte message, that implies 0xA3 means addrv3 from now on\").\n\nThat's fair, but I don't think it matters too much for allocation purposes;\nprotocol designs should still not assign overlapping values, unless the\nprotocols are known to never be used simultaneously?\n\nUnless... the assignment works like \"whenever the sendaddrv3 is sent, the\nnext available byte in range 48..127 gets allocated for addrv3\". That means\nno explicit mapping is needed, as long as the total number of messages from\nsimultaneously-active extensions isn't too large.\n\n\u003e I do still think it'd be better to recommend against reserving a byte for\n\u003e one-shot messages, and not do it for existing one-shot messages though.\n\nAgree.\n\nFWIW, if anyone was wondering about how much is actually saved by having\n1-byte commands vs 12-byte commands, I've gathered statistics from two nodes\n(one with many inbound connections, one only outbound) for two weeks. This is\nobviously very dependent on network topology and local implementation choices,\nbut it may still give an idea:\n* Outbound-only node:\n * Around 4.5% of sent bytes are bytes 2-12 of the command.\n * Sent 979.98 MiB in total.\n* Outbound and inbound node:\n * Around 1.6% of sent bytes are bytes 2-12 of the command.\n * Sent 124.14 GiB in total.\n\nCheers,\n\n-- \nPieter",
"sig": "53b8cd66af9ae3982d71d6718656f5f8c6bda549b1687a63ad7a2ec31aa114dfb3b9b58f80ee23c79b14dd85c913d97f67b9e545d032ec6966f26dd4319fbcdd"
}