All posts in " consensus "

Blockchain Types: Public vs Permissioned Blockchains

By Krisha A / July 31, 2018

In this post, Krisha explains the 2 Types of Blockchains - Public vs Permissioned Blockchains

We have witnessed the term “blockchain” evolve from something dark and unknown, to the hottest topic on the block. While many are drawn to the ‘Investment’ opportunities that the technology presents, others have latched onto the efficiencies that blockchain promises.

This disparity in interests has prompted questions on the multiple types of blockchains available. Questions like, 'Which type of blockchain would best serve an individual's or company’s interests?"

However, when broken down simply, you’ll realize that there’s only one pivotal difference between each of these blockchain types: 

The need for Permission to participate in each of them.

In essence, every blockchain can be categorized under one of these 2 types:
Public (Permissionless) Blockchain
Permissioned Blockchain

Blockchain Consensus Rules All

A Blockchain's Consensus Mechanism allows participants to come to agreement on a truth that the network was intended to acertain.

The context of permission in blockchain lies within this Consensus mechanism.

Depending on the type of blockchain, an individual or entity may or may not require permission to participate in the consensus process.

  • In Public (Open) Blockchains, no permission is required whatsoever. Anyone can participate in the consensus process.

  • In Permissioned Blockchains, an individual will require permission to participate in the consensus process.

A Little Perspective - The blockchain consensus mechanism is akin to a jury in a case trial. A jury reaches consensus on the final verdict - they agree on the truth. Consensus is as crucial a function to blockchain, as it is to a case trial.

​​​​Public vs Permissioned Blockchains


In Public Blockchains, anyone can participate in the consensus process. The network is open for Public use in every capacity. Public blockchains are “permissionless blockchains”, and are considered as “fully decentralized”

An individual/entity does not require permission to …

  • Send/ receive transactions on the network
  • Read the transactions on the chain
  • Secure the integrity of the network by validating transactions and participating in the consensus process (i.e - being a node).

In Permissioned Blockchains however, the consensus process is either controlled by a group of known entities, or a single entity.

The network requires permission for one or all of the following:


  • Send/ receive transactions on the network - Write permissions
  • Read the transactions/events on the chain - Read permissions

A Permissioned Blockchain controlled by a single entity can be deemed a 'Private Blockchain' - A subset of permissioned blockchains

 Private vs Permissioned Blockchains

Permissioned vs Private Blockchain

Note that The lower the number of entities participating in the consensus process, the more centralized the network. 

Permissioned Blockchains? For What?

At this point you’re probably wondering: “Don’t permissioned blockchains defeat the idea of a ‘decentralized’ network’?”

Simple Answer: 
Yes, it does. But permissioned blockchains are more than willing to make that trade-off. 
Confused?? Think back to the blockchain trilemma

The blockchain trilemma states that one sacrifice will have to be made among the three: SecurityScalability and Decentralization

Permissioned blockchains choose to sacrifice Decentralization for Security and Scalability

The sacrifice of decentralization in favour for security and scalability is particularly attractive to large entities. It enables them to leverage blockchain’s cryptographic security measures, and still ensure scalability to meet the needs of a growing customer base.

As of now, permissioned blockchains are the only viable solution for large entities looking to implement blockchain technology. This may change in the future if public blockchains break the trilemma, and learn to scale.

Wrapping Up

The difference between public and permissioned blockchains ultimately boils down to, " who gets to participate in the consensus process ? " - Every network participant? Few known, trusted entities? Or one single entity?

Between Scalability, Security and Decentralization – a tradeoff needs to made. As things stand, Public blockchains have sacrificed scalability, while Permissioned blockchains sacrificed decentralization.

Both, Public and Permissioned Blockchains have their pros and cons. Depending on who you ask, and where their interests lie, one will always be more beneficial than the other.

Did you enjoy this post?

Help Us Keep Doing What We Do Best!

Tip Jar 🙂​​

BTC: 3LrzDr7ZYQ5xWAKnweM1XuUAvU5YEkF7Zb

ETH: 0x87ba0C08910Dbd3b93D74A2A3b61d78A3C2dbDab

Get my upcoming eBook for Free!

"The Mango Guide TO Understanding Blockchain"

Offer Valid For FIRST 500 registrations only

No menu items have been found.
secure
Continue reading >
Share

An Orphaned Block – What happens to your transaction?!

Randy asked a great question in regard to The Longest Chain Rule & Forks. Over the last few posts, we’ve established that Consensus Methods are not as worried about “verifying” transaction but are more concerned with the “ordering” of transaction. When a fork occurs – we have a dispute in the correct ordering. The Longest Chain Rule kicks in and will fix that dispute for us. Awesome! Hope that is clear. If not, I suggest you read through the posts linked above!

Today, its Cassidy’s turn to ask a great question!


“ What happens if I send a transaction that ends up in an orphaned block? Do I lose my BTC or ETH ??“

Ah, this is such a great question!  Because it brings us one step closer to understanding the 51% Attack and Double Spends.

Cassidy is concerned about losing her BTC – and understandably so.  She’s always trusted the bitcoin blockchain, but now I’m telling her that her transaction may end up on an “orphaned chain”.  

Does this mean that her transaction is in peril too? And does that, in turn, mean that she may lose her BTC?

No, not at all. Her BTC is safe – and so is her transaction. She will not lose any BTC and her transaction will go through regardless of the fork.

Orphaned Blocks - The Key is in your Wallet....

A common misconception is that people tend to believe that their BTC or ETH is stored “within” their Wallet.  So, when they send a transaction – there is a belief that they are taking out some BTC (or ETH) and putting it in someone else’s wallet.

This is completely untrue.  But I don’t blame people for thinking that way. The term “wallet” is probably what confuses people. The term “wallet” was probably used to help user adoption, but it’s made explaining the technology even more difficult.

Your Bitcoin or Ethereum Wallet is not like your traditional wallet. It does not hold any of your funds.  

Instead, your wallet holds the keys to access your funds. Your funds are located on the blockchain – and will always be there. Your keys allow you to say to the blockchain “I have the right to spend these funds”

Don’t think of your Wallet as something that holds your BTC or ETH – but more so as something that holds the keys to access your funds.

Your keys allow you to say to the blockchain, “I have the right to spend these funds”

Orphaned Block - Does Cassidy Lose Her Funds?!

Okay, so now we understand that our funds are not really located in our wallet – but on the blockchain. In particular, our funds are located in the current valid Longest Chain! Afterall, the Longest Chain is what represents the blockchain.

(You’re probably having a “Oooh, I see where this is going” moment about now)

Let’s suppose a fork happens, and Cassidy doesn’t know about it. No big deal.

Remember –  her funds are on the chain! And a fork splits the chain into two! So after the fork, her funds will exist on both chains.  Let’s illustrate with some diagrams!

Orphaned Block explained

In the above illustration, Cassidy has 10 BTC up until Block A.

She then sends 10 BTC to Tom. The chain forked, and her transaction ended up on Block B2.

Block B and Block B2 are now both in contention to win the Longest Chain Rule. Another block (Block C) gets added – but it gets added behind Block B.

Orphaned Block explained simply

In the above illustration, Block C gets added behind Block B

Oops, looks like Block B wins with the Longest Chain Rule. So Block B2 gets orphaned.

The transaction that Cassidy sent to Tom gets “orphaned” as well. But Block A still exists – so Cassidy still has her 10 BTC in the Main Chain (longest chain)

Orphaned Block for dummies

In the above illustration, Cassidy still has 10 BTC in Block A

  • So to answer the question:  No - Cassidy does not lose her funds!

Does Cassidy have to RESEND her funds to Tom?

  • AgainNo,  Cassidy doesn’t need to resend her funds 🙂

Why?  -- Because when a block gets orphaned, which in our case is Block B2, all the transactions in block B2 simply go back in the queue and wait to be added to the next block. Cassidy’s transaction will most likely get added in the next block.

Orphaned Block simple

In the above illustration, Cassidy's transaction to Tom will be put in queue, and will likely be added to Block D

Concluding Thoughts

I tried to keep this one short and simple. Believe me, I removed a lot of text that went into more detail. But I think this is more than enough to give you guys the core idea of what’s going on. The nitty-gritty stuff can wait for later!

The key point to remember is that your funds exist on the chain. A fork would entail you now have funds on two chains. But only the chain that ends up being the Longest Chain will be the one that matters! (Yes, the longest chain rule is that important!)

Did this post help you?

Help Us Keep Doing What We Do Best!

Tip Jar 🙂

BTC: 3LrzDr7ZYQ5xWAKnweM1XuUAvU5YEkF7Zb

ETH: 0x87ba0C08910Dbd3b93D74A2A3b61d78A3C2dbDab

Did you enjoy this post?

Help Us Keep Doing What We Do Best!

Tip Jar 🙂​​

BTC: 3LrzDr7ZYQ5xWAKnweM1XuUAvU5YEkF7Zb

ETH: 0x87ba0C08910Dbd3b93D74A2A3b61d78A3C2dbDab

Get my upcoming eBook for Free!

"The Mango Guide TO Understanding Blockchain"

Offer Valid For FIRST 500 registrations only

No menu items have been found.
Continue reading >
Share

Longest Chain – How Are Blockchain Forks Resolved?

In the previous post I explained the Longest Chain Rule using an analogy. The analogy seemed to help several of the Mango Readers grasp the importance the rule plays. If you haven’t read it yet, I urge you to do so. The Longest Chain Rule plays a vital role in the Bitcoin and Ethereum consensus mechanism. Furthermore, it may also clear out other doubts you may have concerning Blockchain Forks.

This brings me to a question I received from Randy yesterday:

“Hey man,
Great explanation on longest chain!  
Quick question:  

" Why do we have 'Forks' if we have the Longest Chain Rule? 
Is the longest chain rule applied during a 'fork' ? "
Cheers! - Randy “

Quick Answer:  Yes, the Longest Chain Rule will kick in when forks appear. Each fork will have its own chain and miners can pick which one to apply their work on. But eventually the longer of the chains will be declared the winner – and all miners will apply their work onto that chain.

That’s the quick and dirty answer. But I’d like to dive a bit deeper into this – and run you guys through exactly how this happens.

Why? Because understanding the Longest Chain Rule will be fundamental in allowing you to grasp other ideas (for example: 51% Attack).  In fact, once you grasp this idea – most of the other concepts will become super easy and intuitive.

Longest Chain & Blockchain Forks

But what exactly is a “fork” ? 
A fork is simply an occurence of a disagreement. Remember, the primary aim of a consensus model is “ordering of events”.  

Questions that fall under “ordering of events” criteria:  
Q) “Who gets to place the next block?”
Q)“Whose transaction gets verified first?”

So when we have a disagreement in who gets to place the next block – we will have a “fork”

Going back to the Farmer Analogy – the fork was simply the two rows that were placed at the townhall.  Up until the disagreement, everything was fine and dandy. Once the disagreement occurred – two rows were laid. Each row represented a decision. Villagers will vote by placing their sacks of rice in each of the two rows and the longer of the two rows will win.

It’s a similar process in a blockchain. Initially, everything is fine & dandy – and there’s only one “main chain”.  When a disagreement occurs, the chain splits into two. This is called a “fork”.

(It’s kinda like when you’re driving down the main road and it “forks” into two different paths. You have to now choose between two paths. In the blockchain, the mainchain splits into two –  and the miners now choose between two chains.)

But why do disagreements occur? Isn’t proof of work supposed to solve that?  

Why Do Blockchain Forks Occur ?

The Proof Of Work Consensus model is designed to allow the network come to agreement. So forks like this shouldn’t happen, right?

If you read my post on the PoW Cryptographic Puzzle, you know that miners compete against each other to win the right to place the next block.

The “winner” is the miner who solves the puzzles first. The rest of the network then “agrees’ that he gets to place the next block – and they will continue the process with his block being deemed the last approved/valid block.

Let’s say the last valid block is Block A. Miners are now competing fo Block B.  Miners will attempt to solve the puzzle until they hear a winner is declared. “

Blockchain Forks

However, ever so often – we may have two “winners” simultaneously.

Since, the winner is broadcasted and propagated through the network  – different participants may hear a different winner. Once a winner is declared and “heard”, the miners accept that winning block and move on to the next block. 

So now we may have one group of miners accepting Block B, and the rest of the miners accepting Block B2. Hence, fork…

Blockchain fork

How Are Blockchain Forks Resolved - Orphaned Chains

Alright, so a fork has occurred. What now? How do we achieve consensus again? Did the Proof Of Work Consensus method fail here?   No – it didn’t.

Proof Of Work accounts for this sort of scenario with the Longest Chain Rule.

The Longest Chain Rule ensures that network will recognise the “chain with most work” as the main chain. The chain with the most work is typically (not always) the longest of the forks.

Blockchain forks

In the figure, the chain split after Block A.

Block B and Block B2 seemed to have won the Cryptographic Puzzle at the same time. The chain splits. There are now two scenarios that may take place:

  • Scenario 1: Majority of the other miners pick Block B as the “last valid block”

OR

  • Scenario 2: Majority of the other miners pick Block B2 as the “last valid block”

Let’s assume Scenario #1 takes place.  

This would mean that there are far more people solving for the cryptographic puzzle on Chain B.
Remember – the chance to solve the puzzle is random. But since Chain B has more people trying to solve the puzzle, it will probably solve it faster.  The key word here is “probably”.  Chain B2 may still solve the next (or next few) puzzles faster.

However, over a longer period of time – the probability will win out. Eventually Chain B will outpace Chain B2. The Longest Chain Rule will then kick in – and the following will happen:

  1. Chain B will be considered the main chain.
  1. The transactions contained within all the blocks on Chain B will be considered true and valid.
  1. All  the blocks & transactions on Chain B2 will be considered orphaned  and will be ignored.

Concluding Thoughts

That’s pretty much it – simpler than you thought it’d be eh?  The longest chain rule plays a crucial role in achieving consensus. You can probably use this explanation to figure out how this would play out in a 51% attack as well.  If not, I’ll be writing a post on that soon. And now that you know the Longest Chain Rule, it’ll be a breeze to understand 🙂

Did this post help you?

Help Us Keep Doing What We Do Best!

Tip Jar 🙂

BTC: 3LrzDr7ZYQ5xWAKnweM1XuUAvU5YEkF7Zb

ETH: 0x87ba0C08910Dbd3b93D74A2A3b61d78A3C2dbDab

Did you enjoy this post?

Help Us Keep Doing What We Do Best!

Tip Jar 🙂​​

BTC: 3LrzDr7ZYQ5xWAKnweM1XuUAvU5YEkF7Zb

ETH: 0x87ba0C08910Dbd3b93D74A2A3b61d78A3C2dbDab

Get my upcoming eBook for Free!

"The Mango Guide TO Understanding Blockchain"

Offer Valid For FIRST 500 registrations only

No menu items have been found.
Continue reading >
Share

Understanding Longest Chain – A Simple Analogy

One of the most popular Consensus Methods used today is Proof Of Work. As I write this post, Bitcoin and Ethereum both still use the Proof Of Work consensus method.  Ethereum is set to switch to Proof Of Stake in it’s upcoming Casper update. However, the first iteration of this update will be a hybrid of PoW & PoS. Bitcoin will continue to use Proof Of Work for the foreseeable future. 

Regardless of the consensus method used,
Bitcoin & Ethereum are still blockchains. And such, both networks rely on the Longest Chain Rule when coming to consensus.

In this post, I’ll attempt to dive a little bit deeper into The Longest Chain Rule while still keeping things as simple as possible 🙂

 Longest Chain Explained  - A Farmer Analogy

Let’s pretend we’re all farmers living in a small town. Majority of us farm rice as our major source of income. Weharvest the rice and pack them into 1KG gunny sacks and then carry the sacks to the Townhall. The sacks are then placed onto the only carriage the town has and transported to The Main City and sold.

The Town Hall Meeting: One day a Town Hall meeting is called to discuss the size of the gunny sacks...

An angry debate ensues on whether or not they should increase the size of each gunny-sack. Some farmers want the increased gunny-sack size for increased profits. But other farmers are against the idea – and claim it will make it more difficult for the older/younger/weaker farmers to carry the gunnysack to the Townhall.

The Mayor suggests that a vote should be conducted to solve the matter. However, an objection is raised:

“How is that fair? I do more work than these guys. I harvest far more rice. My vote should count more”

The Vote : That’s when a farmer named Satoshi comes up with an idea. He suggested that the next time they come to the town hall – they vote with their gunny-sacks of rice.

Each gunny-sack would represent a vote. That way, if you have more gunny-sacks you can cast more votes.Each sack of rice would be proof of their hard work. Farmers who worked harder, had more rice – and hence got to cast more votes 

The Result : Everyone loved the idea. The next day, two rows were laid out near the Town Hall. The first row represented “Increase Gunny Sack Size” and the second row represented “Don't Increase Gunny Sack Size”

Farmers would carry their gunny sacks to the town hall and place each sack in one of the two rows – thus casting their vote.   The row that had the longer chain of gunny sacks would be picked as the final decision.

At the end of the day, the “Don't Increase Gunny Sack Size” row had the longer chain of gunny sacks – and thus was the winner!


Disagreements within a blockchain are pretty much solved the same way. Each gunnysack represents a “block” in the blockchain.  A row of gunny sacks represents a chain.

Whenever there’s a disagreement, network participants can “fork” off the current chain. Thereby starting a new chain of blocks. Participants who agree with this new chain can now start applying their “blocks” to the new chain as well. Eventually, if the new chain extends the old chain – the Longest Chain Rule will kick in and will be declared the winning chain.

Longest Chain & “Work”

In our analogy, farmers were adding sacks of rice to “vote”. These sacks of rice are tangible and represent work done. The longest row of sacks represents the majority.

Similarly, in the blockchain, miners add a block to the chain to cast their vote. And the longest chain of blocks represent the majority.  

But - How does a “digital” block represent something tangible/work?  

Therein lies the beauty of Proof Of Work – but also a lot of confusion. In a previous post we discussed how Proof of Work uses the Cryptographic Puzzle to determine who represents the majority in the network.

To recap:  Miners on the network compete against each other by attempting to solve the puzzle – in order to win the “right” to add the next block onto the chain.  

A miner consumes a lot of electricity to solve these puzzles. But each time he wins (i.e solve it before someone else does)  – his block gets added to the chain.

In a way, the miner has permanently applied his electricity onto the block he just created. Since he won the solved the cryptographic puzzle, his block (with his ‘electricity’) gets added to the chain. 

So now you could say...

The farmers ‘proof of work’ was his sack of rice – and hence got to vote. After all the farmers place their sacks of rice in each of the two rows, we have our decision because: 

“The longest row of sacks represents where the majority farmers have placed their vote”

The miner’s proof of work is his winning “block” of transactions - since each block represents a miner’s electricity consumed – the entire chain represents the consumed electricity of all the previous winning blocks.

“The longest chain of blocks represents where the majority miners have placed their vote"

Concluding Thoughts - Longest Chain & Immutability

Remember, energy is never destroyed – simply transferred. In the proof of work, you could say that the energy is transferred to secure the blockchain.

Why ‘secure’? Because to change a block, you’ll have to redo the “work” that was needed to create that block.

To undo any of the previous blocks, you’ll have to redo the work for that block and every block that followed it. I’ll explain (in detail) why in another post. But this is what gives Bitcoin it’s strong immutability.  

In essence, an attacker will have to start a new chain and do enough work to also become the longest chain. If and only if  his chain is the longest chain will it be considered the winner and valid. And you may understand now – to achieve this, would require consuming a lot of electricity. This is why The Longest Chain rule is so crucial to understand 🙂

Did this post help you?

Help Us Keep Doing What We Do Best!

Tip Jar 🙂

BTC: 3LrzDr7ZYQ5xWAKnweM1XuUAvU5YEkF7Zb

ETH: 0x87ba0C08910Dbd3b93D74A2A3b61d78A3C2dbDab

Did you enjoy this post?

Help Us Keep Doing What We Do Best!

Tip Jar 🙂​​

BTC: 3LrzDr7ZYQ5xWAKnweM1XuUAvU5YEkF7Zb

ETH: 0x87ba0C08910Dbd3b93D74A2A3b61d78A3C2dbDab

Get my upcoming eBook for Free!

"The Mango Guide TO Understanding Blockchain"

Offer Valid For FIRST 500 registrations only

No menu items have been found.
Continue reading >
Share

Cryptographic Puzzle – Understanding Proof of Work

In the previous post of this Proof Of Work series, we discussed how PoW is used to determine representation of the majority. Determining the majority is one of the keys in being able to come to consensus (or agreement) on decisions. But in order to determine the majority, Proof Of Work uses Cryptographic Puzzles (or Proof of Work Puzzles)  – making them just as important.

But how does this Proof Of Work puzzle work? What kind of puzzle is this? I get these questions a lot. Usually in different forms. 

But the general gist of the question is this:
“What exactly is the Proof Of Work Puzzle? What’s the point?”

In this post, I’ll attempt to explain the proof of work puzzle simply. We’ll also discuss its significant importance in Proof Of Work as a Consensus Method.

The PoW Puzzle - The ‘Reverse’ Lottery Analogy

To avoid the nitty-gritty technicals, let’s use an analogy. 

Suppose you enter yourself into a lottery.. But this is a special kind of lottery. We’ll call it a “Reverse Lottery".
In this lottery everybody knows the winning numbers. Sounds like an easy lottery to win, right? Not exactly.

You can’t simply “pick” your numbers when buying your ticket. You can only buy a ticket with numbers randomly generated on it. So, the only way for you to win the lottery is to keep buying ticket after ticket after ticket…. Until you buy one that matches the winning numbers you have.

This is precisely what is involved in the Proof Of Work cryptographic puzzle. People use their computers to randomly generate numbers at a rapid pace. (These people are called miners, btw.)  If they generate the “winning” number, they win the lottery.

The Reverse Lottery & PoW : Breaking It Down

Let’s say you know the winning ticket number of a Reverse Lottery to be:  1111111111.

Now it’d be nice if you could go up to the counter and ask for a ticket with those numbers. But you can’t. All you can do is pay for a ticket and hope it generates: 1111111111. If not – tough luck. Buy another ticket and try again.

The good news is that you can try as many times as you can. The bad news is that you have to pay for each new ticket.

Our “Reverse Lottery” is essentially what the cryptographic puzzle is.

  • Player in the Lottery  = Miner in the Network
  • Buying tickets with random numbers = Using Computational Power To ‘Solve’ Algorithms (Hashing)

In the Reverse Lottery, each player is hoping that he generates the winning ticket number before someone else does.  Similarly, each Miner is hoping that he can generate (by ‘hashing’) the winning numbers before other miners do.

  • In the lottery, players are paying for each ticket with money.
  • Miners are using computational power to “hash” their numbers – which translates to electricity costs.

The good news is the miners are using hardware that generate millions of hashes per second.

The miner who finds the winning hash gets to add his “block” to the blockchain. In return he gets a reward. He also gets to collect transaction fees for all transactions listed in the block.

On average, a winning number (or winning hash) is found every 10 minutes. This average can be adjusted but we’ll talk about that later. And the miners move on to compete for the next winning hash. It’s kinda like a new Reverse Lottery every 10 minutes.

The process of trying to find the winning hash is called “Mining”.  The term actually originates from the traditional “mining” of gold. But instead of using a pick-axe to dig for Gold, Miners are using their computers to dig for the winning hash.

That’s pretty much it. You pretty much understand how the process works now.  But I may have left out one aspect. The Nonce.

The Cryptographic Puzzle: Nonce?

Let’s go back to our Reverse Lottery.  Suppose the creators of this lottery decide to spice things up. They realize that they need to make lottery players feel more “involved”.

To achieve this, they add a new element into the Reverse Lottery. Now, instead of simply randomly generating a number they ask the player for the following information first:

  • His Name  (For example :  Bob )
  • His Favourite Color  (For example : Green )
  • A “random number” of his choice  (For example : 7)

The Reverse Lottery will take all three answers –  Bob, Green, 7 – and put it into a special “mixer”.  You can think of Bob, Green and 7 are the “ingredients”.  The mixer will spit out a Lottery Ticket for Bob based on the ingredients he gave it.

(Btw this is precisely what “hashing” is. A function/algorithm that takes “ingredients” and produces an output based the input.)

If the ticket matches the winning number – great! He wins! If not, he will have to try again – but this time with a different “random number”.  This will give him a new lottery ticket number.

Essentially, his name “Bob” and favorite color “Green” will remain fixed as ingredients. His ‘random number’ keep changing until he gets the winning lottery ticket.

In Mining, this “random number” is what we call the nonce. The other “fixed” ingredients are the transaction data, block data, timestamp etc.

The nonce is incremented after each failed attempt. (Fyi, the other ingredients are relatively fixed. They change when necessary – but that’s nitty-gritty stuff we don’t care about at them moment)

Wrapping Up - PoW Cryptographic Puzzle

To sum it all: In Proof Of Work people (miners) are essentially racing against each other to generate the winning numbers for the Reverse Lottery.

Instead of repeatedly buying tickets at a counter, they expend electricity by rapidly running an algorithm on their computer over and over again. When and If they generate the winning number (winning hash) they get to add their “block” of transactions to the blockchain.  In return, they claim a reward and the transaction fees for all the transactions in the added block.

There’s more I’d like to discuss – like Verifiability. I’ll leave that for the next post though. 

For now, I’ll let you ponder over this question:
“How do the other miners verify that he really did find the winning hash?”

We’ll talk about this and more in the next post 🙂

Did you enjoy this post?

Help Us Keep Doing What We Do Best!

Tip Jar 🙂

BTC: 3LrzDr7ZYQ5xWAKnweM1XuUAvU5YEkF7Zb

ETH: 0x87ba0C08910Dbd3b93D74A2A3b61d78A3C2dbDab

Get my upcoming eBook for Free!

"The Mango Guide TO Understanding Blockchain"

Offer Valid For FIRST 500 registrations only

No menu items have been found.
Continue reading >
Share

Proof Of Work: Determining Majority “Power”

As discussed in a previous post, one of the primary goals for a Consensus Method is to facilitate “agreement” on the network. To come to agreement we need a majority of votes. However, determining this majority may not be as easy as you may think.

The difficulty in achieving Consensus in a networked system is actually a fundamental problem in Computer Science. There are various technical reasons for this. But we’re going to keep it simple in this post. 

We will tackle one particular difficulty that may seem easy on first glance:
"How Do We Determine Who Represents The Majority?"

Let’s take a step back for a moment. Let’s think about how majority decision making is done in the “real” world.

Consensus In A Boardroom Office

Agreement is usually settled by the “rule of the majority”, right? We’d sit in a big boardroom office, and everyone (who matters) would vote by either a ballot-system or raising their hands.

It’s pretty hard to cheat. (You could try to raise two hands, I suppose. But you’ll probably be found out)

But this boardroom clearly represents a centralized system. How do we achieve this in a decentralized system - like a blockchain? Such a system has the following features:

  • People Distributed Around The World
  • People Are Pseudo-Anonymous – Using Their Computers To “Vote”

In the office boardroom, the majority is represented by people raising their hands. We need a way to determine the majority in a networked & decentralized system. Essentially, we need a way for people to vote in such a system – and to do so fairly.

Consensus Online:  IP Addresses?

The first idea that comes to mind is : IP Addresses.  Each IP address could represents one vote. Not bad – but it won’t work.  It’s far too easy for someone create millions of Virtual IPs. A single person could spin-up several IPs around the world and cast a million votes to further his own agenda. 

Proof of Work - a simplified example

Suppose we have a network of 1000 participants. Each of them are allowed one vote per IP Address. The participants have to come to a decision between Decision A and Decision B.

999 participants vote for Decision A.  But John – a network participant – wants Decision B for his own agenda. He decides to create 1000 Virtual IPs and casts votes for Decision B from each one of them. The network now thinks it has a total of 2000 participants.

  • Decision A gets 999 votes.  Decision B gets 1001 votes. (1000 fake votes + John’s real vote

  • Decision B goes through. John wins, everybody else loses.

Consensus Online: CPU Power

The “One-IP-One-Vote” solution was simply not going to cut it. It was far too easy for people to manipulate the votes  – and also face no consequence for doing so. Even failed attempts could be brushed off. We needed the following:

  1. Add a difficulty to casting vote
  2. Make it costly for attempting manipulation

That’s where Proof Of Work stepped in as a Consensus Method - Proof Of Work uses CPU Power to determine the majority decision.

In order to show their support, participants have to expend electricity. (They do so using by solving Cryptographic puzzles – which we will discuss in the this post. For now, all you need to know is that they have to expend energy in order to show who they support)

Therefore, the only way someone could manipulate the “votes” is by  having a A LOT of CPU Power. Achieving this will cost them A LOT in:

  1. Initial hardware costs 
  2. Ongoing electricity costs.

Longest Chain: Determining Majority Support

Note: I explain the Longest Chain using a simple analogy in a post here: The Longest Chain - A Simple Farmer's Analogy

This gives us another interesting (and important) feature. Each time a “block” is added to the blockchain, CPU Power/energy is  consumed. Thus, every block preceding it also involved consumption of energy. These are essentially a “chain of blocks” (hence ‘blockchain’). These “chain of blocks” are representative of the TOTAL energy used for that chain.  

  • Remember, energy consumption is a form of indicating “support” by network participants.  So the longer the chain, the more support the chain has by the network participants.

With this, if there is ever a conflict of decision – we can simply look at the Longest Chain to determine which decision has majority support. Why? Because the longest chain has the most energy invested in it. And hence the most support.

Wrapping Up - Proof of Work

Just like any other system, decision conflict needs to be resolved by a majority vote. However, determining that majority can be difficult when dealing with a networked system. Proof Of Work adds a extrinsic cost to each vote (hardware and electricity).  And thus making it increasingly difficult to manipulate the votes.

Energy is expended to show support on each “block” of data added to the ledger. As the ledger (blockchain) increases in size, more energy is expended. The longest chain serves as representation of the majority support.

In future posts I’ll go into a little bit more detail on the Cryptographic Puzzle and The Longest Chain. For now, I hope this post helps.

If you have any questions, don’t hesitate to shoot me an email or PM 🙂

Further Readings:

Did you enjoy this post?

Help Us Keep Doing What We Do Best!

Tip Jar 🙂​​

BTC: 3LrzDr7ZYQ5xWAKnweM1XuUAvU5YEkF7Zb

ETH: 0x87ba0C08910Dbd3b93D74A2A3b61d78A3C2dbDab

Get my upcoming eBook for Free!

"The Mango Guide TO Understanding Blockchain"

Offer Valid For FIRST 500 registrations only

Continue reading >
Share

How Are Blockchain Transactions Validated? Consensus VS Validation

By Shawn Dexter / March 22, 2018

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.

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

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

No menu items have been found.
Continue reading >
Share
>