Subject: Re: [bitcoin-dev] Pull-req to remove the arbitrary limits on OP_Return outputs

From: ZmnSCPxj <[email-masked]>
Date: Tue, 08 Aug 2023 01:34:56 +0000

Good morning John Light,

> 2. Documentation about OP_RETURN says that OP_RETURN outputs are "provably-prunable".[2] A question I had about this was, are there any tools available that a full node operator could use to prune this data from their nodes?

As I understand it, `OP_RETURN` outputs are already pruned, in the sense that they are never put in the UTXO database in the first place.
Indeed, as I understand it, "pruning" in this context is about removing (or not inserting at all, in the case of `OP_RETURN`) from the UTXO database.
UTXO database is best to keep small to reduce lookups of UTXOs being spent, as that impacts speed of validation.

Archival nodes still retain the raw `OP_RETURN` data as part of the raw block data, as it is necessary to prove that those transactions are (1) valid transactions and (2) part of (i.e. in the Merkle tree of) a valid block on the block header chain.
Block-pruning nodes also still retain this data, as they can at least serve recent blocks with the same requirement of proving that transactions containing `OP_RETURN` are valid transactions in a valid block on the block header chain.

If you want to prove that a block is valid, you need to present even `OP_RETURN` data, as you need to be able to show the actual transaction containing it, so that the verifier can see that the transaction is correctly formatted and its txid matches the supposed location in the Merkle tree.
Block relay requires that the node relaying a block prove that that block is indeed valid, thus you need to retain the `OP_RETURN` data.
Thus, in this context "pruning" refers to not keeping `OP_RETURN` TXOs in the UTXO database.

Regards,
ZmnSCPxj