From 4e4265a4d7439ae615b21aaa5176565afb3a40fc Mon Sep 17 00:00:00 2001 From: Daniel Kraft Date: Sat, 22 Nov 2014 16:06:34 +0100 Subject: [PATCH] Enforce that auxpow parent blocks have no auxpow block version. This is for compatibility with namecoind. See also https://github.com/namecoin/namecoin/pull/199. --- TODO | 4 +++- src/auxpow.h | 12 ++++++++++++ src/main.cpp | 7 +++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/TODO b/TODO index 5b37c6bd0b..766e88c6d5 100644 --- a/TODO +++ b/TODO @@ -1,9 +1,9 @@ * soft fork in namecoind: + prevent "name_new stealing" in memory pool + enforce nametx-version also for name *outputs* + + disallow auxpow parent blocks with auxpow - limit DB locks / unique tx - disallow greedy names - - disallow auxpow parent blocks with auxpow - update fee logic? * handle seed nodes / DNS seeds @@ -15,6 +15,8 @@ - P2SH as enforced soft fork (BIP16) - strict BIP30 as enforced soft fork - allow larger blocks (DB locks) + - no need to disallow auxpow parent blocks with auxpow-flag in the version + any more; instead, the auxpow is simply never loaded for them - name_new format change? - more differences??? diff --git a/src/auxpow.h b/src/auxpow.h index 2ab32eb9a2..1dc60dfb02 100644 --- a/src/auxpow.h +++ b/src/auxpow.h @@ -151,6 +151,18 @@ class CAuxPow : public CMerkleTx return parentBlock.GetHash (); } + /** + * Return parent block. This is only used for the temporary parentblock + * auxpow version check. + * @return The parent block. + */ + /* FIXME: Remove after the hardfork. */ + inline const CPureBlockHeader& + getParentBlock () const + { + return parentBlock; + } + /** * Calculate the expected index in the merkle tree. This is also used * for the test-suite. diff --git a/src/main.cpp b/src/main.cpp index 06d0f993c6..b033872f93 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1194,9 +1194,16 @@ bool CheckProofOfWork(const CBlockHeader& block) } /* We have auxpow. Check it. */ + if (!block.nVersion.IsAuxpow()) return error("%s : auxpow on block with non-auxpow version", __func__); + /* Temporary check: Disallow parent blocks with auxpow version. This is + for compatibility with the old client. */ + /* FIXME: Remove this check with a hardfork later on. */ + if (block.auxpow->getParentBlock().nVersion.IsAuxpow()) + return error("%s : auxpow parent block has auxpow version", __func__); + if (!block.auxpow->check(block.GetHash(), block.nVersion.GetChainId())) return error("%s : AUX POW is not valid", __func__); if (!CheckProofOfWork(block.auxpow->getParentBlockHash(), block.nBits))