How Are Blockchain Transactions Validated?

After my last post on Ethereum Proof Of Stake & Sharding, I received several follow up questions. Many of them could be summarised to one simple question: How Are Blockchain Transactions Validated? Is it done via the Consensus Method? Or does a Blockchain Validator Do It?



As discussed in previous posts, “consensus” is a key aspect in blockchain. It’s imperative that all participants in the network come to an agreement on the state of the ledger.



But what exactly are we trying to achieve consensus on? Are we simply trying to agree that each transaction is “valid”? Or is it more than that? I believe that this is where a lot of people steer the wrong way.

Blockchain Validators

A Blockchain Validator is someone who is responsible for verifying transactions within a blockchain. In the Bitcoin Blockchain, any participant can be a blockchain validator by running a full-node. However, the primary incentive to run a full node is that it increases security. Unfortunately, since this is an intangible incentive, it is not enough to prompt someone to run a full node. As such, Blockchain Validators comprise primarily of miners and mining pools that run full nodes.

Blockchain Validation Explained

Blockchain Validation vs Blockchain Consensus It’s important to note that “validation” and “consensus” aren’t the same thing. A Blockchain Validator performs validation by verifying that transactions are legal (not malicious, double spends etc). However, Consensus involves determining the ordering of events in the blockchain – and coming to agreement on that order.

Essentially, Consensus involves agreeing on the ordering of of validated transactions.

The validation precedes the Consensus. We may very well have something that is “valid” that the network does not “agree” upon. How? Let’s go over an example.

Validation Without Consensus

How Are Blockchain Transactions Validated?

Each time a transaction is made, it’s broadcasted to the entire network. Upon hearing the broadcasts, miners take a bunch of transactions, validate that they are “legitimate” – and put them into a block. (More on how in another post)

But miners “hear” about different transactions at different times (due to latency issues etc). Furthermore, they may simply choose different transactions to include in their block based on transaction fees. So essentially, each miner is building his own block. His block may be completely different from the rest of the miners in the network.

At this point, you’re probably thinking:

“What the hell? Everyone is building different blocks? Then how will we agree upon a single common ledger!?”

And that’s one of the beautiful things about the protocol. Miners don’t need to build the same global block. They can each build their own block – consisting of entirely different transactions. And the participants will come to “consensus” on which block is included next.

A miner may have a block consisting of completely valid transactions, but his block may still fail to achieve consensus by the network. If someone else is picked, he will simply create a new block and try again.

Let’s run through a simplified example of two miners with different blocks.

A Simple Bitcoin Transaction Example

Miner Bob & Miner Joe

Let’s say Bob and Joe are two miners on our network. Neither of them are up to any mischief. They are listening to the network and creating blocks with only valid transactions that have not already been spent.

Miner Bob creates a block consisting of “Transaction A , Transaction B, Transaction C”

Miner Joe creates a block consisting of “Transaction Z, Transaction Y, Transaction B”

Both of these blocks consist of valid transactions. Great. But we still need to come to “consensus” on who’s block to include onto the chain. Remember, a reward is given out to whoever gets to add their block to the chain. So should Bob get it? Or should Joe? How about both of them? Adding both of them would be ideal, right? They both get rewards. And all the transactions get included onto the chain. Everybody wins! - But wait...Note that they both contain “Transaction B” in their blocks.

Let’s suppose that Transaction B is - “Alice pays 10 bitcoin to Jennifer”

If we let Joe and Bob both include their blocks, Alice will end up paying Jennifer 20 bitcoins (two transactions of 10 btc each) when she intended to pay her only 10! Furthermore, Alice may only have 10 bitcoin - so the second payment would be invalid.

As you can see, we can add only one of the blocks. And we need to agree upon which one. But how do we do that?

This is where consensus methods like “Proof Of Work” or “Proof Of Stake” comes into play - Enter Consensus Methods

Using Proof of Work (PoW) for Picking Blocks

Miner Bob and Miner Joe both want their blocks included in the chain – they both want the reward. But only one of them can be picked. To “win” the right to include their block, they go through a consensus process – usually either “Proof Of Work” or “Proof Of Stake”

In Proof Of Work, Miner Bob and Miner Joe compete against each other to solve a cryptographic puzzle. Whoever solves it first, gets to add their block to the chain.

Food for thought: What if they solve it at the same time - or around the same time? That’s how a ‘fork’ can occur. And the bitcoin protocol resolves these occurrences as well. More on that later

Using Proof Of Stake (PoS) for Picking Blocks

Proof Of Stake involves Bob and Joe putting up their coins into a “jar”. A coin is randomly picked from the jar. If it belongs to Bob, Bob gets to add his block. If it belongs to Joe, Joe gets to add his block instead.



Once the block is added, the process repeats. Both miners will listen to the network for pending transactions and create a new block. The competition goes on and on.

(Don’t worry, miners aren’t trying to solve the PoW puzzles themselves. Their computers are doing most of the work) 😉

Wrapping Up - Blockchain Validators vs Miners