Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permit Yul interpreter vs Evmone storage comparison. #11238

Merged
merged 1 commit into from Apr 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion test/EVMHost.cpp
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions test/tools/ossfuzz/strictasm_diff_ossfuzz.cpp
Expand Up @@ -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))
Expand Down
6 changes: 5 additions & 1 deletion test/tools/ossfuzz/yulFuzzerCommon.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions test/tools/ossfuzz/yulFuzzerCommon.h
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions test/tools/yulInterpreter/Interpreter.cpp
Expand Up @@ -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;
Expand All @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions test/tools/yulInterpreter/Interpreter.h
Expand Up @@ -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;
};

/**
Expand Down