Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: FlatPepsi on July 16, 2018, 04:12:02 PM



Title: Are historical blocks validated on current rules?
Post by: FlatPepsi on July 16, 2018, 04:12:02 PM
Let's say I start up a new full node, with nothing but the code & the embedded Genesis block.  My node then asks nearby nodes for blocks to build up my chain.

As I start getting blocks 1, 2, and 3 from 2009, is each block validated using today's current rules?

I'm thinking that there has to have been ancient blocks in the chain that, at the time were valid, but new security rules have since made them invalid.
For example, does famous block 501726 still cause problems?



Title: Re: Are historical blocks validated on current rules?
Post by: Kallisteiros on July 16, 2018, 08:52:08 PM
Yes, the full node doesn't just blindly trust other nodes with whatever blocks they send your way, but actually validates every block and all transactions in it starting from genesis. If a block turns out to be invalid, it is discarded, and the peer giving you such invalid blocks may be banned.

When consensus rules are updated, and a new version is out, the new rules are usually applied starting from specific future point. Within the code, there is a switch saying: if the block height is less than this, validate it using old rules, otherwise with the new ones. Also keep in mind that this creates a hard fork, causing the nodes with the old and new software ban each other and have two different chains.


Title: Re: Are historical blocks validated on current rules?
Post by: Kallisteiros on July 16, 2018, 09:01:01 PM
With that being said, block 501726 was always valid under all consensus rules, even though it was a weird block. Some software might have choked on it, but the network continued to build on top of it.


Title: Re: Are historical blocks validated on current rules?
Post by: aleksej996 on July 17, 2018, 01:30:32 PM
By default Bitcoin Core assumes blocks that came before a block with certain hard-coded hex value are valid.
In the latest version, all blocks before block no. 506067 are assumed valid unless specified otherwise with an -assumevalid argument.


Title: Re: Are historical blocks validated on current rules?
Post by: Kallisteiros on July 17, 2018, 02:28:54 PM
Ah right, forgot about that update. There are also checkpoints, which force selection of a particular chain (go up to block 295000), but IIRC the validation was still performed, unlike with assumevalid (that allows to skip validation but does not the node to accept the chain if a valid longer one with more work is presented).


Title: Re: Are historical blocks validated on current rules?
Post by: achow101 on July 18, 2018, 05:50:33 PM
By default Bitcoin Core assumes blocks that came before a block with certain hard-coded hex value are valid.
In the latest version, all blocks before block no. 506067 are assumed valid unless specified otherwise with an -assumevalid argument.
No, that is not true. The scripts are assumed to be valid, but the blocks themselves are not. They are still checked for everything else, just the transaction scripts are not verified.


Title: Re: Are historical blocks validated on current rules?
Post by: aleksej996 on July 19, 2018, 10:26:22 AM
By default Bitcoin Core assumes blocks that came before a block with certain hard-coded hex value are valid.
In the latest version, all blocks before block no. 506067 are assumed valid unless specified otherwise with an -assumevalid argument.
No, that is not true. The scripts are assumed to be valid, but the blocks themselves are not. They are still checked for everything else, just the transaction scripts are not verified.

Thanks for clarification :) It makes sense