When a new block is propagated, nodes validate from genesis block to propagated block?

0

For example, I have a nth block and when n + 1 th block is propagated, i have to compare with n+1 block's previous hash and nth block's hash for validation. It is pretty trivial.

But do i have to compare hash value for validation from genesis block to n + 1 block?

like comparing 0 and 1, 1 and 2, 2, and 3 ... n and n + 1

One of the most famous pseudo block chain code in github https://github.com/dvf/blockchain/blob/master/blockchain.py#L37, block is validated from genesis block.

Bitcoin use similar way to validate a new block?

HSKim

Posted 2019-07-01T07:10:28.587

Reputation: 41

Answers

2

Nodes do not validate blocks from genesis each time a new block is received.

During the initial sync, nodes will validate, at the very minimum, the headers from the genesis block upto the current chain head - this allows them to find the best chain (by amount of work done). They also usually verify the utxo set.

When a new block is received, simply validating it against the previous block hash and the current utxo set is enough, as your previous block is already verified, which means all blocks before that are also verified.

If you happen to lose your local copy of the chainstate and only have raw blocks left, then you would need to revalidate from genesis.

Raghav Sood

Posted 2019-07-01T07:10:28.587

Reputation: 10 897

Thank you. Exactly what i want to know:)HSKim 2019-07-02T09:32:53.443