Filter log statements and remove gas comparison.

This commit is contained in:
Bhargava Shastry 2022-01-26 15:58:12 +01:00
parent 6f59e228eb
commit cfda0e41ce
2 changed files with 3 additions and 18 deletions

View File

@ -71,11 +71,6 @@ DEFINE_PROTO_FUZZER(Program const& _input)
of.write(yul_source.data(), static_cast<streamsize>(yul_source.size()));
}
// Do not proceed with tests that are too large. 1200 is an arbitrary
// threshold.
if (yul_source.size() > 1200)
return;
YulStringRepository::reset();
solidity::frontend::OptimiserSettings settings = solidity::frontend::OptimiserSettings::full();
@ -162,18 +157,6 @@ DEFINE_PROTO_FUZZER(Program const& _input)
ostringstream optimizedState;
optimizedState << EVMHostPrinter{hostContext, deployResultOpt.create_address}.state();
int64_t constexpr tolerance = 1000;
if (callResult.gas_left > callResultOpt.gas_left)
if (callResult.gas_left - callResultOpt.gas_left > tolerance)
{
cout << "Gas differential " << callResult.gas_left - callResultOpt.gas_left << endl;
cout << "Unoptimised bytecode" << endl;
cout << util::toHex(unoptimisedByteCode) << endl;
cout << "Optimised bytecode" << endl;
cout << util::toHex(optimisedByteCode) << endl;
solAssert(false, "Optimised code consumed more than +1000 gas.");
}
solAssert(
unoptimizedState.str() == optimizedState.str(),
"State of unoptimised and optimised stack reused code do not match."

View File

@ -1348,7 +1348,9 @@ void ProtoConverter::visit(Statement const& _x)
m_output << "continue\n";
break;
case Statement::kLogFunc:
visit(_x.log_func());
// Log is a stateful statement since it writes to storage.
if (!m_filterStatefulInstructions)
visit(_x.log_func());
break;
case Statement::kCopyFunc:
visit(_x.copy_func());