From cf073b8b069135998bb9a8f533aab2749197779c Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 01:15:12 +0100 Subject: [PATCH] check for minGasLimit and minDifficulty when constructing block --- libethcore/BlockInfo.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index 7c3360e4a..3b4878a7d 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -127,8 +127,14 @@ void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce) if (gasUsed > gasLimit) BOOST_THROW_EXCEPTION(TooMuchGasUsed() << RequirementError(bigint(gasLimit), bigint(gasUsed)) ); + if (difficulty < c_minimumDifficulty) + BOOST_THROW_EXCEPTION(InvalidDifficulty() << RequirementError(bigint(c_minimumDifficulty), bigint(difficulty)) ); + + if (gasLimit < c_minGasLimit) + BOOST_THROW_EXCEPTION(InvalidGasLimit() << RequirementError(bigint(c_minGasLimit), bigint(gasLimit)) ); + if (number && extraData.size() > c_maximumExtraDataSize) - BOOST_THROW_EXCEPTION(ExtraDataTooBig()); + BOOST_THROW_EXCEPTION(ExtraDataTooBig() << RequirementError(bigint(c_maximumExtraDataSize), bigint(extraData.size()))); } void BlockInfo::populate(bytesConstRef _block, bool _checkNonce) @@ -213,10 +219,6 @@ void BlockInfo::verifyParent(BlockInfo const& _parent) const gasLimit > _parent.gasLimit * (c_gasLimitBoundDivisor + 1) / c_gasLimitBoundDivisor) BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, _parent.gasLimit * (c_gasLimitBoundDivisor - 1) / c_gasLimitBoundDivisor, _parent.gasLimit * (c_gasLimitBoundDivisor + 1) / c_gasLimitBoundDivisor)); - if (gasLimit < _parent.gasLimit * (c_gasLimitBoundDivisor - 1) / c_gasLimitBoundDivisor || - gasLimit > _parent.gasLimit * (c_gasLimitBoundDivisor + 1) / c_gasLimitBoundDivisor) - BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, _parent.gasLimit * (c_gasLimitBoundDivisor - 1) / c_gasLimitBoundDivisor, _parent.gasLimit * (c_gasLimitBoundDivisor + 1) / c_gasLimitBoundDivisor)); - if (seedHash != calculateSeedHash(_parent)) BOOST_THROW_EXCEPTION(InvalidSeedHash());