2

I've read all the relevant BIPs, and am still confused.

Are segwit enabled blocks stripped of witness data and marker and flag bytes when they are propagated to non-segwit peers? Or are they just serialized in such a way as to ignore the those bytes?

It is my understanding that blocks containing segwit transactions may have the witnesses, flag, and version bytes in them, or may not - depending on where that block is being propagated from. If it is coming from a non-segwit node, the transactions will be stripped. However, what happens when a stripped-witness block then reaches a Segwit-enabled node? How will it know that those transactions are actually segwit and are just missing the relevant data? Do they compare the txid's to txids in their cache and fill in the data?

Follow up question: what is the process/flow for individual transaction messages? Do their contents also depend on what type of node is asking for them?

1 Answer 1

4

When forwarding the block to a non-segwit peer, a segwit-enabled node strips the witness data from the block before transmission, including marker and flag. Note that the stripped blocks still enable the non-segwit peers to arrive at the same UTXO set, since the stripped transactions specify which inputs get spent and which new outputs get created.

If a segwit-enabled node were to receive a stripped block, it would consider the block invalid due to the missing witness data on transactions with segwit inputs (and the presence of a witness commitment). Thus, a segwit-enabled node will not requests blocks from non-segwit peers as they wouldn't be able to provide the complete block anyway (unless the block had no segwit transactions and no witness commitment).

Segwit inputs were designed so that non-segwit nodes consider segwit transactions valid but non-standard. Non-standard transactions are not accepted into the mempool and thus not relayed. This means that non-segwit nodes will not relay (stripped) segwit transactions except in the context of a new block. In turn, this makes it safe for segwit nodes to request transaction inventory offered by non-segwit peers, since non-segwit peers will only offer non-segwit transactions.

4
  • Amazing answer Murch. Just one question. Are blocks that are valid but contain non-standard transactions relayed to other peers? That is, the concept of "standardness" exists only in the case of transactions and their relaying. For blocks, the only rule is: block is valid = relay, otherwise not?
    – dassd
    Sep 17 at 1:21
  • 1
    Yes, "standardness" is a term that refers to mempool policy. Blocks are always propagated. Everyone must get every block in order to synchronize with the network. Of course, segwit nodes propagate the complete block, while they would serve only a stripped block to non-segwit nodes, and non-segwit nodes would propagate a stripped block among each other. ("Stripped" here referring to a block stripped of witness data.)
    – Murch
    Sep 17 at 16:27
  • And only valid blocks are propagated while invalid blocks are rejected by the node and not relayed/propagated to other nodes? (I mean, that's the only that makes sense to me, just wanna be sure)
    – dassd
    Sep 17 at 23:12
  • Correct, when a node receives an invalid block it will discard it.
    – Murch
    Sep 19 at 11:02

Your Answer

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

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