In this post Shawn answers the question: How Are Blockchain Transactions Validated? He also explains what is Blockchain Validator – and the key difference between Consensus and Blockchain Validation.
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.
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?
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!?”
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.
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.
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”
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
As you can see, Consensus methods are primarily concerned with coming to an agreement on the ordering of events/transactions (and who gets to add them). Validation of the transactions is initially handled by the miner before they are added to the block. And then once more by the rest of the Blockchain Validators when a block winner is picked. The miners add the block, and the Blockchain Validators verify that the block is valid. If Consensus is reached, then the network successfully moves on to the next block. (More on that in future posts)
Get my upcoming eBook for Free!
"The Mango Guide TO Understanding Blockchain"
Offer Valid For FIRST 500 registrations only