Who checks if the entire chain in valid?

How can we be sure that the entire chain is valid?

1- I read somewhere that one of the purposes of blockchain is that you can't change the blocks of the past without recomputing the entire thing. Is that assumption correct?

So if you could hypothetically recompute everything, you could generate a new chain. I also read somewhere about some problems that Proof of Work try to solve and there was this possibility of a concurrent plausible solid chain. How is that possible? Who can generate an entire chain?

I explain my doubt:

2- Miner will find a nonce, giving a block data, to generate a hash that matches a certain difficulty. Is that correct?

So the miner knows a new block. But not the entire chain. 3- Does it? So when it finds the nonce and hash it announces a new block to a different kind of node, let's say the full node (what is that exactly?).

4- Where in the flow and by whom in the network the entire chain will be exchanged so they need to decide which chain is better?

5- By the way, what is the best chain given two versions of them?

extra: 6- ok, the blocks are correct and the chain is valid everybody agrees with that. Who in the network checked if A that passed 1btc to B had 1btc to perform this action?

Please could you clarify 1, 2, 3, 4, 5 and 6?

1- I read somewhere that one of the purposes of blockchain is that you can't change the blocks of the past without recomputing the entire thing. Is that assumption correct?

Yes, that is correct. Each block builds upon (references) the one before it, so changing one in the past would require you to update (recompute) every block since then.

2- Miner will find a nonce, giving a block data, to generate a hash that matches a certain difficulty. Is that correct?

Yes, a miner will vary the nonce/extra-nonce/transaction order/etc, until a valid block hash is found.

3- So the miner knows a new block. But not the entire chain.

Incorrect. The valid block hash that the miner finds includes a reference to the prior block's hash. So in effect, the miner knows about the new block, and the entire chain before it, since all prior blocks are linked by their block hashes in this way. Each full node (which includes miners) will store a record of the blockchain so they can reference all new blocks and transactions against the blockchain history.

4- Where in the flow and by whom in the network the entire chain will be exchanged so they need to decide which chain is better?

The longest valid chain is what the network's nodes will follow, which in practice means the valid chain with the highest accumulated proof of work.

5- By the way, what is the best chain given two versions of them?

If two valid blocks with the same block height are found, whichever one is built upon first will be the winner. Please look up info on 'orphan blocks' to learn more about how this plays out.

6- ok, the blocks are correct and the chain is valid everybody agrees with that. Who in the network checked if A that passed 1btc to B had 1btc to perform this action?

Each full nodes will check to ensure that all new transactions and blocks are valid, and they will ignore any that are invalid. Each node keeps track of where all of the bitcoins are located, a blockchain system has extreme redundancy. A full node operator can tailor their node to only store/relay certain types of information if they so desire, but all of the info

• thanks for the explanations. when a miner finds a hash and will create a new valid block, what does it do with the new block? it will broadcast the block to the other nodes or it will broadcast his version of the entire chain to the other nodes? – Victor Ferreira Mar 3 '18 at 23:40
• The miner broadcasts the new block to other nodes in the network. Other nodes know the blockchain history, so they can independently verify that the new block is valid. Broadcasting the entire blockchain with every block would be very resource intensive. – chytrik Mar 4 '18 at 0:16
• they can verify if the block is valid, alright. But how could they decide between two blockchains if they only know their own blockchains plus a new block? – Victor Ferreira Mar 7 '18 at 3:16
• That is up to the node, in the case of multiple valid blocks at the chaintip (same blockheight), most nodes will follow the block they hear about first. If a node follows on block, but the other block is built upon first, then the node will switch and follow that chain instead. This is why traditionally, it is recommended that a user wait 6 block confirmations to be sure the chain will not be rewritten. As I mentioned above, look up 'orphan blocks' for more info. – chytrik Mar 7 '18 at 3:22