Return-Path: Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7E79DC002B for ; Fri, 17 Feb 2023 15:51:32 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 54393402BC for ; Fri, 17 Feb 2023 15:51:32 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 54393402BC X-Virus-Scanned: amavisd-new at osuosl.org X-Spam-Flag: NO X-Spam-Score: -1.902 X-Spam-Level: X-Spam-Status: No, score=-1.902 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Z3hSBqjifJhY for ; Fri, 17 Feb 2023 15:51:29 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 5155A40191 Received: from cerulean.erisian.com.au (azure.erisian.com.au [172.104.61.193]) by smtp2.osuosl.org (Postfix) with ESMTPS id 5155A40191 for ; Fri, 17 Feb 2023 15:51:29 +0000 (UTC) Received: from 60.42.96.58.static.exetel.com.au ([58.96.42.60] helo=sapphire.erisian.com.au) by cerulean.erisian.com.au with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pT319-0004Yt-4G; Sat, 18 Feb 2023 01:51:25 +1000 Received: by sapphire.erisian.com.au (sSMTP sendmail emulation); Sat, 18 Feb 2023 01:51:19 +1000 Date: Sat, 18 Feb 2023 01:51:19 +1000 From: Anthony Towns To: Dhruv M , Bitcoin Protocol Discussion Message-ID: References: <56677685-619a-691f-d5bc-54b69fdb6ed2@bip324.com> <6b83c32e-59ca-65ef-2553-d66f8d117e56@bip324.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6b83c32e-59ca-65ef-2553-d66f8d117e56@bip324.com> X-Spam_score: -1.0 X-Spam_bar: - Subject: Re: [bitcoin-dev] Refreshed BIP324 X-BeenThere: bitcoin-dev@lists.linuxfoundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Bitcoin Protocol Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Feb 2023 15:51:32 -0000 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