diff --git a/src/chainparams.cpp b/src/chainparams.cpp index c7c6fae8e8..3c4f42cffa 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -56,6 +56,12 @@ public: consensus.BIP34Height = 227931; consensus.BIP34Hash = uint256S("0x000000000000024b89b42a942fe0d9fea3bb44ab7bd1b19115dd6a759c0808b8"); consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); + // Peg-ins Bitcoin headers must have higher difficulty target than this field + // This value must be sufficiently small to not preclude realistic parent + // chain difficulty during network lifespan yet sufficiently large to + // deny peg-in DoS attacks due to our inability to ban after failed + // IsBitcoinBlock RPC checks. + consensus.parentChainPowLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks consensus.nPowTargetSpacing = 10 * 60; consensus.fPowAllowMinDifficultyBlocks = false; @@ -153,6 +159,7 @@ public: consensus.BIP34Height = -1; // BIP34 has not necessarily activated on regtest consensus.BIP34Hash = uint256(); consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); + consensus.parentChainPowLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks consensus.nPowTargetSpacing = 10 * 60; consensus.fPowAllowMinDifficultyBlocks = true; diff --git a/src/consensus/params.h b/src/consensus/params.h index d97017d0c4..ed295b493b 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -56,6 +56,7 @@ struct Params { BIP9Deployment vDeployments[MAX_VERSION_BITS_DEPLOYMENTS]; /** Proof of work parameters */ uint256 powLimit; + uint256 parentChainPowLimit; bool fPowAllowMinDifficultyBlocks; bool fPowNoRetargeting; int64_t nPowTargetSpacing; diff --git a/src/pow.cpp b/src/pow.cpp index 1593e491d6..140718d58d 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -48,7 +48,7 @@ bool CheckBitcoinProof(const CBlockHeader& block) bnTarget.SetCompact(block.bitcoinproof.challenge, &fNegative, &fOverflow); // Check range - if (fNegative || bnTarget == 0 || fOverflow || bnTarget > UintToArith256(Params().GetConsensus().powLimit)) + if (fNegative || bnTarget == 0 || fOverflow || bnTarget > UintToArith256(Params().GetConsensus().parentChainPowLimit)) return false; // Check proof of work matches claimed amount