I think we can learn a lot from this lesson
1. Good practice of SPV mining?
Miner should always validate the header, including the version, bits, and timestamp. There is no excuse to skip this. The laziness costs them 125BTC.
Absolutely. Relative to network delay, checking the header chain, in full, is effectively instant.
Miners should never extend an "SPV chain" to more than 2 (or 3 at maximum) blocks, even if that contains their own block.
I think a simple timeout is sufficient. If a minute passes without a header being validated, switch to "emergency mode" and disable SPV-mining until a validated block is found.
The rule to limit fork size would mean that miners would build on the same (invalid) block over and over again.
A <- B <- c
c is not validated, but the miner finds d
A <- B <- c <- d
c & d now make an invalid unverified fork.
Under the max of 2 unvalidated blocks rule, the miner would start mining d', which builds on c. This means the miner is trying to orphan itself
.
The rule should be to enter emergency mode. Once d is found, the miner should start mining on B until the non-validated chain is orphaned.
The timeout rule is better though. A pool just needs to determine what is the maximum latency for validating blocks. If 99% of blocks are validated within 30 seconds of the header arriving, then using 60 seconds as a timeout will almost never harm the node.
2. The 5 consecutive empty blocks
This is fighting the last war. This occurred due to the specifics of this particular issue. Using a timeout would fix the issue anyway.
3. Softfork voting by version bits
It is suggested that softfork voting should be indicated by bits in version, and allowing reuse of bits after the softfork is accepted or rejected. (
https://gist.github.com/sipa/bf69659f43e763540550 ) . I think this is the right way to go. However, in order to be compatible with SPV mining, the version bit should be kept switched on for 5,000 blocks after enforcement. This will be more than a month and should be enough to squeeze any laggards out. After that, the bit is free for another softfork proposal.
I don't think it matters. What is required is that there is a standard way to track version updates. SPV clients should be required to keep up to date with any rule changes.
Bitcoinj apparently doesn't do any version field checking.
I think that SPV wallets should give a warning if they cannot correctly understand the version field.
SPV clients from before the soft fork was released, should give a warning when 75% of the miners were using a version field that could not be interpreted. This would have given a warning that the clients need to be updated when when the miners hit 750 out of 1000.
If the new bits field is added, then SPV clients should be able to track them. Generally, SPV clients should be required to fully understand the header chain. The simplification is that they don't process the entire blocks.
4. Wallet design
Full nodes should report which BIPs are they enforcing. SPV nodes should connect to full nodes with different rule set and compare their chains to identify any fork
SPV nodes should monitor recent forks. They should warn the users if there are long competing forks. They should consider transactions are unconfirmed unless they are included in both forks.
That is a network protocol change and seems reasonable. It could be an added field to the version message or a list of BIPs that are being enforced.