On the Ethereum blockchain, what is the difference (and relationship between) (1) the process used to validate a transaction and (2) the process used to confirm a block? It seems that these processes are pretty autonomous since some blocks get confirmed with zero transactions. But a block can only get confirmed if all the transactions within it have been validated, right? I would love more clarity about similarities and differences between these two processes.

  • Perhaps my terminology is wrong, but I haven't heard of blocks being confirmed (validated/verified, yes). I have heard of transactions being confirmed (separate from validation) based on the number of blocks in the "winning" chain they appear in. Blocks are verified/validated before being appended to the blockchain. Are we referring to the same thing using different terms?
    – lungj
    Jul 20 '17 at 19:44

I can provide a high-level summary that will help things make more sense as you google around for the details.

They are separate concerns.

Validation is concerned with deciding if the transaction is allowed. For example, I can send a transaction that transfers all your ether to my account. Validators will notice that my transaction isn't signed with your signature, so it's not allowed by the protocol, therefore no state changes, and I loose all the gas I sent.

Other reasons to invalidate a transaction. Sender has insufficient funds, contract decided the input wasn't acceptable, contract decided the request wasn't acceptable.

Mining a block is a separate concern.

A block of transactions is a set of transactions in a specific order. Ordering is important because the network needs to determine an order for the transaction processing. Without consensus about the order of events, no consensus about the results is possible.

The challenge here is twofold. There is network latency, so nodes don't learn about pending transactions in exactly the same order. And, to be fully decentralized, the solution can't rely on anyone's clock because no one's clock is considered any better than anyone else's.

Miners order the pending transactions they know about and when they "find" a block they broadcast the solution to the network. This disambiguates the order of events so the network can reach a consensus about the order of events. PoW is like a lottery. The winner gets to "deem" that the transactions in the block unfolded in a certain order. They also get to decide which transactions (they may not know about them all, or the fees might be too low). Missed transactions will usually be processed in a subsequent block.

Confirming a Transaction

After the block with my (failed) transaction, there is a small possibility that a different miner will announce a block with a different solution. This will possibly contain the same transactions but in a different order, or possibly different opinion (byzantine fault tolerance) about validity. It means a block can be overturned by a better idea. Still, a new block arrives about every 15 seconds, so as these pile up the odds of older blocks being overturned becomes vanishing small. This is why it's customary to wait for a few confirmations for recognizing high-value transactions.

All together now:

My ridiculous transaction might be (say ...) the third transaction in a block with a result that I lost my gas. The network reaches consensus through the mining process that the transaction was the third processed by the network and the transaction was invalid and I lost my gas because of it. After a few more blocks arrive, we can be pretty confident we've seen the last word on the network consensus about my lame exploit.

Hope it helps.

  • That was very helpful, Rob, thank you! So, now I understand that the validation of a transaction is basically an evidence-based process (i.e. establishing that there are sufficient funds, that the transaction is signed etc.). And, so that is independent from whether or not it will get confirmed. So, the confirmation of a transaction only happens when the block gets confirmed enough times? Just wanting to make sure I got that right.
    – Tesa
    Jul 28 '17 at 2:23
  • I want to check another thing... I'm also accurate that the confirmation of a block involves (1) solving the mathematical puzzle thing + (2) disseminating the solution to the network faster than others who may be solving it around the same time? I'm still not really clear about the relationship between (a) ordering the transactions in a particular order and (b) solving the mathematical puzzle. How do they relate to the confirmation process?
    – Tesa
    Jul 28 '17 at 2:24
  • 1
    Due to the network latency, nodes learn about pending transactions in different orders. Due to physics, we can't expect everything to be faster than everything else. Due to decentralization, no one's clock is any better than anyone else's, so we can't use them. The puzzle is a way to disambiguate the correct order of events inside a block. The miner that solves the puzzle first wins the privilege of announcing the order transactions are to be (were) processed. Additional details deal with the scenario when two or more miners announce a solution more or less simultaneously => eventual consensus Jul 28 '17 at 14:43
  • @RobHitchens: thanks for the wonderfully simple language used to explain this. Any sources where I can read more about eventual consensus in case of 2 or more miners simultaneously solving/announcing a new block? I got to know that creates a fork in the chain which can be resolved by waiting for a set number of confirmations (6 in case of Ethereum from what I read - but I could be wrong) - but what if the fork goes beyond that set number?
    – anotherDev
    Aug 8 at 9:46
  • Proof-of-Work is one of those things to spend a little time seeing explanations from lots of viewpoints until it clicks. The "fork" you describe is correct. It gets resolved by the longest chain rule. As blocks stack up, node observe which chain has the most proof of the most work and that deem it to be canonical chain. Aug 8 at 23:00

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.