On Thu, Feb 16, 2023 at 05:43:22PM +0000, Dhruv M via bitcoin-dev wrote: > Problem: > - 1 byte message type IDs are lacking a co-ordination mechanism when multiple > in-flight BIPs are proposing new message types as the id space is reduced > form 12 ASCII bytes to 1 byte. > - 1 byte IDs are scarce and should be allocated judiciously, especially given > that gains on bandwidth are very much non-uniform across message types.
ACK. > Solutions: > - Uniform encoding using the high-bit increases the available ID space > drastically, however, there's still the issue of making sure that the most > frequent message types get the shorter IDs. > - Making type IDs negotiable(editable, really) per direction per connection > solves that issue at the cost of some increased complexity. > > Since we don't really know the extent to which the protocol will ossify over > time and that BIP324 is already quite a large change, we might want to > optimize for the least additional complexity that doesn't close the doors on > any of the solutions. I think it's probably less complex to close *some* of the doors? In particular, I think there's two questions that have to get answered: 1) how do you distinguish the command from the payload for non short-ids -- by a length prefix, or by setting the high-bit of the final command byte? 2) are short ids available/meaningful to send prior to VERACK being completed? > How about this: > - BIP324 restricts type IDs to [1, 127] Is this for short ids (currently [13-255] per the bip) or for every byte in a non-short-id command (for p2p v1, IsCommandValid() restricts each byte to being in the printable ascii range, ie [32-126])? Here's another approach: idea: we use short ids to minimise bandwidth, and don't care about bandwidth for long ids implementation: short id 0 is reserved for long commands. when received, we decode the first 12 bytes of the payload and treat them exactly the same as a v1 p2p message (trailing 0-bytes, etc) (if there's not 12 bytes of payload, it's just treated as an invalid command and dropped) short ids 1-255 are available for use as aliases of particular long commands (That's exactly compatible with p2p v1, and also avoids the temptation to try to choose short command names rather than descriptive ones -- the 0-padding to 12 bytes prevents you from saving any bandwidth that way; but that's what we have short ids for anyway) If we decide we want >255 short ids, we can figure out how to extend them later, in a fairly open ended way I think, eg by having [128-255] imply a 2 byte short id, so that seems fine? > - We remove 1 byte allocations for messages that are sent at most once per > connection per direction I think this leaves 32 commands that get short ids initially: misc: ADDR, ADDRV2, BLOCK, FEEFILTER, GETBLOCKS, GETDATA, GETHEADERS, HEADERS, INV, NOTFOUND, PING, PONG, TX bip 35/37: FILTERADD, FILTERCLEAR, FILTERLOAD, MEMPOOL, MERKLEBLOCK bip 152: BLOCKTXN, CMPCTBLOCK, GETBLOCKTXN bip 157: CFCHECKPT, CFHEADERS, CFILTER, GETCFCHCKPT, GETCFHEADERS, GETCFILTERS bip 330: RECONCILDIFF, REQRECON, REQSKETCHEXT, SENDCMPCT, SKETCH which drops: VERSION, VERACK, GETADDR, SENDADDRV2, SENDHEADERS, SENDTXRCNCL, WTXIDRELAY compared to bip 324 currently. I think the things missing from the current list (and not currently in use by bitcoin core) are: bip 61: REJECT bip 331: GETPKGTXNS, PKGTXNS, ANCPKGINFO > - Optionally, in the implementation we can attempt to move the type id > mapping to the p2p layer away from the transport layer. I suspect this could > also be done after the implementation is merged but might be cleaner as the > mapping is a p2p concern. I agree that's fine, though I expect that we'll probably want to do it not long after bip 331 is ready for merge (or some other p2p improvement comes along)... Cheers, aj _______________________________________________ bitcoin-dev mailing list email@example.com https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev