Merge pull request #12586 from ethereum/disable-gas-comparison

Code transform fuzzer: Filter log statements and remove gas comparison.
This commit is contained in:
Bhargava Shastry 2022-01-26 17:59:30 +01:00 committed by GitHub
commit 597426bd1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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())); 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(); YulStringRepository::reset();
solidity::frontend::OptimiserSettings settings = solidity::frontend::OptimiserSettings::full(); solidity::frontend::OptimiserSettings settings = solidity::frontend::OptimiserSettings::full();
@ -162,18 +157,6 @@ DEFINE_PROTO_FUZZER(Program const& _input)
ostringstream optimizedState; ostringstream optimizedState;
optimizedState << EVMHostPrinter{hostContext, deployResultOpt.create_address}.state(); 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( solAssert(
unoptimizedState.str() == optimizedState.str(), unoptimizedState.str() == optimizedState.str(),
"State of unoptimised and optimised stack reused code do not match." "State of unoptimised and optimised stack reused code do not match."

View File

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