Skip to content

Commit

Permalink
adding new structure
Browse files Browse the repository at this point in the history
  • Loading branch information
tutugordillo committed Nov 26, 2024
1 parent e66ffb9 commit 3bf745c
Show file tree
Hide file tree
Showing 3,144 changed files with 177,670 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
contract C {
function f(bytes calldata data) external pure returns (uint256[] memory) {
return abi.decode(data, (uint256[]));
}
}
// ----
// f(bytes): 0x20, 0xc0, 0x20, 0x4, 0x3, 0x4, 0x5, 0x6 -> 0x20, 0x4, 0x3, 0x4, 0x5, 0x6
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"language": "Solidity",
"sources": {
"abi_decode_dynamic_array.sol": {
"content": "contract C {\n function f(bytes calldata data) external pure returns (uint256[] memory) {\n return abi.decode(data, (uint256[]));\n }\n}\n// ----\n// f(bytes): 0x20, 0xc0, 0x20, 0x4, 0x3, 0x4, 0x5, 0x6 -> 0x20, 0x4, 0x3, 0x4, 0x5, 0x6\n"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200,
"details": {
"peephole": false,
"inliner": false,
"jumpdestRemover": false,
"orderLiterals": false,
"deduplicate": false,
"cse": false,
"constantOptimizer": false
}
},
"outputSelection": {
"*": {
"*": [
"abi",
"metadata",
"evm.bytecode",
"evm.deployedBytecode",
"evm.methodIdentifiers"
]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
contract C {
function f(uint16[3] memory a, uint16[2][3] memory b, uint i, uint j, uint k)
public pure returns (uint, uint) {
return (a[i], b[j][k]);
}
}
// ----
// f(uint16[3],uint16[2][3],uint256,uint256,uint256): 1, 2, 3, 11, 12, 21, 22, 31, 32, 1, 2, 1 -> 2, 32
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"language": "Solidity",
"sources": {
"abi_decode_dynamic_array.sol": {
"content": "contract C {\n function f(bytes calldata data) external pure returns (uint256[] memory) {\n return abi.decode(data, (uint256[]));\n }\n}\n// ----\n// f(bytes): 0x20, 0xc0, 0x20, 0x4, 0x3, 0x4, 0x5, 0x6 -> 0x20, 0x4, 0x3, 0x4, 0x5, 0x6\n"
},
"return_dynamic_types_cross_call_out_of_range_2.sol": {
"content": "contract C {\n function dyn(uint x) public returns (bytes memory a) {\n assembly {\n mstore(0, 0x20)\n mstore(0x20, 0x21)\n return(0, x)\n }\n }\n function f(uint x) public returns (bool) {\n this.dyn(x);\n return true;\n }\n}\n// ====\n// EVMVersion: >homestead\n// ----\n// f(uint256): 0x60 -> FAILURE\n// f(uint256): 0x61 -> true\n// f(uint256): 0x80 -> true\n"
},
"dynamic_arrays.sol": {
"content": "contract C {\n function f(uint a, uint16[] memory b, uint c)\n public pure returns (uint, uint, uint) {\n return (b.length, b[a], c);\n }\n}\n// ----\n// f(uint256,uint16[],uint256): 6, 0x60, 9, 7, 11, 12, 13, 14, 15, 16, 17 -> 7, 17, 9\n"
},
"byte_arrays.sol": {
"content": "contract C {\n function f(uint a, bytes memory b, uint c)\n public pure returns (uint, uint, bytes1, uint) {\n return (a, b.length, b[3], c);\n }\n\n function f_external(uint a, bytes calldata b, uint c)\n external pure returns (uint, uint, bytes1, uint) {\n return (a, b.length, b[3], c);\n }\n}\n// ----\n// f(uint256,bytes,uint256): 6, 0x60, 9, 7, \"abcdefg\" -> 6, 7, \"d\", 9\n// f_external(uint256,bytes,uint256): 6, 0x60, 9, 7, \"abcdefg\" -> 6, 7, \"d\", 9\n"
},
"return_dynamic_types_cross_call_out_of_range_1.sol": {
"content": "contract C {\n function dyn(uint x) public returns (bytes memory a) {\n assembly {\n mstore(0, 0x20)\n mstore(0x20, 0x21)\n return(0, x)\n }\n }\n function f(uint x) public returns (bool) {\n this.dyn(x);\n return true;\n }\n}\n// ====\n// EVMVersion: =homestead\n// ----\n// f(uint256): 0x60 -> true\n// f(uint256): 0x7f -> true\n// f(uint256): 0x80 -> true"
},
"abi_encode_decode_simple.sol": {
"content": "contract C {\n function f() public pure returns (uint256, bytes memory) {\n bytes memory arg = \"abcdefg\";\n return abi.decode(abi.encode(uint256(33), arg), (uint256, bytes));\n }\n}\n// ----\n// f() -> 0x21, 0x40, 0x7, \"abcdefg\"\n"
},
"abi_encode_rational.sol": {
"content": "// Tests that rational numbers (even negative ones) are encoded properly.\ncontract C {\n function f() public pure returns (bytes memory) {\n return abi.encode(1, -2);\n }\n}\n// ----\n// f() -> 0x20, 0x40, 0x1, -2\n"
},
"memory_params_in_external_function.sol": {
"content": "contract C {\n function f(bytes memory a, bytes calldata b, uint[] memory c)\n external\n pure\n returns (uint, bytes1, uint, bytes1, uint, uint)\n {\n return (a.length, a[1], b.length, b[2], c.length, c[3]);\n }\n function g() public returns (uint, bytes1, uint, bytes1, uint, uint) {\n uint[] memory x = new uint[](4);\n x[3] = 7;\n return this.f(\"abc\", \"def\", x);\n }\n}\n// ----\n// g() -> 3, 0x6200000000000000000000000000000000000000000000000000000000000000, 3, 0x6600000000000000000000000000000000000000000000000000000000000000, 4, 7\n"
},
"bool_out_of_bounds.sol": {
"content": "pragma abicoder v1;\ncontract C {\n\tfunction f(bool b) public pure returns (bool) { return b; }\n}\n// ====\n// ABIEncoderV1Only: true\n// compileViaYul: false\n// ----\n// f(bool): true -> true\n// f(bool): false -> false\n// f(bool): 0x000000 -> false\n// f(bool): 0xffffff -> true"
},
"return_dynamic_types_cross_call_simple.sol": {
"content": "contract C {\n function dyn() public returns (bytes memory) {\n return \"1234567890123456789012345678901234567890\";\n }\n function f() public returns (bytes memory) {\n return this.dyn();\n }\n}\n// ====\n// EVMVersion: >homestead\n// ----\n// f() -> 0x20, 40, \"12345678901234567890123456789012\", \"34567890\"\n"
},
"abi_decode_trivial.sol": {
"content": "contract C {\n function f(bytes memory data) public pure returns (uint256) {\n return abi.decode(data, (uint256));\n }\n}\n// ----\n// f(bytes): 0x20, 0x20, 0x21 -> 33\n"
},
"abi_encode_empty_string.sol": {
"content": "pragma abicoder v1;\ncontract C {\n function f1() public returns (bytes memory) {\n return abi.encode(\"\");\n }\n function f2(string calldata msg) public returns (bytes memory) {\n return abi.encode(msg);\n }\n function g1() public returns (bytes memory) {\n return abi.encodePacked(\"\");\n }\n function g2(string calldata msg) public returns (bytes memory) {\n return abi.encodePacked(msg);\n }\n function h1() public returns (bytes memory) {\n return abi.encodeWithSelector(0x00000001, \"\");\n }\n function h2(string calldata msg) public returns (bytes memory) {\n return abi.encodeWithSelector(0x00000001, msg);\n }\n}\n// ====\n// ABIEncoderV1Only: true\n// compileViaYul: false\n// ----\n// f1() -> 0x20, 0x40, 0x20, 0\n// f2(string): 0x20, 0 -> 0x20, 0x40, 0x20, 0\n// f2(string): 0x20, 0, 0 -> 0x20, 0x40, 0x20, 0\n// g1() -> 32, 0\n// g2(string): 0x20, 0 -> 0x20, 0\n// g2(string): 0x20, 0, 0 -> 0x20, 0\n// h1() -> 0x20, 0x44, 26959946667150639794667015087019630673637144422540572481103610249216, 862718293348820473429344482784628181556388621521298319395315527974912, 0\n// h2(string): 0x20, 0 -> 0x20, 0x44, 26959946667150639794667015087019630673637144422540572481103610249216, 862718293348820473429344482784628181556388621521298319395315527974912, 0\n// h2(string): 0x20, 0, 0 -> 0x20, 0x44, 26959946667150639794667015087019630673637144422540572481103610249216, 862718293348820473429344482784628181556388621521298319395315527974912, 0\n"
},
"enums.sol": {
"content": "pragma abicoder v1;\ncontract C {\n enum E { A, B }\n function f(E e) public pure returns (uint x) {\n assembly { x := e }\n }\n}\n// ====\n// ABIEncoderV1Only: true\n// compileViaYul: false\n// ----\n// f(uint8): 0 -> 0\n// f(uint8): 1 -> 1\n// f(uint8): 2 -> 2\n// f(uint8): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -> 0xff\n"
},
"abi_decode_v2_storage.sol": {
"content": "pragma abicoder v2;\n\n\ncontract C {\n bytes data;\n struct S {\n uint256 a;\n uint256[] b;\n }\n\n function f() public returns (S memory) {\n S memory s;\n s.a = 8;\n s.b = new uint256[](3);\n s.b[0] = 9;\n s.b[1] = 10;\n s.b[2] = 11;\n data = abi.encode(s);\n return abi.decode(data, (S));\n }\n}\n// ----\n// f() -> 0x20, 0x8, 0x40, 0x3, 0x9, 0xa, 0xb\n// gas irOptimized: 203167\n// gas legacy: 206263\n// gas legacyOptimized: 203172\n"
},
"return_dynamic_types_cross_call_advanced.sol": {
"content": "contract C {\n\tfunction dyn() public returns (bytes memory a, uint b, bytes20[] memory c, uint d) {\n\t\ta = \"1234567890123456789012345678901234567890\";\n\t\tb = type(uint).max;\n\t\tc = new bytes20[](4);\n\t\tc[0] = bytes20(uint160(1234));\n\t\tc[3] = bytes20(uint160(6789));\n\t\td = 0x1234;\n\t}\n\tfunction f() public returns (bytes memory, uint, bytes20[] memory, uint) {\n\t\treturn this.dyn();\n\t}\n}\n// ====\n// EVMVersion: >homestead\n// ----\n// f() -> 0x80, -1, 0xe0, 0x1234, 40, \"12345678901234567890123456789012\", \"34567890\", 4, 97767552542602192590433234714624, 0, 0, 537879995309340587922569878831104\n"
},
"abi_decode_static_array_v2.sol": {
"content": "pragma abicoder v2;\n\n\ncontract C {\n function f(bytes calldata data)\n external\n pure\n returns (uint256[2][3] memory)\n {\n return abi.decode(data, (uint256[2][3]));\n }\n}\n// ----\n// f(bytes): 0x20, 0xc0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6 -> 1, 2, 3, 4, 5, 6\n"
},
"decode_slice.sol": {
"content": "contract C {\n function f(uint256 a, uint256 b) external returns (uint256 c, uint256 d, uint256 e, uint256 f) {\n (c, d) = abi.decode(msg.data[4:], (uint256, uint256));\n e = abi.decode(msg.data[4 : 4 + 32], (uint256));\n f = abi.decode(msg.data[4 + 32 : 4 + 32 + 32], (uint256));\n }\n}\n// ----\n// f(uint256,uint256): 42, 23 -> 42, 23, 42, 23\n"
},
"calldata_arrays_too_large.sol": {
"content": "contract C {\n function f(uint a, uint[] calldata b, uint c) external pure returns (uint) {\n return 7;\n }\n}\n// ----\n// f(uint256,uint256[],uint256): 6, 0x60, 9, 0x8000000000000000000000000000000000000000000000000000000000000002, 1, 2 -> FAILURE\n"
},
"abi_decode_static_array.sol": {
"content": "contract C {\n function f(bytes calldata data)\n external\n pure\n returns (uint256[2][3] memory)\n {\n return abi.decode(data, (uint256[2][3]));\n }\n}\n// ----\n// f(bytes): 0x20, 0xc0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6 -> 1, 2, 3, 4, 5, 6\n"
},
"dynamic_memory_copy.sol": {
"content": "contract C {\n function test(bytes memory buf) public view returns (bool same, bool inplaceDecoded) {\n (uint256[] memory arr1, uint256[] memory arr2) = abi.decode(buf, (uint256[],uint256[]));\n assembly {\n // Check whether arr1 and arr2 end up at the same memory location.\n // This used to be the case, if both tail pointers in buf pointed to the\n // same memory region, i.e. this used to be false in the first two, but true\n // in the last three calls below. The desired behaviour is to always get distinct\n // memory regions, i.e. this should be false.\n same := eq(arr1, arr2)\n // Check whether (given the particular tail pointer of 0x40 for arr1 in the calls below)\n // arr1 points to the part of buf containing the encoding of arr1.\n // The position of the encoding of arr1 in buf is at offset 0x20 (length) + 0x40 (tail pointer)\n // of buf.\n // This used to be the case for all the test calls below, whereas now arr1 is always copied\n // from buf to a new memory area. Should always be false.\n inplaceDecoded := eq(arr1, add(buf, 0x60))\n }\n }\n}\n// ----\n// test(bytes): 0x20, 0x80, 0x40, 0x60, 0, 0 -> false, false\n// test(bytes): 0x20, 0xC0, 0x40, 0x80, 1, 0x42, 1, 0x42 -> false, false\n// test(bytes): 0x20, 0x80, 0x40, 0x40, 1, 0x42 -> false, false\n// test(bytes): 0x20, 0x60, 0x40, 0x40, 0 -> false, false\n// test(bytes): 0x20, 0x80, 0x40, 0x40, 1, 0x42 -> false, false\n"
},
"abi_encode_call.sol": {
"content": "contract C {\n bool x;\n\n function c(uint256 a, uint256[] memory b) public {\n require(a == 5);\n require(b.length == 2);\n require(b[0] == 6);\n require(b[1] == 7);\n x = true;\n }\n\n function f() public returns (bool) {\n uint256 a = 5;\n uint256[] memory b = new uint256[](2);\n b[0] = 6;\n b[1] = 7;\n (bool success, ) = address(this).call(\n abi.encodeWithSignature(\"c(uint256,uint256[])\", a, b)\n );\n require(success);\n return x;\n }\n}\n// ----\n// f() -> true\n"
},
"abi_decode_fixed_arrays.sol": {
"content": "contract C {\n function f(uint16[3] memory a, uint16[2][3] memory b, uint i, uint j, uint k)\n public pure returns (uint, uint) {\n return (a[i], b[j][k]);\n }\n}\n// ----\n// f(uint16[3],uint16[2][3],uint256,uint256,uint256): 1, 2, 3, 11, 12, 21, 22, 31, 32, 1, 2, 1 -> 2, 32\n"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200,
"details": {
"peephole": false,
"inliner": false,
"jumpdestRemover": false,
"orderLiterals": false,
"deduplicate": false,
"cse": false,
"constantOptimizer": false
}
},
"outputSelection": {
"*": {
"*": [
"abi",
"metadata",
"evm.bytecode",
"evm.deployedBytecode",
"evm.methodIdentifiers"
]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
contract C {
function f(bytes calldata data)
external
pure
returns (uint256[2][3] memory)
{
return abi.decode(data, (uint256[2][3]));
}
}
// ----
// f(bytes): 0x20, 0xc0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6 -> 1, 2, 3, 4, 5, 6
Loading

0 comments on commit 3bf745c

Please sign in to comment.