27 SealEngineRegistrar* SealEngineRegistrar::s_this =
nullptr;
36 SealEngineFace::populateFromParent(_bi, _parent);
48 if (m_onSealGenerated)
49 m_onSealGenerated(ret.
out());
61 if (difficulty != expected)
73 _bi.
verify(_s, _parent, _block);
77 if (_bi.
difficulty() < chainParams().minimumDifficulty)
78 BOOST_THROW_EXCEPTION(
82 if (_bi.
gasLimit() < chainParams().minGasLimit)
86 if (_bi.
gasLimit() > chainParams().maxGasLimit)
90 if (_bi.
number() && _bi.
extraData().size() > chainParams().maximumExtraDataSize)
92 BOOST_THROW_EXCEPTION(
99 u256 const& daoHardfork = chainParams().daoHardforkBlock;
100 if (daoHardfork != 0 && daoHardfork + 9 >= daoHardfork && _bi.
number() >= daoHardfork &&
101 _bi.
number() <= daoHardfork + 9)
103 BOOST_THROW_EXCEPTION(
105 <<
errinfo_comment(
"Received block from the wrong fork (invalid extradata)."));
111 auto parentGasLimit = _parent.
gasLimit();
112 if (gasLimit < chainParams().minGasLimit || gasLimit > chainParams().maxGasLimit ||
113 gasLimit <= parentGasLimit - parentGasLimit / chainParams().gasLimitBoundDivisor ||
114 gasLimit >= parentGasLimit + parentGasLimit / chainParams().gasLimitBoundDivisor)
115 BOOST_THROW_EXCEPTION(
119 (
bigint)(parentGasLimit / chainParams().gasLimitBoundDivisor)))
122 parentGasLimit / chainParams().gasLimitBoundDivisor)));
134 if ((_ir & ImportRequirements::TransactionSignatures) && _header.
number() < chainParams().EIP158ForkBlock && _t.
isReplayProtected())
137 if ((_ir & ImportRequirements::TransactionSignatures) &&
141 if ((_ir & ImportRequirements::TransactionBasic) &&
146 if (_header.
number() >= chainParams().homesteadForkBlock && (_ir & ImportRequirements::TransactionSignatures) && _t.
hasSignature())
152 if ((_ir & ImportRequirements::TransactionBasic) && _t.
baseGasRequired(schedule) > _t.
gas())
160 string(
"_gasUsed + (bigint)_t.gas() > _header.gasLimit()")));
166 assert(ret &&
"Seal engine not found.");
174 return chainParams().scheduleForBlockNumber(_blockNumber);
177 u256 SealEngineBase::blockReward(
u256 const& _blockNumber)
const
179 EVMSchedule const& schedule{evmSchedule(_blockNumber)};
180 return chainParams().blockReward(schedule);
186 const unsigned c_expDiffPeriod = 100000;
189 throw GenesisBlockCannotBeCalculated();
205 max<bigint>(1 - timestampDiff / 10, -99) :
206 max<bigint>((_parent.
hasUncles() ? 2 : 1) - timestampDiff / 9,
213 unsigned exponentialIceAgeBlockNumber = unsigned(_parent.
number() + 1);
218 if (exponentialIceAgeBlockNumber >= 5000000)
219 exponentialIceAgeBlockNumber -= 5000000;
221 exponentialIceAgeBlockNumber = 0;
226 if (exponentialIceAgeBlockNumber >= 3000000)
227 exponentialIceAgeBlockNumber -= 3000000;
229 exponentialIceAgeBlockNumber = 0;
232 unsigned periodCount = exponentialIceAgeBlockNumber / c_expDiffPeriod;
234 o += (
bigint(1) << (periodCount - 2));
237 o = max<bigint>(minimumDifficulty, o);
238 return u256(min<bigint>(o, std::numeric_limits<u256>::max()));
244 u256 gasFloorTarget = _gasFloorTarget ==
Invalid256 ? 3141562 : _gasFloorTarget;
247 if (gasLimit < gasFloorTarget)
248 return min<u256>(gasFloorTarget, gasLimit + gasLimit / boundDivisor - 1);
250 return max<u256>(gasFloorTarget,
251 gasLimit - gasLimit / boundDivisor + 1 + (_bi.
gasUsed() * 6 / 5) / boundDivisor);