mirror of
https://github.com/dashpay/dash.git
synced 2024-12-28 05:23:01 +01:00
Longer term workaround for chainstate corruption from negative versions.
This also makes negative transaction versions non-standard. This avoids an issue triggered in Bitcoin block 256818 where transactions with negative version numbers were incorrectly serialized into the UTXO set. On restart nodes detect the inconsistency and refuse to start so long as a block with these transactions is inside the self-consistency check window, logging "coin database inconsistencies found". The software recommends reindexing, but reindexing does not correct the problem. This should be fixed by changing the chainstate serialization, but working around it seems harmless for now because the version is not used by any network rule currently. A patch free workaround is to start with -checklevel=2 which skips the consistency checks, but the IsStandard change is important for miners in order to protect unpatched nodes.
This commit is contained in:
parent
4be9f4d40e
commit
2a22054025
@ -362,7 +362,7 @@ bool CTxOut::IsDust() const
|
||||
|
||||
bool CTransaction::IsStandard(string& strReason) const
|
||||
{
|
||||
if (nVersion > CTransaction::CURRENT_VERSION) {
|
||||
if (nVersion > CTransaction::CURRENT_VERSION || nVersion < 1) {
|
||||
strReason = "version";
|
||||
return false;
|
||||
}
|
||||
@ -1513,6 +1513,11 @@ bool CBlock::DisconnectBlock(CValidationState &state, CBlockIndex *pindex, CCoin
|
||||
CCoins &outs = view.GetCoins(hash);
|
||||
|
||||
CCoins outsBlock = CCoins(tx, pindex->nHeight);
|
||||
// The CCoins serialization does not serialize negative numbers.
|
||||
// No network rules currently depend on the version here, so an inconsistency is harmless
|
||||
// but it must be corrected before txout nversion ever influences a network rule.
|
||||
if (outsBlock.nVersion < 0)
|
||||
outs.nVersion = outsBlock.nVersion;
|
||||
if (outs != outsBlock)
|
||||
fClean = fClean && error("DisconnectBlock() : added transaction mismatch? database corrupted");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user