Repository navigation
Extend checkpointing to 24 hours in the past. - #143
Conversation
|
Is this active only during initial sync? Also haven't we had accidental forks last longer than 24 hours before? What would this code do in such a situation? |
It is active during any sync that has more backlog that 24 hours of blocks.
I don't think we had those, care to elaborate? Only the checking of signatures is skipped. The block merkle hashes are still computed and checked, so the proof of work needed to create such a fork is still going to be the needed and we validate that its done properly. |
I was thinking of the March 2013 fork but:
So nevermind that. |
There was a problem hiding this comment.
Shouldn't the check be for number of blocks instead? Explanation here:
EDIT: As many people I misunderstood this as signature of blocks, not in blocks. Gavin explained it here:
Leaving my comment as I hope it will help others understand the change better.
|
In the Bitco.in forums, jl777 recently wrote: "I am pretty sure that if you skip validation, a bootstrapping node could be vulnerable to a fake chain from the attacker." It looks like this PR would open such a vulnerability. Thoughts? |
|
24h ? Are you serious guys ? In case of a fork, this can open the network to serious abuse. The feature kind of make sense, but 24h is ridiculously small. Also, you don't check how much PoW has been put in a block by checking its time, but by checking its height. I hope this isn't considered seriously for merging. |
|
Ok, I'll just dump my analysis here in case it helps others who are trying to figure out the pros/cons: Benefits
Drawbacks
Unknowns
|
|
This pull request will reduce network reliability and confidence in network reliability at the expense of improving performance in one time only case (initial sync) or rare cases of properly operated nodes (catch up after node down case). Performance in both these cases is presently acceptable for users with adequate computers. Users not willing to run a bitcoin node 24/7 should run SPV wallets. Checkpoints are acceptable in time frames of months, and for historical data. This allows any errors or hacks to become exposed and spread throughout the community at human speeds. They are a questionable optimization at best when used in periods of months. They strike me as insane if used in a time frame measured in days. |
|
Everybody: note that this is the develop branch, not master. This is an idea that is being played around with, and nothing more. @zander: nTime is insecure against trickery. See https://www.reddit.com/r/btc/comments/428tjl/softforking_the_block_time_to_2_min_my_primarily/ for an example of things you can do to manipulate it. An improvement would be to use since IsInitialBlockDownload() checks to see if the chain tip is at least 144 blocks behind the best seen header. The block.nTime > yesterday check is still needed to make sure that the last day's worth of blocks are checked. I'm unconvinced that this would be safe even with the IsInitialBlockDownload() check. Perhaps more than 144 blocks should be required? Perhaps a check to make sure that the node was recently restarted? E.g., switching into this mode when we've been online continuously for 30 days just because some miners created and broadcast an abnormal chain would be a bad thing. I'm unconvinced this is going to provide a very large performance benefit, since (a) you still have to update the UTXO, which takes more time than signature verification unless you've changed the -dbcache setting (or have an enterprise-grade SSD), and (b) most of the benefit could also be obtained by just adding some new checkpoints to chainparams.cpp, which is easier and a lot safer. (Currently, the most recent checkpoint is block 295000.) |
|
Sounds like a good idea to catch up quickly, however unverified blocks should not be distributed to other nodes, and to validate these blocks there should be a background thread or something similar started to check all the signatures. (there can be one thread per core to take advantage of multi core systems and thus speed up the process) |
|
It would also be a good idea to make this behavior configurable with one or more command-line options. |
|
I would find optimal to pass a command line option with the hash of a trusted checkpoint. This way, if no checkpoint is passed the program uses the hardcoded one, otherwise the one trusted by the operator. |
|
I'm a bit surprised about the amount of interest on this pull request, which was mostly get get Travis to build and test it on all platforms... I have to say I am very thankful for the amount of reviews and amount of thought that went into the ideas how to attack this. When writing this I tried hard to find a way to attack this and systematically rejected any threats. Its awesome to have all you guys try to attack it too. Thats what makes Bitcoin better! I have so far not heard any actual credible attack vector yet. The threat model of Bitcoin has for as long as I remember stated that the majority of the miners have to be honest. This makes sense since if the majority of the hashpower is against the coin they are protecting, the value of that coin goes down to zero. This is the basis of Bitcoin guys! Anyone suggesting that this speedup makes Bitcoin more insecure is saying that a 51% attack that lasts longer than 24 hours before all those blocks can be pushed onto the network all at the same time to actually replace the current tip. My answer to those is that if that happens, we have much bigger worries and those coins stolen would end up with practically no value anyway. Or, simply said; |
|
I have not heard a response to this concern: a bootstrapping node could be connected solely to malicious peers serving a fake chain. This PR makes such a scenario undetectable. |
|
@zander Do you have any "pro" agruments to add to @christophebiocca's list? Also, to consider:
|
|
People have asked about actual performance numbers. I did an offline run of about a week worth of blocks to check (actual live data). 3 runs before this patch; 3 runs after this patch, all older blocks. Thats a factor 6 speedup, in short. |
There was a problem hiding this comment.
This if () block should be removed -- the hard-coded checkpoints will always be way behind the current time.
|
RE: making this configurable: I vote to use the existing -checkpoints / fCheckpointsEnabled to enable or disable this feature. If somebody has bothered to set -checkpoints=0 in their bitcoin.conf, that should continue to work. A new -checkpointtime=number_of_seconds (0/default means auto-configure based on -par) would be spiffy. |
Checkpoints are hardcoded points that are shipped in the client and we skip checking of script validity if they come before a checkpoint. This change builds on that and extends the no-check requirement from known good points to acceptable points. It would be absurd to have more than 100 block reorg, the cost of such an event would be catastrophic in itself (it is the reason why we have that coinbase spending limit there), but lets be certain and make it one day (approx 144 blocks) at minimum. Additionally, to avoid predictability, make a node have the amount of script-checking-threads as a multiplication factor.
|
Processed all the feedback and pushed an even simpler version. |
|
Further feedback always welcome! |
|
Last time that I've read about this on Slack, it was advised 7 days instead of one ... |
Please read the code that was actually merged. |
Checkpoints are hardcoded points that are shipped in the client and we
skip checking of script validity if they come before a checkpoint.
This change builds on that and extends the no-check requirement from
known good points to proven-good points.
A chain with more than 24 hours work on it has proven to be correct
and we can skip the checking of scripts.