How does a node compare two blockchains?

3

1

Let's say an attacker connects to the Bitcoin network. Let's say this attacker possesses an old ASIC HW and she used it to generate a blockchain of half a million blocks, with faked timestamps and really low difficulty, but otherwise valid. So, this chain is longer than the Bitcoin blockchain, but is shorter difficulty-wise.

How does the attacker presents this version of blockchain to the network and how much work will the network nodes spend on finding out that that blockchain is difficulty-wise shorter. Do they need to (and will they) download the whole chain from the attacker? Or is there any information on the top of the blockchain that can be used as hint on how much total work was spent in the entire chain?

Wapac

Posted 2016-05-29T09:02:40.993

Reputation: 869

Answers

5

Block headers include a field called bits, which can be used to calculate the difficulty and hence the amount of proof-of-work in the chain. There's probably a shortcut to being able to eliminate a 100,000 longer chain, but all core does is calculate the proof-of-work present in both chains and take the one with more.

Note that block headers are only 80 bytes each, so the 500k blocks would only be about 40 MB, not an unreasonable amount of data to calculate how much proof-of-work a chain has.

Jimmy Song

Posted 2016-05-29T09:02:40.993

Reputation: 7 067

3Also note, that since recently, Bitcoin Core performs header first synchronization, so it actually will only download the headers until it realizes that it needs the block bodies.Murch 2016-05-29T14:54:19.867