how does GHOST protocol really work?
I am trying to wrap my head around GHOST protocol... I know it's too much to read, but not my fault. It's GHOST that's complicated (i guess)
As I read, it's said that:
instead of a longest chain consensus rule, GHOST follows the path of the subtree with the combined hardest proof of work/difficulty.
OK, SO Let me explain how I understand it. Every node started at 0 block. Then other nodes mined 1B block, attacker mind 1A block.. and attacker solves his block(belowest one) secretly.He doesn't broadcast it. Other nodes are at 1B and now there happened to be a fork (2D,2C,2B) since blocks got mined at the same time. then some nodes went ahead and got the longest chain ending at 5B(the most top chain). Remaining nodes(L1) are at 2C and 2B. some nodes(L2) from these remaining nodes(L1) are at 3E,3D,3C. and one of the nodes from L2 is at 4B now. Now, let's take a moment and say that everyone on the network broadcasted their blockchains. Attacker's chain won't be accepted because there's only 1 subtree(one path only).. Also, the most top chain is only one. As we can see on the image, The biggest subtree is 3E, 3D,3C. So what happens is some nodes share 0->1B->2C->3E, some share 0->1B->2C->3D->4B, some share 0->1B->2C->3C. Let's say I am nodeA and I receive all the broadcasted chains. When I get all of those, I have to choose from them. Since I found that different chains are derived from 2C, I should follow that path. I follow it and try to find the longest one in them which results in 0->1B->2C->3d->4B and that's the one i am gonna accept.
In this case, attacker's chain is doomed. so i think one of the problem's chance which is having 51% hash rate power and broadcasting the longest chain has been decreased(which is great). But I still see a couple of issues.
- If blocks don't get mined at the same time, we won't have subtrees as shown on the image, Hence GHOST protocol is powerless here. and we still have 51% attack possibility and in this case, attacker's secret chain will succeed.
- So, if blocks get mined at the same time, that's when GHOST protocol will help us. I guess GHOST protocol is a little bit of extra safety added on top of proof of work. but as soon as nodes followed GHOST protocol(which means, they accepted the chain - from the image it's 0->1B->2C->3D->4B), we are back to where we were(longest chain wins). until blocks start to get mined at the same time again..
- Let's say attacker broadcasted his chain, and my node received it. And let's also say that i've not received other node's chain due to network propagation delay. How will my node know that it shouldn't accept attacker's chain ? if my node had received all other node's chains, it would figure out that subtree in 0->1B->2C is bigger and would reject attacker's chain. Any idea ?