solidity icon indicating copy to clipboard operation
solidity copied to clipboard

solProtoFuzzer of OSSFUZZ can not generate different solidity program

Open Subway2023 opened this issue 9 months ago • 1 comments

Description

I added code in solProtoFuzzer.cpp to output the Solidity program each time, but I found that each outputted program is the same.

Environment

  • Compiler version: 0.8.25
  • Target EVM version (as per compiler settings): None
  • Framework/IDE (e.g. Truffle or Remix): None
  • EVM execution environment / backend / blockchain client: None
  • Operating system: Linux

Steps to Reproduce

DEFINE_PROTO_FUZZER(Program const& _input)
{
	ProtoConverter converter;
	string sol_source = converter.protoToSolidity(_input);

	// ·········································································
        auto now = std::chrono::system_clock::now();
        std::time_t now_c = std::chrono::system_clock::to_time_t(now);
        std::tm localTime = *std::localtime(&now_c);
        std::ostringstream oss;
        oss << std::put_time(&localTime, "%Y%m%d-%H%M%S");

	std::hash<std::string> hasher;
	size_t hashValue = hasher(sol_source);
	std::string hashString = std::to_string(hashValue);
	
	std::string dump_path_string="/mnt/sdd1/solProtoFuzzer/"+hashString+"_"+oss.str()+".sol";
	ofstream of(dump_path_string.c_str());
	of.write(sol_source.data(), static_cast<streamsize>(sol_source.size()));
	// ············································································

However, I found that all the generated programs are the same, as follows.


pragma solidity >=0.0;


contract C {
	function test() public returns (uint)
	{
		return 0;
	}
}

Subway2023 avatar Apr 29 '24 05:04 Subway2023

This is correct. At the time, the idea was to merge boiler plate code that would eventually expand to different generators for the solidity language. But the latter is mostly code that has been unmerged unfortunately.

bshastry avatar May 13 '24 09:05 bshastry