Place calldata to calldata coder sanity checks.

Co-authored-by: Kamil Śliwak <kamil.sliwak@codepoets.it>
This commit is contained in:
Bhargava Shastry 2022-08-05 13:05:13 +02:00
parent 19ad8b115e
commit 53947404e4
3 changed files with 23 additions and 5 deletions

View File

@ -66,9 +66,16 @@ DEFINE_PROTO_FUZZER(Contract const& _input)
// We don't care about EVM One failures other than EVMC_REVERT
solAssert(result->status_code != EVMC_REVERT, "Proto ABIv2 fuzzer: EVM One reverted");
if (result->status_code == EVMC_SUCCESS)
solAssert(
EvmoneUtility::zeroWord(result->output_data, result->output_size),
"Proto ABIv2 fuzzer: ABIv2 coding failure found"
);
if (!EvmoneUtility::zeroWord(result->output_data, result->output_size))
{
solidity::bytes resultAsBytes;
for (size_t i = 0; i < result->output_size; i++)
resultAsBytes.push_back(result->output_data[i]);
cout << solidity::util::toHex(resultAsBytes) << endl;
solAssert(
false,
"Proto ABIv2 fuzzer: ABIv2 coding failure found"
);
}
}
}

View File

@ -426,6 +426,10 @@ void ProtoConverter::appendTypedParamsExternal(
("type", qualifiedTypeString)
("varName", _varName)
.render();
m_untypedParamsExternal << Whiskers(R"(<delimiter><varName>)")
("delimiter", delimiterToString(_delimiter))
("varName", _varName)
.render();
}
// Adds the qualifier "memory" to non-value parameter of an external function.
@ -671,7 +675,11 @@ string ProtoConverter::calldataHelperFunctions()
return 0;
}
function coder_calldata_external(<parameters_calldata>) external pure returns (uint) {
function coder_calldata_external(<parameters_calldata>) external view returns (uint) {
return this.coder_calldata_external_indirection(<untyped_parameters>);
}
function coder_calldata_external_indirection(<parameters_calldata>) external pure returns (uint) {
<equality_checks>
return 0;
}
@ -679,6 +687,7 @@ string ProtoConverter::calldataHelperFunctions()
("parameters_memory", typedParametersAsString(CalleeType::PUBLIC))
("equality_checks", equalityChecksAsString())
("parameters_calldata", typedParametersAsString(CalleeType::EXTERNAL))
("untyped_parameters", m_untypedParamsExternal.str())
.render();
return calldataHelperFuncs.str();

View File

@ -390,6 +390,8 @@ private:
/// Contains typed parameter list to be passed to callee functions
std::ostringstream m_typedParamsExternal;
std::ostringstream m_typedParamsPublic;
/// Contains parameter list to be passed to callee functions
std::ostringstream m_untypedParamsExternal;
/// Contains type string to be passed to Isabelle API
std::ostringstream m_isabelleTypeString;
/// Contains values to be encoded in the format accepted