-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabi-encode-storage-array.sol
More file actions
133 lines (107 loc) · 4.03 KB
/
abi-encode-storage-array.sol
File metadata and controls
133 lines (107 loc) · 4.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
contract C {
struct U256Pair {
uint256 left;
uint256 right;
}
uint256[] dyn256;
uint8[4] static8x4;
uint8[31] static8x31;
uint8[32] static8x32;
uint8[33] static8x33;
uint256[3] static256x3;
uint256[][] dynRefDyn256;
uint256[2][] dynRefStatic2x;
uint256[][2] staticRefDyn256x2;
U256Pair[] dynStructPair;
U256Pair[2] staticStructPair2;
constructor() {
dyn256.push(11);
dyn256.push(22);
dyn256.push(33);
static8x4[0] = 1;
static8x4[1] = 2;
static8x4[2] = 3;
static8x4[3] = 4;
for (uint256 i = 0; i < 31; ++i)
static8x31[i] = uint8(i + 1);
for (uint256 i = 0; i < 32; ++i)
static8x32[i] = uint8(i + 1);
for (uint256 i = 0; i < 33; ++i)
static8x33[i] = uint8(i + 1);
static256x3[0] = 1;
static256x3[1] = 2;
static256x3[2] = 3;
dynRefDyn256.push();
dynRefDyn256[0].push(101);
dynRefDyn256[0].push(202);
dynRefDyn256.push();
dynRefDyn256[1].push(303);
dynRefStatic2x.push();
dynRefStatic2x[0][0] = 10;
dynRefStatic2x[0][1] = 20;
dynRefStatic2x.push();
dynRefStatic2x[1][0] = 30;
dynRefStatic2x[1][1] = 40;
staticRefDyn256x2[0].push(7);
staticRefDyn256x2[0].push(8);
staticRefDyn256x2[1].push(9);
dynStructPair.push();
dynStructPair[0].left = 111;
dynStructPair[0].right = 222;
dynStructPair.push();
dynStructPair[1].left = 333;
dynStructPair[1].right = 444;
staticStructPair2[0].left = 555;
staticStructPair2[0].right = 666;
staticStructPair2[1].left = 777;
staticStructPair2[1].right = 888;
}
function ei_u256_array_dynamic_storage() public view returns (bytes memory) {
return abi.encode(dyn256);
}
function ei_u8_array_static_storage_4() public view returns (bytes memory) {
return abi.encode(static8x4);
}
function ei_u8_array_static_storage_31() public view returns (bytes memory) {
return abi.encode(static8x31);
}
function ei_u8_array_static_storage_32() public view returns (bytes memory) {
return abi.encode(static8x32);
}
function ei_u8_array_static_storage_33() public view returns (bytes memory) {
return abi.encode(static8x33);
}
function ei_u256_array_static_storage_3() public view returns (bytes memory) {
return abi.encode(static256x3);
}
function ei_u256_array_array_dynamic_storage() public view returns (bytes memory) {
return abi.encode(dynRefDyn256);
}
function ei_u256x2_array_dynamic_storage() public view returns (bytes memory) {
return abi.encode(dynRefStatic2x);
}
function ei_u256_array_static_storage_2() public view returns (bytes memory) {
return abi.encode(staticRefDyn256x2);
}
function ei_u256_pair_array_dynamic_storage() public view returns (bytes memory) {
return abi.encode(dynStructPair);
}
function ei_u256_pair_array_static_storage_2() public view returns (bytes memory) {
return abi.encode(staticStructPair2);
}
}
// ====
// compileViaMlir: true
// ----
// constructor() ->
// ei_u256_array_dynamic_storage() -> 0x20, 160, 0x20, 3, 11, 22, 33
// ei_u8_array_static_storage_4() -> 0x20, 128, 1, 2, 3, 4
// ei_u8_array_static_storage_31() -> 0x20, 992, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
// ei_u8_array_static_storage_32() -> 0x20, 1024, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32
// ei_u8_array_static_storage_33() -> 0x20, 1056, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33
// ei_u256_array_static_storage_3() -> 0x20, 96, 1, 2, 3
// ei_u256_array_array_dynamic_storage() -> 0x20, 288, 0x20, 2, 0x40, 0xa0, 2, 101, 202, 1, 303
// ei_u256x2_array_dynamic_storage() -> 0x20, 192, 0x20, 2, 10, 20, 30, 40
// ei_u256_array_static_storage_2() -> 0x20, 256, 0x20, 0x40, 0xa0, 2, 7, 8, 1, 9
// ei_u256_pair_array_dynamic_storage() -> 0x20, 192, 0x20, 2, 111, 222, 333, 444
// ei_u256_pair_array_static_storage_2() -> 0x20, 128, 555, 666, 777, 888