Complete POC.

This commit is contained in:
Daniel Kirchner 2022-12-05 20:54:42 +01:00
parent ffb3a2bdd9
commit 6cfe620f43
7 changed files with 16 additions and 6 deletions

View File

@ -175,8 +175,8 @@ enum class Instruction: uint8_t
LOG3, ///< Makes a log entry; 3 topics.
LOG4, ///< Makes a log entry; 4 topics.
SWAP_N = 0xB0,
DUP_N,
DUP_N = 0xB3,
SWAP_N,
CREATE = 0xf0, ///< create a new account with associated code
CALL, ///< message-call into an account

View File

@ -57,10 +57,12 @@ public:
static EVMVersion berlin() { return {Version::Berlin}; }
static EVMVersion london() { return {Version::London}; }
static EVMVersion paris() { return {Version::Paris}; }
static EVMVersion shanghai() { return {Version::Shanghai}; }
static EVMVersion cancun() { return {Version::Cancun}; }
static std::optional<EVMVersion> fromString(std::string const& _version)
{
for (auto const& v: {homestead(), tangerineWhistle(), spuriousDragon(), byzantium(), constantinople(), petersburg(), istanbul(), berlin(), london(), paris()})
for (auto const& v: {homestead(), tangerineWhistle(), spuriousDragon(), byzantium(), constantinople(), petersburg(), istanbul(), berlin(), london(), paris(), shanghai(), cancun()})
if (_version == v.name())
return v;
return std::nullopt;
@ -83,6 +85,8 @@ public:
case Version::Berlin: return "berlin";
case Version::London: return "london";
case Version::Paris: return "paris";
case Version::Shanghai: return "shanghai";
case Version::Cancun: return "cancun";
}
return "INVALID";
}
@ -104,7 +108,7 @@ public:
bool canOverchargeGasForCall() const { return *this >= tangerineWhistle(); }
private:
enum class Version { Homestead, TangerineWhistle, SpuriousDragon, Byzantium, Constantinople, Petersburg, Istanbul, Berlin, London, Paris };
enum class Version { Homestead, TangerineWhistle, SpuriousDragon, Byzantium, Constantinople, Petersburg, Istanbul, Berlin, London, Paris, Shanghai, Cancun };
EVMVersion(Version _version): m_version(_version) {}

View File

@ -65,6 +65,7 @@ CompilabilityChecker::CompilabilityChecker(
for (StackTooDeepError const& error: transform.stackErrors())
{
yulAssert(false, "Still stack too deeps??");
unreachableVariables[error.functionName].emplace(error.variable);
int& deficit = stackDeficit[error.functionName];
deficit = std::max(error.depth, deficit);

View File

@ -76,7 +76,7 @@ void EVMObjectCompiler::run(Object& _object, bool _optimize)
yulAssert(_object.code, "No code.");
if (m_eofVersion.has_value())
yulAssert(
_optimize && (m_dialect.evmVersion() == langutil::EVMVersion()),
_optimize && (m_dialect.evmVersion() >= langutil::EVMVersion()),
"Experimental EOF support is only available for optimized via-IR compilation and the most recent EVM version."
);
if (_optimize && m_dialect.evmVersion().canOverchargeGasForCall())

View File

@ -82,6 +82,7 @@ void StackToMemoryMover::run(
Block& _block
)
{
yulAssert(_numRequiredSlots == 0, "NEEDED STACK TO MEMORY AFTER ALL???");
VariableMemoryOffsetTracker memoryOffsetTracker(_reservedMemory, _memorySlots, _numRequiredSlots);
StackToMemoryMover stackToMemoryMover(
_context,

View File

@ -148,7 +148,7 @@ void CommonOptions::validate() const
if (enforceGasTest)
{
assertThrow(
evmVersion() == langutil::EVMVersion{},
evmVersion() >= langutil::EVMVersion{},
ConfigException,
"Gas costs can only be enforced on latest evm version."
);

View File

@ -124,6 +124,10 @@ EVMHost::EVMHost(langutil::EVMVersion _evmVersion, evmc::VM& _vm):
m_evmRevision = EVMC_LONDON;
else if (_evmVersion == langutil::EVMVersion::paris())
m_evmRevision = EVMC_PARIS;
else if (_evmVersion == langutil::EVMVersion::shanghai())
m_evmRevision = EVMC_SHANGHAI;
else if (_evmVersion == langutil::EVMVersion::cancun())
m_evmRevision = EVMC_CANCUN;
else
assertThrow(false, Exception, "Unsupported EVM version");