13

With 100% segwit transactions, what would be the max number of transaction confirmation possible on a block?

And, how many utxo can be updated by a block full of segwit transactions?

3
  • 2
    what does it mean for an "utxo to be updated". UTXOs get consumed, and new ones are produced in each transaction. Can you elaborate what you actually mean?
    – rny
    Commented Sep 23, 2017 at 5:08
  • Maximum, how many utxo are updated (created or consumed or updated) by a block full of segwit transactions (~12k)? Is it the same as pre-segwit? I mean, max how many bitcoin addresses get updated by a block full of segwit transactions?
    – vi.su.
    Commented Sep 23, 2017 at 7:33
  • 2
    i think cdecker made it really clear, if they are all transactions with 1 input and 1 output, then 12k will be the maximum number of UTXOs consumed and produced. Also, 12k transaction implies a maximum of 12k unique addresses getting produced.
    – rny
    Commented Sep 23, 2017 at 9:20

1 Answer 1

15
+100

Very interesting question, let's see what the smallest transaction we can build is. For it to be minimal it has to be a single input and a single output. The non-segwit part would look something like this:

  • 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

This sums up to a total of 82 bytes for the non-witness part. So with a total non-witness blocksize of 1 million bytes we get a maximum of 12195 transactions. Assuming that all spent outputs were P2WPKH the witness part for each transaction consists of two pushes: one for the signature and one for the pubkey. These are around 72 bytes and 33 bytes long, and each need a length prefix of 1 byte. Additionally there is 1 byte witness version. So the total witness size is 108 bytes. With 3 MB of space in the witness block left, this brings us to about 27777 witnesses per block. So the limiting factor is the space in the non-witness part of the block, so that's the final number that we should consider.

Notice that I used the non-segwit serialization for the non-segwit part since that is what non-upgraded nodes will enfore. Notice also that this is an extreme example, since most transactions are not single-input-single-output. A corresponding non-segwit transaction would have a size of 192 bytes, which, together with the 1MB size limit brings us to 5208 transactions per block, compared to 12195 max segwit transaction per block.

The second part of your question regarding maximum UTXO in a block is rather easy. We'd like to amortize the overhead from the transaction structure, and maximize inputs + outputs. Since inputs are larger than outputs we will simple use a single input and compute the maximum number of outputs that fits in a block which is 32256. Since the outputs are non-segwit data, it also changes minimally from before the segwit activation (only the signature from the one input is moved to the segwit part). Therefore the maximum UTXO churn is 1 UTXO gets removed, 32256 get added. For comparison, without segwit the maximum number added was 32252. Notice that there may be other limits that I haven't considered, but this definitely are the upper limits, and these limits are unlikely to have changed during the activation of segwit.

7
  • 1
    Just to make sure we're comparing apples to apples: In both cases, we're talking about signed inputs and outputs that are not anyone-can-spend, right?
    – Nick ODell
    Commented Sep 13, 2017 at 13:28
  • 1
    Right, in both cases we're talking SIGHASH_ALL, which is the most common use. Since we have just a single input and a single output, this also matches SIGHASH_SINGLE.
    – cdecker
    Commented Sep 13, 2017 at 14:25
  • 1
    Probably not, but this is the smallest reasonable use I could come up with. If you were to create outputs with just OP_TRUE in it, you could get away with slightly smaller transactions, but you couldn't make sure that only the owner can spend them. Specifically you can get rid of 21 of the 22 bytes scriptPubKey, making the non-witness part only 61 bytes, bringing you to 16393 transactions, but again those wouldn't be secure at all.
    – cdecker
    Commented Sep 14, 2017 at 18:03
  • 1
    Well we are in the same order of magnitude for the updated UTXO entries. Remove 12195 and add 12195 new ones, though it might be possible to squeeze in some more inputs/outputs and further amortizing the transaction overhead.
    – cdecker
    Commented Sep 23, 2017 at 13:41
  • 1
    Ok, looks like the maximum UTXO churn is a bit different, I'll amend my response :-)
    – cdecker
    Commented Sep 23, 2017 at 13:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.