Many Bitcoin wallets vulnerable to double-spending of confirmed transactions
bitcoin.org
bitcoin.org
The consensus rule was pre-programmed to automatically activate after 995 of the last 1000 blocks (in theory 99.5% of the network) included a flag in the block indicating that they would auto-activate the new consensus rule. So think of it like green and red lights. If there is no set of 1000 blocks where at least 995 of them are green, then the old ordering is still valid.
Important to note that the new ordering is a stricter subset of the old, so new ordering is perfectly fine under the old rules, just old ordering is not acceptable under the new rules. This is called a SOFT fork. As soon as there are any 1000 blocks where 995 are green, then every block from that point onward MUST be properly ordered. (BTW, if you change rules such that something new you are doing would be invalid under the old code, like say, increasing the block size limit, it is called a HARD fork. Hard forks are considered much more disruptive to the network, soft forks are supposed to be easier to orchestrate)
By "showing green" the miners were supposed to be advertising that they would enforce the rule once the cutoff point was met. The problem is enough miners showed green, the cutoff was hit, but then when an "incorrectly" ordered block came up sometime after the threshold was met, too many miners still accepted the block as VALID and so now we have a significant (majority?) hashpower running on blocks which are "supposed" to be invalid.
Of course consensus is, by definition, whatever the majority is doing. So now it's a battle of dev's trying to cajole enough hashpower into enforcing the rule, or somehow backing off the change. With every new block mined on each head, there's more money at stake for which way the decision ultimately falls. For Bitcoin to survive, "There Can Be Only One".
It will be interesting to see how exactly this came about. Were there bugs in the trigger code which was supposed to activate the new consensus rule? Did ignoramus miners simply turn on the flag without actually priming the new consensus code for activation? Did miners mistakenly think they just needed to show "green" and then their blocks would be valid, but then they published a "green" block with the older ordering?
So, don't lie about your SPV status in your coinbase is one of the lessons here for a pool operator.
When I ran a (small but noticeable) pool, the bitcoin core team would occasionally reach out with warnings when an impending network change was coming that we didn't look compliant with; often we'd get two or three e-mails independently with plenty of warning.
So, I would say this is chinese mining pools not playing by the rules, either because they didn't care to listen, or didn't care to have engineers do anything about it, and now they are eating it a bit, (and of course we all have some minor knock-on effects for a little while).
Optimize would be less judgmental than cheat and speaks more precisely to the motivations[1]... we do need to be careful about this and make sure we're managing the incentives. Cheating is a moral judgement[2]
Bonus quote, unearthed while digging up the above:
While the identifiable parties in question here were Chinese; the first miners I saw doing this in the pastwere not Chinese-- it's not a Chinese specific issue; its a response to orphan rate. (China just has lots of hash power and poor connectivity).[3]
[1] https://www.reddit.com/r/Bitcoin/comments/3c305f/if_you_are_...
[2] https://www.reddit.com/r/BitcoinMarkets/comments/3c2jci/dail...
[3] https://www.reddit.com/r/Bitcoin/comments/3c305f/if_you_are_...
[4] One could interpret the block version increment as a policy advertisement, but you know what they say about assumptions.
And incrementing your version number is precisely a policy advertisement, full stop. It is saying you are in compliance with v1/2/3 of the spec. If you want to lie about that to other miners, there may well be consequences.
So I think it doesn't really apply here.
Consensus is what everyone is doing. That is why the terminology used here would be "split consensus". The purpose of the devs trying to get the hash power back into the correct blockchain is so consensus can be re-established.
For instance, "split consensus" is dangerously close to being self evident nonsense. I think "untenable distributed state" captures the picture there.
I hope this incident has convinced other miners that the ~1% profit boost from "SPV Mining" is not worth the fork risk that it enables, although apparently one of the pools (Discus Fish aka F2Pool) has already been warned against SPV Mining in the past. Let's hope that coins lost through this fork event is the sterner warning they needed.
I doubt any potential F2Pool miner loss is enough to persuade them to not do SPV mining. Just look at how many blocks they've mined overall and consider how much extra they've earned over time thanks to this 1% boost...
It is not a 1% profit boost. It is a ~1% revenue boost, and mining is a very thin profit margin business. 1% revenue can be 10-20% profit. Furthermore, that gives an edge over the competition which doesn't use the patch which may be enough to shut them out.
This is a serious problem for Bitcoin, because right now it takes 2-3 days to download and verify the full block chain, and is fast approaching 10^H^H40 gigabytes in size.
There's going to need to be some sort of mitigation for this at some point but I don't see how that's possible.
It did say that pools need to run a full node to not lose money, but the 36GiB burden should be a lot less of a problem for them.
But more importantly, even to run as a "full node" all you need is the UTXO (unspent transactions) and you can throw away the rest. Bitcoin Core can be flagged to prune the blockchain as you go. Pruning just discards transactions after they are spent, keeping track of just enough headers to still provide "full node" validation strength. Basically all you need to know is what available "outputs" there are, aka the unspent outputs, because that is the universe of "coins" which can be used as inputs in new transactions.
I think the only thing that may be missing from all this is a way to download a proven pre-pruned blockchain to get started. That is possible, and it would bring startup costs of a full node down to about 1GB.
The trickier challenge is if you have a historical wallet and you want to download the full transaction history of the wallet, without any meta-data you are left to downloading the whole blockchain in order to discover them. But you would still be able to get your current wallet balance even with pruning.
https://www.reddit.com/r/Bitcoin/comments/33qv3a/pruning_sup...
The problem behind the fork here is that 950 out of the last 1000 blocks had the block version set to 3, but didn't follow through with their promise. By setting the block version to 3, they were voting to transition to BIP66, meaning that once 950 of the last 1000 blocks vote for version 3, then no more nonstandard DER signatures will be allowed in blocks.
Even if you prune spent transactions (so only keep UTXO) you still keep the block version, so you can still measure if 950/1000 blocks vote for version 3. And you are still able to verify that new blocks don't have nonstandard DER signatures.
In regards to the size of the blockchain, you might be interested in the recently merged Autoprune functionality (https://github.com/bitcoin/bitcoin/pull/5863), which deletes block and undo files to keep the total space used by those files below a certain threshold.
The idea that all these miners aren't validating blocks before building on top of them now is scary. Everything's designed around the assumption that they will unless they're trying to actively attack Bitcoin.
[1] https://blockchain.info/charts/blocks-size?timespan=all&show...
This statement is false. Not all lightweight wallets (wallets that function without needing to download the blockchain) are SPV wallets. Some lightweight wallets use blockchain APIs (and therefore are immune to this problem)
Downloading the full blockhain is not the only way to secure bitcoin.
What doest that even mean?
You mean blockchain.info API? Well Blockchain.info is not immune to this problem, they were running an old bitcoin core version.
They don't verify the has in the header is the hash of the previous block's header? They don't that the hash is sufficiently small? They don't calculate the difficulty correctly?
Yes. It's possible to create a long chain at low difficulty and the original bitcoin client protects against that by computing the total "work" that has gone in a chain. However, Electrum just assumes that the longest chain will be the one which has most "work" in it which is wrong.
Electrum does validate block headers but it doesn't handle re-orgs correctly. It just assumes the longest chain has the most PoW in it which is wrong and makes it vulnerable to attacks by malicious Electrum servers.
Block headers do not contain the cumulative work that has gone into the chain (only the difficulty of the current block). A chain's total work must be calculated and stored locally by clients.
https://github.com/spesmilo/electrum/blob/master/lib/blockch...
One could run a modified Electrum server that sends a long chain at low difficulty and double spend Electrum users.