1

It is mentioned in this post that:

If all validation of all transactions in a block succeeds, the consumed inputs are removed from the database, and all outputs of those transactions added as fresh unspent outputs in the database, allowing them to be spent by future blocks.

But if the UTXO set is updated only after appending a block, and a miner only checks the UTXO set for understanding the spent/unspent outputs, how will verification happen if a transaction (say tx_B) in a block spends an output of another transaction (say tx_A) in the same block? In another word, how will tx_B understand the state of the output of tx_A if the output is not stored in the UTXO set yet?

4
  • 3
    Does this answer your question? Spending UTXO from same block
    – Claris
    Feb 11 at 14:04
  • @Anonymous No, I know that spending UTXO from the same block can happen, but my question is how the verification happens if miners are not seeing UTXO of their same block in the UTXO set.
    – MHT
    Feb 11 at 14:18
  • 1
    The answer is the same, blocks are processed sequentially and the UTXO is effectively updated after each operation. Therefor a later transaction in the same block can spend an earlier one.
    – Claris
    Feb 11 at 14:25
  • @Anonymous, Perfect! This is what I was looking for and it was missing in the other question: UTXO set is updated after verification of each transaction (not after appending a block). Thanks for your answer.
    – MHT
    Feb 11 at 14:35
1

While a miner is building a block template, they are maintaining a "virtual" UTXO set to keep track of the consumed UTXOs and the newly created UTXOs. A transaction can only be included in a block once all of its inputs are available for spending, so this approach is also sufficient to achieve the required topological order of transactions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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