mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix wrong cleanup when copying from calldata to memory
Co-authored-by: Kamil Śliwak <kamil.sliwak@codepoets.it>
This commit is contained in:
parent
5b0f4a724a
commit
22c7cd22b9
@ -1,5 +1,8 @@
|
||||
### 0.8.16 (unreleased)
|
||||
|
||||
Important Bugfixes:
|
||||
* Code Generation: Fix data corruption that affected ABI-encoding of calldata values represented by tuples: structs at any nesting level; argument lists of external functions, events and errors; return value lists of external functions. The 32 leading bytes of the first dynamically-encoded value in the tuple would get zeroed when the last component contained a statically-encoded array.
|
||||
|
||||
Language Features:
|
||||
|
||||
|
||||
@ -10,6 +13,7 @@ Compiler Features:
|
||||
* Yul Optimizer: Add rule to convert `mod(add(X, Y), A)` into `addmod(X, Y, A)`, if `A` is a power of two.
|
||||
* Code Generator: More efficient code for checked addition and subtraction.
|
||||
|
||||
|
||||
Bugfixes:
|
||||
* Commandline Interface: Disallow the following options outside of the compiler mode: ``--via-ir``,``--metadata-literal``, ``--metadata-hash``, ``--model-checker-show-unproved``, ``--model-checker-div-mod-no-slacks``, ``--model-checker-engine``, ``--model-checker-invariants``, ``--model-checker-solvers``, ``--model-checker-timeout``, ``--model-checker-contracts``, ``--model-checker-targets``.
|
||||
* Type Checker: Fix null dereference in `abi.encodeCall` type checking of free function.
|
||||
|
@ -1,4 +1,16 @@
|
||||
[
|
||||
{
|
||||
"uid": "SOL-2022-6",
|
||||
"name": "AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"summary": "ABI-encoding a tuple with a statically-sized calldata array in the last component would corrupt 32 leading bytes of its first dynamically encoded component.",
|
||||
"description": "When ABI-encoding a statically-sized calldata array, the compiler always pads the data area to a multiple of 32-bytes and ensures that the padding bytes are zeroed. In some cases, this cleanup used to be performed by always writing exactly 32 bytes, regardless of how many needed to be zeroed. This was done with the assumption that the data that would eventually occupy the area past the end of the array had not yet been written, because the encoder processes tuple components in the order they were given. While this assumption is mostly true, there is an important corner case: dynamically encoded tuple components are stored separately from the statically-sized ones in an area called the *tail* of the encoding and the tail immediately follows the *head*, which is where the statically-sized components are placed. The aforementioned cleanup, if performed for the last component of the head would cross into the tail and overwrite up to 32 bytes of the first component stored there with zeros. The only array type for which the cleanup could actually result in an overwrite were arrays with ``uint256`` or ``bytes32`` as the base element type and in this case the size of the corrupted area was always exactly 32 bytes. The problem affected tuples at any nesting level. This included also structs, which are encoded as tuples in the ABI. Note also that lists of parameters and return values of functions, events and errors are encoded as tuples.",
|
||||
"introduced": "0.5.8",
|
||||
"fixed": "0.8.16",
|
||||
"severity": "medium",
|
||||
"conditions": {
|
||||
"ABIEncoderV2": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"uid": "SOL-2022-5",
|
||||
"name": "DirtyBytesArrayToStorage",
|
||||
|
@ -1083,6 +1083,7 @@
|
||||
},
|
||||
"0.5.10": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
"ABIDecodeTwoDimensionalArrayMemory",
|
||||
@ -1100,6 +1101,7 @@
|
||||
},
|
||||
"0.5.11": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
"ABIDecodeTwoDimensionalArrayMemory",
|
||||
@ -1116,6 +1118,7 @@
|
||||
},
|
||||
"0.5.12": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
"ABIDecodeTwoDimensionalArrayMemory",
|
||||
@ -1132,6 +1135,7 @@
|
||||
},
|
||||
"0.5.13": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
"ABIDecodeTwoDimensionalArrayMemory",
|
||||
@ -1148,6 +1152,7 @@
|
||||
},
|
||||
"0.5.14": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
"ABIDecodeTwoDimensionalArrayMemory",
|
||||
@ -1166,6 +1171,7 @@
|
||||
},
|
||||
"0.5.15": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
"ABIDecodeTwoDimensionalArrayMemory",
|
||||
@ -1183,6 +1189,7 @@
|
||||
},
|
||||
"0.5.16": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
"ABIDecodeTwoDimensionalArrayMemory",
|
||||
@ -1199,6 +1206,7 @@
|
||||
},
|
||||
"0.5.17": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
"ABIDecodeTwoDimensionalArrayMemory",
|
||||
@ -1338,6 +1346,7 @@
|
||||
},
|
||||
"0.5.8": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
"ABIDecodeTwoDimensionalArrayMemory",
|
||||
@ -1358,6 +1367,7 @@
|
||||
},
|
||||
"0.5.9": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
"ABIDecodeTwoDimensionalArrayMemory",
|
||||
@ -1377,6 +1387,7 @@
|
||||
},
|
||||
"0.6.0": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
"ABIDecodeTwoDimensionalArrayMemory",
|
||||
@ -1394,6 +1405,7 @@
|
||||
},
|
||||
"0.6.1": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
"ABIDecodeTwoDimensionalArrayMemory",
|
||||
@ -1410,6 +1422,7 @@
|
||||
},
|
||||
"0.6.10": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"DataLocationChangeInInternalOverride",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
@ -1423,6 +1436,7 @@
|
||||
},
|
||||
"0.6.11": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"DataLocationChangeInInternalOverride",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
@ -1436,6 +1450,7 @@
|
||||
},
|
||||
"0.6.12": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"DataLocationChangeInInternalOverride",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
@ -1449,6 +1464,7 @@
|
||||
},
|
||||
"0.6.2": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
"ABIDecodeTwoDimensionalArrayMemory",
|
||||
@ -1465,6 +1481,7 @@
|
||||
},
|
||||
"0.6.3": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
"ABIDecodeTwoDimensionalArrayMemory",
|
||||
@ -1481,6 +1498,7 @@
|
||||
},
|
||||
"0.6.4": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
"ABIDecodeTwoDimensionalArrayMemory",
|
||||
@ -1497,6 +1515,7 @@
|
||||
},
|
||||
"0.6.5": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
"SignedImmutables",
|
||||
@ -1513,6 +1532,7 @@
|
||||
},
|
||||
"0.6.6": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
"SignedImmutables",
|
||||
@ -1528,6 +1548,7 @@
|
||||
},
|
||||
"0.6.7": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
"SignedImmutables",
|
||||
@ -1543,6 +1564,7 @@
|
||||
},
|
||||
"0.6.8": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
"SignedImmutables",
|
||||
@ -1555,6 +1577,7 @@
|
||||
},
|
||||
"0.6.9": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"DataLocationChangeInInternalOverride",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
@ -1569,6 +1592,7 @@
|
||||
},
|
||||
"0.7.0": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"DataLocationChangeInInternalOverride",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
@ -1582,6 +1606,7 @@
|
||||
},
|
||||
"0.7.1": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"DataLocationChangeInInternalOverride",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
@ -1596,6 +1621,7 @@
|
||||
},
|
||||
"0.7.2": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"DataLocationChangeInInternalOverride",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
@ -1609,6 +1635,7 @@
|
||||
},
|
||||
"0.7.3": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"DataLocationChangeInInternalOverride",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
@ -1621,6 +1648,7 @@
|
||||
},
|
||||
"0.7.4": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"DataLocationChangeInInternalOverride",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
@ -1632,6 +1660,7 @@
|
||||
},
|
||||
"0.7.5": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"DataLocationChangeInInternalOverride",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
@ -1643,6 +1672,7 @@
|
||||
},
|
||||
"0.7.6": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"DataLocationChangeInInternalOverride",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
@ -1654,6 +1684,7 @@
|
||||
},
|
||||
"0.8.0": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"DataLocationChangeInInternalOverride",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
@ -1665,6 +1696,7 @@
|
||||
},
|
||||
"0.8.1": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"DataLocationChangeInInternalOverride",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
@ -1676,6 +1708,7 @@
|
||||
},
|
||||
"0.8.10": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"DataLocationChangeInInternalOverride",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation"
|
||||
@ -1684,6 +1717,7 @@
|
||||
},
|
||||
"0.8.11": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"DataLocationChangeInInternalOverride",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
@ -1693,6 +1727,7 @@
|
||||
},
|
||||
"0.8.12": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"DataLocationChangeInInternalOverride",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
@ -1702,6 +1737,7 @@
|
||||
},
|
||||
"0.8.13": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"InlineAssemblyMemorySideEffects",
|
||||
"DataLocationChangeInInternalOverride",
|
||||
@ -1711,17 +1747,21 @@
|
||||
},
|
||||
"0.8.14": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"InlineAssemblyMemorySideEffects"
|
||||
],
|
||||
"released": "2022-05-17"
|
||||
},
|
||||
"0.8.15": {
|
||||
"bugs": [],
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup"
|
||||
],
|
||||
"released": "2022-06-15"
|
||||
},
|
||||
"0.8.2": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"DataLocationChangeInInternalOverride",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
@ -1733,6 +1773,7 @@
|
||||
},
|
||||
"0.8.3": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"DataLocationChangeInInternalOverride",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
@ -1743,6 +1784,7 @@
|
||||
},
|
||||
"0.8.4": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"DataLocationChangeInInternalOverride",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
@ -1752,6 +1794,7 @@
|
||||
},
|
||||
"0.8.5": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"DataLocationChangeInInternalOverride",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
@ -1761,6 +1804,7 @@
|
||||
},
|
||||
"0.8.6": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"DataLocationChangeInInternalOverride",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
@ -1770,6 +1814,7 @@
|
||||
},
|
||||
"0.8.7": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"DataLocationChangeInInternalOverride",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
@ -1779,6 +1824,7 @@
|
||||
},
|
||||
"0.8.8": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"DataLocationChangeInInternalOverride",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation",
|
||||
@ -1789,6 +1835,7 @@
|
||||
},
|
||||
"0.8.9": {
|
||||
"bugs": [
|
||||
"AbiReencodingHeadOverflowWithStaticArrayCleanup",
|
||||
"DirtyBytesArrayToStorage",
|
||||
"DataLocationChangeInInternalOverride",
|
||||
"NestedCallataArrayAbiReencodingSizeValidation"
|
||||
|
@ -468,7 +468,8 @@ string ABIFunctions::abiEncodingFunctionCalldataArrayWithoutCleanup(
|
||||
_to.identifier() +
|
||||
_options.toFunctionNameSuffix();
|
||||
return createFunction(functionName, [&]() {
|
||||
bool needsPadding = _options.padded && fromArrayType.isByteArrayOrString();
|
||||
bool bytesOrString = fromArrayType.isByteArrayOrString();
|
||||
bool needsPadding = _options.padded && bytesOrString;
|
||||
if (fromArrayType.isDynamicallySized())
|
||||
{
|
||||
Whiskers templ(R"(
|
||||
@ -498,7 +499,7 @@ string ABIFunctions::abiEncodingFunctionCalldataArrayWithoutCleanup(
|
||||
);
|
||||
templ("readableTypeNameFrom", _from.toString(true));
|
||||
templ("readableTypeNameTo", _to.toString(true));
|
||||
templ("copyFun", m_utils.copyToMemoryFunction(true));
|
||||
templ("copyFun", m_utils.copyToMemoryFunction(true, /*cleanup*/bytesOrString));
|
||||
templ("lengthPadded", needsPadding ? m_utils.roundUpFunction() + "(length)" : "length");
|
||||
return templ.render();
|
||||
}
|
||||
@ -514,7 +515,7 @@ string ABIFunctions::abiEncodingFunctionCalldataArrayWithoutCleanup(
|
||||
templ("functionName", functionName);
|
||||
templ("readableTypeNameFrom", _from.toString(true));
|
||||
templ("readableTypeNameTo", _to.toString(true));
|
||||
templ("copyFun", m_utils.copyToMemoryFunction(true));
|
||||
templ("copyFun", m_utils.copyToMemoryFunction(true, /*cleanup*/bytesOrString));
|
||||
templ("byteLength", toCompactHexWithPrefix(fromArrayType.length() * fromArrayType.calldataStride()));
|
||||
return templ.render();
|
||||
}
|
||||
@ -662,7 +663,7 @@ string ABIFunctions::abiEncodingFunctionMemoryByteArray(
|
||||
templ("functionName", functionName);
|
||||
templ("lengthFun", m_utils.arrayLengthFunction(_from));
|
||||
templ("storeLength", arrayStoreLengthForEncodingFunction(_to, _options));
|
||||
templ("copyFun", m_utils.copyToMemoryFunction(false));
|
||||
templ("copyFun", m_utils.copyToMemoryFunction(false, /*cleanup*/true));
|
||||
templ("lengthPadded", _options.padded ? m_utils.roundUpFunction() + "(length)" : "length");
|
||||
return templ.render();
|
||||
});
|
||||
@ -1296,7 +1297,7 @@ string ABIFunctions::abiDecodingFunctionByteArrayAvailableLength(ArrayType const
|
||||
templ("functionName", functionName);
|
||||
templ("allocate", m_utils.allocationFunction());
|
||||
templ("allocationSize", m_utils.arrayAllocationSizeFunction(_type));
|
||||
templ("copyToMemFun", m_utils.copyToMemoryFunction(!_fromMemory));
|
||||
templ("copyToMemFun", m_utils.copyToMemoryFunction(!_fromMemory, /*cleanup*/true));
|
||||
return templ.render();
|
||||
});
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ private:
|
||||
std::string abiDecodingFunctionArray(ArrayType const& _type, bool _fromMemory);
|
||||
/// Part of @a abiDecodingFunction for calldata array types.
|
||||
std::string abiDecodingFunctionCalldataArray(ArrayType const& _type);
|
||||
/// Part of @a abiDecodingFunctionArrayWithAvailableLength
|
||||
/// Part of @a abiDecodingFunctionArrayAvailableLength
|
||||
std::string abiDecodingFunctionByteArrayAvailableLength(ArrayType const& _type, bool _fromMemory);
|
||||
/// Part of @a abiDecodingFunction for calldata struct types.
|
||||
std::string abiDecodingFunctionCalldataStruct(StructType const& _type);
|
||||
|
@ -80,20 +80,25 @@ string YulUtilFunctions::splitExternalFunctionIdFunction()
|
||||
});
|
||||
}
|
||||
|
||||
string YulUtilFunctions::copyToMemoryFunction(bool _fromCalldata)
|
||||
string YulUtilFunctions::copyToMemoryFunction(bool _fromCalldata, bool _cleanup)
|
||||
{
|
||||
string functionName = "copy_" + string(_fromCalldata ? "calldata" : "memory") + "_to_memory";
|
||||
string functionName =
|
||||
"copy_"s +
|
||||
(_fromCalldata ? "calldata"s : "memory"s) +
|
||||
"_to_memory"s +
|
||||
(_cleanup ? "_with_cleanup"s : ""s);
|
||||
|
||||
return m_functionCollector.createFunction(functionName, [&]() {
|
||||
if (_fromCalldata)
|
||||
{
|
||||
return Whiskers(R"(
|
||||
function <functionName>(src, dst, length) {
|
||||
calldatacopy(dst, src, length)
|
||||
// clear end
|
||||
mstore(add(dst, length), 0)
|
||||
<?cleanup>mstore(add(dst, length), 0)</cleanup>
|
||||
}
|
||||
)")
|
||||
("functionName", functionName)
|
||||
("cleanup", _cleanup)
|
||||
.render();
|
||||
}
|
||||
else
|
||||
@ -105,14 +110,11 @@ string YulUtilFunctions::copyToMemoryFunction(bool _fromCalldata)
|
||||
{
|
||||
mstore(add(dst, i), mload(add(src, i)))
|
||||
}
|
||||
if gt(i, length)
|
||||
{
|
||||
// clear end
|
||||
mstore(add(dst, length), 0)
|
||||
}
|
||||
<?cleanup>mstore(add(dst, length), 0)</cleanup>
|
||||
}
|
||||
)")
|
||||
("functionName", functionName)
|
||||
("cleanup", _cleanup)
|
||||
.render();
|
||||
}
|
||||
});
|
||||
|
@ -73,8 +73,9 @@ public:
|
||||
|
||||
/// @returns a function that copies raw bytes of dynamic length from calldata
|
||||
/// or memory to memory.
|
||||
/// Pads with zeros and might write more than exactly length.
|
||||
std::string copyToMemoryFunction(bool _fromCalldata);
|
||||
/// @params _cleanup If true, pads with zeros up to the 32 byte boundary after the specified length
|
||||
/// signature: (src, dst, length) ->
|
||||
std::string copyToMemoryFunction(bool _fromCalldata, bool _cleanup);
|
||||
|
||||
/// @returns the name of a function that copies a string literal to memory
|
||||
/// and returns a pointer to the memory area containing the string literal.
|
||||
|
@ -179,17 +179,13 @@ object "D_27" {
|
||||
updated_pos := add(pos, 0x20)
|
||||
}
|
||||
|
||||
function copy_memory_to_memory(src, dst, length) {
|
||||
function copy_memory_to_memory_with_cleanup(src, dst, length) {
|
||||
let i := 0
|
||||
for { } lt(i, length) { i := add(i, 32) }
|
||||
{
|
||||
mstore(add(dst, i), mload(add(src, i)))
|
||||
}
|
||||
if gt(i, length)
|
||||
{
|
||||
// clear end
|
||||
mstore(add(dst, length), 0)
|
||||
}
|
||||
mstore(add(dst, length), 0)
|
||||
}
|
||||
|
||||
function round_up_to_mul_of_32(value) -> result {
|
||||
@ -199,7 +195,7 @@ object "D_27" {
|
||||
function abi_encode_t_string_memory_ptr_to_t_string_memory_ptr_fromStack(value, pos) -> end {
|
||||
let length := array_length_t_string_memory_ptr(value)
|
||||
pos := array_storeLengthForEncoding_t_string_memory_ptr_fromStack(pos, length)
|
||||
copy_memory_to_memory(add(value, 0x20), pos, length)
|
||||
copy_memory_to_memory_with_cleanup(add(value, 0x20), pos, length)
|
||||
end := add(pos, round_up_to_mul_of_32(length))
|
||||
}
|
||||
|
||||
@ -496,10 +492,7 @@ object "D_27" {
|
||||
{
|
||||
mstore(add(add(memPos, i), _2), mload(add(add(memPtr_1, i), _7)))
|
||||
}
|
||||
if gt(i, length)
|
||||
{
|
||||
mstore(add(add(memPos, length), _2), _3)
|
||||
}
|
||||
mstore(add(add(memPos, length), _2), _3)
|
||||
return(memPos, add(sub(add(memPos, and(add(length, 31), not(31))), memPos), _2))
|
||||
}
|
||||
}
|
||||
|
@ -114,10 +114,7 @@ object "C_59" {
|
||||
{
|
||||
mstore(add(add(memPos, i), _12), mload(add(add(memPtr_1, i), _4)))
|
||||
}
|
||||
if gt(i, length)
|
||||
{
|
||||
mstore(add(add(memPos, length), _12), _3)
|
||||
}
|
||||
mstore(add(add(memPos, length), _12), _3)
|
||||
return(memPos, add(sub(add(memPos, and(add(length, 31), _9)), memPos), _12))
|
||||
}
|
||||
}
|
||||
|
@ -132,17 +132,18 @@ sub_0: assembly {
|
||||
/* "viair_subobject_optimization/input.sol":745:765 type(C).creationCode */
|
||||
dataSize(sub_0)
|
||||
/* "viair_subobject_optimization/input.sol":669:772 contract D {... */
|
||||
swap2
|
||||
not(0x1f)
|
||||
swap1
|
||||
dup2
|
||||
0x3f
|
||||
dup3
|
||||
dup6
|
||||
add
|
||||
and
|
||||
dup5
|
||||
dup2
|
||||
add
|
||||
swap3
|
||||
dup5
|
||||
dup2
|
||||
dup5
|
||||
lt
|
||||
0xffffffffffffffff
|
||||
@ -151,61 +152,61 @@ sub_0: assembly {
|
||||
or
|
||||
tag_9
|
||||
jumpi
|
||||
swap3
|
||||
swap1
|
||||
swap2
|
||||
dup5
|
||||
0x40
|
||||
swap4
|
||||
dup5
|
||||
mstore
|
||||
/* "viair_subobject_optimization/input.sol":745:765 type(C).creationCode */
|
||||
dup3
|
||||
dup2
|
||||
mstore
|
||||
0x20
|
||||
swap3
|
||||
dataOffset(sub_0)
|
||||
dup5
|
||||
dup4
|
||||
mstore
|
||||
0x20
|
||||
swap5
|
||||
dataOffset(sub_0)
|
||||
dup7
|
||||
dup6
|
||||
add
|
||||
codecopy
|
||||
/* "viair_subobject_optimization/input.sol":669:772 contract D {... */
|
||||
dup4
|
||||
mload
|
||||
swap5
|
||||
dup4
|
||||
dup7
|
||||
swap5
|
||||
dup6
|
||||
mstore
|
||||
dup3
|
||||
mload
|
||||
swap3
|
||||
dup4
|
||||
dup2
|
||||
dup5
|
||||
mstore
|
||||
dup5
|
||||
mload
|
||||
swap2
|
||||
dup3
|
||||
dup8
|
||||
dup2
|
||||
dup7
|
||||
add
|
||||
mstore
|
||||
dup3
|
||||
swap2
|
||||
dup2
|
||||
swap6
|
||||
tag_11:
|
||||
dup5
|
||||
dup4
|
||||
dup8
|
||||
lt
|
||||
tag_12
|
||||
jumpi
|
||||
pop
|
||||
pop
|
||||
swap1
|
||||
dup4
|
||||
swap5
|
||||
pop
|
||||
dup6
|
||||
dup3
|
||||
0x1f
|
||||
swap4
|
||||
swap3
|
||||
gt
|
||||
tag_14
|
||||
jumpi
|
||||
tag_15:
|
||||
pop
|
||||
swap5
|
||||
swap6
|
||||
add
|
||||
add
|
||||
mstore
|
||||
add
|
||||
and
|
||||
dup2
|
||||
@ -214,35 +215,26 @@ sub_0: assembly {
|
||||
add
|
||||
swap1
|
||||
return
|
||||
tag_14:
|
||||
dup6
|
||||
dup3
|
||||
dup7
|
||||
add
|
||||
add
|
||||
mstore
|
||||
dup7
|
||||
jump(tag_15)
|
||||
tag_12:
|
||||
dup7
|
||||
dup2
|
||||
dup4
|
||||
add
|
||||
dup2
|
||||
dup3
|
||||
add
|
||||
mload
|
||||
dup10
|
||||
dup5
|
||||
dup9
|
||||
add
|
||||
dup10
|
||||
add
|
||||
mstore
|
||||
dup9
|
||||
swap7
|
||||
pop
|
||||
swap2
|
||||
dup3
|
||||
swap6
|
||||
dup2
|
||||
add
|
||||
swap2
|
||||
swap6
|
||||
dup9
|
||||
swap6
|
||||
pop
|
||||
jump(tag_11)
|
||||
tag_9:
|
||||
shl(0xe0, 0x4e487b71)
|
||||
|
@ -88,17 +88,13 @@ object \"C_11\" {
|
||||
updated_pos := add(pos, 0x20)
|
||||
}
|
||||
|
||||
function copy_memory_to_memory(src, dst, length) {
|
||||
function copy_memory_to_memory_with_cleanup(src, dst, length) {
|
||||
let i := 0
|
||||
for { } lt(i, length) { i := add(i, 32) }
|
||||
{
|
||||
mstore(add(dst, i), mload(add(src, i)))
|
||||
}
|
||||
if gt(i, length)
|
||||
{
|
||||
// clear end
|
||||
mstore(add(dst, length), 0)
|
||||
}
|
||||
mstore(add(dst, length), 0)
|
||||
}
|
||||
|
||||
function round_up_to_mul_of_32(value) -> result {
|
||||
@ -108,7 +104,7 @@ object \"C_11\" {
|
||||
function abi_encode_t_string_memory_ptr_to_t_string_memory_ptr_fromStack(value, pos) -> end {
|
||||
let length := array_length_t_string_memory_ptr(value)
|
||||
pos := array_storeLengthForEncoding_t_string_memory_ptr_fromStack(pos, length)
|
||||
copy_memory_to_memory(add(value, 0x20), pos, length)
|
||||
copy_memory_to_memory_with_cleanup(add(value, 0x20), pos, length)
|
||||
end := add(pos, round_up_to_mul_of_32(length))
|
||||
}
|
||||
|
||||
|
@ -88,17 +88,13 @@ object \"C_11\" {
|
||||
updated_pos := add(pos, 0x20)
|
||||
}
|
||||
|
||||
function copy_memory_to_memory(src, dst, length) {
|
||||
function copy_memory_to_memory_with_cleanup(src, dst, length) {
|
||||
let i := 0
|
||||
for { } lt(i, length) { i := add(i, 32) }
|
||||
{
|
||||
mstore(add(dst, i), mload(add(src, i)))
|
||||
}
|
||||
if gt(i, length)
|
||||
{
|
||||
// clear end
|
||||
mstore(add(dst, length), 0)
|
||||
}
|
||||
mstore(add(dst, length), 0)
|
||||
}
|
||||
|
||||
function round_up_to_mul_of_32(value) -> result {
|
||||
@ -108,7 +104,7 @@ object \"C_11\" {
|
||||
function abi_encode_t_string_memory_ptr_to_t_string_memory_ptr_fromStack(value, pos) -> end {
|
||||
let length := array_length_t_string_memory_ptr(value)
|
||||
pos := array_storeLengthForEncoding_t_string_memory_ptr_fromStack(pos, length)
|
||||
copy_memory_to_memory(add(value, 0x20), pos, length)
|
||||
copy_memory_to_memory_with_cleanup(add(value, 0x20), pos, length)
|
||||
end := add(pos, round_up_to_mul_of_32(length))
|
||||
}
|
||||
|
||||
|
@ -14,9 +14,9 @@ contract C {
|
||||
}
|
||||
// ----
|
||||
// creation:
|
||||
// codeDepositCost: 1243000
|
||||
// executionCost: 1295
|
||||
// totalCost: 1244295
|
||||
// codeDepositCost: 1241200
|
||||
// executionCost: 1288
|
||||
// totalCost: 1242488
|
||||
// external:
|
||||
// a(): 2430
|
||||
// b(uint256): infinite
|
||||
|
@ -17,9 +17,9 @@ contract C {
|
||||
// optimize-yul: true
|
||||
// ----
|
||||
// creation:
|
||||
// codeDepositCost: 660800
|
||||
// executionCost: 696
|
||||
// totalCost: 661496
|
||||
// codeDepositCost: 659000
|
||||
// executionCost: 689
|
||||
// totalCost: 659689
|
||||
// external:
|
||||
// a(): 2285
|
||||
// b(uint256): 4652
|
||||
|
@ -59,10 +59,10 @@ contract C {
|
||||
// EVMVersion: >homestead
|
||||
// ----
|
||||
// test_bytes() ->
|
||||
// gas irOptimized: 367365
|
||||
// gas legacy: 416585
|
||||
// gas legacyOptimized: 322043
|
||||
// gas irOptimized: 362445
|
||||
// gas legacy: 414569
|
||||
// gas legacyOptimized: 319271
|
||||
// test_uint256() ->
|
||||
// gas irOptimized: 515982
|
||||
// gas legacy: 583100
|
||||
// gas legacyOptimized: 444161
|
||||
// gas irOptimized: 511910
|
||||
// gas legacy: 581876
|
||||
// gas legacyOptimized: 442757
|
||||
|
@ -0,0 +1,14 @@
|
||||
pragma abicoder v1;
|
||||
|
||||
contract C {
|
||||
function f(bool a, bytes calldata b, bytes32[2] calldata c)
|
||||
public
|
||||
returns (bool, bytes calldata, bytes32[2] calldata)
|
||||
{
|
||||
return (a, b, c);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: false
|
||||
// ----
|
||||
// f(bool,bytes,bytes32[2]): true, 0x80, "a", "b", 4, "abcd" -> true, 0x80, "a", "b", 4, "abcd"
|
@ -0,0 +1,17 @@
|
||||
pragma abicoder v1;
|
||||
|
||||
contract C {
|
||||
function f(uint256[] memory a, bytes calldata b) public returns (bytes memory) {
|
||||
return abi.encode(a, b);
|
||||
}
|
||||
|
||||
function g(uint256[] memory a, bytes calldata b) external returns (bytes memory) {
|
||||
return f(a, b);
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// EVMVersion: >homestead
|
||||
// ----
|
||||
// f(uint256[],bytes): 0x40, 0x80, 1, 0xFF, 6, "123456" -> 0x20, 0xc0, 0x40, 0x80, 1, 0xff, 6, "123456"
|
||||
// g(uint256[],bytes): 0x40, 0x80, 1, 0xffff, 8, "12345678" -> 0x20, 0xc0, 0x40, 0x80, 1, 0xffff, 8, "12345678"
|
@ -60,10 +60,10 @@ contract C {
|
||||
// EVMVersion: >homestead
|
||||
// ----
|
||||
// test_bytes() ->
|
||||
// gas irOptimized: 367365
|
||||
// gas legacy: 416585
|
||||
// gas legacyOptimized: 322043
|
||||
// gas irOptimized: 362445
|
||||
// gas legacy: 414569
|
||||
// gas legacyOptimized: 319271
|
||||
// test_uint256() ->
|
||||
// gas irOptimized: 515982
|
||||
// gas legacy: 583100
|
||||
// gas legacyOptimized: 444161
|
||||
// gas irOptimized: 511910
|
||||
// gas legacy: 581876
|
||||
// gas legacyOptimized: 442757
|
||||
|
@ -51,6 +51,6 @@ contract C {
|
||||
// f2() -> 0x20, 0xa0, 0x1, 0x60, 0x2, 0x3, "abc"
|
||||
// f3() -> 0x20, 0xa0, 0x1, 0x60, 0x2, 0x3, "abc"
|
||||
// f4() -> 0x20, 0x160, 0x1, 0x80, 0xc0, 0x2, 0x3, "abc", 0x7, 0x40, 0x2, 0x2, 0x3
|
||||
// gas irOptimized: 112820
|
||||
// gas legacy: 114900
|
||||
// gas legacyOptimized: 112606
|
||||
// gas irOptimized: 112646
|
||||
// gas legacy: 114866
|
||||
// gas legacyOptimized: 112586
|
||||
|
@ -0,0 +1,17 @@
|
||||
pragma abicoder v2;
|
||||
|
||||
struct T {
|
||||
bytes x;
|
||||
uint[3] y;
|
||||
}
|
||||
|
||||
contract E {
|
||||
function f(bool a, T calldata b, bytes32[2] calldata c)
|
||||
public
|
||||
returns (bool, T calldata, bytes32[2] calldata)
|
||||
{
|
||||
return (a, b, c);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// f(bool,(bytes,uint256[3]),bytes32[2]): 1, 0x80, "a", "b", 0x80, 11, 12, 13, 4, "abcd" -> 1, 0x80, "a", "b", 0x80, 11, 12, 13, 4, "abcd"
|
@ -20,6 +20,6 @@ contract C {
|
||||
// f(uint256[][1]): 32, 32, 0 -> true
|
||||
// f(uint256[][1]): 32, 32, 1, 42 -> true
|
||||
// f(uint256[][1]): 32, 32, 8, 421, 422, 423, 424, 425, 426, 427, 428 -> true
|
||||
// gas irOptimized: 128098
|
||||
// gas legacy: 140672
|
||||
// gas legacyOptimized: 119588
|
||||
// gas irOptimized: 127347
|
||||
// gas legacy: 140553
|
||||
// gas legacyOptimized: 119450
|
||||
|
@ -0,0 +1,17 @@
|
||||
library L {
|
||||
// This case used to be affected by the buggy cleanup due to ABIEncoderV2HeadOverflowWithStaticArrayCleanup bug.
|
||||
function g(uint[] memory a, uint[1] calldata b) public returns (uint[] memory, uint[1] calldata) {
|
||||
return (a, b);
|
||||
}
|
||||
}
|
||||
|
||||
contract C {
|
||||
function f(uint[] memory a, uint[1] calldata b) public returns (uint[] memory, uint[1] memory) {
|
||||
return L.g(a, b);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: >homestead
|
||||
// ----
|
||||
// library: L
|
||||
// f(uint256[],uint256[1]): 0x40, 0xff, 1, 0xffff -> 0x40, 0xff, 0x01, 0xffff
|
@ -0,0 +1,27 @@
|
||||
contract C {
|
||||
function f(string calldata x) external returns (bytes memory r) {
|
||||
uint mptr;
|
||||
assembly {
|
||||
// dirty memory
|
||||
mptr := mload(0x40)
|
||||
for { let i := mptr } lt(i, add(mptr, 0x0100)) { i := add(i, 32) }
|
||||
{
|
||||
mstore(i, sub(0, 1))
|
||||
}
|
||||
}
|
||||
r = abi.encode(x);
|
||||
assembly {
|
||||
// assert that we dirtied the memory that was encoded to
|
||||
if iszero(eq(mptr, r)) {
|
||||
revert(0, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
function test() external returns (bytes memory) {
|
||||
return this.f("abc");
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: >homestead
|
||||
// ----
|
||||
// test() -> 0x20, 0x60, 0x20, 3, "abc"
|
@ -0,0 +1,13 @@
|
||||
contract C {
|
||||
function f(uint256[] memory a, bytes calldata b) public returns (bytes memory) {
|
||||
return abi.encode(a, b);
|
||||
}
|
||||
|
||||
function g(uint256[] memory a, bytes calldata b) external returns (bytes memory) {
|
||||
return f(a, b);
|
||||
}
|
||||
}
|
||||
|
||||
// ----
|
||||
// f(uint256[],bytes): 0x40, 0x80, 1, 0xFF, 6, "123456" -> 0x20, 0xc0, 0x40, 0x80, 1, 0xff, 6, "123456"
|
||||
// g(uint256[],bytes): 0x40, 0x80, 1, 0xffff, 8, "12345678" -> 0x20, 0xc0, 0x40, 0x80, 1, 0xffff, 8, "12345678"
|
@ -0,0 +1,18 @@
|
||||
contract C {
|
||||
function f(uint256[] memory a, uint256[1] calldata b) public returns (bytes memory) {
|
||||
return abi.encode(a, b);
|
||||
}
|
||||
|
||||
function g(uint256[] memory a, uint256[1] calldata b) external returns (bytes memory) {
|
||||
return f(a, b);
|
||||
}
|
||||
|
||||
function h(uint256[] memory a, uint256[1] calldata b) external returns (uint256[] memory, uint256[1] calldata) {
|
||||
return (a, b);
|
||||
}
|
||||
}
|
||||
|
||||
// ----
|
||||
// f(uint256[],uint256[1]): 0x40, 0xff, 1, 0xffff -> 0x20, 0x80, 0x40, 0xff, 1, 0xffff
|
||||
// g(uint256[],uint256[1]): 0x40, 0xff, 1, 0xffff -> 0x20, 0x80, 0x40, 0xff, 1, 0xffff
|
||||
// h(uint256[],uint256[1]): 0x40, 0xff, 1, 0xffff -> 0x40, 0xff, 1, 0xffff
|
@ -18,10 +18,10 @@ contract C {
|
||||
// EVMVersion: >homestead
|
||||
// ----
|
||||
// h(uint256[2][]): 0x20, 3, 123, 124, 223, 224, 323, 324 -> 32, 256, 0x20, 3, 123, 124, 223, 224, 323, 324
|
||||
// gas irOptimized: 180768
|
||||
// gas legacy: 184929
|
||||
// gas legacyOptimized: 181504
|
||||
// gas irOptimized: 180726
|
||||
// gas legacy: 184921
|
||||
// gas legacyOptimized: 181506
|
||||
// i(uint256[2][2]): 123, 124, 223, 224 -> 32, 128, 123, 124, 223, 224
|
||||
// gas irOptimized: 112471
|
||||
// gas legacy: 115468
|
||||
// gas legacyOptimized: 112988
|
||||
// gas irOptimized: 112453
|
||||
// gas legacy: 115460
|
||||
// gas legacyOptimized: 112990
|
||||
|
@ -9,6 +9,6 @@ contract C {
|
||||
|
||||
// ----
|
||||
// f(bytes): 0x20, 0x80, 0x21, 0x40, 0x7, "abcdefg" -> 0x21, 0x40, 0x7, "abcdefg"
|
||||
// gas irOptimized: 135787
|
||||
// gas legacy: 137377
|
||||
// gas legacyOptimized: 136125
|
||||
// gas irOptimized: 135699
|
||||
// gas legacy: 137325
|
||||
// gas legacyOptimized: 136059
|
||||
|
@ -17,25 +17,25 @@ contract c {
|
||||
// ----
|
||||
// f(uint256): 0 -> 0x20, 0x00
|
||||
// f(uint256): 31 -> 0x20, 0x1f, 0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e00
|
||||
// gas irOptimized: 108395
|
||||
// gas legacy: 124322
|
||||
// gas legacyOptimized: 119141
|
||||
// gas irOptimized: 109413
|
||||
// gas legacy: 124296
|
||||
// gas legacyOptimized: 119119
|
||||
// f(uint256): 32 -> 0x20, 0x20, 1780731860627700044960722568376592200742329637303199754547598369979440671
|
||||
// gas irOptimized: 117480
|
||||
// gas legacy: 135259
|
||||
// gas legacyOptimized: 130089
|
||||
// gas irOptimized: 118565
|
||||
// gas legacy: 135251
|
||||
// gas legacyOptimized: 130091
|
||||
// f(uint256): 33 -> 0x20, 33, 1780731860627700044960722568376592200742329637303199754547598369979440671, 0x2000000000000000000000000000000000000000000000000000000000000000
|
||||
// gas irOptimized: 124117
|
||||
// gas legacy: 142861
|
||||
// gas legacyOptimized: 137030
|
||||
// gas irOptimized: 125184
|
||||
// gas legacy: 142835
|
||||
// gas legacyOptimized: 137008
|
||||
// f(uint256): 63 -> 0x20, 0x3f, 1780731860627700044960722568376592200742329637303199754547598369979440671, 14532552714582660066924456880521368950258152170031413196862950297402215316992
|
||||
// gas irOptimized: 126467
|
||||
// gas legacy: 160901
|
||||
// gas legacyOptimized: 150960
|
||||
// gas irOptimized: 128584
|
||||
// gas legacy: 160875
|
||||
// gas legacyOptimized: 150938
|
||||
// f(uint256): 12 -> 0x20, 0x0c, 0x0102030405060708090a0b0000000000000000000000000000000000000000
|
||||
// gas legacy: 59345
|
||||
// gas legacyOptimized: 57279
|
||||
// f(uint256): 129 -> 0x20, 0x81, 1780731860627700044960722568376592200742329637303199754547598369979440671, 0x202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f, 29063324697304692433803953038474361308315562010425523193971352996434451193439, 0x606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f, -57896044618658097711785492504343953926634992332820282019728792003956564819968
|
||||
// gas irOptimized: 353326
|
||||
// gas legacy: 421700
|
||||
// gas legacyOptimized: 402999
|
||||
// gas irOptimized: 357699
|
||||
// gas legacy: 421674
|
||||
// gas legacyOptimized: 402977
|
||||
|
@ -35,12 +35,12 @@ contract C {
|
||||
}
|
||||
// ----
|
||||
// f() -> 0x40, 0x80, 6, 0x6162636465660000000000000000000000000000000000000000000000000000, 0x49, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738390000000000000000000000000000000000000000000000
|
||||
// gas irOptimized: 179880
|
||||
// gas legacy: 181099
|
||||
// gas legacyOptimized: 180073
|
||||
// gas irOptimized: 179766
|
||||
// gas legacy: 181047
|
||||
// gas legacyOptimized: 180029
|
||||
// g() -> 0x40, 0xc0, 0x49, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738390000000000000000000000000000000000000000000000, 0x11, 0x3132333435363738393233343536373839000000000000000000000000000000
|
||||
// gas irOptimized: 107211
|
||||
// gas legacy: 110253
|
||||
// gas legacyOptimized: 107397
|
||||
// gas irOptimized: 107097
|
||||
// gas legacy: 110201
|
||||
// gas legacyOptimized: 107353
|
||||
// h() -> 0x40, 0x60, 0x00, 0x00
|
||||
// storageEmpty -> 1
|
||||
|
@ -46,11 +46,11 @@ contract C {
|
||||
}
|
||||
// ----
|
||||
// test() -> 0x20, 0x14, "[a called][b called]"
|
||||
// gas irOptimized: 116724
|
||||
// gas legacy: 119056
|
||||
// gas legacyOptimized: 117043
|
||||
// gas irOptimized: 116688
|
||||
// gas legacy: 119030
|
||||
// gas legacyOptimized: 117021
|
||||
// test2() -> 0x20, 0x14, "[b called][a called]"
|
||||
// test3() -> 0x20, 0x14, "[b called][a called]"
|
||||
// gas irOptimized: 103304
|
||||
// gas legacy: 102840
|
||||
// gas legacyOptimized: 101728
|
||||
// gas irOptimized: 103268
|
||||
// gas legacy: 102814
|
||||
// gas legacyOptimized: 101706
|
||||
|
@ -11,6 +11,6 @@ contract C {
|
||||
}
|
||||
// ----
|
||||
// f() -> 0x20, 0x02, 0x40, 0x80, 3, 0x6162630000000000000000000000000000000000000000000000000000000000, 0x99, 44048183304486788312148433451363384677562265908331949128489393215789685032262, 32241931068525137014058842823026578386641954854143559838526554899205067598957, 49951309422467613961193228765530489307475214998374779756599339590522149884499, 0x54555658595a6162636465666768696a6b6c6d6e6f707172737475767778797a, 0x4142434445464748494a4b4c4d4e4f5051525354555658595a00000000000000
|
||||
// gas irOptimized: 202952
|
||||
// gas legacy: 204912
|
||||
// gas legacyOptimized: 203437
|
||||
// gas irOptimized: 202808
|
||||
// gas legacy: 204860
|
||||
// gas legacyOptimized: 203385
|
||||
|
@ -10,6 +10,6 @@ contract c {
|
||||
|
||||
// ----
|
||||
// test() -> 0x20, 29, 0x0303030303030303030303030303030303030303030303030303030303000000
|
||||
// gas irOptimized: 109341
|
||||
// gas legacy: 126728
|
||||
// gas legacyOptimized: 123444
|
||||
// gas irOptimized: 109310
|
||||
// gas legacy: 126702
|
||||
// gas legacyOptimized: 123422
|
||||
|
@ -10,6 +10,6 @@ contract c {
|
||||
|
||||
// ----
|
||||
// test() -> 0x20, 33, 0x303030303030303030303030303030303030303030303030303030303030303, 0x0300000000000000000000000000000000000000000000000000000000000000
|
||||
// gas irOptimized: 108146
|
||||
// gas legacy: 125610
|
||||
// gas legacyOptimized: 122582
|
||||
// gas irOptimized: 108115
|
||||
// gas legacy: 125584
|
||||
// gas legacyOptimized: 122560
|
||||
|
@ -28,9 +28,9 @@ contract C {
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// constructor() ->
|
||||
// gas irOptimized: 521983
|
||||
// gas legacy: 731840
|
||||
// gas legacyOptimized: 494859
|
||||
// gas irOptimized: 518935
|
||||
// gas legacy: 729908
|
||||
// gas legacyOptimized: 493347
|
||||
// h() -> 0x20, 0x40, 0x00, 0
|
||||
// ~ emit ev(uint256[],uint256): 0x40, 0x21, 0x02, 0x00, 0x00
|
||||
// g() -> 0x20, 0x40, 0, 0x00
|
||||
|
@ -24,6 +24,6 @@ contract Creator {
|
||||
}
|
||||
// ----
|
||||
// f(uint256,bytes): 7, 0x40, 78, "abcdefghijklmnopqrstuvwxyzabcdef", "ghijklmnopqrstuvwxyzabcdefghijkl", "mnopqrstuvwxyz" -> 7, "h"
|
||||
// gas irOptimized: 282398
|
||||
// gas legacy: 429047
|
||||
// gas legacyOptimized: 297958
|
||||
// gas irOptimized: 279069
|
||||
// gas legacy: 427192
|
||||
// gas legacyOptimized: 296504
|
||||
|
@ -8,8 +8,8 @@ contract Test {
|
||||
}
|
||||
// ----
|
||||
// constructor(): 7, 0x40, 78, "abcdefghijklmnopqrstuvwxyzabcdef", "ghijklmnopqrstuvwxyzabcdefghijkl", "mnopqrstuvwxyz" ->
|
||||
// gas irOptimized: 273340
|
||||
// gas legacy: 317746
|
||||
// gas legacyOptimized: 262368
|
||||
// gas irOptimized: 270118
|
||||
// gas legacy: 315616
|
||||
// gas legacyOptimized: 260686
|
||||
// m_x() -> 7
|
||||
// m_s() -> 0x20, 78, "abcdefghijklmnopqrstuvwxyzabcdef", "ghijklmnopqrstuvwxyzabcdefghijkl", "mnopqrstuvwxyz"
|
||||
|
@ -0,0 +1,10 @@
|
||||
contract C {
|
||||
error E(uint[], uint[1]);
|
||||
|
||||
// This case used to be affected by the buggy cleanup due to ABIEncoderV2HeadOverflowWithStaticArrayCleanup bug.
|
||||
function f(uint[] memory a, uint[1] calldata b) public {
|
||||
revert E(a, b);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// f(uint256[],uint256[1]): 0x40, 0xff, 1, 0xffff -> FAILURE, hex"f42f106d", 0x40, 0xff, 1, 0xffff
|
@ -0,0 +1,11 @@
|
||||
contract C {
|
||||
event E(uint[], uint[1]);
|
||||
|
||||
// This case used to be affected by the buggy cleanup due to ABIEncoderV2HeadOverflowWithStaticArrayCleanup bug.
|
||||
function f(uint[] memory a, uint[1] calldata b) public {
|
||||
emit E(a, b);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// f(uint256[],uint256[1]): 0x40, 0xff, 1, 0xffff ->
|
||||
// ~ emit E(uint256[],uint256[1]): 0x40, 0xff, 0x01, 0xffff
|
@ -74,9 +74,9 @@ contract FixedFeeRegistrar is Registrar {
|
||||
}
|
||||
// ----
|
||||
// constructor()
|
||||
// gas irOptimized: 414897
|
||||
// gas legacy: 935817
|
||||
// gas legacyOptimized: 489951
|
||||
// gas irOptimized: 411435
|
||||
// gas legacy: 933867
|
||||
// gas legacyOptimized: 487352
|
||||
// reserve(string), 69 ether: 0x20, 3, "abc" ->
|
||||
// ~ emit Changed(string): #0x4e03657aea45a94fc7d47ba826c8d667c0d1e6e33a64a036ec44f58fa12d6c45
|
||||
// gas irOptimized: 45967
|
||||
|
@ -33,9 +33,9 @@ contract test {
|
||||
// EVMVersion: >=constantinople
|
||||
// ----
|
||||
// constructor()
|
||||
// gas irOptimized: 444190
|
||||
// gas legacy: 757857
|
||||
// gas legacyOptimized: 539866
|
||||
// gas irOptimized: 441142
|
||||
// gas legacy: 755907
|
||||
// gas legacyOptimized: 538354
|
||||
// encode_inline_asm(bytes): 0x20, 0 -> 0x20, 0
|
||||
// encode_inline_asm(bytes): 0x20, 1, "f" -> 0x20, 4, "Zg=="
|
||||
// encode_inline_asm(bytes): 0x20, 2, "fo" -> 0x20, 4, "Zm8="
|
||||
|
@ -176,35 +176,35 @@ contract DepositContract is IDepositContract, ERC165 {
|
||||
}
|
||||
// ----
|
||||
// constructor()
|
||||
// gas irOptimized: 1432633
|
||||
// gas legacy: 2427722
|
||||
// gas legacyOptimized: 1773892
|
||||
// gas irOptimized: 1428137
|
||||
// gas legacy: 2425301
|
||||
// gas legacyOptimized: 1770477
|
||||
// supportsInterface(bytes4): 0x0 -> 0
|
||||
// supportsInterface(bytes4): 0xffffffff00000000000000000000000000000000000000000000000000000000 -> false # defined to be false by ERC-165 #
|
||||
// supportsInterface(bytes4): 0x01ffc9a700000000000000000000000000000000000000000000000000000000 -> true # ERC-165 id #
|
||||
// supportsInterface(bytes4): 0x8564090700000000000000000000000000000000000000000000000000000000 -> true # the deposit interface id #
|
||||
// get_deposit_root() -> 0xd70a234731285c6804c2a4f56711ddb8c82c99740f207854891028af34e27e5e
|
||||
// gas irOptimized: 116284
|
||||
// gas legacy: 150273
|
||||
// gas legacyOptimized: 122510
|
||||
// gas irOptimized: 114626
|
||||
// gas legacy: 149888
|
||||
// gas legacyOptimized: 121887
|
||||
// get_deposit_count() -> 0x20, 8, 0 # TODO: check balance and logs after each deposit #
|
||||
// deposit(bytes,bytes,bytes,bytes32), 32 ether: 0 -> FAILURE # Empty input #
|
||||
// get_deposit_root() -> 0xd70a234731285c6804c2a4f56711ddb8c82c99740f207854891028af34e27e5e
|
||||
// gas irOptimized: 116284
|
||||
// gas legacy: 150273
|
||||
// gas legacyOptimized: 122510
|
||||
// gas irOptimized: 114626
|
||||
// gas legacy: 149888
|
||||
// gas legacyOptimized: 121887
|
||||
// get_deposit_count() -> 0x20, 8, 0
|
||||
// deposit(bytes,bytes,bytes,bytes32), 1 ether: 0x80, 0xe0, 0x120, 0xaa4a8d0b7d9077248630f1a4701ae9764e42271d7f22b7838778411857fd349e, 0x30, 0x933ad9491b62059dd065b560d256d8957a8c402cc6e8d8ee7290ae11e8f73292, 0x67a8811c397529dac52ae1342ba58c9500000000000000000000000000000000, 0x20, 0x00f50428677c60f997aadeab24aabf7fceaef491c96a52b463ae91f95611cf71, 0x60, 0xa29d01cc8c6296a8150e515b5995390ef841dc18948aa3e79be6d7c1851b4cbb, 0x5d6ff49fa70b9c782399506a22a85193151b9b691245cebafd2063012443c132, 0x4b6c36debaedefb7b2d71b0503ffdc00150aaffd42e63358238ec888901738b8 -> # txhash: 0x7085c586686d666e8bb6e9477a0f0b09565b2060a11f1c4209d3a52295033832 #
|
||||
// ~ emit DepositEvent(bytes,bytes,bytes,bytes,bytes): 0xa0, 0x0100, 0x0140, 0x0180, 0x0200, 0x30, 0x933ad9491b62059dd065b560d256d8957a8c402cc6e8d8ee7290ae11e8f73292, 0x67a8811c397529dac52ae1342ba58c9500000000000000000000000000000000, 0x20, 0xf50428677c60f997aadeab24aabf7fceaef491c96a52b463ae91f95611cf71, 0x08, 0xca9a3b00000000000000000000000000000000000000000000000000000000, 0x60, 0xa29d01cc8c6296a8150e515b5995390ef841dc18948aa3e79be6d7c1851b4cbb, 0x5d6ff49fa70b9c782399506a22a85193151b9b691245cebafd2063012443c132, 0x4b6c36debaedefb7b2d71b0503ffdc00150aaffd42e63358238ec888901738b8, 0x08, 0x00
|
||||
// get_deposit_root() -> 0x2089653123d9c721215120b6db6738ba273bbc5228ac093b1f983badcdc8a438
|
||||
// gas irOptimized: 116269
|
||||
// gas legacy: 150283
|
||||
// gas legacyOptimized: 122523
|
||||
// gas irOptimized: 114611
|
||||
// gas legacy: 149898
|
||||
// gas legacyOptimized: 121900
|
||||
// get_deposit_count() -> 0x20, 8, 0x0100000000000000000000000000000000000000000000000000000000000000
|
||||
// deposit(bytes,bytes,bytes,bytes32), 32 ether: 0x80, 0xe0, 0x120, 0xdbd986dc85ceb382708cf90a3500f500f0a393c5ece76963ac3ed72eccd2c301, 0x30, 0xb2ce0f79f90e7b3a113ca5783c65756f96c4b4673c2b5c1eb4efc22280259441, 0x06d601211e8866dc5b50dc48a244dd7c00000000000000000000000000000000, 0x20, 0x00344b6c73f71b11c56aba0d01b7d8ad83559f209d0a4101a515f6ad54c89771, 0x60, 0x945caaf82d18e78c033927d51f452ebcd76524497b91d7a11219cb3db6a1d369, 0x7595fc095ce489e46b2ef129591f2f6d079be4faaf345a02c5eb133c072e7c56, 0x0c6c3617eee66b4b878165c502357d49485326bc6b31bc96873f308c8f19c09d -> # txhash: 0x404d8e109822ce448e68f45216c12cb051b784d068fbe98317ab8e50c58304ac #
|
||||
// ~ emit DepositEvent(bytes,bytes,bytes,bytes,bytes): 0xa0, 0x0100, 0x0140, 0x0180, 0x0200, 0x30, 0xb2ce0f79f90e7b3a113ca5783c65756f96c4b4673c2b5c1eb4efc22280259441, 0x06d601211e8866dc5b50dc48a244dd7c00000000000000000000000000000000, 0x20, 0x344b6c73f71b11c56aba0d01b7d8ad83559f209d0a4101a515f6ad54c89771, 0x08, 0x40597307000000000000000000000000000000000000000000000000000000, 0x60, 0x945caaf82d18e78c033927d51f452ebcd76524497b91d7a11219cb3db6a1d369, 0x7595fc095ce489e46b2ef129591f2f6d079be4faaf345a02c5eb133c072e7c56, 0x0c6c3617eee66b4b878165c502357d49485326bc6b31bc96873f308c8f19c09d, 0x08, 0x0100000000000000000000000000000000000000000000000000000000000000
|
||||
// get_deposit_root() -> 0x40255975859377d912c53aa853245ebd939bdd2b33a28e084babdcc1ed8238ee
|
||||
// gas irOptimized: 116269
|
||||
// gas legacy: 150283
|
||||
// gas legacyOptimized: 122523
|
||||
// gas irOptimized: 114611
|
||||
// gas legacy: 149898
|
||||
// gas legacyOptimized: 121900
|
||||
// get_deposit_count() -> 0x20, 8, 0x0200000000000000000000000000000000000000000000000000000000000000
|
||||
|
@ -49,9 +49,9 @@ contract test {
|
||||
}
|
||||
// ----
|
||||
// constructor()
|
||||
// gas irOptimized: 678980
|
||||
// gas legacy: 1103242
|
||||
// gas legacyOptimized: 745184
|
||||
// gas irOptimized: 675980
|
||||
// gas legacy: 1101298
|
||||
// gas legacyOptimized: 743666
|
||||
// toSlice(string): 0x20, 11, "hello world" -> 11, 0xa0
|
||||
// gas irOptimized: 22660
|
||||
// gas legacy: 23190
|
||||
|
@ -23,9 +23,9 @@ contract C {
|
||||
|
||||
// ----
|
||||
// constructor(), 1 ether ->
|
||||
// gas irOptimized: 270449
|
||||
// gas legacy: 456680
|
||||
// gas legacyOptimized: 302975
|
||||
// gas irOptimized: 266135
|
||||
// gas legacy: 454729
|
||||
// gas legacyOptimized: 301679
|
||||
// f(uint256): 0 -> FAILURE
|
||||
// f(uint256): 1 -> FAILURE
|
||||
// f(uint256): 2 -> FAILURE
|
||||
|
@ -26,9 +26,9 @@ contract C {
|
||||
// revertStrings: debug
|
||||
// ----
|
||||
// constructor(), 1 ether ->
|
||||
// gas irOptimized: 428444
|
||||
// gas legacy: 825625
|
||||
// gas legacyOptimized: 508492
|
||||
// gas irOptimized: 424088
|
||||
// gas legacy: 823681
|
||||
// gas legacyOptimized: 505900
|
||||
// f(uint256): 0 -> FAILURE, hex"08c379a0", 0x20, 37, "Target contract does not contain", " code"
|
||||
// f(uint256): 1 -> FAILURE, hex"08c379a0", 0x20, 37, "Target contract does not contain", " code"
|
||||
// f(uint256): 2 -> FAILURE, hex"08c379a0", 0x20, 37, "Target contract does not contain", " code"
|
||||
|
@ -16,9 +16,9 @@ contract C {
|
||||
// compileToEwasm: also
|
||||
// ----
|
||||
// constructor() ->
|
||||
// gas irOptimized: 177507
|
||||
// gas legacy: 249207
|
||||
// gas legacyOptimized: 157489
|
||||
// gas irOptimized: 175791
|
||||
// gas legacy: 247263
|
||||
// gas legacyOptimized: 155977
|
||||
// initCode() -> 0x20, 0
|
||||
// f() -> true
|
||||
// g() -> 0
|
||||
|
@ -20,6 +20,6 @@ contract C {
|
||||
|
||||
// ----
|
||||
// g() -> 2, 6
|
||||
// gas irOptimized: 178637
|
||||
// gas legacy: 180945
|
||||
// gas legacyOptimized: 179460
|
||||
// gas irOptimized: 178549
|
||||
// gas legacy: 180893
|
||||
// gas legacyOptimized: 179394
|
||||
|
@ -9,4 +9,4 @@ contract test {
|
||||
// ====
|
||||
// EVMVersion: >byzantium
|
||||
// ----
|
||||
// Warning 5574: (21-27154): Contract code size is 27199 bytes and exceeds 24576 bytes (a limit introduced in Spurious Dragon). This contract may not be deployable on Mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries.
|
||||
// Warning 5574: (21-27154): Contract code size is 27192 bytes and exceeds 24576 bytes (a limit introduced in Spurious Dragon). This contract may not be deployable on Mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries.
|
||||
|
@ -7,4 +7,4 @@ contract test {
|
||||
// ====
|
||||
// EVMVersion: =byzantium
|
||||
// ----
|
||||
// Warning 5574: (0-27133): Contract code size is 27227 bytes and exceeds 24576 bytes (a limit introduced in Spurious Dragon). This contract may not be deployable on Mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries.
|
||||
// Warning 5574: (0-27133): Contract code size is 27220 bytes and exceeds 24576 bytes (a limit introduced in Spurious Dragon). This contract may not be deployable on Mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries.
|
||||
|
Loading…
Reference in New Issue
Block a user