Ejemplo n.º 1
0
void SealEngineFace::verifyTransaction(ImportRequirements::value _ir, TransactionBase const& _t, BlockHeader const&) const
{
	if (_ir & ImportRequirements::TransactionSignatures)
		_t.checkLowS();
}
Ejemplo n.º 2
0
void SealEngineFace::verifyTransaction(ImportRequirements::value _ir, TransactionBase const& _t,
                                       BlockHeader const& _header, u256 const& _gasUsed) const
{
    if ((_ir & ImportRequirements::TransactionSignatures) && _header.number() < chainParams().EIP158ForkBlock && _t.isReplayProtected())
        BOOST_THROW_EXCEPTION(InvalidSignature());

    if ((_ir & ImportRequirements::TransactionSignatures) &&
        _header.number() < chainParams().experimentalForkBlock && _t.hasZeroSignature())
        BOOST_THROW_EXCEPTION(InvalidSignature());

    if ((_ir & ImportRequirements::TransactionBasic) &&
        _header.number() >= chainParams().experimentalForkBlock && _t.hasZeroSignature() &&
        (_t.value() != 0 || _t.gasPrice() != 0 || _t.nonce() != 0))
        BOOST_THROW_EXCEPTION(InvalidZeroSignatureTransaction() << errinfo_got((bigint)_t.gasPrice()) << errinfo_got((bigint)_t.value()) << errinfo_got((bigint)_t.nonce()));

    if (_header.number() >= chainParams().homesteadForkBlock && (_ir & ImportRequirements::TransactionSignatures) && _t.hasSignature())
        _t.checkLowS();

    eth::EVMSchedule const& schedule = evmSchedule(_header.number());

    // Pre calculate the gas needed for execution
    if ((_ir & ImportRequirements::TransactionBasic) && _t.baseGasRequired(schedule) > _t.gas())
        BOOST_THROW_EXCEPTION(OutOfGasIntrinsic() << RequirementError(
                                  (bigint)(_t.baseGasRequired(schedule)), (bigint)_t.gas()));

    // Avoid transactions that would take us beyond the block gas limit.
    if (_gasUsed + (bigint)_t.gas() > _header.gasLimit())
        BOOST_THROW_EXCEPTION(BlockGasLimitReached() << RequirementErrorComment(
                                  (bigint)(_header.gasLimit() - _gasUsed), (bigint)_t.gas(),
                                  string("_gasUsed + (bigint)_t.gas() > _header.gasLimit()")));
}