Merge pull request #7868 from ethereum/evmc-host-byzantium

EVMHost: disallow Byzantium precompiles on earlier EVM versions
This commit is contained in:
Daniel Kirchner 2019-12-02 20:41:07 +01:00 committed by GitHub
commit 04222f0e2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -123,13 +123,13 @@ evmc::result EVMHost::call(evmc_message const& _message) noexcept
return precompileRipeMD160(_message);
else if (_message.destination == 0x0000000000000000000000000000000000000004_address)
return precompileIdentity(_message);
else if (_message.destination == 0x0000000000000000000000000000000000000005_address)
else if (_message.destination == 0x0000000000000000000000000000000000000005_address && m_evmVersion >= langutil::EVMVersion::byzantium())
return precompileModExp(_message);
else if (_message.destination == 0x0000000000000000000000000000000000000006_address)
else if (_message.destination == 0x0000000000000000000000000000000000000006_address && m_evmVersion >= langutil::EVMVersion::byzantium())
return precompileALTBN128G1Add(_message);
else if (_message.destination == 0x0000000000000000000000000000000000000007_address)
else if (_message.destination == 0x0000000000000000000000000000000000000007_address && m_evmVersion >= langutil::EVMVersion::byzantium())
return precompileALTBN128G1Mul(_message);
else if (_message.destination == 0x0000000000000000000000000000000000000008_address)
else if (_message.destination == 0x0000000000000000000000000000000000000008_address && m_evmVersion >= langutil::EVMVersion::byzantium())
return precompileALTBN128PairingProduct(_message);
State stateBackup = m_state;

View File

@ -43,6 +43,7 @@
using namespace std;
using namespace std::placeholders;
using namespace dev::test;
using namespace langutil;
#define ALSO_VIA_YUL(CODE) \
{ \
@ -12888,6 +12889,9 @@ BOOST_AUTO_TEST_CASE(address_overload_resolution)
BOOST_AUTO_TEST_CASE(snark)
{
if (dev::test::Options::get().evmVersion() <= EVMVersion::byzantium())
return;
char const* sourceCode = R"(
library Pairing {
struct G1Point {