Skip to content

Commit

Permalink
Enforce that auxpow parent blocks have no auxpow block version.
Browse files Browse the repository at this point in the history
This is for compatibility with namecoind.  See also
namecoin/namecoin-legacy#199.
  • Loading branch information
domob1812 committed Dec 9, 2014
1 parent cdf312f commit 783e731
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
4 changes: 3 additions & 1 deletion TODO
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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???

Expand Down
12 changes: 12 additions & 0 deletions src/auxpow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1165,9 +1165,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))
Expand Down

0 comments on commit 783e731

Please sign in to comment.