Return-Path: Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 4E993CCD for ; Mon, 18 Dec 2017 16:40:12 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail8.dominiofaidate.com (mail8.dominiofaidate.com [212.35.195.17]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id B0982456 for ; Mon, 18 Dec 2017 16:40:08 +0000 (UTC) Received: from bto20160722 (host37-187-static.103-195-b.business.telecomitalia.it [195.103.187.37]) by mail8.dominiofaidate.com with ESMTPA ; Mon, 18 Dec 2017 17:40:03 +0100 From: "Alberto De Luigi" To: Date: Mon, 18 Dec 2017 17:40:08 +0100 Message-ID: <003c01d3781e$dda115f0$98e341d0$@albertodeluigi.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_003D_01D37827.3F67C7E0" X-Mailer: Microsoft Outlook 16.0 Thread-Index: AdN4GlzdacPQd1hIQO+3VMTcs3pyrA== Content-Language: it X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_20,HTML_MESSAGE, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org X-Mailman-Approved-At: Mon, 18 Dec 2017 16:41:53 +0000 Subject: [bitcoin-dev] Clarification about SegWit transaction size and bech32 X-BeenThere: bitcoin-dev@lists.linuxfoundation.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Bitcoin Protocol Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Dec 2017 16:40:12 -0000 This is a multipart message in MIME format. ------=_NextPart_000_003D_01D37827.3F67C7E0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hello guys, I have a few questions about the SegWit tx size, I'd like to have confirmation about the following statements. Can you correct mistakes or inaccuracies? Thank you in advance. In general, SegWit tx costs more than legacy tx (source https://bitcoincore.org/en/2016/10/28/segwit-costs/): * Compared to P2PKH, P2WPKH uses 3 fewer bytes (-1%) in the scriptPubKey, and the same number of witness bytes as P2PKH scriptSig. * Compared to P2SH, P2WSH uses 11 additional bytes (6%) in the scriptPubKey, and the same number of witness bytes as P2SH scriptSig. * Compared to P2PKH, P2WPKH/P2SH uses 21 additional bytes (11%), due to using 24 bytes in scriptPubKey, 3 fewer bytes in scriptSig than in P2PKH scriptPubKey, and the same number of witness bytes as P2PKH scriptSig. * Compared to P2SH, P2WSH/P2SH uses 35 additional bytes (19%), due to using 24 bytes in scriptPubKey, 11 additional bytes in scriptSig compared to P2SH scriptPubKey, and the same number of witness bytes as P2SH scriptSig. But still it is convenient to adopt segwit because you move the bytes to the blockweight part, paying smaller fee. In general, a tx with 1 input and 1 output is about 190kb. If it's a Segwit tx, 82kb in the non-witness part (blocksize), 108 in the witness part (blockweight). See source: 4 bytes version 1 byte input count Input 36 bytes outpoint 1 byte scriptSigLen (0x00) 0 bytes scriptSig 4 bytes sequence 1 byte output count 8 bytes value 1 byte scriptPubKeyLen 22 bytes scriptPubKey (0x0014{20-byte keyhash}) 4 bytes locktime https://bitcoin.stackexchange.com/questions/59408/with-100-segwit-transactio ns-what-would-be-the-max-number-of-transaction-confi Which means, if you fill a block entirely with this kind of tx, you can approximately double the capacity of the blockchain (blocksize capped to 1mb, blockweight a little bit more than 2mb) My concern is about segwit adoption by the exchanges. SegWit transactions cost 10bytes more than legacy transactions for each output (vout is 256 bits instead of 160). Exchanges aggregate tx adding many outputs, which is of course something good for bitcoin scalability, since this way we save space and pay less fees. But when a tx has at least 10 outputs, using segwit you don't save space, instead: - the total blockweight is at least 100bytes higher (10bytes x 10 outputs), so the blockchain is heavier - you don't save space inside the blocksize, so you cannot validate more transactions of this kind (with many outputs), nor get cheaper fee - without cheaper fees exchanges have no incentives for segwit adoption before they decide to adopt LN In general we can say that using SegWit: - you decrease the fee only for some specific kind of transactions, and just because you move some bytes to the blockweight - you don't save space in the blockchain, on the contrary the total weight of the blockchain increases (so it's clear to me why some time ago Luke tweeted to not use SegWit unless really necessary... but then it's not clear why so much haste in promoting BIP148 the 1st august risking a split) If it's all correct, does something change with bech32? I'm reading bech32 allows to save about 22% of the space. Is this true for whatever kind of tx? Immediate benefits of segwit for scalability are only with bech32? Bech32 is non-compatible with the entire ecosystem (you cannot receive coins from the quasi-totality of wallets in circulation), I would say it is a hard fork. But the bare segwit is really so different? the soft fork is "soft" for the reference client Bitcoin Core, but outside you cannot know what happens, there are plenty of implementations (especially frontend customization) which don't work with segwit and need to upgrade. To upgrade takes a lot of time, especially when services are so crowded and so many new people want to step in. At this point, if bech32 brings only efficiency (but correct me if it's not so) and it is well planned, it could be a consensual upgrade, maybe together with a 2x blocksize? Is there a specific plan for some upgrade in 2018? I personally think it is far easier to reach consensus on a blocksize increase una tantum rather than a dynamic increase. You cannot predict the technology growth: will it be linear, exponential, or suddenly stop for a while, maybe right before a huge innovation? I think a hard fork bech32 upgrade + 2x could help a lot in scalability while we test LN, and it might be the only way to effectively promote (or should I say enforce?) SegWit adoption. thank you, Alberto De Luigi (.com) ------=_NextPart_000_003D_01D37827.3F67C7E0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hello guys,

I have a few questions about the = SegWit tx size, I'd like to have confirmation about the following = statements. Can you correct mistakes or inaccuracies? Thank you in = advance.

 

In general, SegWit tx costs more than legacy tx (source https://bitc= oincore.org/en/2016/10/28/segwit-costs/):

 

  • Compared to P2PKH, P2WPKH uses 3 fewer bytes (-1%) in the = scriptPubKey, and the same number of witness bytes as P2PKH = scriptSig.
  • Compared to P2SH, P2WSH uses 11 additional bytes (6%) in = the scriptPubKey, and the same number of witness bytes as P2SH = scriptSig.
  • Compared to P2PKH, P2WPKH/P2SH uses 21 additional bytes = (11%), due to using 24 bytes in scriptPubKey, 3 fewer bytes in scriptSig = than in P2PKH scriptPubKey, and the same number of witness bytes as = P2PKH scriptSig.
  • Compared to P2SH, P2WSH/P2SH uses 35 additional bytes = (19%), due to using 24 bytes in scriptPubKey, 11 additional bytes in = scriptSig compared to P2SH scriptPubKey, and the same number of witness = bytes as P2SH scriptSig.

 

But still it is convenient to adopt = segwit because you move the bytes to the blockweight part, paying = smaller fee. In general, a tx with 1 input and 1 output is about 190kb. = If it's a Segwit tx, 82kb in the non-witness part (blocksize), 108 in = the witness part (blockweight).

See source:

4 bytes = version

1 = byte input count

Input

36 bytes outpoint

1 byte scriptSigLen = (0x00)

0 = bytes scriptSig

4 bytes sequence

1 byte output = count

8 = bytes value

1 byte scriptPubKeyLen

22 bytes scriptPubKey = (0x0014{20-byte keyhash})

4 bytes = locktime

https://= bitcoin.stackexchange.com/questions/59408/with-100-segwit-transactions-wh= at-would-be-the-max-number-of-transaction-confi

=

 

Which means, if you fill a block = entirely with this kind of tx, you can approximately double the capacity = of the blockchain (blocksize capped to 1mb, blockweight a little bit = more than 2mb)

 

My concern is about segwit adoption by the exchanges. =

SegWit = transactions cost 10bytes more than legacy transactions for each output = (vout is 256 bits instead of 160). Exchanges aggregate tx adding many = outputs, which is of course something good for bitcoin scalability, = since this way we save space and pay less fees.

But when a tx has at least 10 = outputs, using segwit you don't save space, = instead:

=

- the = total blockweight is at least 100bytes higher (10bytes x 10 outputs), so = the blockchain is heavier

- you don't save space inside the = blocksize, so you cannot validate more transactions of this kind (with = many outputs), nor get cheaper fee

- without cheaper fees exchanges = have no incentives for segwit adoption before they decide to adopt = LN

 

In general we can say that using = SegWit:

- = you decrease the fee only for some specific kind of transactions, and = just because you move some bytes to the = blockweight

- you don’t save space in the blockchain, on the = contrary the total weight of the blockchain increases (so it's clear to = me why some time ago Luke tweeted to not use SegWit unless really = necessary... but then it's not clear why so much haste in promoting = BIP148 the 1st august risking a split)

 

If it's all correct, does something = change with bech32? I'm reading bech32 allows to save about 22% of the = space. Is this true for whatever kind of tx? Immediate benefits of = segwit for scalability are only with bech32?

 

Bech32 is non-compatible with the = entire ecosystem (you cannot receive coins from the quasi-totality of = wallets in circulation), I would say it is a hard fork. But the bare = segwit is really so different? the soft fork is "soft" for the = reference client Bitcoin Core, but outside you cannot know what happens, = there are plenty of implementations (especially frontend customization) = which don’t work with segwit and need to upgrade. To upgrade takes = a lot of time, especially when services are so crowded and so many new = people want to step in. At this point, if bech32 brings only efficiency = (but correct me if it’s not so) and it is well planned, it could = be a consensual upgrade, maybe together with a 2x blocksize? Is there a = specific plan for some upgrade in 2018? I personally think it is far = easier to reach consensus on a blocksize increase una tantum rather than = a dynamic increase. You cannot predict the technology growth: will it be = linear, exponential, or suddenly stop for a while, maybe right before a = huge innovation? I think a hard fork bech32 upgrade + 2x could help a = lot in scalability while we test LN, and it might be the only way to = effectively promote (or should I say enforce?) SegWit = adoption.

 

thank you,

Alberto De Luigi

(.com)

------=_NextPart_000_003D_01D37827.3F67C7E0--