This question already has an answer here:

I'm a newbie to cryto and wanted understand this. what happens to the chain when the isolated block is formed (in case of a double spend) ? Since chains only add blocks that come from the longest running chain. it could be easily possible that initially 2 nodes proposed 2 blocks at the same time of the double spend attack. so

Node A -Block A(Double Spend)

Node B- Block B (Genuine)

Both have same length at this time but Node A decides to go rouge.

Lets consider Node C is close to Node A and hears block A. it adds it to it's block Chain. now another Node D hears about both Block B and A and decides to add A since it's coming from the longest blockchain. Now, It's a successful double spend if the customer didn't wait for any validations. (But the money is only spend once as we can see Block B is not accepted by any other blocks)

In this case Block B is orphaned.. How does not Node B redeem itself?? How does the Node B add new chain to it's orphaned Block. I guess the orphaned one is just left there and the new Node is added from the previous block.

For easier understanding:I was considering one transaction per block. ;)

Edit: Anyone Coming to this page may find this Flow helpful:

1) New transactions are broadcast to all nodes.

2) Each node collects new transactions to form block.

3) Each node competes with one another to solve the mining puzzle (Proof of Work)for its block.

4) When a node cracks the puzzle, it broadcasts the block to all nodes.

5) Nodes accept the block only if all transactions in it are valid and not already spent.

6) Nodes express their acceptance of the block by working on creating the next block in the chain, using the hash of the accepted block as the previous hash.

Nodes always consider the longest chain to be the correct one and will keep working on extending it. If two nodes broadcast different versions of the next block simultaneously, some nodes may receive one or the other first. In that case, they work on the first one they received, but save the other branch in case it becomes longer. The tie will be broken when the next block is found and one branch becomes longer; the nodes that were working on the other branch will then switch to the longer one branch. Also to prevent double spend it creates a DB of Unspent Bitcoin and validates every transaction based on that.How is a transaction verified

marked as duplicate by alcio, MeshCollider, Pieter Wuille, Jestin, renlord Oct 5 '17 at 23:49

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

If a block is mined on top of block A (let's call it block C), when Node B hears about block C, it will change its blockchain state to have block C as its tip and block B will become orphaned. This is because block C's chain has more work than block B's chain.

Seeing a double spend in blocks as you describe it does not make a block invalid. If I see a conflicting transaction in block A and block B, that conflict does not make one of those blocks invalid to me.

  • Thanks for the response Andrew. so the whole block will not be declared invalid. only that transaction will be made invalid. depending on which block gets accepted. am I correct? – Kid101 Oct 2 '17 at 14:46
  • Yes, that is correct. – Andrew Chow Oct 2 '17 at 14:58
  • another quick question andrew if you can spare a few minutes. Lets bring into picture orphaned blocks. what if the produced block is orphaned.. How does a Node merge with the longest chain in this case when it has a orphaned block at it's tip? – Kid101 Oct 2 '17 at 15:11
  • Nothing is merged. It just switches to using the chain with the most work. It discovers this chain because it will hear about blocks from its peers. Its peers will announce a block which it does not have so it will fetch that block. That block will have a parent it does not have (or it ignored because it conflicted with its current blockchain because its best block and that block have the same parent) so it fetches that block. Since the chain containing this new block has more work than the chain containing the node's best block, it will simply switch to using that other chain. – Andrew Chow Oct 2 '17 at 15:14
  • got it. Thanks Andrew. I'll keep learning Blockchain mean while. – Kid101 Oct 2 '17 at 15:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.