Permit Yul interpreter vs Evmone storage comparison.

This commit is contained in:
Bhargava Shastry 2021-04-12 09:34:58 +02:00
parent 124db22f04
commit 033ee0e2bc
6 changed files with 20 additions and 7 deletions

View File

@ -794,7 +794,8 @@ void EVMHostPrinter::storage()
{
for (auto const& [slot, value]: m_host.get_address_storage(m_account))
if (m_host.get_storage(m_account, slot))
m_stateStream << m_host.convertFromEVMC(slot)
m_stateStream << " "
<< m_host.convertFromEVMC(slot)
<< ": "
<< m_host.convertFromEVMC(value.value)
<< endl;

View File

@ -93,8 +93,7 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size)
termReason = yulFuzzerUtil::interpret(
os2,
stack.parserResult()->code,
EVMDialect::strictAssemblyForEVMObjects(langutil::EVMVersion()),
(yul::test::yul_fuzzer::yulFuzzerUtil::maxSteps * 4)
EVMDialect::strictAssemblyForEVMObjects(langutil::EVMVersion())
);
if (yulFuzzerUtil::resourceLimitsExceeded(termReason))

View File

@ -26,6 +26,7 @@ yulFuzzerUtil::TerminationReason yulFuzzerUtil::interpret(
ostream& _os,
shared_ptr<yul::Block> _ast,
Dialect const& _dialect,
bool _outputStorageOnly,
size_t _maxSteps,
size_t _maxTraceSize,
size_t _maxExprNesting
@ -70,7 +71,10 @@ yulFuzzerUtil::TerminationReason yulFuzzerUtil::interpret(
reason = TerminationReason::ExplicitlyTerminated;
}
state.dumpTraceAndState(_os);
if (_outputStorageOnly)
state.dumpStorage(_os);
else
state.dumpTraceAndState(_os);
return reason;
}

View File

@ -36,6 +36,7 @@ struct yulFuzzerUtil
std::ostream& _os,
std::shared_ptr<yul::Block> _ast,
Dialect const& _dialect,
bool _outputStorageOnly = false,
size_t _maxSteps = maxSteps,
size_t _maxTraceSize = maxTraceSize,
size_t _maxExprNesting = maxExprNesting

View File

@ -48,6 +48,13 @@ using namespace solidity::yul::test;
using solidity::util::h256;
void InterpreterState::dumpStorage(ostream& _out) const
{
for (auto const& slot: storage)
if (slot.second != h256{})
_out << " " << slot.first.hex() << ": " << slot.second.hex() << endl;
}
void InterpreterState::dumpTraceAndState(ostream& _out) const
{
_out << "Trace:" << endl;
@ -61,9 +68,7 @@ void InterpreterState::dumpTraceAndState(ostream& _out) const
if (value != 0)
_out << " " << std::uppercase << std::hex << std::setw(4) << offset << ": " << h256(value).hex() << endl;
_out << "Storage dump:" << endl;
for (auto const& slot: storage)
if (slot.second != h256{})
_out << " " << slot.first.hex() << ": " << slot.second.hex() << endl;
dumpStorage(_out);
}
void Interpreter::run(InterpreterState& _state, Dialect const& _dialect, Block const& _ast)

View File

@ -99,7 +99,10 @@ struct InterpreterState
size_t maxExprNesting = 0;
ControlFlowState controlFlowState = ControlFlowState::Default;
/// Prints execution trace and non-zero storage to @param _out.
void dumpTraceAndState(std::ostream& _out) const;
/// Prints non-zero storage to @param _out.
void dumpStorage(std::ostream& _out) const;
};
/**