Added EVMVersion london.

Also set the value of `block_base_fee` for testing to 7 wei.
This commit is contained in:
hrkrshnn 2021-07-12 16:50:16 +02:00
parent 543ccf5287
commit af1dabb555
3 changed files with 10 additions and 3 deletions

View File

@ -28,7 +28,7 @@ set -e
REPODIR="$(realpath "$(dirname "$0")"/..)" REPODIR="$(realpath "$(dirname "$0")"/..)"
EVM_VALUES=(homestead byzantium constantinople petersburg istanbul berlin) EVM_VALUES=(homestead byzantium constantinople petersburg istanbul berlin london)
DEFAULT_EVM=berlin DEFAULT_EVM=berlin
[[ " ${EVM_VALUES[*]} " =~ $DEFAULT_EVM ]] [[ " ${EVM_VALUES[*]} " =~ $DEFAULT_EVM ]]
OPTIMIZE_VALUES=(0 1) OPTIMIZE_VALUES=(0 1)

View File

@ -51,10 +51,11 @@ public:
static EVMVersion petersburg() { return {Version::Petersburg}; } static EVMVersion petersburg() { return {Version::Petersburg}; }
static EVMVersion istanbul() { return {Version::Istanbul}; } static EVMVersion istanbul() { return {Version::Istanbul}; }
static EVMVersion berlin() { return {Version::Berlin}; } static EVMVersion berlin() { return {Version::Berlin}; }
static EVMVersion london() { return {Version::London}; }
static std::optional<EVMVersion> fromString(std::string const& _version) static std::optional<EVMVersion> fromString(std::string const& _version)
{ {
for (auto const& v: {homestead(), tangerineWhistle(), spuriousDragon(), byzantium(), constantinople(), petersburg(), istanbul(), berlin()}) for (auto const& v: {homestead(), tangerineWhistle(), spuriousDragon(), byzantium(), constantinople(), petersburg(), istanbul(), berlin(), london()})
if (_version == v.name()) if (_version == v.name())
return v; return v;
return std::nullopt; return std::nullopt;
@ -75,6 +76,7 @@ public:
case Version::Petersburg: return "petersburg"; case Version::Petersburg: return "petersburg";
case Version::Istanbul: return "istanbul"; case Version::Istanbul: return "istanbul";
case Version::Berlin: return "berlin"; case Version::Berlin: return "berlin";
case Version::London: return "london";
} }
return "INVALID"; return "INVALID";
} }
@ -87,6 +89,7 @@ public:
bool hasExtCodeHash() const { return *this >= constantinople(); } bool hasExtCodeHash() const { return *this >= constantinople(); }
bool hasChainID() const { return *this >= istanbul(); } bool hasChainID() const { return *this >= istanbul(); }
bool hasSelfBalance() const { return *this >= istanbul(); } bool hasSelfBalance() const { return *this >= istanbul(); }
bool hasBaseFee() const { return *this >= london(); }
bool hasOpcode(evmasm::Instruction _opcode) const; bool hasOpcode(evmasm::Instruction _opcode) const;
@ -95,7 +98,7 @@ public:
bool canOverchargeGasForCall() const { return *this >= tangerineWhistle(); } bool canOverchargeGasForCall() const { return *this >= tangerineWhistle(); }
private: private:
enum class Version { Homestead, TangerineWhistle, SpuriousDragon, Byzantium, Constantinople, Petersburg, Istanbul, Berlin }; enum class Version { Homestead, TangerineWhistle, SpuriousDragon, Byzantium, Constantinople, Petersburg, Istanbul, Berlin, London };
EVMVersion(Version _version): m_version(_version) {} EVMVersion(Version _version): m_version(_version) {}

View File

@ -122,6 +122,8 @@ EVMHost::EVMHost(langutil::EVMVersion _evmVersion, evmc::VM& _vm):
m_evmRevision = EVMC_ISTANBUL; m_evmRevision = EVMC_ISTANBUL;
else if (_evmVersion == langutil::EVMVersion::berlin()) else if (_evmVersion == langutil::EVMVersion::berlin())
m_evmRevision = EVMC_BERLIN; m_evmRevision = EVMC_BERLIN;
else if (_evmVersion == langutil::EVMVersion::london())
m_evmRevision = EVMC_LONDON;
else else
assertThrow(false, Exception, "Unsupported EVM version"); assertThrow(false, Exception, "Unsupported EVM version");
@ -132,6 +134,8 @@ EVMHost::EVMHost(langutil::EVMVersion _evmVersion, evmc::VM& _vm):
tx_context.tx_origin = 0x9292929292929292929292929292929292929292_address; tx_context.tx_origin = 0x9292929292929292929292929292929292929292_address;
// Mainnet according to EIP-155 // Mainnet according to EIP-155
tx_context.chain_id = evmc::uint256be{1}; tx_context.chain_id = evmc::uint256be{1};
// The minimum value of basefee
tx_context.block_base_fee = evmc::bytes32{7};
// Reserve space for recording calls. // Reserve space for recording calls.
if (!recorded_calls.capacity()) if (!recorded_calls.capacity())