Compare commits
1449 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
23bee16208 | ||
|
|
d78d302f3d | ||
|
|
d8f963811d | ||
|
|
30602163d5 | ||
|
|
3273ad1a58 | ||
|
|
bc013bc42e | ||
|
|
8cfd1214b7 | ||
|
|
6ad620d642 | ||
|
|
1cf58c7b81 | ||
|
|
f74bb3a3bf | ||
|
|
a907d7e81a | ||
|
|
eb94896270 | ||
|
|
3f5b5ec3e5 | ||
|
|
594e321662 | ||
|
|
f5037185aa | ||
|
|
6160296445 | ||
|
|
b60a08d2fd | ||
|
|
c4dab8ceca | ||
|
|
106a162b7c | ||
|
|
138f0d7494 | ||
|
|
41e75480df | ||
|
|
450f5da7e1 | ||
|
|
403624a4a1 | ||
|
|
5e8fa1da70 | ||
|
|
84b327244d | ||
|
|
d9566e39bd | ||
|
|
7e9514b8c3 | ||
|
|
6b3e6cb2ab | ||
|
|
096daa9a7d | ||
|
|
10da98072c | ||
|
|
22defa5af7 | ||
|
|
c375ee91e9 | ||
|
|
d6b55749e6 | ||
|
|
997f1c4f0a | ||
|
|
b453767ccd | ||
|
|
5bc4e8f09d | ||
|
|
490c45c70f | ||
|
|
6f075bf6af | ||
|
|
2227589f9b | ||
|
|
3c6d6f7ee8 | ||
|
|
d8a2305565 | ||
|
|
f9806dc872 | ||
|
|
8c0c0434c9 | ||
|
|
03157b6efa | ||
|
|
2140aabf53 | ||
|
|
93fe17559b | ||
|
|
8845227306 | ||
|
|
a10660b7f8 | ||
|
|
86af788790 | ||
|
|
be9742721f | ||
|
|
0287e1a7c0 | ||
|
|
0559a9a61e | ||
|
|
d575a2d3bc | ||
|
|
de23cf910b | ||
|
|
b807f785c3 | ||
|
|
8798cd3a09 | ||
|
|
9244d5cd61 | ||
|
|
6cc4cc68c2 | ||
|
|
e31ff1f33c | ||
|
|
64d6c787b3 | ||
|
|
c9e324ce16 | ||
|
|
3ff479bc94 | ||
|
|
94c8de0217 | ||
|
|
ba47d800b1 | ||
|
|
8541ddbd95 | ||
|
|
af02e97929 | ||
|
|
59ac229f87 | ||
|
|
2b0d0ce8b0 | ||
|
|
d4faff965f | ||
|
|
adcad1cd39 | ||
|
|
04b6c56375 | ||
|
|
8cab5e171c | ||
|
|
7aced8114f | ||
|
|
34bda5eae3 | ||
|
|
4a4d531052 | ||
|
|
310f751639 | ||
|
|
a35a5cad22 | ||
|
|
59e0f1ee00 | ||
|
|
2bfd9a28d1 | ||
|
|
7bcbbbf836 | ||
|
|
2f4996a9b2 | ||
|
|
5c5ef6f16e | ||
|
|
975dee2593 | ||
|
|
21a3a21bf9 | ||
|
|
bf693228a3 | ||
|
|
cc9fb8e21d | ||
|
|
e6fa102eb0 | ||
|
|
57192bd0dc | ||
|
|
4b309c7006 | ||
|
|
e644d45c14 | ||
|
|
e0a9752b96 | ||
|
|
381c66caf0 | ||
|
|
29a6b6bcac | ||
|
|
39fb82bcfb | ||
|
|
fe5a26733c | ||
|
|
af806168b6 | ||
|
|
07508ac0e9 | ||
|
|
330e53fbb9 | ||
|
|
fcbc05ccb6 | ||
|
|
0a55b9731c | ||
|
|
4f80f7806e | ||
|
|
ae7d834bc7 | ||
|
|
97f308a98f | ||
|
|
440c9fcf75 | ||
|
|
e0a1fd5fdc | ||
|
|
f5ff022dbc | ||
|
|
539bbd6349 | ||
|
|
24c590cbec | ||
|
|
8a008ee0e6 | ||
|
|
646503208e | ||
|
|
52eb87d87c | ||
|
|
91751cbaa7 | ||
|
|
5b46f1d1eb | ||
|
|
7caa2d8163 | ||
|
|
86d5477079 | ||
|
|
345b1fb827 | ||
|
|
1b26991bec | ||
|
|
7175f82495 | ||
|
|
3b967d16ca | ||
|
|
1941c5e6c9 | ||
|
|
cef1a86df2 | ||
|
|
33d7a469f6 | ||
|
|
ca8e2f1ecf | ||
|
|
256aae0bfa | ||
|
|
1c90d97c1e | ||
|
|
7f6f01d46f | ||
|
|
11b56ace2a | ||
|
|
992151fa6d | ||
|
|
ecae8e4f65 | ||
|
|
0a9e384cd5 | ||
|
|
b3af0a5538 | ||
|
|
d6b77f661c | ||
|
|
d73df893a6 | ||
|
|
c164aed1d1 | ||
|
|
8d84a701a5 | ||
|
|
53304ff6c7 | ||
|
|
6b60d68344 | ||
|
|
c153bd40d7 | ||
|
|
344d6f95cf | ||
|
|
5157d4540a | ||
|
|
559a174899 | ||
|
|
f94e23ca66 | ||
|
|
84041e8f31 | ||
|
|
5a584c2133 | ||
|
|
c3a5054c27 | ||
|
|
1f5943e4f9 | ||
|
|
16701c5169 | ||
|
|
a52bcccfe1 | ||
|
|
195c2d3d69 | ||
|
|
0914234d10 | ||
|
|
7ab15490e9 | ||
|
|
63972e7548 | ||
|
|
fb801d8837 | ||
|
|
4024c1e869 | ||
|
|
7d7a96530b | ||
|
|
9e0a10004e | ||
|
|
2951b50bae | ||
|
|
a15a32a2f1 | ||
|
|
7163e6d47f | ||
|
|
a8bb49b8ea | ||
|
|
40cfe71002 | ||
|
|
637cf34ded | ||
|
|
8bf0565ebb | ||
|
|
bb5633c5ee | ||
|
|
f0328f241b | ||
|
|
9f7bcb9d76 | ||
|
|
86216189a5 | ||
|
|
ca298a2821 | ||
|
|
9c82c646e4 | ||
|
|
d4d288e3f1 | ||
|
|
eb69f490ed | ||
|
|
195c979168 | ||
|
|
c40943a167 | ||
|
|
59f0e8ae60 | ||
|
|
40b736463a | ||
|
|
6c3fea0fc9 | ||
|
|
c1b69bd121 | ||
|
|
8d066f1f42 | ||
|
|
bf5cacfb8f | ||
|
|
92e3c56e7b | ||
|
|
9fd8825d5a | ||
|
|
f6891ba40d | ||
|
|
65825cd134 | ||
|
|
111a1b73cf | ||
|
|
fb3a081c7e | ||
|
|
7e2bbb9cbb | ||
|
|
0654014652 | ||
|
|
aa123939c2 | ||
|
|
28ec26094b | ||
|
|
1e973a96b4 | ||
|
|
3fd16af5a9 | ||
|
|
da16d089c0 | ||
|
|
127dc5982e | ||
|
|
8cacb42278 | ||
|
|
9f75994b5e | ||
|
|
67c070c379 | ||
|
|
b5a129ea24 | ||
|
|
763b3f8d1f | ||
|
|
25bd17d725 | ||
|
|
33022c2e7d | ||
|
|
8ec8b81b29 | ||
|
|
25c9b49fdb | ||
|
|
de6a113f84 | ||
|
|
b502b6ac97 | ||
|
|
1027cb52c4 | ||
|
|
b06e8c4a8a | ||
|
|
b45d82e94a | ||
|
|
0fffd3acbd | ||
|
|
eb3ebceaa1 | ||
|
|
d1c243f841 | ||
|
|
19b9cf714f | ||
|
|
6a44bf6826 | ||
|
|
a8040bc2c5 | ||
|
|
535f25d65f | ||
|
|
f252154599 | ||
|
|
fd4f60f49b | ||
|
|
e0e8bf31c5 | ||
|
|
7ae6c4a790 | ||
|
|
34501ed235 | ||
|
|
6afb717be5 | ||
|
|
51de2bc9dc | ||
|
|
afe9558bba | ||
|
|
667e1c038e | ||
|
|
4f4622bc8b | ||
|
|
830231c1c4 | ||
|
|
7a80cf6543 | ||
|
|
8d99fedeae | ||
|
|
2352c72229 | ||
|
|
6b8718c374 | ||
|
|
be7eb8ae17 | ||
|
|
dbfd397262 | ||
|
|
6cd72660d0 | ||
|
|
85042b7090 | ||
|
|
a6bf2487d1 | ||
|
|
fb2ae8e995 | ||
|
|
c3701b265e | ||
|
|
70da74e73a | ||
|
|
279409a98e | ||
|
|
496f05cf52 | ||
|
|
8f66ea3786 | ||
|
|
1b58e42802 | ||
|
|
7d3ecca451 | ||
|
|
57cec89253 | ||
|
|
658415960e | ||
|
|
538a868384 | ||
|
|
8c8a9e5ca1 | ||
|
|
5079e3c6e5 | ||
|
|
65ed1a6871 | ||
|
|
d1f6a9f544 | ||
|
|
19c2c60bbe | ||
|
|
8401e4277a | ||
|
|
ec64358ac9 | ||
|
|
48605b5f61 | ||
|
|
0a4ec1dde5 | ||
|
|
870b4505a0 | ||
|
|
a79afd9ac3 | ||
|
|
4860e50e05 | ||
|
|
37f9d25ba0 | ||
|
|
8fddf27a98 | ||
|
|
f4ff4268f7 | ||
|
|
7307d97ae1 | ||
|
|
6662c78ec0 | ||
|
|
7033724522 | ||
|
|
03b7de28b2 | ||
|
|
687e4dc855 | ||
|
|
0cb4d65f8d | ||
|
|
862f8e98bc | ||
|
|
d6f49bf764 | ||
|
|
06aaeed1a6 | ||
|
|
9b93564e21 | ||
|
|
4335bbbf0a | ||
|
|
fc8ad1b70d | ||
|
|
4d086430bd | ||
|
|
2056e596f2 | ||
|
|
20356e57b1 | ||
|
|
e98114da4f | ||
|
|
f01e2fab07 | ||
|
|
55430b6ea2 | ||
|
|
6c3513c077 | ||
|
|
51e7968b8b | ||
|
|
fb3a6528cf | ||
|
|
5a0d487c3b | ||
|
|
2d20fed893 | ||
|
|
6ce4670bc0 | ||
|
|
aaca58a7a1 | ||
|
|
1a7e345af4 | ||
|
|
d99e759e76 | ||
|
|
afe344bcf3 | ||
|
|
c5436c8eb7 | ||
|
|
b868ca1790 | ||
|
|
9da25c5db7 | ||
|
|
a5c0cfb451 | ||
|
|
cac09a3823 | ||
|
|
0c1bd22ec0 | ||
|
|
64c53edf83 | ||
|
|
abd49a6c48 | ||
|
|
a9885505ca | ||
|
|
e282246a4b | ||
|
|
015fde9a2c | ||
|
|
29cb5deea3 | ||
|
|
78f13a3a57 | ||
|
|
0e35192797 | ||
|
|
f39f068161 | ||
|
|
f9ce40bb84 | ||
|
|
4230f5f08f | ||
|
|
78636ee568 | ||
|
|
bd615e0e5f | ||
|
|
683854255c | ||
|
|
06e16de894 | ||
|
|
2dfa4bcf6c | ||
|
|
eef7a33135 | ||
|
|
ae45c97d3d | ||
|
|
c029cdc90b | ||
|
|
5bcbb2980b | ||
|
|
514ae7cfa3 | ||
|
|
03aaea11d1 | ||
|
|
7dec26db2a | ||
|
|
51eb5f8ca8 | ||
|
|
4aab440ee2 | ||
|
|
f80ce141a1 | ||
|
|
b1f09596e6 | ||
|
|
045e90c897 | ||
|
|
2c58e6b62d | ||
|
|
52448e9585 | ||
|
|
c006261758 | ||
|
|
e6b61edd57 | ||
|
|
acd7b36999 | ||
|
|
b1e72f7ea9 | ||
|
|
1884f37f2c | ||
|
|
23471288c8 | ||
|
|
adc0a6adca | ||
|
|
0dec47b5c0 | ||
|
|
127ce93db4 | ||
|
|
9aa2e98191 | ||
|
|
7403a38ab7 | ||
|
|
af2ca5a654 | ||
|
|
0f893109c9 | ||
|
|
8be800ffa9 | ||
|
|
335914a63a | ||
|
|
3ccd6b6dbb | ||
|
|
c20de3c4bd | ||
|
|
0169d579d0 | ||
|
|
c0d17bca52 | ||
|
|
4bd2d0eccf | ||
|
|
66a908c5e8 | ||
|
|
d0bd5017ed | ||
|
|
98be5f9a72 | ||
|
|
062d910b26 | ||
|
|
356bbe343a | ||
|
|
dddf73abbd | ||
|
|
11a3a35097 | ||
|
|
3f2e96cf95 | ||
|
|
980b7682b4 | ||
|
|
b8edc04ce3 | ||
|
|
99be62a9b1 | ||
|
|
8bbf83e7a4 | ||
|
|
2295640ebd | ||
|
|
f5f5c0855a | ||
|
|
ada9c774e9 | ||
|
|
3e47e38a4e | ||
|
|
81ec6b1d4c | ||
|
|
bc6bf1e193 | ||
|
|
893502e561 | ||
|
|
0ba0b81e54 | ||
|
|
fc01a7ce8e | ||
|
|
155795be99 | ||
|
|
adec878c1d | ||
|
|
b3b8b268eb | ||
|
|
72c2c0ae7e | ||
|
|
ae8ff2661d | ||
|
|
db03faa10d | ||
|
|
7f7877a023 | ||
|
|
d78590560d | ||
|
|
cc87cbd70a | ||
|
|
acb0f7a67b | ||
|
|
a25906e4c0 | ||
|
|
69686fa328 | ||
|
|
a95675d50f | ||
|
|
619a3e7085 | ||
|
|
93f196c4b0 | ||
|
|
46f701ca93 | ||
|
|
cca482b4b1 | ||
|
|
58d1988349 | ||
|
|
b02fe5317f | ||
|
|
9331fe28e8 | ||
|
|
a0f7771962 | ||
|
|
5e78fc034b | ||
|
|
85064ed09b | ||
|
|
b45931cc4a | ||
|
|
8fbe0b9b68 | ||
|
|
c893488349 | ||
|
|
721c5723c0 | ||
|
|
2be129b5cf | ||
|
|
9393d1fb5d | ||
|
|
1988b47e02 | ||
|
|
163f1665dd | ||
|
|
a69d4b273d | ||
|
|
1fa91729f2 | ||
|
|
86fe359a56 | ||
|
|
c10a0a62c3 | ||
|
|
3038e480f5 | ||
|
|
519cf98b69 | ||
|
|
4ebeca19d7 | ||
|
|
1876cb443b | ||
|
|
9055cc14ec | ||
|
|
ad7c90c198 | ||
|
|
10b1cd9b1b | ||
|
|
66ee9422f5 | ||
|
|
8151dd67e1 | ||
|
|
7a0c19f813 | ||
|
|
0a7672fc9a | ||
|
|
7322b2590c | ||
|
|
743769f48e | ||
|
|
d15e423562 | ||
|
|
347c37b362 | ||
|
|
50e07a1e16 | ||
|
|
23f69c6db0 | ||
|
|
17f1c2dc0f | ||
|
|
d9c13d407f | ||
|
|
441c7f2b0f | ||
|
|
5d4bcbc14f | ||
|
|
6f2c3f2114 | ||
|
|
e0761432a4 | ||
|
|
e761255ba7 | ||
|
|
c52def7f11 | ||
|
|
ab31fbbde1 | ||
|
|
16341e0563 | ||
|
|
fa96718512 | ||
|
|
33f2813809 | ||
|
|
b7a6409cc1 | ||
|
|
05acc272b5 | ||
|
|
b0b708bf23 | ||
|
|
abc74a5ffe | ||
|
|
e9294a7fe9 | ||
|
|
5358e491f3 | ||
|
|
c57df9ca28 | ||
|
|
f32feeb260 | ||
|
|
e185a8c818 | ||
|
|
fb7da82dde | ||
|
|
0efed7f58b | ||
|
|
6b9c77f060 | ||
|
|
9489853321 | ||
|
|
ad11691daf | ||
|
|
6c4dc6c388 | ||
|
|
787a3b185c | ||
|
|
851256e856 | ||
|
|
c4fff0f56e | ||
|
|
aa2727f82c | ||
|
|
e61b8cb1f8 | ||
|
|
e1c000b0dd | ||
|
|
8be8ba450e | ||
|
|
476fb565ce | ||
|
|
8d7e6062ec | ||
|
|
3bbeb94c1c | ||
|
|
53b94f135a | ||
|
|
03bc8b7858 | ||
|
|
f49e90e32c | ||
|
|
178debe435 | ||
|
|
2e8b58f076 | ||
|
|
551bd6e721 | ||
|
|
c576fa153a | ||
|
|
c2e64db3b1 | ||
|
|
1e4becb5c1 | ||
|
|
ff844918e8 | ||
|
|
c113520d5d | ||
|
|
57c252ef4e | ||
|
|
410e731bea | ||
|
|
31870a59ff | ||
|
|
32150f8aa9 | ||
|
|
bff330335b | ||
|
|
52c02ccb1f | ||
|
|
eab4d898fd | ||
|
|
526c3f6b9e | ||
|
|
53f81574e3 | ||
|
|
c72b16c340 | ||
|
|
48dc34b8d9 | ||
|
|
0e7efd696b | ||
|
|
2954f40eac | ||
|
|
b6fb18479c | ||
|
|
3ce9f6d96f | ||
|
|
114ed3edcd | ||
|
|
7231b3efb8 | ||
|
|
da1b6f3906 | ||
|
|
f423290ac8 | ||
|
|
312e02bca9 | ||
|
|
0183256e7f | ||
|
|
84d8eb2ca8 | ||
|
|
554b1b9d5f | ||
|
|
b97f57882c | ||
|
|
60d3cc8b77 | ||
|
|
c36f8fefc3 | ||
|
|
433f0919cc | ||
|
|
b8dc1e2705 | ||
|
|
eaa24a8a15 | ||
|
|
c641cff51a | ||
|
|
464885faaa | ||
|
|
bb74230f2a | ||
|
|
f915f6873f | ||
|
|
08e782c61f | ||
|
|
011fe3eb5e | ||
|
|
79b727bc8a | ||
|
|
778ff94794 | ||
|
|
e4f570fcc6 | ||
|
|
f9d683b07f | ||
|
|
633e7ef478 | ||
|
|
3d11a22c99 | ||
|
|
6289137827 | ||
|
|
da3da7c0e7 | ||
|
|
cf8a6d6173 | ||
|
|
088bc34194 | ||
|
|
53b1420ede | ||
|
|
8b6e018401 | ||
|
|
64da037e99 | ||
|
|
8a430fbd1c | ||
|
|
bcbd700367 | ||
|
|
84bccd0900 | ||
|
|
a6a0609b05 | ||
|
|
1bea4b0dfa | ||
|
|
ee120ef865 | ||
|
|
28d30b51f8 | ||
|
|
2fe0c65f4b | ||
|
|
ec2b43c2c3 | ||
|
|
48496e0675 | ||
|
|
edb1937cf7 | ||
|
|
4e599ee469 | ||
|
|
57ff2dee06 | ||
|
|
307156cc46 | ||
|
|
0dbb3b1601 | ||
|
|
5a0e1d88f4 | ||
|
|
12f971fb2d | ||
|
|
01fdca53e1 | ||
|
|
5240725041 | ||
|
|
b522f5e091 | ||
|
|
a47b8cf6f5 | ||
|
|
07a5bc1b0b | ||
|
|
f2491c5ed7 | ||
|
|
06082fe267 | ||
|
|
eae3b1946a | ||
|
|
3a6fe69f23 | ||
|
|
42bc1944a1 | ||
|
|
a541fbea18 | ||
|
|
3531ca2246 | ||
|
|
92c5d104d0 | ||
|
|
783e97ef1f | ||
|
|
ab2caaee11 | ||
|
|
443afc975c | ||
|
|
ac7baeab57 | ||
|
|
12674d493e | ||
|
|
51ececb64e | ||
|
|
57a3fab8a7 | ||
|
|
ca9bce9a45 | ||
|
|
b61ef24cce | ||
|
|
d8211c7ec7 | ||
|
|
b1a5e4afdd | ||
|
|
5b246af54e | ||
|
|
86f3625455 | ||
|
|
9bf495bfc9 | ||
|
|
e28f713ada | ||
|
|
62e3b83af6 | ||
|
|
1b34283810 | ||
|
|
401354976b | ||
|
|
7ada89d4e6 | ||
|
|
84ff152de5 | ||
|
|
b8d7c662cd | ||
|
|
babe9b993e | ||
|
|
578bc8164d | ||
|
|
9ada4a2e2c | ||
|
|
9e17648d8c | ||
|
|
90987db733 | ||
|
|
5c1fc3bf54 | ||
|
|
51ed39c093 | ||
|
|
6ef3a16869 | ||
|
|
794c6133ef | ||
|
|
9a0df80bbc | ||
|
|
ca5bc676d1 | ||
|
|
7957530225 | ||
|
|
de2c44ab5c | ||
|
|
4d88974864 | ||
|
|
067084feda | ||
|
|
d019e90162 | ||
|
|
31be5d41d9 | ||
|
|
f85cf722ff | ||
|
|
3258211f68 | ||
|
|
ffae2043f0 | ||
|
|
62ad17fb00 | ||
|
|
108eec3fee | ||
|
|
d584e39862 | ||
|
|
7c4cad064c | ||
|
|
154b525ce8 | ||
|
|
32c576bd3c | ||
|
|
8a134014b4 | ||
|
|
887902ea4d | ||
|
|
d16214228f | ||
|
|
3784e15106 | ||
|
|
84c51bc5ec | ||
|
|
efee85378e | ||
|
|
45f34430fd | ||
|
|
83ad92c421 | ||
|
|
fe2f153b55 | ||
|
|
a5a5237178 | ||
|
|
a789dcc978 | ||
|
|
b69f5ca7d4 | ||
|
|
0db0b27754 | ||
|
|
d705f5a554 | ||
|
|
5cee33eb72 | ||
|
|
85126c4eb9 | ||
|
|
a0a4a153e9 | ||
|
|
0b40977480 | ||
|
|
5c66bab3b8 | ||
|
|
8e0771c218 | ||
|
|
8dbf261fd9 | ||
|
|
79bb9300c1 | ||
|
|
ea4bc2dbff | ||
|
|
26675454bf | ||
|
|
1d99573192 | ||
|
|
f38abc55f1 | ||
|
|
dfeb2f7e80 | ||
|
|
bb1f7ebf20 | ||
|
|
d02c605367 | ||
|
|
c368f728c1 | ||
|
|
5566e5d152 | ||
|
|
57feabea66 | ||
|
|
16ecdd5839 | ||
|
|
85b9bdd641 | ||
|
|
6902485767 | ||
|
|
fb4007bb22 | ||
|
|
0a68558e7e | ||
|
|
fd604becbb | ||
|
|
5f98020a21 | ||
|
|
a580f7d6c5 | ||
|
|
12f0ff40b1 | ||
|
|
971df49fe2 | ||
|
|
f4ad493870 | ||
|
|
2a451f9eb3 | ||
|
|
278ec7176a | ||
|
|
deff5056fb | ||
|
|
c27bd3481e | ||
|
|
0fbc94eabc | ||
|
|
9097d0a325 | ||
|
|
5d0ab07343 | ||
|
|
9d6480c3cd | ||
|
|
a879c42bd3 | ||
|
|
39fe7eca6b | ||
|
|
66948316f7 | ||
|
|
57d9e0ac75 | ||
|
|
e4b687cf46 | ||
|
|
6d175460df | ||
|
|
520f25688a | ||
|
|
3b38a83274 | ||
|
|
97bd6cd216 | ||
|
|
d60cfd2604 | ||
|
|
9e59474e46 | ||
|
|
8a24b56331 | ||
|
|
0658712f65 | ||
|
|
d3e3a460ec | ||
|
|
28ba686cbf | ||
|
|
f311488d2c | ||
|
|
c38fab912b | ||
|
|
4cd6a1458e | ||
|
|
82c5085399 | ||
|
|
95bbd46eab | ||
|
|
85afdeef37 | ||
|
|
860184d542 | ||
|
|
3526f69047 | ||
|
|
295bc35ecf | ||
|
|
8f11d279d2 | ||
|
|
b157bae2c9 | ||
|
|
64a5e125c5 | ||
|
|
fb8ea5993f | ||
|
|
5c13012b56 | ||
|
|
523866c2cc | ||
|
|
56e9001a1a | ||
|
|
0730acc5a0 | ||
|
|
2faf796d2a | ||
|
|
3aea432b35 | ||
|
|
b20bc5c0ca | ||
|
|
5c89ec9b98 | ||
|
|
bbfa6488ac | ||
|
|
a1f16bc74c | ||
|
|
576681f29b | ||
|
|
370680a7a9 | ||
|
|
97aacd9b35 | ||
|
|
f05419f0fb | ||
|
|
a5e3aa693c | ||
|
|
89fde59a80 | ||
|
|
f0b1bddac4 | ||
|
|
33ca98ece9 | ||
|
|
1fac96c1f9 | ||
|
|
b9e6e43722 | ||
|
|
c49e065fea | ||
|
|
846badc480 | ||
|
|
8fe47b0a0d | ||
|
|
58b0420a8a | ||
|
|
afd4227df8 | ||
|
|
9624f92ede | ||
|
|
dea71556cc | ||
|
|
ff4ff30a68 | ||
|
|
00b922fc5d | ||
|
|
7522642393 | ||
|
|
b9d4412715 | ||
|
|
5441a8fa47 | ||
|
|
e13d14e6a3 | ||
|
|
d21a069619 | ||
|
|
13bc9c0c6e | ||
|
|
5afc82de6e | ||
|
|
bd566977e8 | ||
|
|
99169016d2 | ||
|
|
78c34fdc3c | ||
|
|
d081c935d7 | ||
|
|
bb0191f22b | ||
|
|
c619562313 | ||
|
|
6b6d3190cf | ||
|
|
3b05318525 | ||
|
|
a182c76815 | ||
|
|
6ed812db13 | ||
|
|
3212fb6838 | ||
|
|
f5f906dd0d | ||
|
|
bbbeb7d8ba | ||
|
|
c131e812ae | ||
|
|
686b2884ee | ||
|
|
e7c8693635 | ||
|
|
ec88bd0cd0 | ||
|
|
acdf9238fb | ||
|
|
d3f018fde8 | ||
|
|
4fcc93d922 | ||
|
|
61f4b5aa89 | ||
|
|
35dbf7a8a3 | ||
|
|
1b5582acf7 | ||
|
|
dde6f1e92d | ||
|
|
2d4eff21ca | ||
|
|
bca8c03e57 | ||
|
|
c07918e7d8 | ||
|
|
0e6961366a | ||
|
|
948a600ed5 | ||
|
|
9e23610b0f | ||
|
|
29905d86ae | ||
|
|
10eb654f27 | ||
|
|
4dde0665c8 | ||
|
|
a750bf8686 | ||
|
|
bef78efb49 | ||
|
|
ddf10250c7 | ||
|
|
fcd7bdc2b7 | ||
|
|
1e44c3585f | ||
|
|
5228b2a353 | ||
|
|
e0123026b6 | ||
|
|
653a30f4ca | ||
|
|
0f2347d070 | ||
|
|
da000c8314 | ||
|
|
f915a4bf20 | ||
|
|
732a6a3666 | ||
|
|
7b6c8363da | ||
|
|
4695117f2e | ||
|
|
e9f99d1c91 | ||
|
|
ef946a6c87 | ||
|
|
58aeab77d2 | ||
|
|
97ce6dfa6d | ||
|
|
bbb2b30506 | ||
|
|
15fe3050a1 | ||
|
|
c63c2d855e | ||
|
|
87a11a87c2 | ||
|
|
aa637fd38a | ||
|
|
e1f244a6e6 | ||
|
|
40a11d644c | ||
|
|
b28f8c0c43 | ||
|
|
90ffcfde89 | ||
|
|
a675c89c75 | ||
|
|
080b6ebe91 | ||
|
|
ae315ef7a1 | ||
|
|
aa69d36152 | ||
|
|
0aadb49c86 | ||
|
|
cdb9fefc48 | ||
|
|
7a7abe3de8 | ||
|
|
087ed9c92e | ||
|
|
7530803065 | ||
|
|
8a4460c47e | ||
|
|
1d57f22d58 | ||
|
|
ccf53daee1 | ||
|
|
eff998effb | ||
|
|
a2ea537a6f | ||
|
|
1fc0eba50d | ||
|
|
be1267ced5 | ||
|
|
f68a68a313 | ||
|
|
7a00378e2b | ||
|
|
c503f98f6d | ||
|
|
f763846e6e | ||
|
|
248572ee54 | ||
|
|
ddeeb89c03 | ||
|
|
0e9c7d564d | ||
|
|
08379b5533 | ||
|
|
92b8f28df3 | ||
|
|
71ff65b188 | ||
|
|
7e915ee379 | ||
|
|
3094e7f3b8 | ||
|
|
216ed05c6e | ||
|
|
7760a60794 | ||
|
|
5cff9754d7 | ||
|
|
2dee31930c | ||
|
|
2cde472650 | ||
|
|
9aaa4208a8 | ||
|
|
08ea52e77a | ||
|
|
2d716c4b01 | ||
|
|
966ee3ae6d | ||
|
|
ee35ddc8fd | ||
|
|
04cb5e2be3 | ||
|
|
427175153c | ||
|
|
0703ef62d3 | ||
|
|
d836ad141e | ||
|
|
7194c847b6 | ||
|
|
2e7714f864 | ||
|
|
5869789d75 | ||
|
|
c73652da0b | ||
|
|
05dab7f6bd | ||
|
|
10962b685e | ||
|
|
49bde05a55 | ||
|
|
6c7d6cf886 | ||
|
|
750115ff39 | ||
|
|
51b32cc7e4 | ||
|
|
836c647bdd | ||
|
|
4d33de9b49 | ||
|
|
017cf71fbd | ||
|
|
93407b14a6 | ||
|
|
154ca32a8a | ||
|
|
0d076d92db | ||
|
|
59f259b058 | ||
|
|
6bc72783f6 | ||
|
|
835fe06f1d | ||
|
|
81662fe827 | ||
|
|
a6c462781f | ||
|
|
16bc57438b | ||
|
|
3e795881ea | ||
|
|
b3a1fda650 | ||
|
|
088da24ebf | ||
|
|
3e6f46caec | ||
|
|
32c1ed8a9c | ||
|
|
b7a91663ab | ||
|
|
bb9f9ccf4f | ||
|
|
67e7f61af7 | ||
|
|
94451c2788 | ||
|
|
14bc6e5130 | ||
|
|
597ecb39cc | ||
|
|
addd8824cf | ||
|
|
1cca781a02 | ||
|
|
a2c456a526 | ||
|
|
f34f749e81 | ||
|
|
0524cede37 | ||
|
|
ca98080798 | ||
|
|
643fd0efc6 | ||
|
|
e536bb52ff | ||
|
|
c0e201b690 | ||
|
|
ae5fcdc67f | ||
|
|
f19a679b09 | ||
|
|
7ab7acfded | ||
|
|
700df1442d | ||
|
|
17b1be2661 | ||
|
|
8a070e8f7d | ||
|
|
a5669ae292 | ||
|
|
e77ef8fa8a | ||
|
|
e69130d9f1 | ||
|
|
cc606be74c | ||
|
|
df20b3b982 | ||
|
|
37b5595456 | ||
|
|
991384a7f6 | ||
|
|
0f3a1e7f9b | ||
|
|
41671d449f | ||
|
|
3a2b29c1ed | ||
|
|
973ad66b49 | ||
|
|
d107f90d1c | ||
|
|
effaf18523 | ||
|
|
b8040a430e | ||
|
|
640d2c5e30 | ||
|
|
856c379626 | ||
|
|
fc1c1cbea9 | ||
|
|
8f94fc26e3 | ||
|
|
afb097eda8 | ||
|
|
ca9c576e62 | ||
|
|
0e00ee42ec | ||
|
|
8ff98108e5 | ||
|
|
afc1abd878 | ||
|
|
52b5d2d869 | ||
|
|
8681a2536c | ||
|
|
745757ac6b | ||
|
|
bbb57fd64b | ||
|
|
f66f1a16b3 | ||
|
|
ff75b21f25 | ||
|
|
b778e37daa | ||
|
|
dde6cb0b92 | ||
|
|
1e57ab5de6 | ||
|
|
8130dd5cef | ||
|
|
bb43cd7a79 | ||
|
|
b50b17ac69 | ||
|
|
63bad18c33 | ||
|
|
56f533d00c | ||
|
|
793c8f889f | ||
|
|
c7d07294a6 | ||
|
|
871f50b911 | ||
|
|
06f44c0fd4 | ||
|
|
64b60c7995 | ||
|
|
fae165a5de | ||
|
|
a81cf0d2b3 | ||
|
|
abb6cfae6a | ||
|
|
e4270cacf4 | ||
|
|
558bff4008 | ||
|
|
6d7c9566df | ||
|
|
9e5bb84c0e | ||
|
|
256c5d68b2 | ||
|
|
0c99868416 | ||
|
|
d9c9ee5ac9 | ||
|
|
ff3535e8e0 | ||
|
|
55043eec45 | ||
|
|
45fca44c24 | ||
|
|
caea6c4661 | ||
|
|
65a1c2d829 | ||
|
|
a0a99e610d | ||
|
|
ad983b300b | ||
|
|
85a0bab6d7 | ||
|
|
a3f0da1ac4 | ||
|
|
854f068ed6 | ||
|
|
9b99e3dfe0 | ||
|
|
83375b0873 | ||
|
|
34f3c9539b | ||
|
|
cac1b21d39 | ||
|
|
49281ab84f | ||
|
|
ea54c58d4f | ||
|
|
1fb9a6dd32 | ||
|
|
9357280fce | ||
|
|
67da83aca5 | ||
|
|
4b783c0064 | ||
|
|
3e68d627b1 | ||
|
|
96828c90f5 | ||
|
|
dd9c3225cf | ||
|
|
cc33398cef | ||
|
|
beee6b77a0 | ||
|
|
581539c6ee | ||
|
|
d7bfb978ba | ||
|
|
d6ffa14035 | ||
|
|
653b7e959d | ||
|
|
424656519a | ||
|
|
e43ac53264 | ||
|
|
f79cce5de9 | ||
|
|
09d44e9925 | ||
|
|
4f3ba6742f | ||
|
|
65689e7fce | ||
|
|
f8afb681dd | ||
|
|
fda93f643e | ||
|
|
3cfd0fe7a8 | ||
|
|
9553c98de8 | ||
|
|
1e207342b5 | ||
|
|
d8ff53dfb8 | ||
|
|
d5e57948d1 | ||
|
|
7088f1e814 | ||
|
|
a50251e6cb | ||
|
|
72e37942f3 | ||
|
|
271e5b7fc9 | ||
|
|
6c27d8f996 | ||
|
|
9c653ff662 | ||
|
|
fe1586b094 | ||
|
|
04dcc9378d | ||
|
|
97d11b0187 | ||
|
|
a665f5d2d6 | ||
|
|
e3ff37c47a | ||
|
|
264fff7dd4 | ||
|
|
2a7c4b62a9 | ||
|
|
9d10856e84 | ||
|
|
a600dab7e5 | ||
|
|
2d89fe0883 | ||
|
|
e275b1a293 | ||
|
|
95219ae62d | ||
|
|
5338ce4447 | ||
|
|
adf09aeab1 | ||
|
|
706683ea72 | ||
|
|
c79fc209cd | ||
|
|
73ed68988f | ||
|
|
55300d4fdb | ||
|
|
4a37ae510e | ||
|
|
61ff3e86b2 | ||
|
|
3faae5defc | ||
|
|
44fe466999 | ||
|
|
59ac3c9fd3 | ||
|
|
43a3768066 | ||
|
|
24588bacfd | ||
|
|
b6912c1047 | ||
|
|
7644795950 | ||
|
|
76700ac892 | ||
|
|
27056f62e5 | ||
|
|
e7f3962612 | ||
|
|
099be04100 | ||
|
|
063f78c6ba | ||
|
|
62379f02c6 | ||
|
|
cae6b5527e | ||
|
|
955727181b | ||
|
|
6477ea6502 | ||
|
|
2550e46269 | ||
|
|
efe0229768 | ||
|
|
6d7ff6acea | ||
|
|
54c0d573d7 | ||
|
|
4adf0b9187 | ||
|
|
bed74b38d9 | ||
|
|
497448bf90 | ||
|
|
0fda25e471 | ||
|
|
c5df05b9a9 | ||
|
|
ab8fd4d005 | ||
|
|
15e6c27f8b | ||
|
|
5129cdc4f0 | ||
|
|
e862cbff95 | ||
|
|
477ec75323 | ||
|
|
f304290b7d | ||
|
|
a31f6d54df | ||
|
|
8d6cc16742 | ||
|
|
0c70b83e00 | ||
|
|
aab35600bc | ||
|
|
eaccdba4ab | ||
|
|
ec73ec092d | ||
|
|
36b51b8156 | ||
|
|
5bf6612a2e | ||
|
|
9429ab1472 | ||
|
|
d3040a80d7 | ||
|
|
c454717fa6 | ||
|
|
5bc0343ed3 | ||
|
|
e3a3f7cd64 | ||
|
|
d50e9d24be | ||
|
|
345890a558 | ||
|
|
a90861ae0c | ||
|
|
38ea7f2cf4 | ||
|
|
aa8b2189c6 | ||
|
|
6a528fce33 | ||
|
|
117fa7d4a1 | ||
|
|
410089afea | ||
|
|
91726e8aad | ||
|
|
6d9707a458 | ||
|
|
62d8022b51 | ||
|
|
94ab4ea341 | ||
|
|
7cbf1d70a7 | ||
|
|
7076e8e42f | ||
|
|
99830720f6 | ||
|
|
bc47993692 | ||
|
|
faacc8e0fa | ||
|
|
c6d45009f1 | ||
|
|
3f74c8e0e5 | ||
|
|
6387c520b7 | ||
|
|
aae7660410 | ||
|
|
22082f9e56 | ||
|
|
3d299b7468 | ||
|
|
be87f769f6 | ||
|
|
182670849e | ||
|
|
c2d2f4ed8f | ||
|
|
5aba946164 | ||
|
|
72b8cacf13 | ||
|
|
44c0bb2b44 | ||
|
|
658cb9fc4f | ||
|
|
dab90e4d42 | ||
|
|
5b95453ef2 | ||
|
|
89026d5d70 | ||
|
|
de61da99c4 | ||
|
|
9230ca4924 | ||
|
|
63385374ec | ||
|
|
56dec25ae2 | ||
|
|
cd316d7c71 | ||
|
|
5a81dd97d5 | ||
|
|
b24804d88c | ||
|
|
ba999105ef | ||
|
|
07e907c7d4 | ||
|
|
c539a052bd | ||
|
|
0540d3c6f6 | ||
|
|
430f69e01e | ||
|
|
7834e4a278 | ||
|
|
19d7a37abb | ||
|
|
d96870428f | ||
|
|
498458b410 | ||
|
|
3822b09904 | ||
|
|
744707a490 | ||
|
|
27b31371d4 | ||
|
|
0928562670 | ||
|
|
dc109cce26 | ||
|
|
de9465f991 | ||
|
|
bbfb1e4008 | ||
|
|
7a3c890009 | ||
|
|
378e961d85 | ||
|
|
96d9306413 | ||
|
|
b2b5c82aca | ||
|
|
8e547eecd5 | ||
|
|
f54dc4ab3d | ||
|
|
bf5b379b13 | ||
|
|
70afe15f68 | ||
|
|
b502c86662 | ||
|
|
c9aa267049 | ||
|
|
cdb6a84339 | ||
|
|
4ee8d2d305 | ||
|
|
2743fb0429 | ||
|
|
2d1a0e9b03 | ||
|
|
142fbcfd6f | ||
|
|
c4a2b682ff | ||
|
|
3ecfdccd9a | ||
|
|
8f03e3b107 | ||
|
|
8647233a8e | ||
|
|
c5023e1dc5 | ||
|
|
ca76db6116 | ||
|
|
c027507e03 | ||
|
|
d36276d85e | ||
|
|
6ec1561044 | ||
|
|
b1835b3855 | ||
|
|
9ec32a9e7b | ||
|
|
52e5c38aa5 | ||
|
|
e01096f531 | ||
|
|
1489c3f494 | ||
|
|
f9445e93bb | ||
|
|
bfdff4c5b8 | ||
|
|
6291fc9230 | ||
|
|
9ec3329899 | ||
|
|
915c614959 | ||
|
|
f4fcd4f506 | ||
|
|
e991bdae24 | ||
|
|
77787802fe | ||
|
|
08c878acd2 | ||
|
|
7d1b711c7d | ||
|
|
2fc465a7be | ||
|
|
ef227c5f42 | ||
|
|
111abdcfbd | ||
|
|
1bbc8a1944 | ||
|
|
409b16e5ab | ||
|
|
cb3c7e4319 | ||
|
|
27786671d2 | ||
|
|
2fdba3aacb | ||
|
|
74dbc20260 | ||
|
|
944d901436 | ||
|
|
2728672c28 | ||
|
|
123e934e72 | ||
|
|
f566dd305e | ||
|
|
d86906f1e6 | ||
|
|
bbe694fc52 | ||
|
|
477fd420b3 | ||
|
|
994cdc69c8 | ||
|
|
e74bd587f7 | ||
|
|
7ed860d4f1 | ||
|
|
fba5a63afe | ||
|
|
098a2b6e26 | ||
|
|
28121324ac | ||
|
|
54735a6723 | ||
|
|
3512b41c5c | ||
|
|
83e4c49e2b | ||
|
|
ef84da8481 | ||
|
|
4eae0c6b6f | ||
|
|
e3430ac7df | ||
|
|
3c728fb129 | ||
|
|
f25b437b70 | ||
|
|
7a800f98f6 | ||
|
|
eb21c652c0 | ||
|
|
2e5d141708 | ||
|
|
a72fa88a0d | ||
|
|
9c5729311e | ||
|
|
ad038b6289 | ||
|
|
681618275c | ||
|
|
14d495491d | ||
|
|
573f373d2b | ||
|
|
7202b410b0 | ||
|
|
d2779ed7ac | ||
|
|
adf130def8 | ||
|
|
49cdcf5c70 | ||
|
|
04a72260c5 | ||
|
|
59a79137b9 | ||
|
|
c0862f4f4c | ||
|
|
1770fe718a | ||
|
|
797b0812ab | ||
|
|
3708454f58 | ||
|
|
db35d77b63 | ||
|
|
f26c19cbcd | ||
|
|
9e1bd0f367 | ||
|
|
231040c633 | ||
|
|
c4307a9339 | ||
|
|
ddadc3d273 | ||
|
|
42f9f1f073 | ||
|
|
1e1865b73f | ||
|
|
81bf9f97c9 | ||
|
|
7da8f75d5b | ||
|
|
d1301eb0df | ||
|
|
45cb1a580a | ||
|
|
24c1e3053b | ||
|
|
5e9f5ca5d3 | ||
|
|
10555d4684 | ||
|
|
398182284c | ||
|
|
034ecc3210 | ||
|
|
c76573a97b | ||
|
|
8d62ee65b2 | ||
|
|
3944976a9a | ||
|
|
c4deebbf1e | ||
|
|
d13c59fef0 | ||
|
|
12969084d1 | ||
|
|
96157a897b | ||
|
|
2aaff0ad76 | ||
|
|
6296211a3e | ||
|
|
c94081774f | ||
|
|
c7a6be163f | ||
|
|
93a89b2681 | ||
|
|
23f837c388 | ||
|
|
984e752ce5 | ||
|
|
39b3b8ffb4 | ||
|
|
49c2816d54 | ||
|
|
79e2174e4d | ||
|
|
ab5e3f400f | ||
|
|
5a1b384352 | ||
|
|
89030ec0b4 | ||
|
|
889f5645b5 | ||
|
|
6b88ab75bc | ||
|
|
165f53fc6e | ||
|
|
d3952898c3 | ||
|
|
3c6665e7d6 | ||
|
|
4bb5c6ca7a | ||
|
|
38310f9022 | ||
|
|
58b9db5f7c | ||
|
|
44208d9258 | ||
|
|
8bd8e1b24a | ||
|
|
d2e1b17f18 | ||
|
|
072fd96254 | ||
|
|
d667ee2d10 | ||
|
|
83d317cff9 | ||
|
|
618454214b | ||
|
|
9ba306d47e | ||
|
|
4714ce9430 | ||
|
|
eb2a1dfdd2 | ||
|
|
664903dc88 | ||
|
|
9584f56b9d | ||
|
|
6ada9f0f38 | ||
|
|
e4571d8c12 | ||
|
|
1951e20d10 | ||
|
|
5c2a7ce2cc | ||
|
|
47820ef726 | ||
|
|
f83fc302a5 | ||
|
|
167ff563d1 | ||
|
|
0a3993c558 | ||
|
|
a425a47ddc | ||
|
|
c17a7733df | ||
|
|
653e8b9dd9 | ||
|
|
ab0979f930 | ||
|
|
0a09a39325 | ||
|
|
2f8100615a | ||
|
|
b13e9c4e3d | ||
|
|
9c6b5b904a | ||
|
|
25c0bd9b43 | ||
|
|
b9012a039b | ||
|
|
158f72cc0c | ||
|
|
61469cfeaf | ||
|
|
c5a3ffa363 | ||
|
|
3c46f5570b | ||
|
|
c7f2536735 | ||
|
|
8cde2966af | ||
|
|
0fe66f8ae4 | ||
|
|
4859929798 | ||
|
|
017831dd5b | ||
|
|
00d10e610f | ||
|
|
38c1d592b7 | ||
|
|
4d48980e74 | ||
|
|
c49aae9870 | ||
|
|
efe6dd2904 | ||
|
|
88c696240d | ||
|
|
b47f4ca5cf | ||
|
|
62dc59c2bd | ||
|
|
1a715d7db5 | ||
|
|
fc0662bb23 | ||
|
|
e787272901 | ||
|
|
1d1f5fea4a | ||
|
|
004541098d | ||
|
|
b44f24e3e6 | ||
|
|
9f6bb492bb | ||
|
|
817a3fb562 | ||
|
|
f935b1d542 | ||
|
|
915643a3e5 | ||
|
|
40b6ccf383 | ||
|
|
bd848aad7c | ||
|
|
ed0670cb17 | ||
|
|
6a4e730003 | ||
|
|
581c028d18 | ||
|
|
15339cf1c9 | ||
|
|
7770e41cb5 | ||
|
|
62cedb3aab | ||
|
|
d7a64dc02b | ||
|
|
0b2f1446bb | ||
|
|
e9e86aeacb | ||
|
|
908c18073a | ||
|
|
a2795c8055 | ||
|
|
e7db1dbc96 | ||
|
|
a1ddd9e1d3 | ||
|
|
aba0c234c2 | ||
|
|
566cb4c5f0 | ||
|
|
b71334ac3d | ||
|
|
fa572cd297 | ||
|
|
429e7141f2 | ||
|
|
810f9e057d | ||
|
|
f59ed3565d | ||
|
|
c92faee66e | ||
|
|
29efe1fc7e | ||
|
|
59b480ab4b | ||
|
|
7e7a3f0f71 | ||
|
|
bddd103a9f | ||
|
|
6b58409614 | ||
|
|
ead814616c | ||
|
|
6104ab6b6d | ||
|
|
f6e1aed504 | ||
|
|
bddf5aaa2f | ||
|
|
3ef52775c4 | ||
|
|
ebb9591c4d | ||
|
|
6f88d6530a | ||
|
|
f1e1d9f874 | ||
|
|
28080463d2 | ||
|
|
b9ff57c59e | ||
|
|
23524f8900 | ||
|
|
6b9858085f | ||
|
|
db87223269 | ||
|
|
d513584e52 | ||
|
|
844485ec6a | ||
|
|
1ea7537997 | ||
|
|
92c56eb820 | ||
|
|
cf856ea1ad | ||
|
|
2045a2bba3 | ||
|
|
6f4cccf8d2 | ||
|
|
0703c91fba | ||
|
|
9ded4e33c5 | ||
|
|
a19b4235c7 | ||
|
|
919229d63c | ||
|
|
cc05b050df | ||
|
|
920a287117 | ||
|
|
d49407427d | ||
|
|
d990df909d | ||
|
|
27d93c1848 | ||
|
|
70868b1e4a | ||
|
|
941d8b5c5c | ||
|
|
c52dfd55fb | ||
|
|
0c34eae172 | ||
|
|
7c30f4d085 | ||
|
|
040928d8bb | ||
|
|
9e688fb64c | ||
|
|
1143dc6e29 | ||
|
|
eb694ea706 | ||
|
|
81678971db | ||
|
|
7b7b327ff2 | ||
|
|
81ff700077 | ||
|
|
97fc1c3b1d | ||
|
|
6cfe494276 | ||
|
|
175506e7fd | ||
|
|
36bb7ac083 | ||
|
|
5d20fbbb6f | ||
|
|
e6402677c2 | ||
|
|
3eebf34038 | ||
|
|
b63bffe820 | ||
|
|
b63e3c37a6 | ||
|
|
43c278cdf9 | ||
|
|
18145adf08 | ||
|
|
296a27d106 | ||
|
|
1a55e20d35 | ||
|
|
7b748e550a | ||
|
|
68ac4eb796 | ||
|
|
8a94aa91fb | ||
|
|
f5182c7b9c | ||
|
|
95f720fffc | ||
|
|
6487c002f6 | ||
|
|
fb2c79df19 | ||
|
|
91c4607979 | ||
|
|
85d81b2cdd | ||
|
|
3e82c9ef67 | ||
|
|
9d25f34263 | ||
|
|
6e7137103c | ||
|
|
cef3e2dc5a | ||
|
|
b305591e14 | ||
|
|
51d026ca85 | ||
|
|
8c2f271528 | ||
|
|
524aaf5ec6 | ||
|
|
4eb01b21c8 | ||
|
|
bdc7554918 | ||
|
|
1fed223483 | ||
|
|
1e10489196 | ||
|
|
2a9ea6be87 | ||
|
|
7a5a822905 | ||
|
|
5c6155f9f4 | ||
|
|
348c3bc47d | ||
|
|
94d1f5888a | ||
|
|
c37e68e7c1 | ||
|
|
32341f88e3 | ||
|
|
66c3eb2f1a | ||
|
|
86dd005544 | ||
|
|
706f5e3b98 | ||
|
|
19a1c95046 | ||
|
|
905ed109ed | ||
|
|
43cd31ea9f | ||
|
|
5e86e4ed29 | ||
|
|
6d29e192e9 | ||
|
|
015e78928a | ||
|
|
716864deba | ||
|
|
e43d827a19 | ||
|
|
eb87121300 | ||
|
|
2b2fd74158 | ||
|
|
d9890a6a8f | ||
|
|
a15d71a255 | ||
|
|
9d1e2027a0 | ||
|
|
053ed9cc84 | ||
|
|
dad26582b6 | ||
|
|
6c8310ebb4 | ||
|
|
4ee11b072e | ||
|
|
901471f733 | ||
|
|
666092936c | ||
|
|
b007df89dd | ||
|
|
a04294d160 | ||
|
|
eebfb13053 | ||
|
|
0ddd4612b7 | ||
|
|
a90e645ccd | ||
|
|
420b78659b | ||
|
|
c9959145a9 | ||
|
|
c71a7e26a8 | ||
|
|
7ddb44b80e | ||
|
|
b5d362b2bf | ||
|
|
fdd42d425b | ||
|
|
39f8268147 | ||
|
|
a25899f3dc | ||
|
|
c1544423d6 | ||
|
|
e5defccd58 | ||
|
|
0921f8a74f | ||
|
|
25b16085da | ||
|
|
e1365b2464 | ||
|
|
fdb742419e | ||
|
|
129cf075e9 | ||
|
|
2c097bb7a2 | ||
|
|
9a39c6bcb1 | ||
|
|
f354c622ca | ||
|
|
2482ba016e | ||
|
|
fb835c024c | ||
|
|
07751c3d26 | ||
|
|
faba018b29 | ||
|
|
89884dc353 | ||
|
|
93f047023f | ||
|
|
8696dd39cb | ||
|
|
cf2a77af28 | ||
|
|
0185ee0993 | ||
|
|
4764b2f0be | ||
|
|
b65c384181 | ||
|
|
4996fce25a | ||
|
|
f7112cc182 | ||
|
|
71c37d82ad | ||
|
|
4eb9296910 | ||
|
|
a99ac5335c | ||
|
|
4e2641319b | ||
|
|
df219e23df | ||
|
|
7cf56d6f06 | ||
|
|
d7f02b448a | ||
|
|
1167639524 | ||
|
|
4ea9737de6 | ||
|
|
a3cd8a040a | ||
|
|
328901c24c | ||
|
|
3a98c6f6e6 | ||
|
|
d81c9d9b76 | ||
|
|
367f12f734 | ||
|
|
8d35b1eb2b | ||
|
|
493100ba4d |
6
.github/CODEOWNERS
vendored
6
.github/CODEOWNERS
vendored
@@ -9,11 +9,13 @@ cmd/puppeth @karalabe
|
|||||||
consensus @karalabe
|
consensus @karalabe
|
||||||
core/ @karalabe @holiman @rjl493456442
|
core/ @karalabe @holiman @rjl493456442
|
||||||
eth/ @karalabe @holiman @rjl493456442
|
eth/ @karalabe @holiman @rjl493456442
|
||||||
graphql/ @gballet
|
eth/catalyst/ @gballet
|
||||||
|
eth/tracers/ @s1na
|
||||||
|
graphql/ @gballet @s1na
|
||||||
les/ @zsfelfoldi @rjl493456442
|
les/ @zsfelfoldi @rjl493456442
|
||||||
light/ @zsfelfoldi @rjl493456442
|
light/ @zsfelfoldi @rjl493456442
|
||||||
mobile/ @karalabe @ligi
|
mobile/ @karalabe @ligi
|
||||||
node/ @fjl @renaynay
|
node/ @fjl
|
||||||
p2p/ @fjl @zsfelfoldi
|
p2p/ @fjl @zsfelfoldi
|
||||||
rpc/ @fjl @holiman
|
rpc/ @fjl @holiman
|
||||||
p2p/simulations @fjl
|
p2p/simulations @fjl
|
||||||
|
|||||||
4
.github/CONTRIBUTING.md
vendored
4
.github/CONTRIBUTING.md
vendored
@@ -30,11 +30,11 @@ Please make sure your contributions adhere to our coding guidelines:
|
|||||||
Before you submit a feature request, please check and make sure that it isn't
|
Before you submit a feature request, please check and make sure that it isn't
|
||||||
possible through some other means. The JavaScript-enabled console is a powerful
|
possible through some other means. The JavaScript-enabled console is a powerful
|
||||||
feature in the right hands. Please check our
|
feature in the right hands. Please check our
|
||||||
[Wiki page](https://github.com/ethereum/go-ethereum/wiki) for more info
|
[Geth documentation page](https://geth.ethereum.org/docs/) for more info
|
||||||
and help.
|
and help.
|
||||||
|
|
||||||
## Configuration, dependencies, and tests
|
## Configuration, dependencies, and tests
|
||||||
|
|
||||||
Please see the [Developers' Guide](https://github.com/ethereum/go-ethereum/wiki/Developers'-Guide)
|
Please see the [Developers' Guide](https://geth.ethereum.org/docs/developers/devguide)
|
||||||
for more details on configuring your environment, managing project dependencies
|
for more details on configuring your environment, managing project dependencies
|
||||||
and testing procedures.
|
and testing procedures.
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
Hi there,
|
---
|
||||||
|
name: Report a bug
|
||||||
Please note that this is an issue tracker reserved for bug reports and feature requests.
|
about: Something with go-ethereum is not working as expected
|
||||||
|
title: ''
|
||||||
For general questions please use [discord](https://discord.gg/nthXNEv) or the Ethereum stack exchange at https://ethereum.stackexchange.com.
|
labels: 'type:bug'
|
||||||
|
assignees: ''
|
||||||
|
---
|
||||||
|
|
||||||
#### System information
|
#### System information
|
||||||
|
|
||||||
@@ -24,3 +26,5 @@ Commit hash : (if `develop`)
|
|||||||
````
|
````
|
||||||
[backtrace]
|
[backtrace]
|
||||||
````
|
````
|
||||||
|
|
||||||
|
When submitting logs: please submit them as text and not screenshots.
|
||||||
17
.github/ISSUE_TEMPLATE/feature.md
vendored
Normal file
17
.github/ISSUE_TEMPLATE/feature.md
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
name: Request a feature
|
||||||
|
about: Report a missing feature - e.g. as a step before submitting a PR
|
||||||
|
title: ''
|
||||||
|
labels: 'type:feature'
|
||||||
|
assignees: ''
|
||||||
|
---
|
||||||
|
|
||||||
|
# Rationale
|
||||||
|
|
||||||
|
Why should this feature exist?
|
||||||
|
What are the use-cases?
|
||||||
|
|
||||||
|
# Implementation
|
||||||
|
|
||||||
|
Do you have ideas regarding the implementation of this feature?
|
||||||
|
Are you willing to implement this feature?
|
||||||
9
.github/ISSUE_TEMPLATE/question.md
vendored
Normal file
9
.github/ISSUE_TEMPLATE/question.md
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
name: Ask a question
|
||||||
|
about: Something is unclear
|
||||||
|
title: ''
|
||||||
|
labels: 'type:docs'
|
||||||
|
assignees: ''
|
||||||
|
---
|
||||||
|
|
||||||
|
This should only be used in very rare cases e.g. if you are not 100% sure if something is a bug or asking a question that leads to improving the documentation. For general questions please use [discord](https://discord.gg/nthXNEv) or the Ethereum stack exchange at https://ethereum.stackexchange.com.
|
||||||
5
.gitmodules
vendored
5
.gitmodules
vendored
@@ -1,3 +1,8 @@
|
|||||||
[submodule "tests"]
|
[submodule "tests"]
|
||||||
path = tests/testdata
|
path = tests/testdata
|
||||||
url = https://github.com/ethereum/tests
|
url = https://github.com/ethereum/tests
|
||||||
|
shallow = true
|
||||||
|
[submodule "evm-benchmarks"]
|
||||||
|
path = tests/evm-benchmarks
|
||||||
|
url = https://github.com/ipsilon/evm-benchmarks
|
||||||
|
shallow = true
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# This file configures github.com/golangci/golangci-lint.
|
# This file configures github.com/golangci/golangci-lint.
|
||||||
|
|
||||||
run:
|
run:
|
||||||
timeout: 3m
|
timeout: 20m
|
||||||
tests: true
|
tests: true
|
||||||
# default is true. Enables skipping of directories:
|
# default is true. Enables skipping of directories:
|
||||||
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
|
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
|
||||||
@@ -19,10 +19,24 @@ linters:
|
|||||||
- govet
|
- govet
|
||||||
- ineffassign
|
- ineffassign
|
||||||
- misspell
|
- misspell
|
||||||
# - staticcheck
|
|
||||||
- unconvert
|
- unconvert
|
||||||
# - unused
|
|
||||||
- varcheck
|
- varcheck
|
||||||
|
- typecheck
|
||||||
|
- unused
|
||||||
|
- staticcheck
|
||||||
|
- bidichk
|
||||||
|
- durationcheck
|
||||||
|
- exportloopref
|
||||||
|
- gosec
|
||||||
|
|
||||||
|
#- structcheck # lots of false positives
|
||||||
|
#- errcheck #lot of false positives
|
||||||
|
# - contextcheck
|
||||||
|
# - errchkjson # lots of false positives
|
||||||
|
# - errorlint # this check crashes
|
||||||
|
# - exhaustive # silly check
|
||||||
|
# - makezero # false positives
|
||||||
|
# - nilerr # several intentional
|
||||||
|
|
||||||
linters-settings:
|
linters-settings:
|
||||||
gofmt:
|
gofmt:
|
||||||
@@ -30,21 +44,28 @@ linters-settings:
|
|||||||
goconst:
|
goconst:
|
||||||
min-len: 3 # minimum length of string constant
|
min-len: 3 # minimum length of string constant
|
||||||
min-occurrences: 6 # minimum number of occurrences
|
min-occurrences: 6 # minimum number of occurrences
|
||||||
|
gosec:
|
||||||
|
excludes:
|
||||||
|
- G404 # Use of weak random number generator - lots of FP
|
||||||
|
- G107 # Potential http request -- those are intentional
|
||||||
|
- G306 # G306: Expect WriteFile permissions to be 0600 or less
|
||||||
|
|
||||||
issues:
|
issues:
|
||||||
exclude-rules:
|
exclude-rules:
|
||||||
- path: crypto/blake2b/
|
- path: crypto/bn256/cloudflare/optate.go
|
||||||
linters:
|
|
||||||
- deadcode
|
|
||||||
- path: crypto/bn256/cloudflare
|
|
||||||
linters:
|
|
||||||
- deadcode
|
|
||||||
- path: p2p/discv5/
|
|
||||||
linters:
|
|
||||||
- deadcode
|
|
||||||
- path: core/vm/instructions_test.go
|
|
||||||
linters:
|
|
||||||
- goconst
|
|
||||||
- path: cmd/faucet/
|
|
||||||
linters:
|
linters:
|
||||||
- deadcode
|
- deadcode
|
||||||
|
- staticcheck
|
||||||
|
- path: internal/build/pgp.go
|
||||||
|
text: 'SA1019: package golang.org/x/crypto/openpgp is deprecated'
|
||||||
|
- path: core/vm/contracts.go
|
||||||
|
text: 'SA1019: package golang.org/x/crypto/ripemd160 is deprecated'
|
||||||
|
- path: accounts/usbwallet/trezor.go
|
||||||
|
text: 'SA1019: package github.com/golang/protobuf/proto is deprecated'
|
||||||
|
- path: accounts/usbwallet/trezor/
|
||||||
|
text: 'SA1019: package github.com/golang/protobuf/proto is deprecated'
|
||||||
|
exclude:
|
||||||
|
- 'SA1019: event.TypeMux is deprecated: use Feed'
|
||||||
|
- 'SA1019: strings.Title is deprecated'
|
||||||
|
- 'SA1029: should not use built-in type string as key for value'
|
||||||
|
- 'G306: Expect WriteFile permissions to be 0600 or less'
|
||||||
294
.mailmap
294
.mailmap
@@ -1,123 +1,237 @@
|
|||||||
Jeffrey Wilcke <jeffrey@ethereum.org>
|
Aaron Buchwald <aaron.buchwald56@gmail.com>
|
||||||
Jeffrey Wilcke <jeffrey@ethereum.org> <geffobscura@gmail.com>
|
|
||||||
Jeffrey Wilcke <jeffrey@ethereum.org> <obscuren@obscura.com>
|
|
||||||
Jeffrey Wilcke <jeffrey@ethereum.org> <obscuren@users.noreply.github.com>
|
|
||||||
|
|
||||||
Viktor Trón <viktor.tron@gmail.com>
|
Aaron Kumavis <kumavis@users.noreply.github.com>
|
||||||
|
|
||||||
Joseph Goulden <joegoulden@gmail.com>
|
Abel Nieto <abel.nieto90@gmail.com>
|
||||||
|
Abel Nieto <abel.nieto90@gmail.com> <anietoro@uwaterloo.ca>
|
||||||
|
|
||||||
Nick Savers <nicksavers@gmail.com>
|
Afri Schoedon <58883403+q9f@users.noreply.github.com>
|
||||||
|
Afri Schoedon <5chdn@users.noreply.github.com> <58883403+q9f@users.noreply.github.com>
|
||||||
|
|
||||||
Maran Hidskes <maran.hidskes@gmail.com>
|
Alec Perseghin <aperseghin@gmail.com>
|
||||||
|
|
||||||
Taylor Gerring <taylor.gerring@gmail.com>
|
Aleksey Smyrnov <i@soar.name>
|
||||||
Taylor Gerring <taylor.gerring@gmail.com> <taylor.gerring@ethereum.org>
|
|
||||||
|
Alex Leverington <alex@ethdev.com>
|
||||||
|
Alex Leverington <alex@ethdev.com> <subtly@users.noreply.github.com>
|
||||||
|
|
||||||
|
Alex Pozhilenkov <alex_pozhilenkov@adoriasoft.com>
|
||||||
|
Alex Pozhilenkov <alex_pozhilenkov@adoriasoft.com> <leshiy12345678@gmail.com>
|
||||||
|
|
||||||
|
Alexey Akhunov <akhounov@gmail.com>
|
||||||
|
|
||||||
|
Alon Muroch <alonmuroch@gmail.com>
|
||||||
|
|
||||||
|
Andrey Petrov <shazow@gmail.com>
|
||||||
|
Andrey Petrov <shazow@gmail.com> <andrey.petrov@shazow.net>
|
||||||
|
|
||||||
|
Arkadiy Paronyan <arkadiy@ethdev.com>
|
||||||
|
|
||||||
|
Armin Braun <me@obrown.io>
|
||||||
|
|
||||||
|
Aron Fischer <github@aron.guru> <homotopycolimit@users.noreply.github.com>
|
||||||
|
|
||||||
|
Austin Roberts <code@ausiv.com>
|
||||||
|
Austin Roberts <code@ausiv.com> <git@ausiv.com>
|
||||||
|
|
||||||
Bas van Kervel <bas@ethdev.com>
|
Bas van Kervel <bas@ethdev.com>
|
||||||
Bas van Kervel <bas@ethdev.com> <basvankervel@ziggo.nl>
|
Bas van Kervel <bas@ethdev.com> <basvankervel@ziggo.nl>
|
||||||
Bas van Kervel <bas@ethdev.com> <basvankervel@gmail.com>
|
Bas van Kervel <bas@ethdev.com> <basvankervel@gmail.com>
|
||||||
Bas van Kervel <bas@ethdev.com> <bas-vk@users.noreply.github.com>
|
Bas van Kervel <bas@ethdev.com> <bas-vk@users.noreply.github.com>
|
||||||
|
|
||||||
Sven Ehlert <sven@ethdev.com>
|
Boqin Qin <bobbqqin@bupt.edu.cn>
|
||||||
|
Boqin Qin <bobbqqin@bupt.edu.cn> <Bobbqqin@gmail.com>
|
||||||
Vitalik Buterin <v@buterin.com>
|
|
||||||
|
|
||||||
Marian Oancea <contact@siteshop.ro>
|
|
||||||
|
|
||||||
Christoph Jentzsch <jentzsch.software@gmail.com>
|
|
||||||
|
|
||||||
Heiko Hees <heiko@heiko.org>
|
|
||||||
|
|
||||||
Alex Leverington <alex@ethdev.com>
|
|
||||||
Alex Leverington <alex@ethdev.com> <subtly@users.noreply.github.com>
|
|
||||||
|
|
||||||
Zsolt Felföldi <zsfelfoldi@gmail.com>
|
|
||||||
|
|
||||||
Gavin Wood <i@gavwood.com>
|
|
||||||
|
|
||||||
Martin Becze <mjbecze@gmail.com>
|
|
||||||
Martin Becze <mjbecze@gmail.com> <wanderer@users.noreply.github.com>
|
|
||||||
|
|
||||||
Dimitry Khokhlov <winsvega@mail.ru>
|
|
||||||
|
|
||||||
Roman Mandeleil <roman.mandeleil@gmail.com>
|
|
||||||
|
|
||||||
Alec Perseghin <aperseghin@gmail.com>
|
|
||||||
|
|
||||||
Alon Muroch <alonmuroch@gmail.com>
|
|
||||||
|
|
||||||
Arkadiy Paronyan <arkadiy@ethdev.com>
|
|
||||||
|
|
||||||
Jae Kwon <jkwon.work@gmail.com>
|
|
||||||
|
|
||||||
Aaron Kumavis <kumavis@users.noreply.github.com>
|
|
||||||
|
|
||||||
Nick Dodson <silentcicero@outlook.com>
|
|
||||||
|
|
||||||
Jason Carver <jacarver@linkedin.com>
|
|
||||||
Jason Carver <jacarver@linkedin.com> <ut96caarrs@snkmail.com>
|
|
||||||
|
|
||||||
Joseph Chow <ethereum@outlook.com>
|
|
||||||
Joseph Chow <ethereum@outlook.com> ethers <TODO>
|
|
||||||
|
|
||||||
Enrique Fynn <enriquefynn@gmail.com>
|
|
||||||
|
|
||||||
Vincent G <caktux@gmail.com>
|
|
||||||
|
|
||||||
RJ Catalano <catalanor0220@gmail.com>
|
|
||||||
RJ Catalano <catalanor0220@gmail.com> <rj@erisindustries.com>
|
|
||||||
|
|
||||||
Nchinda Nchinda <nchinda2@gmail.com>
|
|
||||||
|
|
||||||
Aron Fischer <github@aron.guru> <homotopycolimit@users.noreply.github.com>
|
|
||||||
|
|
||||||
Vlad Gluhovsky <gluk256@users.noreply.github.com>
|
|
||||||
|
|
||||||
Ville Sundell <github@solarius.fi>
|
|
||||||
|
|
||||||
Elliot Shepherd <elliot@identitii.com>
|
|
||||||
|
|
||||||
Yohann Léon <sybiload@gmail.com>
|
|
||||||
|
|
||||||
Gregg Dourgarian <greggd@tempworks.com>
|
|
||||||
|
|
||||||
Casey Detrio <cdetrio@gmail.com>
|
Casey Detrio <cdetrio@gmail.com>
|
||||||
|
|
||||||
Jens Agerberg <github@agerberg.me>
|
Cheng Li <lob4tt@gmail.com>
|
||||||
|
|
||||||
Nick Johnson <arachnid@notdot.net>
|
Chris Ziogas <ziogaschr@gmail.com>
|
||||||
|
Chris Ziogas <ziogaschr@gmail.com> <ziogas_chr@hotmail.com>
|
||||||
|
|
||||||
Henning Diedrich <hd@eonblast.com>
|
Christoph Jentzsch <jentzsch.software@gmail.com>
|
||||||
Henning Diedrich <hd@eonblast.com> Drake Burroughs <wildfyre@hotmail.com>
|
|
||||||
|
Diederik Loerakker <proto@protolambda.com>
|
||||||
|
|
||||||
|
Dimitry Khokhlov <winsvega@mail.ru>
|
||||||
|
|
||||||
|
Domino Valdano <dominoplural@gmail.com>
|
||||||
|
Domino Valdano <dominoplural@gmail.com> <jeff@okcupid.com>
|
||||||
|
|
||||||
|
Edgar Aroutiounian <edgar.factorial@gmail.com>
|
||||||
|
|
||||||
|
Elliot Shepherd <elliot@identitii.com>
|
||||||
|
|
||||||
|
Enrique Fynn <enriquefynn@gmail.com>
|
||||||
|
|
||||||
|
Enrique Fynn <me@enriquefynn.com>
|
||||||
|
Enrique Fynn <me@enriquefynn.com> <enriquefynn@gmail.com>
|
||||||
|
|
||||||
|
Ernesto del Toro <ernesto.deltoro@gmail.com>
|
||||||
|
Ernesto del Toro <ernesto.deltoro@gmail.com> <ernestodeltoro@users.noreply.github.com>
|
||||||
|
|
||||||
|
Everton Fraga <ev@ethereum.org>
|
||||||
|
|
||||||
Felix Lange <fjl@twurst.com>
|
Felix Lange <fjl@twurst.com>
|
||||||
Felix Lange <fjl@twurst.com> <fjl@users.noreply.github.com>
|
Felix Lange <fjl@twurst.com> <fjl@users.noreply.github.com>
|
||||||
|
|
||||||
Максим Чусовлянов <mchusovlianov@gmail.com>
|
|
||||||
|
|
||||||
Louis Holbrook <dev@holbrook.no>
|
|
||||||
Louis Holbrook <dev@holbrook.no> <nolash@users.noreply.github.com>
|
|
||||||
|
|
||||||
Thomas Bocek <tom@tomp2p.net>
|
|
||||||
|
|
||||||
Victor Tran <vu.tran54@gmail.com>
|
|
||||||
|
|
||||||
Justin Drake <drakefjustin@gmail.com>
|
|
||||||
|
|
||||||
Frank Wang <eternnoir@gmail.com>
|
Frank Wang <eternnoir@gmail.com>
|
||||||
|
|
||||||
Gary Rong <garyrong0905@gmail.com>
|
Gary Rong <garyrong0905@gmail.com>
|
||||||
|
|
||||||
|
Gavin Wood <i@gavwood.com>
|
||||||
|
|
||||||
|
Gregg Dourgarian <greggd@tempworks.com>
|
||||||
|
|
||||||
|
Guillaume Ballet <gballet@gmail.com>
|
||||||
|
Guillaume Ballet <gballet@gmail.com> <3272758+gballet@users.noreply.github.com>
|
||||||
|
|
||||||
Guillaume Nicolas <guin56@gmail.com>
|
Guillaume Nicolas <guin56@gmail.com>
|
||||||
|
|
||||||
|
Hanjiang Yu <delacroix.yu@gmail.com>
|
||||||
|
Hanjiang Yu <delacroix.yu@gmail.com> <42531996+de1acr0ix@users.noreply.github.com>
|
||||||
|
|
||||||
|
Heiko Hees <heiko@heiko.org>
|
||||||
|
|
||||||
|
Henning Diedrich <hd@eonblast.com>
|
||||||
|
Henning Diedrich <hd@eonblast.com> Drake Burroughs <wildfyre@hotmail.com>
|
||||||
|
|
||||||
|
Hwanjo Heo <34005989+hwanjo@users.noreply.github.com>
|
||||||
|
|
||||||
|
Iskander (Alex) Sharipov <quasilyte@gmail.com>
|
||||||
|
Iskander (Alex) Sharipov <quasilyte@gmail.com> <i.sharipov@corp.vk.com>
|
||||||
|
|
||||||
|
Jae Kwon <jkwon.work@gmail.com>
|
||||||
|
|
||||||
|
Janoš Guljaš <janos@resenje.org> <janos@users.noreply.github.com>
|
||||||
|
Janoš Guljaš <janos@resenje.org> Janos Guljas <janos@resenje.org>
|
||||||
|
|
||||||
|
Jared Wasinger <j-wasinger@hotmail.com>
|
||||||
|
|
||||||
|
Jason Carver <jacarver@linkedin.com>
|
||||||
|
Jason Carver <jacarver@linkedin.com> <ut96caarrs@snkmail.com>
|
||||||
|
|
||||||
|
Javier Peletier <jm@epiclabs.io>
|
||||||
|
Javier Peletier <jm@epiclabs.io> <jpeletier@users.noreply.github.com>
|
||||||
|
|
||||||
|
Jeffrey Wilcke <jeffrey@ethereum.org>
|
||||||
|
Jeffrey Wilcke <jeffrey@ethereum.org> <geffobscura@gmail.com>
|
||||||
|
Jeffrey Wilcke <jeffrey@ethereum.org> <obscuren@obscura.com>
|
||||||
|
Jeffrey Wilcke <jeffrey@ethereum.org> <obscuren@users.noreply.github.com>
|
||||||
|
|
||||||
|
Jens Agerberg <github@agerberg.me>
|
||||||
|
|
||||||
|
Joseph Chow <ethereum@outlook.com>
|
||||||
|
Joseph Chow <ethereum@outlook.com> ethers <TODO>
|
||||||
|
|
||||||
|
|
||||||
|
Joseph Goulden <joegoulden@gmail.com>
|
||||||
|
|
||||||
|
Justin Drake <drakefjustin@gmail.com>
|
||||||
|
|
||||||
|
Kenso Trabing <ktrabing@acm.org>
|
||||||
|
Kenso Trabing <ktrabing@acm.org> <kenso.trabing@bloomwebsite.com>
|
||||||
|
|
||||||
|
Liang Ma <liangma@liangbit.com>
|
||||||
|
Liang Ma <liangma@liangbit.com> <liangma.ul@gmail.com>
|
||||||
|
|
||||||
|
Louis Holbrook <dev@holbrook.no>
|
||||||
|
Louis Holbrook <dev@holbrook.no> <nolash@users.noreply.github.com>
|
||||||
|
|
||||||
|
Maran Hidskes <maran.hidskes@gmail.com>
|
||||||
|
|
||||||
|
Marian Oancea <contact@siteshop.ro>
|
||||||
|
|
||||||
|
Martin Becze <mjbecze@gmail.com>
|
||||||
|
Martin Becze <mjbecze@gmail.com> <wanderer@users.noreply.github.com>
|
||||||
|
|
||||||
|
Martin Lundfall <martin.lundfall@protonmail.com>
|
||||||
|
|
||||||
|
Matt Garnett <14004106+lightclient@users.noreply.github.com>
|
||||||
|
|
||||||
|
Matthew Halpern <matthalp@gmail.com>
|
||||||
|
Matthew Halpern <matthalp@gmail.com> <matthalp@google.com>
|
||||||
|
|
||||||
|
Michael Riabzev <michael@starkware.co>
|
||||||
|
|
||||||
|
Nchinda Nchinda <nchinda2@gmail.com>
|
||||||
|
|
||||||
|
Nick Dodson <silentcicero@outlook.com>
|
||||||
|
|
||||||
|
Nick Johnson <arachnid@notdot.net>
|
||||||
|
|
||||||
|
Nick Savers <nicksavers@gmail.com>
|
||||||
|
|
||||||
|
Nishant Das <nishdas93@gmail.com>
|
||||||
|
Nishant Das <nishdas93@gmail.com> <nish1993@hotmail.com>
|
||||||
|
|
||||||
|
Olivier Hervieu <olivier.hervieu@gmail.com>
|
||||||
|
|
||||||
|
Pascal Dierich <pascal@merkleplant.xyz>
|
||||||
|
Pascal Dierich <pascal@merkleplant.xyz> <pascal@pascaldierich.com>
|
||||||
|
|
||||||
|
RJ Catalano <catalanor0220@gmail.com>
|
||||||
|
RJ Catalano <catalanor0220@gmail.com> <rj@erisindustries.com>
|
||||||
|
|
||||||
|
Ralph Caraveo <deckarep@gmail.com>
|
||||||
|
|
||||||
|
Rene Lubov <41963722+renaynay@users.noreply.github.com>
|
||||||
|
|
||||||
|
Robert Zaremba <robert@zaremba.ch>
|
||||||
|
Robert Zaremba <robert@zaremba.ch> <robert.zaremba@scale-it.pl>
|
||||||
|
|
||||||
|
Roman Mandeleil <roman.mandeleil@gmail.com>
|
||||||
|
|
||||||
Sorin Neacsu <sorin.neacsu@gmail.com>
|
Sorin Neacsu <sorin.neacsu@gmail.com>
|
||||||
Sorin Neacsu <sorin.neacsu@gmail.com> <sorin@users.noreply.github.com>
|
Sorin Neacsu <sorin.neacsu@gmail.com> <sorin@users.noreply.github.com>
|
||||||
|
|
||||||
|
Sven Ehlert <sven@ethdev.com>
|
||||||
|
|
||||||
|
Taylor Gerring <taylor.gerring@gmail.com>
|
||||||
|
Taylor Gerring <taylor.gerring@gmail.com> <taylor.gerring@ethereum.org>
|
||||||
|
|
||||||
|
Thomas Bocek <tom@tomp2p.net>
|
||||||
|
|
||||||
|
Tim Cooijmans <timcooijmans@gmail.com>
|
||||||
|
|
||||||
Valentin Wüstholz <wuestholz@gmail.com>
|
Valentin Wüstholz <wuestholz@gmail.com>
|
||||||
Valentin Wüstholz <wuestholz@gmail.com> <wuestholz@users.noreply.github.com>
|
Valentin Wüstholz <wuestholz@gmail.com> <wuestholz@users.noreply.github.com>
|
||||||
|
|
||||||
Armin Braun <me@obrown.io>
|
Victor Tran <vu.tran54@gmail.com>
|
||||||
|
|
||||||
Ernesto del Toro <ernesto.deltoro@gmail.com>
|
Viktor Trón <viktor.tron@gmail.com>
|
||||||
Ernesto del Toro <ernesto.deltoro@gmail.com> <ernestodeltoro@users.noreply.github.com>
|
|
||||||
|
Ville Sundell <github@solarius.fi>
|
||||||
|
|
||||||
|
Vincent G <caktux@gmail.com>
|
||||||
|
|
||||||
|
Vitalik Buterin <v@buterin.com>
|
||||||
|
|
||||||
|
Vlad Gluhovsky <gluk256@gmail.com>
|
||||||
|
Vlad Gluhovsky <gluk256@gmail.com> <gluk256@users.noreply.github.com>
|
||||||
|
|
||||||
|
Wenshao Zhong <wzhong20@uic.edu>
|
||||||
|
Wenshao Zhong <wzhong20@uic.edu> <11510383@mail.sustc.edu.cn>
|
||||||
|
Wenshao Zhong <wzhong20@uic.edu> <374662347@qq.com>
|
||||||
|
|
||||||
|
Will Villanueva <hello@willvillanueva.com>
|
||||||
|
|
||||||
|
Xiaobing Jiang <s7v7nislands@gmail.com>
|
||||||
|
|
||||||
|
Xudong Liu <33193253+r1cs@users.noreply.github.com>
|
||||||
|
|
||||||
|
Yohann Léon <sybiload@gmail.com>
|
||||||
|
|
||||||
|
Zachinquarantine <Zachinquarantine@protonmail.com>
|
||||||
|
Zachinquarantine <Zachinquarantine@protonmail.com> <zachinquarantine@yahoo.com>
|
||||||
|
|
||||||
|
Ziyuan Zhong <zzy.albert@163.com>
|
||||||
|
|
||||||
|
Zsolt Felföldi <zsfelfoldi@gmail.com>
|
||||||
|
|
||||||
|
meowsbits <b5c6@protonmail.com>
|
||||||
|
meowsbits <b5c6@protonmail.com> <45600330+meowsbits@users.noreply.github.com>
|
||||||
|
|
||||||
|
nedifi <103940716+nedifi@users.noreply.github.com>
|
||||||
|
|
||||||
|
Максим Чусовлянов <mchusovlianov@gmail.com>
|
||||||
|
|||||||
233
.travis.yml
233
.travis.yml
@@ -5,7 +5,7 @@ jobs:
|
|||||||
allow_failures:
|
allow_failures:
|
||||||
- stage: build
|
- stage: build
|
||||||
os: osx
|
os: osx
|
||||||
go: 1.14.x
|
go: 1.17.x
|
||||||
env:
|
env:
|
||||||
- azure-osx
|
- azure-osx
|
||||||
- azure-ios
|
- azure-ios
|
||||||
@@ -15,8 +15,8 @@ jobs:
|
|||||||
# This builder only tests code linters on latest version of Go
|
# This builder only tests code linters on latest version of Go
|
||||||
- stage: lint
|
- stage: lint
|
||||||
os: linux
|
os: linux
|
||||||
dist: xenial
|
dist: bionic
|
||||||
go: 1.15.x
|
go: 1.18.x
|
||||||
env:
|
env:
|
||||||
- lint
|
- lint
|
||||||
git:
|
git:
|
||||||
@@ -24,75 +24,48 @@ jobs:
|
|||||||
script:
|
script:
|
||||||
- go run build/ci.go lint
|
- go run build/ci.go lint
|
||||||
|
|
||||||
|
# These builders create the Docker sub-images for multi-arch push and each
|
||||||
|
# will attempt to push the multi-arch image if they are the last builder
|
||||||
- stage: build
|
- stage: build
|
||||||
os: linux
|
if: type = push
|
||||||
dist: xenial
|
|
||||||
go: 1.13.x
|
|
||||||
env:
|
|
||||||
- GO111MODULE=on
|
|
||||||
script:
|
|
||||||
- go run build/ci.go install
|
|
||||||
- go run build/ci.go test -coverage $TEST_PACKAGES
|
|
||||||
|
|
||||||
- stage: build
|
|
||||||
os: linux
|
|
||||||
dist: xenial
|
|
||||||
go: 1.14.x
|
|
||||||
env:
|
|
||||||
- GO111MODULE=on
|
|
||||||
script:
|
|
||||||
- go run build/ci.go install
|
|
||||||
- go run build/ci.go test -coverage $TEST_PACKAGES
|
|
||||||
|
|
||||||
# These are the latest Go versions.
|
|
||||||
- stage: build
|
|
||||||
os: linux
|
os: linux
|
||||||
arch: amd64
|
arch: amd64
|
||||||
dist: xenial
|
dist: bionic
|
||||||
go: 1.15.x
|
go: 1.18.x
|
||||||
env:
|
env:
|
||||||
- GO111MODULE=on
|
- docker
|
||||||
|
services:
|
||||||
|
- docker
|
||||||
|
git:
|
||||||
|
submodules: false # avoid cloning ethereum/tests
|
||||||
|
before_install:
|
||||||
|
- export DOCKER_CLI_EXPERIMENTAL=enabled
|
||||||
script:
|
script:
|
||||||
- go run build/ci.go install
|
- go run build/ci.go docker -image -manifest amd64,arm64 -upload ethereum/client-go
|
||||||
- go run build/ci.go test -coverage $TEST_PACKAGES
|
|
||||||
|
|
||||||
- stage: build
|
- stage: build
|
||||||
if: type = pull_request
|
if: type = push
|
||||||
os: linux
|
os: linux
|
||||||
arch: arm64
|
arch: arm64
|
||||||
dist: xenial
|
dist: bionic
|
||||||
go: 1.15.x
|
go: 1.18.x
|
||||||
env:
|
env:
|
||||||
- GO111MODULE=on
|
- docker
|
||||||
|
services:
|
||||||
|
- docker
|
||||||
|
git:
|
||||||
|
submodules: false # avoid cloning ethereum/tests
|
||||||
|
before_install:
|
||||||
|
- export DOCKER_CLI_EXPERIMENTAL=enabled
|
||||||
script:
|
script:
|
||||||
- go run build/ci.go install
|
- go run build/ci.go docker -image -manifest amd64,arm64 -upload ethereum/client-go
|
||||||
- go run build/ci.go test -coverage $TEST_PACKAGES
|
|
||||||
|
|
||||||
- stage: build
|
|
||||||
os: osx
|
|
||||||
osx_image: xcode11.3
|
|
||||||
go: 1.15.x
|
|
||||||
env:
|
|
||||||
- GO111MODULE=on
|
|
||||||
script:
|
|
||||||
- echo "Increase the maximum number of open file descriptors on macOS"
|
|
||||||
- NOFILE=20480
|
|
||||||
- sudo sysctl -w kern.maxfiles=$NOFILE
|
|
||||||
- sudo sysctl -w kern.maxfilesperproc=$NOFILE
|
|
||||||
- sudo launchctl limit maxfiles $NOFILE $NOFILE
|
|
||||||
- sudo launchctl limit maxfiles
|
|
||||||
- ulimit -S -n $NOFILE
|
|
||||||
- ulimit -n
|
|
||||||
- unset -f cd # workaround for https://github.com/travis-ci/travis-ci/issues/8703
|
|
||||||
- go run build/ci.go install
|
|
||||||
- go run build/ci.go test -coverage $TEST_PACKAGES
|
|
||||||
|
|
||||||
# This builder does the Ubuntu PPA upload
|
# This builder does the Ubuntu PPA upload
|
||||||
- stage: build
|
- stage: build
|
||||||
if: type = push
|
if: type = push
|
||||||
os: linux
|
os: linux
|
||||||
dist: xenial
|
dist: bionic
|
||||||
go: 1.15.x
|
go: 1.18.x
|
||||||
env:
|
env:
|
||||||
- ubuntu-ppa
|
- ubuntu-ppa
|
||||||
- GO111MODULE=on
|
- GO111MODULE=on
|
||||||
@@ -109,15 +82,15 @@ jobs:
|
|||||||
- python-paramiko
|
- python-paramiko
|
||||||
script:
|
script:
|
||||||
- echo '|1|7SiYPr9xl3uctzovOTj4gMwAC1M=|t6ReES75Bo/PxlOPJ6/GsGbTrM0= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0aKz5UTUndYgIGG7dQBV+HaeuEZJ2xPHo2DS2iSKvUL4xNMSAY4UguNW+pX56nAQmZKIZZ8MaEvSj6zMEDiq6HFfn5JcTlM80UwlnyKe8B8p7Nk06PPQLrnmQt5fh0HmEcZx+JU9TZsfCHPnX7MNz4ELfZE6cFsclClrKim3BHUIGq//t93DllB+h4O9LHjEUsQ1Sr63irDLSutkLJD6RXchjROXkNirlcNVHH/jwLWR5RcYilNX7S5bIkK8NlWPjsn/8Ua5O7I9/YoE97PpO6i73DTGLh5H9JN/SITwCKBkgSDWUt61uPK3Y11Gty7o2lWsBjhBUm2Y38CBsoGmBw==' >> ~/.ssh/known_hosts
|
- echo '|1|7SiYPr9xl3uctzovOTj4gMwAC1M=|t6ReES75Bo/PxlOPJ6/GsGbTrM0= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0aKz5UTUndYgIGG7dQBV+HaeuEZJ2xPHo2DS2iSKvUL4xNMSAY4UguNW+pX56nAQmZKIZZ8MaEvSj6zMEDiq6HFfn5JcTlM80UwlnyKe8B8p7Nk06PPQLrnmQt5fh0HmEcZx+JU9TZsfCHPnX7MNz4ELfZE6cFsclClrKim3BHUIGq//t93DllB+h4O9LHjEUsQ1Sr63irDLSutkLJD6RXchjROXkNirlcNVHH/jwLWR5RcYilNX7S5bIkK8NlWPjsn/8Ua5O7I9/YoE97PpO6i73DTGLh5H9JN/SITwCKBkgSDWUt61uPK3Y11Gty7o2lWsBjhBUm2Y38CBsoGmBw==' >> ~/.ssh/known_hosts
|
||||||
- go run build/ci.go debsrc -goversion 1.15 -upload ethereum/ethereum -sftp-user geth-ci -signer "Go Ethereum Linux Builder <geth-ci@ethereum.org>"
|
- go run build/ci.go debsrc -upload ethereum/ethereum -sftp-user geth-ci -signer "Go Ethereum Linux Builder <geth-ci@ethereum.org>"
|
||||||
|
|
||||||
# This builder does the Linux Azure uploads
|
# This builder does the Linux Azure uploads
|
||||||
- stage: build
|
- stage: build
|
||||||
if: type = push
|
if: type = push
|
||||||
os: linux
|
os: linux
|
||||||
dist: xenial
|
dist: bionic
|
||||||
sudo: required
|
sudo: required
|
||||||
go: 1.15.x
|
go: 1.18.x
|
||||||
env:
|
env:
|
||||||
- azure-linux
|
- azure-linux
|
||||||
- GO111MODULE=on
|
- GO111MODULE=on
|
||||||
@@ -129,72 +102,33 @@ jobs:
|
|||||||
- gcc-multilib
|
- gcc-multilib
|
||||||
script:
|
script:
|
||||||
# Build for the primary platforms that Trusty can manage
|
# Build for the primary platforms that Trusty can manage
|
||||||
- go run build/ci.go install
|
- go run build/ci.go install -dlgo
|
||||||
- go run build/ci.go archive -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
|
- go run build/ci.go archive -type tar -signer LINUX_SIGNING_KEY -signify SIGNIFY_KEY -upload gethstore/builds
|
||||||
- go run build/ci.go install -arch 386
|
- go run build/ci.go install -dlgo -arch 386
|
||||||
- go run build/ci.go archive -arch 386 -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
|
- go run build/ci.go archive -arch 386 -type tar -signer LINUX_SIGNING_KEY -signify SIGNIFY_KEY -upload gethstore/builds
|
||||||
|
|
||||||
# Switch over GCC to cross compilation (breaks 386, hence why do it here only)
|
# Switch over GCC to cross compilation (breaks 386, hence why do it here only)
|
||||||
- sudo -E apt-get -yq --no-install-suggests --no-install-recommends --force-yes install gcc-arm-linux-gnueabi libc6-dev-armel-cross gcc-arm-linux-gnueabihf libc6-dev-armhf-cross gcc-aarch64-linux-gnu libc6-dev-arm64-cross
|
- sudo -E apt-get -yq --no-install-suggests --no-install-recommends --force-yes install gcc-arm-linux-gnueabi libc6-dev-armel-cross gcc-arm-linux-gnueabihf libc6-dev-armhf-cross gcc-aarch64-linux-gnu libc6-dev-arm64-cross
|
||||||
- sudo ln -s /usr/include/asm-generic /usr/include/asm
|
- sudo ln -s /usr/include/asm-generic /usr/include/asm
|
||||||
|
|
||||||
- GOARM=5 go run build/ci.go install -arch arm -cc arm-linux-gnueabi-gcc
|
- GOARM=5 go run build/ci.go install -dlgo -arch arm -cc arm-linux-gnueabi-gcc
|
||||||
- GOARM=5 go run build/ci.go archive -arch arm -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
|
- GOARM=5 go run build/ci.go archive -arch arm -type tar -signer LINUX_SIGNING_KEY -signify SIGNIFY_KEY -upload gethstore/builds
|
||||||
- GOARM=6 go run build/ci.go install -arch arm -cc arm-linux-gnueabi-gcc
|
- GOARM=6 go run build/ci.go install -dlgo -arch arm -cc arm-linux-gnueabi-gcc
|
||||||
- GOARM=6 go run build/ci.go archive -arch arm -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
|
- GOARM=6 go run build/ci.go archive -arch arm -type tar -signer LINUX_SIGNING_KEY -signify SIGNIFY_KEY -upload gethstore/builds
|
||||||
- GOARM=7 go run build/ci.go install -arch arm -cc arm-linux-gnueabihf-gcc
|
- GOARM=7 go run build/ci.go install -dlgo -arch arm -cc arm-linux-gnueabihf-gcc
|
||||||
- GOARM=7 go run build/ci.go archive -arch arm -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
|
- GOARM=7 go run build/ci.go archive -arch arm -type tar -signer LINUX_SIGNING_KEY -signify SIGNIFY_KEY -upload gethstore/builds
|
||||||
- go run build/ci.go install -arch arm64 -cc aarch64-linux-gnu-gcc
|
- go run build/ci.go install -dlgo -arch arm64 -cc aarch64-linux-gnu-gcc
|
||||||
- go run build/ci.go archive -arch arm64 -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
|
- go run build/ci.go archive -arch arm64 -type tar -signer LINUX_SIGNING_KEY -signify SIGNIFY_KEY -upload gethstore/builds
|
||||||
|
|
||||||
# This builder does the Linux Azure MIPS xgo uploads
|
|
||||||
- stage: build
|
|
||||||
if: type = push
|
|
||||||
os: linux
|
|
||||||
dist: xenial
|
|
||||||
services:
|
|
||||||
- docker
|
|
||||||
go: 1.15.x
|
|
||||||
env:
|
|
||||||
- azure-linux-mips
|
|
||||||
- GO111MODULE=on
|
|
||||||
git:
|
|
||||||
submodules: false # avoid cloning ethereum/tests
|
|
||||||
script:
|
|
||||||
- go run build/ci.go xgo --alltools -- --targets=linux/mips --ldflags '-extldflags "-static"' -v
|
|
||||||
- for bin in build/bin/*-linux-mips; do mv -f "${bin}" "${bin/-linux-mips/}"; done
|
|
||||||
- go run build/ci.go archive -arch mips -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
|
|
||||||
|
|
||||||
- go run build/ci.go xgo --alltools -- --targets=linux/mipsle --ldflags '-extldflags "-static"' -v
|
|
||||||
- for bin in build/bin/*-linux-mipsle; do mv -f "${bin}" "${bin/-linux-mipsle/}"; done
|
|
||||||
- go run build/ci.go archive -arch mipsle -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
|
|
||||||
|
|
||||||
- go run build/ci.go xgo --alltools -- --targets=linux/mips64 --ldflags '-extldflags "-static"' -v
|
|
||||||
- for bin in build/bin/*-linux-mips64; do mv -f "${bin}" "${bin/-linux-mips64/}"; done
|
|
||||||
- go run build/ci.go archive -arch mips64 -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
|
|
||||||
|
|
||||||
- go run build/ci.go xgo --alltools -- --targets=linux/mips64le --ldflags '-extldflags "-static"' -v
|
|
||||||
- for bin in build/bin/*-linux-mips64le; do mv -f "${bin}" "${bin/-linux-mips64le/}"; done
|
|
||||||
- go run build/ci.go archive -arch mips64le -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
|
|
||||||
|
|
||||||
# This builder does the Android Maven and Azure uploads
|
# This builder does the Android Maven and Azure uploads
|
||||||
- stage: build
|
- stage: build
|
||||||
if: type = push
|
if: type = push
|
||||||
os: linux
|
os: linux
|
||||||
dist: xenial
|
dist: bionic
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
packages:
|
packages:
|
||||||
- oracle-java8-installer
|
- openjdk-8-jdk
|
||||||
- oracle-java8-set-default
|
|
||||||
language: android
|
|
||||||
android:
|
|
||||||
components:
|
|
||||||
- platform-tools
|
|
||||||
- tools
|
|
||||||
- android-15
|
|
||||||
- android-19
|
|
||||||
- android-24
|
|
||||||
env:
|
env:
|
||||||
- azure-android
|
- azure-android
|
||||||
- maven-android
|
- maven-android
|
||||||
@@ -202,25 +136,33 @@ jobs:
|
|||||||
git:
|
git:
|
||||||
submodules: false # avoid cloning ethereum/tests
|
submodules: false # avoid cloning ethereum/tests
|
||||||
before_install:
|
before_install:
|
||||||
- curl https://dl.google.com/go/go1.15.linux-amd64.tar.gz | tar -xz
|
# Install Android and it's dependencies manually, Travis is stale
|
||||||
|
- export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
|
||||||
|
- curl https://dl.google.com/android/repository/commandlinetools-linux-6858069_latest.zip -o android.zip
|
||||||
|
- unzip -q android.zip -d $HOME/sdk && rm android.zip
|
||||||
|
- mv $HOME/sdk/cmdline-tools $HOME/sdk/latest && mkdir $HOME/sdk/cmdline-tools && mv $HOME/sdk/latest $HOME/sdk/cmdline-tools
|
||||||
|
- export PATH=$PATH:$HOME/sdk/cmdline-tools/latest/bin
|
||||||
|
- export ANDROID_HOME=$HOME/sdk
|
||||||
|
|
||||||
|
- yes | sdkmanager --licenses >/dev/null
|
||||||
|
- sdkmanager "platform-tools" "platforms;android-15" "platforms;android-19" "platforms;android-24" "ndk-bundle"
|
||||||
|
|
||||||
|
# Install Go to allow building with
|
||||||
|
- curl https://dl.google.com/go/go1.18.linux-amd64.tar.gz | tar -xz
|
||||||
- export PATH=`pwd`/go/bin:$PATH
|
- export PATH=`pwd`/go/bin:$PATH
|
||||||
- export GOROOT=`pwd`/go
|
- export GOROOT=`pwd`/go
|
||||||
- export GOPATH=$HOME/go
|
- export GOPATH=$HOME/go
|
||||||
script:
|
script:
|
||||||
# Build the Android archive and upload it to Maven Central and Azure
|
# Build the Android archive and upload it to Maven Central and Azure
|
||||||
- curl https://dl.google.com/android/repository/android-ndk-r19b-linux-x86_64.zip -o android-ndk-r19b.zip
|
|
||||||
- unzip -q android-ndk-r19b.zip && rm android-ndk-r19b.zip
|
|
||||||
- mv android-ndk-r19b $ANDROID_HOME/ndk-bundle
|
|
||||||
|
|
||||||
- mkdir -p $GOPATH/src/github.com/ethereum
|
- mkdir -p $GOPATH/src/github.com/ethereum
|
||||||
- ln -s `pwd` $GOPATH/src/github.com/ethereum/go-ethereum
|
- ln -s `pwd` $GOPATH/src/github.com/ethereum/go-ethereum
|
||||||
- go run build/ci.go aar -signer ANDROID_SIGNING_KEY -deploy https://oss.sonatype.org -upload gethstore/builds
|
- go run build/ci.go aar -signer ANDROID_SIGNING_KEY -signify SIGNIFY_KEY -deploy https://oss.sonatype.org -upload gethstore/builds
|
||||||
|
|
||||||
# This builder does the OSX Azure, iOS CocoaPods and iOS Azure uploads
|
# This builder does the OSX Azure, iOS CocoaPods and iOS Azure uploads
|
||||||
- stage: build
|
- stage: build
|
||||||
if: type = push
|
if: type = push
|
||||||
os: osx
|
os: osx
|
||||||
go: 1.15.x
|
go: 1.18.x
|
||||||
env:
|
env:
|
||||||
- azure-osx
|
- azure-osx
|
||||||
- azure-ios
|
- azure-ios
|
||||||
@@ -229,8 +171,8 @@ jobs:
|
|||||||
git:
|
git:
|
||||||
submodules: false # avoid cloning ethereum/tests
|
submodules: false # avoid cloning ethereum/tests
|
||||||
script:
|
script:
|
||||||
- go run build/ci.go install
|
- go run build/ci.go install -dlgo
|
||||||
- go run build/ci.go archive -type tar -signer OSX_SIGNING_KEY -upload gethstore/builds
|
- go run build/ci.go archive -type tar -signer OSX_SIGNING_KEY -signify SIGNIFY_KEY -upload gethstore/builds
|
||||||
|
|
||||||
# Build the iOS framework and upload it to CocoaPods and Azure
|
# Build the iOS framework and upload it to CocoaPods and Azure
|
||||||
- gem uninstall cocoapods -a -x
|
- gem uninstall cocoapods -a -x
|
||||||
@@ -245,14 +187,45 @@ jobs:
|
|||||||
|
|
||||||
# Workaround for https://github.com/golang/go/issues/23749
|
# Workaround for https://github.com/golang/go/issues/23749
|
||||||
- export CGO_CFLAGS_ALLOW='-fmodules|-fblocks|-fobjc-arc'
|
- export CGO_CFLAGS_ALLOW='-fmodules|-fblocks|-fobjc-arc'
|
||||||
- go run build/ci.go xcode -signer IOS_SIGNING_KEY -deploy trunk -upload gethstore/builds
|
- go run build/ci.go xcode -signer IOS_SIGNING_KEY -signify SIGNIFY_KEY -deploy trunk -upload gethstore/builds
|
||||||
|
|
||||||
|
# These builders run the tests
|
||||||
|
- stage: build
|
||||||
|
os: linux
|
||||||
|
arch: amd64
|
||||||
|
dist: bionic
|
||||||
|
go: 1.18.x
|
||||||
|
env:
|
||||||
|
- GO111MODULE=on
|
||||||
|
script:
|
||||||
|
- go run build/ci.go test -coverage $TEST_PACKAGES
|
||||||
|
|
||||||
|
- stage: build
|
||||||
|
if: type = pull_request
|
||||||
|
os: linux
|
||||||
|
arch: arm64
|
||||||
|
dist: bionic
|
||||||
|
go: 1.18.x
|
||||||
|
env:
|
||||||
|
- GO111MODULE=on
|
||||||
|
script:
|
||||||
|
- go run build/ci.go test -coverage $TEST_PACKAGES
|
||||||
|
|
||||||
|
- stage: build
|
||||||
|
os: linux
|
||||||
|
dist: bionic
|
||||||
|
go: 1.17.x
|
||||||
|
env:
|
||||||
|
- GO111MODULE=on
|
||||||
|
script:
|
||||||
|
- go run build/ci.go test -coverage $TEST_PACKAGES
|
||||||
|
|
||||||
# This builder does the Azure archive purges to avoid accumulating junk
|
# This builder does the Azure archive purges to avoid accumulating junk
|
||||||
- stage: build
|
- stage: build
|
||||||
if: type = cron
|
if: type = cron
|
||||||
os: linux
|
os: linux
|
||||||
dist: xenial
|
dist: bionic
|
||||||
go: 1.15.x
|
go: 1.18.x
|
||||||
env:
|
env:
|
||||||
- azure-purge
|
- azure-purge
|
||||||
- GO111MODULE=on
|
- GO111MODULE=on
|
||||||
@@ -260,3 +233,15 @@ jobs:
|
|||||||
submodules: false # avoid cloning ethereum/tests
|
submodules: false # avoid cloning ethereum/tests
|
||||||
script:
|
script:
|
||||||
- go run build/ci.go purge -store gethstore/builds -days 14
|
- go run build/ci.go purge -store gethstore/builds -days 14
|
||||||
|
|
||||||
|
# This builder executes race tests
|
||||||
|
- stage: build
|
||||||
|
if: type = cron
|
||||||
|
os: linux
|
||||||
|
dist: bionic
|
||||||
|
go: 1.18.x
|
||||||
|
env:
|
||||||
|
- GO111MODULE=on
|
||||||
|
script:
|
||||||
|
- go run build/ci.go test -race -coverage $TEST_PACKAGES
|
||||||
|
|
||||||
|
|||||||
260
AUTHORS
260
AUTHORS
@@ -1,27 +1,46 @@
|
|||||||
# This is the official list of go-ethereum authors for copyright purposes.
|
# This is the official list of go-ethereum authors for copyright purposes.
|
||||||
|
|
||||||
|
6543 <6543@obermui.de>
|
||||||
a e r t h <aerth@users.noreply.github.com>
|
a e r t h <aerth@users.noreply.github.com>
|
||||||
|
Aaron Buchwald <aaron.buchwald56@gmail.com>
|
||||||
Abel Nieto <abel.nieto90@gmail.com>
|
Abel Nieto <abel.nieto90@gmail.com>
|
||||||
Abel Nieto <anietoro@uwaterloo.ca>
|
|
||||||
Adam Babik <a.babik@designfortress.com>
|
Adam Babik <a.babik@designfortress.com>
|
||||||
|
Adam Schmideg <adamschmideg@users.noreply.github.com>
|
||||||
Aditya <adityasripal@gmail.com>
|
Aditya <adityasripal@gmail.com>
|
||||||
|
Aditya Arora <arora.aditya520@gmail.com>
|
||||||
Adrià Cidre <adria.cidre@gmail.com>
|
Adrià Cidre <adria.cidre@gmail.com>
|
||||||
|
Afanasii Kurakin <afanasy@users.noreply.github.com>
|
||||||
Afri Schoedon <5chdn@users.noreply.github.com>
|
Afri Schoedon <5chdn@users.noreply.github.com>
|
||||||
Agustin Armellini Fischer <armellini13@gmail.com>
|
Agustin Armellini Fischer <armellini13@gmail.com>
|
||||||
|
Ahyun <urbanart2251@gmail.com>
|
||||||
Airead <fgh1987168@gmail.com>
|
Airead <fgh1987168@gmail.com>
|
||||||
Alan Chen <alanchchen@users.noreply.github.com>
|
Alan Chen <alanchchen@users.noreply.github.com>
|
||||||
Alejandro Isaza <alejandro.isaza@gmail.com>
|
Alejandro Isaza <alejandro.isaza@gmail.com>
|
||||||
|
Aleksey Smyrnov <i@soar.name>
|
||||||
Ales Katona <ales@coinbase.com>
|
Ales Katona <ales@coinbase.com>
|
||||||
|
Alex Beregszaszi <alex@rtfs.hu>
|
||||||
Alex Leverington <alex@ethdev.com>
|
Alex Leverington <alex@ethdev.com>
|
||||||
|
Alex Mazalov <mazalov@gmail.com>
|
||||||
|
Alex Pozhilenkov <alex_pozhilenkov@adoriasoft.com>
|
||||||
|
Alex Prut <1648497+alexprut@users.noreply.github.com>
|
||||||
Alex Wu <wuyiding@gmail.com>
|
Alex Wu <wuyiding@gmail.com>
|
||||||
|
Alexander van der Meij <alexandervdm@users.noreply.github.com>
|
||||||
|
Alexander Yastrebov <yastrebov.alex@gmail.com>
|
||||||
Alexandre Van de Sande <alex.vandesande@ethdev.com>
|
Alexandre Van de Sande <alex.vandesande@ethdev.com>
|
||||||
|
Alexey Akhunov <akhounov@gmail.com>
|
||||||
|
Alexey Shekhirin <a.shekhirin@gmail.com>
|
||||||
|
alexwang <39109351+dipingxian2@users.noreply.github.com>
|
||||||
|
Ali Atiia <42751398+aliatiia@users.noreply.github.com>
|
||||||
Ali Hajimirza <Ali92hm@users.noreply.github.com>
|
Ali Hajimirza <Ali92hm@users.noreply.github.com>
|
||||||
am2rican5 <am2rican5@gmail.com>
|
am2rican5 <am2rican5@gmail.com>
|
||||||
|
AmitBRD <60668103+AmitBRD@users.noreply.github.com>
|
||||||
|
Anatole <62328077+a2br@users.noreply.github.com>
|
||||||
Andrea Franz <andrea@gravityblast.com>
|
Andrea Franz <andrea@gravityblast.com>
|
||||||
Andrey Petrov <andrey.petrov@shazow.net>
|
Andrei Maiboroda <andrei@ethereum.org>
|
||||||
Andrey Petrov <shazow@gmail.com>
|
Andrey Petrov <shazow@gmail.com>
|
||||||
ANOTHEL <anothel1@naver.com>
|
ANOTHEL <anothel1@naver.com>
|
||||||
Antoine Rondelet <rondelet.antoine@gmail.com>
|
Antoine Rondelet <rondelet.antoine@gmail.com>
|
||||||
|
Antoine Toulme <atoulme@users.noreply.github.com>
|
||||||
Anton Evangelatov <anton.evangelatov@gmail.com>
|
Anton Evangelatov <anton.evangelatov@gmail.com>
|
||||||
Antonio Salazar Cardozo <savedfastcool@gmail.com>
|
Antonio Salazar Cardozo <savedfastcool@gmail.com>
|
||||||
Arba Sasmoyo <arba.sasmoyo@gmail.com>
|
Arba Sasmoyo <arba.sasmoyo@gmail.com>
|
||||||
@@ -29,19 +48,26 @@ Armani Ferrante <armaniferrante@berkeley.edu>
|
|||||||
Armin Braun <me@obrown.io>
|
Armin Braun <me@obrown.io>
|
||||||
Aron Fischer <github@aron.guru>
|
Aron Fischer <github@aron.guru>
|
||||||
atsushi-ishibashi <atsushi.ishibashi@finatext.com>
|
atsushi-ishibashi <atsushi.ishibashi@finatext.com>
|
||||||
|
Austin Roberts <code@ausiv.com>
|
||||||
ayeowch <ayeowch@gmail.com>
|
ayeowch <ayeowch@gmail.com>
|
||||||
b00ris <b00ris@mail.ru>
|
b00ris <b00ris@mail.ru>
|
||||||
|
b1ackd0t <blackd0t@protonmail.com>
|
||||||
bailantaotao <Edwin@maicoin.com>
|
bailantaotao <Edwin@maicoin.com>
|
||||||
baizhenxuan <nkbai@163.com>
|
baizhenxuan <nkbai@163.com>
|
||||||
|
Balaji Shetty Pachai <32358081+balajipachai@users.noreply.github.com>
|
||||||
Balint Gabor <balint.g@gmail.com>
|
Balint Gabor <balint.g@gmail.com>
|
||||||
|
baptiste-b-pegasys <85155432+baptiste-b-pegasys@users.noreply.github.com>
|
||||||
Bas van Kervel <bas@ethdev.com>
|
Bas van Kervel <bas@ethdev.com>
|
||||||
Benjamin Brent <benjamin@benjaminbrent.com>
|
Benjamin Brent <benjamin@benjaminbrent.com>
|
||||||
benma <mbencun@gmail.com>
|
benma <mbencun@gmail.com>
|
||||||
Benoit Verkindt <benoit.verkindt@gmail.com>
|
Benoit Verkindt <benoit.verkindt@gmail.com>
|
||||||
|
Binacs <bin646891055@gmail.com>
|
||||||
bloonfield <bloonfield@163.com>
|
bloonfield <bloonfield@163.com>
|
||||||
Bo <bohende@gmail.com>
|
Bo <bohende@gmail.com>
|
||||||
Bo Ye <boy.e.computer.1982@outlook.com>
|
Bo Ye <boy.e.computer.1982@outlook.com>
|
||||||
Bob Glickstein <bobg@users.noreply.github.com>
|
Bob Glickstein <bobg@users.noreply.github.com>
|
||||||
|
Boqin Qin <bobbqqin@bupt.edu.cn>
|
||||||
|
Brandon Harden <b.harden92@gmail.com>
|
||||||
Brent <bmperrea@gmail.com>
|
Brent <bmperrea@gmail.com>
|
||||||
Brian Schroeder <bts@gmail.com>
|
Brian Schroeder <bts@gmail.com>
|
||||||
Bruno Škvorc <bruno@skvorc.me>
|
Bruno Škvorc <bruno@skvorc.me>
|
||||||
@@ -49,36 +75,58 @@ C. Brown <hackdom@majoolr.io>
|
|||||||
Caesar Chad <BLUE.WEB.GEEK@gmail.com>
|
Caesar Chad <BLUE.WEB.GEEK@gmail.com>
|
||||||
Casey Detrio <cdetrio@gmail.com>
|
Casey Detrio <cdetrio@gmail.com>
|
||||||
CDsigma <cdsigma271@gmail.com>
|
CDsigma <cdsigma271@gmail.com>
|
||||||
|
Ceelog <chenwei@ceelog.org>
|
||||||
|
Ceyhun Onur <ceyhun.onur@avalabs.org>
|
||||||
|
chabashilah <doumodoumo@gmail.com>
|
||||||
changhong <changhong.yu@shanbay.com>
|
changhong <changhong.yu@shanbay.com>
|
||||||
Chase Wright <mysticryuujin@gmail.com>
|
Chase Wright <mysticryuujin@gmail.com>
|
||||||
Chen Quan <terasum@163.com>
|
Chen Quan <terasum@163.com>
|
||||||
|
Cheng Li <lob4tt@gmail.com>
|
||||||
|
chenglin <910372762@qq.com>
|
||||||
chenyufeng <yufengcode@gmail.com>
|
chenyufeng <yufengcode@gmail.com>
|
||||||
|
Chris Pacia <ctpacia@gmail.com>
|
||||||
|
Chris Ziogas <ziogaschr@gmail.com>
|
||||||
Christian Muehlhaeuser <muesli@gmail.com>
|
Christian Muehlhaeuser <muesli@gmail.com>
|
||||||
Christoph Jentzsch <jentzsch.software@gmail.com>
|
Christoph Jentzsch <jentzsch.software@gmail.com>
|
||||||
|
chuwt <weitaochu@gmail.com>
|
||||||
cong <ackratos@users.noreply.github.com>
|
cong <ackratos@users.noreply.github.com>
|
||||||
|
Connor Stein <connor.stein@mail.mcgill.ca>
|
||||||
Corey Lin <514971757@qq.com>
|
Corey Lin <514971757@qq.com>
|
||||||
|
courtier <derinilter@gmail.com>
|
||||||
cpusoft <cpusoft@live.com>
|
cpusoft <cpusoft@live.com>
|
||||||
Crispin Flowerday <crispin@bitso.com>
|
Crispin Flowerday <crispin@bitso.com>
|
||||||
croath <croathliu@gmail.com>
|
croath <croathliu@gmail.com>
|
||||||
cui <523516579@qq.com>
|
cui <523516579@qq.com>
|
||||||
|
Dan DeGreef <dan.degreef@gmail.com>
|
||||||
Dan Kinsley <dan@joincivil.com>
|
Dan Kinsley <dan@joincivil.com>
|
||||||
|
Dan Sosedoff <dan.sosedoff@gmail.com>
|
||||||
Daniel A. Nagy <nagy.da@gmail.com>
|
Daniel A. Nagy <nagy.da@gmail.com>
|
||||||
|
Daniel Perez <daniel@perez.sh>
|
||||||
Daniel Sloof <goapsychadelic@gmail.com>
|
Daniel Sloof <goapsychadelic@gmail.com>
|
||||||
|
Darioush Jalali <darioush.jalali@avalabs.org>
|
||||||
Darrel Herbst <dherbst@gmail.com>
|
Darrel Herbst <dherbst@gmail.com>
|
||||||
Dave Appleton <calistralabs@gmail.com>
|
Dave Appleton <calistralabs@gmail.com>
|
||||||
Dave McGregor <dave.s.mcgregor@gmail.com>
|
Dave McGregor <dave.s.mcgregor@gmail.com>
|
||||||
|
David Cai <davidcai1993@yahoo.com>
|
||||||
David Huie <dahuie@gmail.com>
|
David Huie <dahuie@gmail.com>
|
||||||
|
Denver <aeharvlee@gmail.com>
|
||||||
|
Derek Chiang <me@derekchiang.com>
|
||||||
Derek Gottfrid <derek@codecubed.com>
|
Derek Gottfrid <derek@codecubed.com>
|
||||||
|
Di Peng <pendyaaa@gmail.com>
|
||||||
|
Diederik Loerakker <proto@protolambda.com>
|
||||||
Diego Siqueira <DiSiqueira@users.noreply.github.com>
|
Diego Siqueira <DiSiqueira@users.noreply.github.com>
|
||||||
Diep Pham <mrfavadi@gmail.com>
|
Diep Pham <mrfavadi@gmail.com>
|
||||||
dipingxian2 <39109351+dipingxian2@users.noreply.github.com>
|
dipingxian2 <39109351+dipingxian2@users.noreply.github.com>
|
||||||
|
divergencetech <94644849+divergencetech@users.noreply.github.com>
|
||||||
dm4 <sunrisedm4@gmail.com>
|
dm4 <sunrisedm4@gmail.com>
|
||||||
Dmitrij Koniajev <dimchansky@gmail.com>
|
Dmitrij Koniajev <dimchansky@gmail.com>
|
||||||
Dmitry Shulyak <yashulyak@gmail.com>
|
Dmitry Shulyak <yashulyak@gmail.com>
|
||||||
|
Dmitry Zenovich <dzenovich@gmail.com>
|
||||||
Domino Valdano <dominoplural@gmail.com>
|
Domino Valdano <dominoplural@gmail.com>
|
||||||
Domino Valdano <jeff@okcupid.com>
|
|
||||||
Dragan Milic <dragan@netice9.com>
|
Dragan Milic <dragan@netice9.com>
|
||||||
dragonvslinux <35779158+dragononcrypto@users.noreply.github.com>
|
dragonvslinux <35779158+dragononcrypto@users.noreply.github.com>
|
||||||
|
Edgar Aroutiounian <edgar.factorial@gmail.com>
|
||||||
|
Eduard S <eduardsanou@posteo.net>
|
||||||
Egon Elbre <egonelbre@gmail.com>
|
Egon Elbre <egonelbre@gmail.com>
|
||||||
Elad <theman@elad.im>
|
Elad <theman@elad.im>
|
||||||
Eli <elihanover@yahoo.com>
|
Eli <elihanover@yahoo.com>
|
||||||
@@ -86,131 +134,189 @@ Elias Naur <elias.naur@gmail.com>
|
|||||||
Elliot Shepherd <elliot@identitii.com>
|
Elliot Shepherd <elliot@identitii.com>
|
||||||
Emil <mursalimovemeel@gmail.com>
|
Emil <mursalimovemeel@gmail.com>
|
||||||
emile <emile@users.noreply.github.com>
|
emile <emile@users.noreply.github.com>
|
||||||
Enrique Fynn <enriquefynn@gmail.com>
|
Emmanuel T Odeke <odeke@ualberta.ca>
|
||||||
|
Eng Zer Jun <engzerjun@gmail.com>
|
||||||
Enrique Fynn <me@enriquefynn.com>
|
Enrique Fynn <me@enriquefynn.com>
|
||||||
|
Enrique Ortiz <hi@enriqueortiz.dev>
|
||||||
EOS Classic <info@eos-classic.io>
|
EOS Classic <info@eos-classic.io>
|
||||||
Erichin <erichinbato@gmail.com>
|
Erichin <erichinbato@gmail.com>
|
||||||
Ernesto del Toro <ernesto.deltoro@gmail.com>
|
Ernesto del Toro <ernesto.deltoro@gmail.com>
|
||||||
Ethan Buchman <ethan@coinculture.info>
|
Ethan Buchman <ethan@coinculture.info>
|
||||||
ethersphere <thesw@rm.eth>
|
ethersphere <thesw@rm.eth>
|
||||||
|
Eugene Lepeico <eugenelepeico@gmail.com>
|
||||||
Eugene Valeyev <evgen.povt@gmail.com>
|
Eugene Valeyev <evgen.povt@gmail.com>
|
||||||
Evangelos Pappas <epappas@evalonlabs.com>
|
Evangelos Pappas <epappas@evalonlabs.com>
|
||||||
|
Everton Fraga <ev@ethereum.org>
|
||||||
Evgeny <awesome.observer@yandex.com>
|
Evgeny <awesome.observer@yandex.com>
|
||||||
Evgeny Danilenko <6655321@bk.ru>
|
Evgeny Danilenko <6655321@bk.ru>
|
||||||
evgk <evgeniy.kamyshev@gmail.com>
|
evgk <evgeniy.kamyshev@gmail.com>
|
||||||
|
Evolution404 <35091674+Evolution404@users.noreply.github.com>
|
||||||
|
EXEC <execvy@gmail.com>
|
||||||
Fabian Vogelsteller <fabian@frozeman.de>
|
Fabian Vogelsteller <fabian@frozeman.de>
|
||||||
Fabio Barone <fabio.barone.co@gmail.com>
|
Fabio Barone <fabio.barone.co@gmail.com>
|
||||||
Fabio Berger <fabioberger1991@gmail.com>
|
Fabio Berger <fabioberger1991@gmail.com>
|
||||||
FaceHo <facehoshi@gmail.com>
|
FaceHo <facehoshi@gmail.com>
|
||||||
|
Felipe Strozberg <48066928+FelStroz@users.noreply.github.com>
|
||||||
Felix Lange <fjl@twurst.com>
|
Felix Lange <fjl@twurst.com>
|
||||||
Ferenc Szabo <frncmx@gmail.com>
|
Ferenc Szabo <frncmx@gmail.com>
|
||||||
ferhat elmas <elmas.ferhat@gmail.com>
|
ferhat elmas <elmas.ferhat@gmail.com>
|
||||||
|
Ferran Borreguero <ferranbt@protonmail.com>
|
||||||
Fiisio <liangcszzu@163.com>
|
Fiisio <liangcszzu@163.com>
|
||||||
|
Fire Man <55934298+basdevelop@users.noreply.github.com>
|
||||||
|
flowerofdream <775654398@qq.com>
|
||||||
|
fomotrader <82184770+fomotrader@users.noreply.github.com>
|
||||||
|
ForLina <471133417@qq.com>
|
||||||
Frank Szendzielarz <33515470+FrankSzendzielarz@users.noreply.github.com>
|
Frank Szendzielarz <33515470+FrankSzendzielarz@users.noreply.github.com>
|
||||||
Frank Wang <eternnoir@gmail.com>
|
Frank Wang <eternnoir@gmail.com>
|
||||||
Franklin <mr_franklin@126.com>
|
Franklin <mr_franklin@126.com>
|
||||||
Furkan KAMACI <furkankamaci@gmail.com>
|
Furkan KAMACI <furkankamaci@gmail.com>
|
||||||
|
Fuyang Deng <dengfuyang@outlook.com>
|
||||||
GagziW <leon.stanko@rwth-aachen.de>
|
GagziW <leon.stanko@rwth-aachen.de>
|
||||||
Gary Rong <garyrong0905@gmail.com>
|
Gary Rong <garyrong0905@gmail.com>
|
||||||
|
Gautam Botrel <gautam.botrel@gmail.com>
|
||||||
George Ornbo <george@shapeshed.com>
|
George Ornbo <george@shapeshed.com>
|
||||||
|
Giuseppe Bertone <bertone.giuseppe@gmail.com>
|
||||||
|
Greg Colvin <greg@colvin.org>
|
||||||
Gregg Dourgarian <greggd@tempworks.com>
|
Gregg Dourgarian <greggd@tempworks.com>
|
||||||
|
Gregory Markou <16929357+GregTheGreek@users.noreply.github.com>
|
||||||
|
Guifel <toowik@gmail.com>
|
||||||
Guilherme Salgado <gsalgado@gmail.com>
|
Guilherme Salgado <gsalgado@gmail.com>
|
||||||
Guillaume Ballet <gballet@gmail.com>
|
Guillaume Ballet <gballet@gmail.com>
|
||||||
Guillaume Nicolas <guin56@gmail.com>
|
Guillaume Nicolas <guin56@gmail.com>
|
||||||
GuiltyMorishita <morilliantblue@gmail.com>
|
GuiltyMorishita <morilliantblue@gmail.com>
|
||||||
|
Guruprasad Kamath <48196632+gurukamath@users.noreply.github.com>
|
||||||
Gus <yo@soygus.com>
|
Gus <yo@soygus.com>
|
||||||
Gustav Simonsson <gustav.simonsson@gmail.com>
|
Gustav Simonsson <gustav.simonsson@gmail.com>
|
||||||
Gísli Kristjánsson <gislik@hamstur.is>
|
Gísli Kristjánsson <gislik@hamstur.is>
|
||||||
Ha ĐANG <dvietha@gmail.com>
|
Ha ĐANG <dvietha@gmail.com>
|
||||||
HackyMiner <hackyminer@gmail.com>
|
HackyMiner <hackyminer@gmail.com>
|
||||||
hadv <dvietha@gmail.com>
|
hadv <dvietha@gmail.com>
|
||||||
|
Hanjiang Yu <delacroix.yu@gmail.com>
|
||||||
Hao Bryan Cheng <haobcheng@gmail.com>
|
Hao Bryan Cheng <haobcheng@gmail.com>
|
||||||
|
Hao Duan <duanhao0814@gmail.com>
|
||||||
HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com>
|
HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com>
|
||||||
|
Harry Dutton <me@bytejedi.com>
|
||||||
|
haryu703 <34744512+haryu703@users.noreply.github.com>
|
||||||
|
Hendrik Hofstadt <hendrik@nexantic.com>
|
||||||
Henning Diedrich <hd@eonblast.com>
|
Henning Diedrich <hd@eonblast.com>
|
||||||
|
henopied <13500516+henopied@users.noreply.github.com>
|
||||||
|
hero5512 <lvshuaino@gmail.com>
|
||||||
holisticode <holistic.computing@gmail.com>
|
holisticode <holistic.computing@gmail.com>
|
||||||
Hongbin Mao <hello2mao@gmail.com>
|
Hongbin Mao <hello2mao@gmail.com>
|
||||||
Hsien-Tang Kao <htkao@pm.me>
|
Hsien-Tang Kao <htkao@pm.me>
|
||||||
|
hsyodyssey <47173566+hsyodyssey@users.noreply.github.com>
|
||||||
Husam Ibrahim <39692071+HusamIbrahim@users.noreply.github.com>
|
Husam Ibrahim <39692071+HusamIbrahim@users.noreply.github.com>
|
||||||
|
Hwanjo Heo <34005989+hwanjo@users.noreply.github.com>
|
||||||
hydai <z54981220@gmail.com>
|
hydai <z54981220@gmail.com>
|
||||||
Hyung-Kyu Hqueue Choi <hyungkyu.choi@gmail.com>
|
Hyung-Kyu Hqueue Choi <hyungkyu.choi@gmail.com>
|
||||||
|
Håvard Anda Estensen <haavard.ae@gmail.com>
|
||||||
Ian Macalinao <me@ian.pw>
|
Ian Macalinao <me@ian.pw>
|
||||||
Ian Norden <iannordenn@gmail.com>
|
Ian Norden <iannordenn@gmail.com>
|
||||||
|
icodezjb <icodezjb@163.com>
|
||||||
|
Ikko Ashimine <eltociear@gmail.com>
|
||||||
|
Ilan Gitter <8359193+gitteri@users.noreply.github.com>
|
||||||
|
ImanSharaf <78227895+ImanSharaf@users.noreply.github.com>
|
||||||
Isidoro Ghezzi <isidoro.ghezzi@icloud.com>
|
Isidoro Ghezzi <isidoro.ghezzi@icloud.com>
|
||||||
Iskander (Alex) Sharipov <quasilyte@gmail.com>
|
Iskander (Alex) Sharipov <quasilyte@gmail.com>
|
||||||
|
Ivan Bogatyy <bogatyi@gmail.com>
|
||||||
Ivan Daniluk <ivan.daniluk@gmail.com>
|
Ivan Daniluk <ivan.daniluk@gmail.com>
|
||||||
Ivo Georgiev <ivo@strem.io>
|
Ivo Georgiev <ivo@strem.io>
|
||||||
|
jacksoom <lifengliu1994@gmail.com>
|
||||||
Jae Kwon <jkwon.work@gmail.com>
|
Jae Kwon <jkwon.work@gmail.com>
|
||||||
|
James Prestwich <10149425+prestwich@users.noreply.github.com>
|
||||||
Jamie Pitts <james.pitts@gmail.com>
|
Jamie Pitts <james.pitts@gmail.com>
|
||||||
Janos Guljas <janos@resenje.org>
|
Janoš Guljaš <janos@resenje.org>
|
||||||
Janoš Guljaš <janos@users.noreply.github.com>
|
Jared Wasinger <j-wasinger@hotmail.com>
|
||||||
Jason Carver <jacarver@linkedin.com>
|
Jason Carver <jacarver@linkedin.com>
|
||||||
Javier Peletier <jm@epiclabs.io>
|
Javier Peletier <jm@epiclabs.io>
|
||||||
Javier Peletier <jpeletier@users.noreply.github.com>
|
|
||||||
Javier Sagredo <jasataco@gmail.com>
|
Javier Sagredo <jasataco@gmail.com>
|
||||||
Jay <codeholic.arena@gmail.com>
|
Jay <codeholic.arena@gmail.com>
|
||||||
Jay Guo <guojiannan1101@gmail.com>
|
Jay Guo <guojiannan1101@gmail.com>
|
||||||
Jaynti Kanani <jdkanani@gmail.com>
|
Jaynti Kanani <jdkanani@gmail.com>
|
||||||
Jeff Prestes <jeffprestes@gmail.com>
|
Jeff Prestes <jeffprestes@gmail.com>
|
||||||
Jeff R. Allen <jra@nella.org>
|
Jeff R. Allen <jra@nella.org>
|
||||||
|
Jeff Wentworth <jeff@curvegrid.com>
|
||||||
Jeffery Robert Walsh <rlxrlps@gmail.com>
|
Jeffery Robert Walsh <rlxrlps@gmail.com>
|
||||||
Jeffrey Wilcke <jeffrey@ethereum.org>
|
Jeffrey Wilcke <jeffrey@ethereum.org>
|
||||||
Jens Agerberg <github@agerberg.me>
|
Jens Agerberg <github@agerberg.me>
|
||||||
Jeremy McNevin <jeremy.mcnevin@optum.com>
|
Jeremy McNevin <jeremy.mcnevin@optum.com>
|
||||||
Jeremy Schlatter <jeremy.schlatter@gmail.com>
|
Jeremy Schlatter <jeremy.schlatter@gmail.com>
|
||||||
Jerzy Lasyk <jerzylasyk@gmail.com>
|
Jerzy Lasyk <jerzylasyk@gmail.com>
|
||||||
|
Jesse Tane <jesse.tane@gmail.com>
|
||||||
Jia Chenhui <jiachenhui1989@gmail.com>
|
Jia Chenhui <jiachenhui1989@gmail.com>
|
||||||
Jim McDonald <Jim@mcdee.net>
|
Jim McDonald <Jim@mcdee.net>
|
||||||
|
jk-jeongkyun <45347815+jeongkyun-oh@users.noreply.github.com>
|
||||||
jkcomment <jkcomment@gmail.com>
|
jkcomment <jkcomment@gmail.com>
|
||||||
|
JoeGruffins <34998433+JoeGruffins@users.noreply.github.com>
|
||||||
Joel Burget <joelburget@gmail.com>
|
Joel Burget <joelburget@gmail.com>
|
||||||
John C. Vernaleo <john@netpurgatory.com>
|
John C. Vernaleo <john@netpurgatory.com>
|
||||||
|
John Difool <johndifoolpi@gmail.com>
|
||||||
Johns Beharry <johns@peakshift.com>
|
Johns Beharry <johns@peakshift.com>
|
||||||
Jonas <felberj@users.noreply.github.com>
|
Jonas <felberj@users.noreply.github.com>
|
||||||
Jonathan Brown <jbrown@bluedroplet.com>
|
Jonathan Brown <jbrown@bluedroplet.com>
|
||||||
|
Jonathan Chappelow <chappjc@users.noreply.github.com>
|
||||||
|
Jonathan Gimeno <jgimeno@gmail.com>
|
||||||
JoranHonig <JoranHonig@users.noreply.github.com>
|
JoranHonig <JoranHonig@users.noreply.github.com>
|
||||||
Jordan Krage <jmank88@gmail.com>
|
Jordan Krage <jmank88@gmail.com>
|
||||||
|
Jorropo <jorropo.pgm@gmail.com>
|
||||||
Joseph Chow <ethereum@outlook.com>
|
Joseph Chow <ethereum@outlook.com>
|
||||||
|
Joshua Colvin <jcolvin@offchainlabs.com>
|
||||||
|
Joshua Gutow <jbgutow@gmail.com>
|
||||||
|
jovijovi <mageyul@hotmail.com>
|
||||||
jtakalai <juuso.takalainen@streamr.com>
|
jtakalai <juuso.takalainen@streamr.com>
|
||||||
JU HYEONG PARK <dkdkajej@gmail.com>
|
JU HYEONG PARK <dkdkajej@gmail.com>
|
||||||
|
Julian Y <jyap808@users.noreply.github.com>
|
||||||
Justin Clark-Casey <justincc@justincc.org>
|
Justin Clark-Casey <justincc@justincc.org>
|
||||||
Justin Drake <drakefjustin@gmail.com>
|
Justin Drake <drakefjustin@gmail.com>
|
||||||
jwasinger <j-wasinger@hotmail.com>
|
Justus <jus@gtsbr.org>
|
||||||
|
Kawashima <91420903+sscodereth@users.noreply.github.com>
|
||||||
ken10100147 <sunhongping@kanjian.com>
|
ken10100147 <sunhongping@kanjian.com>
|
||||||
Kenji Siu <kenji@isuntv.com>
|
Kenji Siu <kenji@isuntv.com>
|
||||||
Kenso Trabing <kenso.trabing@bloomwebsite.com>
|
|
||||||
Kenso Trabing <ktrabing@acm.org>
|
Kenso Trabing <ktrabing@acm.org>
|
||||||
Kevin <denk.kevin@web.de>
|
Kevin <denk.kevin@web.de>
|
||||||
kevin.xu <cming.xu@gmail.com>
|
kevin.xu <cming.xu@gmail.com>
|
||||||
|
KibGzr <kibgzr@gmail.com>
|
||||||
kiel barry <kiel.j.barry@gmail.com>
|
kiel barry <kiel.j.barry@gmail.com>
|
||||||
|
kilic <onurkilic1004@gmail.com>
|
||||||
kimmylin <30611210+kimmylin@users.noreply.github.com>
|
kimmylin <30611210+kimmylin@users.noreply.github.com>
|
||||||
Kitten King <53072918+kittenking@users.noreply.github.com>
|
Kitten King <53072918+kittenking@users.noreply.github.com>
|
||||||
knarfeh <hejun1874@gmail.com>
|
knarfeh <hejun1874@gmail.com>
|
||||||
Kobi Gurkan <kobigurk@gmail.com>
|
Kobi Gurkan <kobigurk@gmail.com>
|
||||||
|
komika <komika@komika.org>
|
||||||
Konrad Feldmeier <konrad@brainbot.com>
|
Konrad Feldmeier <konrad@brainbot.com>
|
||||||
Kris Shinn <raggamuffin.music@gmail.com>
|
Kris Shinn <raggamuffin.music@gmail.com>
|
||||||
|
Kristofer Peterson <svenski123@users.noreply.github.com>
|
||||||
|
Kumar Anirudha <mail@anirudha.dev>
|
||||||
Kurkó Mihály <kurkomisi@users.noreply.github.com>
|
Kurkó Mihály <kurkomisi@users.noreply.github.com>
|
||||||
Kushagra Sharma <ksharm01@gmail.com>
|
Kushagra Sharma <ksharm01@gmail.com>
|
||||||
Kwuaint <34888408+kwuaint@users.noreply.github.com>
|
Kwuaint <34888408+kwuaint@users.noreply.github.com>
|
||||||
Kyuntae Ethan Kim <ethan.kyuntae.kim@gmail.com>
|
Kyuntae Ethan Kim <ethan.kyuntae.kim@gmail.com>
|
||||||
ledgerwatch <akhounov@gmail.com>
|
Lee Bousfield <ljbousfield@gmail.com>
|
||||||
Lefteris Karapetsas <lefteris@refu.co>
|
Lefteris Karapetsas <lefteris@refu.co>
|
||||||
Leif Jurvetson <leijurv@gmail.com>
|
Leif Jurvetson <leijurv@gmail.com>
|
||||||
Leo Shklovskii <leo@thermopylae.net>
|
Leo Shklovskii <leo@thermopylae.net>
|
||||||
LeoLiao <leofantast@gmail.com>
|
LeoLiao <leofantast@gmail.com>
|
||||||
Lewis Marshall <lewis@lmars.net>
|
Lewis Marshall <lewis@lmars.net>
|
||||||
lhendre <lhendre2@gmail.com>
|
lhendre <lhendre2@gmail.com>
|
||||||
Liang Ma <liangma.ul@gmail.com>
|
Li Dongwei <lidw1988@126.com>
|
||||||
Liang Ma <liangma@liangbit.com>
|
Liang Ma <liangma@liangbit.com>
|
||||||
Liang ZOU <liang.d.zou@gmail.com>
|
Liang ZOU <liang.d.zou@gmail.com>
|
||||||
|
libby kent <viskovitzzz@gmail.com>
|
||||||
libotony <liboliqi@gmail.com>
|
libotony <liboliqi@gmail.com>
|
||||||
|
LieutenantRoger <dijsky_2015@hotmail.com>
|
||||||
ligi <ligi@ligi.de>
|
ligi <ligi@ligi.de>
|
||||||
Lio李欧 <lionello@users.noreply.github.com>
|
Lio李欧 <lionello@users.noreply.github.com>
|
||||||
|
lmittmann <lmittmann@users.noreply.github.com>
|
||||||
Lorenzo Manacorda <lorenzo@kinvolk.io>
|
Lorenzo Manacorda <lorenzo@kinvolk.io>
|
||||||
Louis Holbrook <dev@holbrook.no>
|
Louis Holbrook <dev@holbrook.no>
|
||||||
Luca Zeug <luclu@users.noreply.github.com>
|
Luca Zeug <luclu@users.noreply.github.com>
|
||||||
|
Lucas Hendren <lhendre2@gmail.com>
|
||||||
|
lzhfromustc <43191155+lzhfromustc@users.noreply.github.com>
|
||||||
Magicking <s@6120.eu>
|
Magicking <s@6120.eu>
|
||||||
manlio <manlio.poltronieri@gmail.com>
|
manlio <manlio.poltronieri@gmail.com>
|
||||||
Maran Hidskes <maran.hidskes@gmail.com>
|
Maran Hidskes <maran.hidskes@gmail.com>
|
||||||
Marek Kotewicz <marek.kotewicz@gmail.com>
|
Marek Kotewicz <marek.kotewicz@gmail.com>
|
||||||
|
Mariano Cortesi <mcortesi@gmail.com>
|
||||||
Marius van der Wijden <m.vanderwijden@live.de>
|
Marius van der Wijden <m.vanderwijden@live.de>
|
||||||
Mark <markya0616@gmail.com>
|
Mark <markya0616@gmail.com>
|
||||||
Mark Rushakoff <mark.rushakoff@gmail.com>
|
Mark Rushakoff <mark.rushakoff@gmail.com>
|
||||||
@@ -218,108 +324,193 @@ mark.lin <mark@maicoin.com>
|
|||||||
Martin Alex Philip Dawson <u1356770@gmail.com>
|
Martin Alex Philip Dawson <u1356770@gmail.com>
|
||||||
Martin Holst Swende <martin@swende.se>
|
Martin Holst Swende <martin@swende.se>
|
||||||
Martin Klepsch <martinklepsch@googlemail.com>
|
Martin Klepsch <martinklepsch@googlemail.com>
|
||||||
|
Martin Lundfall <martin.lundfall@protonmail.com>
|
||||||
|
Martin Michlmayr <tbm@cyrius.com>
|
||||||
|
Martin Redmond <21436+reds@users.noreply.github.com>
|
||||||
|
Mason Fischer <mason@kissr.co>
|
||||||
|
Mateusz Morusiewicz <11313015+Ruteri@users.noreply.github.com>
|
||||||
Mats Julian Olsen <mats@plysjbyen.net>
|
Mats Julian Olsen <mats@plysjbyen.net>
|
||||||
|
Matt Garnett <14004106+lightclient@users.noreply.github.com>
|
||||||
Matt K <1036969+mkrump@users.noreply.github.com>
|
Matt K <1036969+mkrump@users.noreply.github.com>
|
||||||
Matthew Di Ferrante <mattdf@users.noreply.github.com>
|
Matthew Di Ferrante <mattdf@users.noreply.github.com>
|
||||||
Matthew Halpern <matthalp@gmail.com>
|
Matthew Halpern <matthalp@gmail.com>
|
||||||
Matthew Halpern <matthalp@google.com>
|
|
||||||
Matthew Wampler-Doty <matthew.wampler.doty@gmail.com>
|
Matthew Wampler-Doty <matthew.wampler.doty@gmail.com>
|
||||||
Max Sistemich <mafrasi2@googlemail.com>
|
Max Sistemich <mafrasi2@googlemail.com>
|
||||||
|
Maxim Zhiburt <zhiburt@gmail.com>
|
||||||
Maximilian Meister <mmeister@suse.de>
|
Maximilian Meister <mmeister@suse.de>
|
||||||
|
me020523 <me020523@gmail.com>
|
||||||
|
Melvin Junhee Woo <melvin.woo@groundx.xyz>
|
||||||
|
meowsbits <b5c6@protonmail.com>
|
||||||
Micah Zoltu <micah@zoltu.net>
|
Micah Zoltu <micah@zoltu.net>
|
||||||
|
Michael Forney <mforney@mforney.org>
|
||||||
|
Michael Riabzev <michael@starkware.co>
|
||||||
Michael Ruminer <michael.ruminer+github@gmail.com>
|
Michael Ruminer <michael.ruminer+github@gmail.com>
|
||||||
|
michael1011 <me@michael1011.at>
|
||||||
Miguel Mota <miguelmota2@gmail.com>
|
Miguel Mota <miguelmota2@gmail.com>
|
||||||
|
Mike Burr <mburr@nightmare.com>
|
||||||
|
Mikhail Mikheev <mmvsha73@gmail.com>
|
||||||
|
milesvant <milesvant@gmail.com>
|
||||||
|
Miro <mirokuratczyk@users.noreply.github.com>
|
||||||
Miya Chen <miyatlchen@gmail.com>
|
Miya Chen <miyatlchen@gmail.com>
|
||||||
Mohanson <mohanson@outlook.com>
|
Mohanson <mohanson@outlook.com>
|
||||||
mr_franklin <mr_franklin@126.com>
|
mr_franklin <mr_franklin@126.com>
|
||||||
|
Mudit Gupta <guptamudit@ymail.com>
|
||||||
Mymskmkt <1847234666@qq.com>
|
Mymskmkt <1847234666@qq.com>
|
||||||
Nalin Bhardwaj <nalinbhardwaj@nibnalin.me>
|
Nalin Bhardwaj <nalinbhardwaj@nibnalin.me>
|
||||||
|
Natsu Kagami <natsukagami@gmail.com>
|
||||||
Nchinda Nchinda <nchinda2@gmail.com>
|
Nchinda Nchinda <nchinda2@gmail.com>
|
||||||
|
nebojsa94 <nebojsa94@users.noreply.github.com>
|
||||||
necaremus <necaremus@gmail.com>
|
necaremus <necaremus@gmail.com>
|
||||||
|
nedifi <103940716+nedifi@users.noreply.github.com>
|
||||||
needkane <604476380@qq.com>
|
needkane <604476380@qq.com>
|
||||||
Nguyen Kien Trung <trung.n.k@gmail.com>
|
Nguyen Kien Trung <trung.n.k@gmail.com>
|
||||||
Nguyen Sy Thanh Son <thanhson1085@gmail.com>
|
Nguyen Sy Thanh Son <thanhson1085@gmail.com>
|
||||||
|
Nic Jansma <nic@nicj.net>
|
||||||
Nick Dodson <silentcicero@outlook.com>
|
Nick Dodson <silentcicero@outlook.com>
|
||||||
Nick Johnson <arachnid@notdot.net>
|
Nick Johnson <arachnid@notdot.net>
|
||||||
|
Nicolas Feignon <nfeignon@gmail.com>
|
||||||
Nicolas Guillaume <gunicolas@sqli.com>
|
Nicolas Guillaume <gunicolas@sqli.com>
|
||||||
|
Nikita Kozhemyakin <enginegl.ec@gmail.com>
|
||||||
|
Nikola Madjarevic <nikola.madjarevic@gmail.com>
|
||||||
Nilesh Trivedi <nilesh@hypertrack.io>
|
Nilesh Trivedi <nilesh@hypertrack.io>
|
||||||
Nimrod Gutman <nimrod.gutman@gmail.com>
|
Nimrod Gutman <nimrod.gutman@gmail.com>
|
||||||
|
Nishant Das <nishdas93@gmail.com>
|
||||||
njupt-moon <1015041018@njupt.edu.cn>
|
njupt-moon <1015041018@njupt.edu.cn>
|
||||||
nkbai <nkbai@163.com>
|
nkbai <nkbai@163.com>
|
||||||
|
noam-alchemy <76969113+noam-alchemy@users.noreply.github.com>
|
||||||
nobody <ddean2009@163.com>
|
nobody <ddean2009@163.com>
|
||||||
Noman <noman@noman.land>
|
Noman <noman@noman.land>
|
||||||
|
nujabes403 <nujabes403@gmail.com>
|
||||||
|
Nye Liu <nyet@nyet.org>
|
||||||
Oleg Kovalov <iamolegkovalov@gmail.com>
|
Oleg Kovalov <iamolegkovalov@gmail.com>
|
||||||
Oli Bye <olibye@users.noreply.github.com>
|
Oli Bye <olibye@users.noreply.github.com>
|
||||||
|
Oliver Tale-Yazdi <oliver@perun.network>
|
||||||
|
Olivier Hervieu <olivier.hervieu@gmail.com>
|
||||||
|
Or Neeman <oneeman@gmail.com>
|
||||||
|
Osoro Bironga <fanosoro@gmail.com>
|
||||||
Osuke <arget-fee.free.dgm@hotmail.co.jp>
|
Osuke <arget-fee.free.dgm@hotmail.co.jp>
|
||||||
|
Pantelis Peslis <pespantelis@gmail.com>
|
||||||
|
Pascal Dierich <pascal@merkleplant.xyz>
|
||||||
|
Patrick O'Grady <prohb125@gmail.com>
|
||||||
|
Pau <pau@dabax.net>
|
||||||
Paul Berg <hello@paulrberg.com>
|
Paul Berg <hello@paulrberg.com>
|
||||||
Paul Litvak <litvakpol@012.net.il>
|
Paul Litvak <litvakpol@012.net.il>
|
||||||
|
Paul-Armand Verhaegen <paularmand.verhaegen@gmail.com>
|
||||||
Paulo L F Casaretto <pcasaretto@gmail.com>
|
Paulo L F Casaretto <pcasaretto@gmail.com>
|
||||||
Paweł Bylica <chfast@gmail.com>
|
Paweł Bylica <chfast@gmail.com>
|
||||||
|
Pedro Gomes <otherview@gmail.com>
|
||||||
Pedro Pombeiro <PombeirP@users.noreply.github.com>
|
Pedro Pombeiro <PombeirP@users.noreply.github.com>
|
||||||
Peter Broadhurst <peter@themumbles.net>
|
Peter Broadhurst <peter@themumbles.net>
|
||||||
|
peter cresswell <pcresswell@gmail.com>
|
||||||
Peter Pratscher <pratscher@gmail.com>
|
Peter Pratscher <pratscher@gmail.com>
|
||||||
|
Peter Simard <petesimard56@gmail.com>
|
||||||
Petr Mikusek <petr@mikusek.info>
|
Petr Mikusek <petr@mikusek.info>
|
||||||
Philip Schlump <pschlump@gmail.com>
|
Philip Schlump <pschlump@gmail.com>
|
||||||
Pierre Neter <pierreneter@gmail.com>
|
Pierre Neter <pierreneter@gmail.com>
|
||||||
|
Pierre R <p.rousset@gmail.com>
|
||||||
|
piersy <pierspowlesland@gmail.com>
|
||||||
PilkyuJung <anothel1@naver.com>
|
PilkyuJung <anothel1@naver.com>
|
||||||
protolambda <proto@protolambda.com>
|
Piotr Dyraga <piotr.dyraga@keep.network>
|
||||||
|
ploui <64719999+ploui@users.noreply.github.com>
|
||||||
|
Preston Van Loon <preston@prysmaticlabs.com>
|
||||||
|
Prince Sinha <sinhaprince013@gmail.com>
|
||||||
Péter Szilágyi <peterke@gmail.com>
|
Péter Szilágyi <peterke@gmail.com>
|
||||||
qd-ethan <31876119+qdgogogo@users.noreply.github.com>
|
qd-ethan <31876119+qdgogogo@users.noreply.github.com>
|
||||||
|
Qian Bin <cola.tin.com@gmail.com>
|
||||||
|
Quest Henkart <qhenkart@gmail.com>
|
||||||
|
Rachel Franks <nfranks@protonmail.com>
|
||||||
|
Rafael Matias <rafael@skyle.net>
|
||||||
Raghav Sood <raghavsood@gmail.com>
|
Raghav Sood <raghavsood@gmail.com>
|
||||||
Ralph Caraveo <deckarep@gmail.com>
|
Ralph Caraveo <deckarep@gmail.com>
|
||||||
Ralph Caraveo III <deckarep@gmail.com>
|
|
||||||
Ramesh Nair <ram@hiddentao.com>
|
Ramesh Nair <ram@hiddentao.com>
|
||||||
|
rangzen <public@l-homme.com>
|
||||||
reinerRubin <tolstov.georgij@gmail.com>
|
reinerRubin <tolstov.georgij@gmail.com>
|
||||||
|
Rene Lubov <41963722+renaynay@users.noreply.github.com>
|
||||||
rhaps107 <dod-source@yandex.ru>
|
rhaps107 <dod-source@yandex.ru>
|
||||||
Ricardo Catalinas Jiménez <r@untroubled.be>
|
Ricardo Catalinas Jiménez <r@untroubled.be>
|
||||||
Ricardo Domingos <ricardohsd@gmail.com>
|
Ricardo Domingos <ricardohsd@gmail.com>
|
||||||
Richard Hart <richardhart92@gmail.com>
|
Richard Hart <richardhart92@gmail.com>
|
||||||
|
Rick <rick.no@groundx.xyz>
|
||||||
RJ Catalano <catalanor0220@gmail.com>
|
RJ Catalano <catalanor0220@gmail.com>
|
||||||
Rob <robert@rojotek.com>
|
Rob <robert@rojotek.com>
|
||||||
Rob Mulholand <rmulholand@8thlight.com>
|
Rob Mulholand <rmulholand@8thlight.com>
|
||||||
Robert Zaremba <robert.zaremba@scale-it.pl>
|
Robert Zaremba <robert@zaremba.ch>
|
||||||
Roc Yu <rociiu0112@gmail.com>
|
Roc Yu <rociiu0112@gmail.com>
|
||||||
|
Roman Mazalov <83914728+gopherxyz@users.noreply.github.com>
|
||||||
|
Ross <9055337+Chadsr@users.noreply.github.com>
|
||||||
Runchao Han <elvisage941102@gmail.com>
|
Runchao Han <elvisage941102@gmail.com>
|
||||||
Russ Cox <rsc@golang.org>
|
Russ Cox <rsc@golang.org>
|
||||||
Ryan Schneider <ryanleeschneider@gmail.com>
|
Ryan Schneider <ryanleeschneider@gmail.com>
|
||||||
|
ryanc414 <ryan@tokencard.io>
|
||||||
Rémy Roy <remyroy@remyroy.com>
|
Rémy Roy <remyroy@remyroy.com>
|
||||||
S. Matthew English <s-matthew-english@users.noreply.github.com>
|
S. Matthew English <s-matthew-english@users.noreply.github.com>
|
||||||
salanfe <salanfe@users.noreply.github.com>
|
salanfe <salanfe@users.noreply.github.com>
|
||||||
|
Sam <39165351+Xia-Sam@users.noreply.github.com>
|
||||||
|
Sammy Libre <7374093+sammy007@users.noreply.github.com>
|
||||||
Samuel Marks <samuelmarks@gmail.com>
|
Samuel Marks <samuelmarks@gmail.com>
|
||||||
|
sanskarkhare <sanskarkhare47@gmail.com>
|
||||||
Sarlor <kinsleer@outlook.com>
|
Sarlor <kinsleer@outlook.com>
|
||||||
Sasuke1964 <neilperry1964@gmail.com>
|
Sasuke1964 <neilperry1964@gmail.com>
|
||||||
|
Satpal <28562234+SatpalSandhu61@users.noreply.github.com>
|
||||||
Saulius Grigaitis <saulius@necolt.com>
|
Saulius Grigaitis <saulius@necolt.com>
|
||||||
Sean <darcys22@gmail.com>
|
Sean <darcys22@gmail.com>
|
||||||
Sheldon <11510383@mail.sustc.edu.cn>
|
Serhat Şevki Dinçer <jfcgauss@gmail.com>
|
||||||
Sheldon <374662347@qq.com>
|
Shane Bammel <sjb933@gmail.com>
|
||||||
|
shawn <36943337+lxex@users.noreply.github.com>
|
||||||
|
shigeyuki azuchi <azuchi@chaintope.com>
|
||||||
|
Shihao Xia <charlesxsh@hotmail.com>
|
||||||
|
Shiming <codingmylife@gmail.com>
|
||||||
Shintaro Kaneko <kaneshin0120@gmail.com>
|
Shintaro Kaneko <kaneshin0120@gmail.com>
|
||||||
|
shiqinfeng1 <150627601@qq.com>
|
||||||
Shuai Qi <qishuai231@gmail.com>
|
Shuai Qi <qishuai231@gmail.com>
|
||||||
|
Shude Li <islishude@gmail.com>
|
||||||
Shunsuke Watanabe <ww.shunsuke@gmail.com>
|
Shunsuke Watanabe <ww.shunsuke@gmail.com>
|
||||||
silence <wangsai.silence@qq.com>
|
silence <wangsai.silence@qq.com>
|
||||||
Simon Jentzsch <simon@slock.it>
|
Simon Jentzsch <simon@slock.it>
|
||||||
|
Sina Mahmoodi <1591639+s1na@users.noreply.github.com>
|
||||||
|
sixdays <lj491685571@126.com>
|
||||||
|
SjonHortensius <SjonHortensius@users.noreply.github.com>
|
||||||
|
Slava Karpenko <slavikus@gmail.com>
|
||||||
slumber1122 <slumber1122@gmail.com>
|
slumber1122 <slumber1122@gmail.com>
|
||||||
Smilenator <yurivanenko@yandex.ru>
|
Smilenator <yurivanenko@yandex.ru>
|
||||||
|
soc1c <soc1c@users.noreply.github.com>
|
||||||
Sorin Neacsu <sorin.neacsu@gmail.com>
|
Sorin Neacsu <sorin.neacsu@gmail.com>
|
||||||
|
Sparty <vignesh.crysis@gmail.com>
|
||||||
Stein Dekker <dekker.stein@gmail.com>
|
Stein Dekker <dekker.stein@gmail.com>
|
||||||
Steve Gattuso <steve@stevegattuso.me>
|
Steve Gattuso <steve@stevegattuso.me>
|
||||||
Steve Ruckdashel <steve.ruckdashel@gmail.com>
|
Steve Ruckdashel <steve.ruckdashel@gmail.com>
|
||||||
Steve Waldman <swaldman@mchange.com>
|
Steve Waldman <swaldman@mchange.com>
|
||||||
|
Steven E. Harris <seh@panix.com>
|
||||||
Steven Roose <stevenroose@gmail.com>
|
Steven Roose <stevenroose@gmail.com>
|
||||||
stompesi <stompesi@gmail.com>
|
stompesi <stompesi@gmail.com>
|
||||||
stormpang <jialinpeng@vip.qq.com>
|
stormpang <jialinpeng@vip.qq.com>
|
||||||
sunxiaojun2014 <sunxiaojun-xy@360.cn>
|
sunxiaojun2014 <sunxiaojun-xy@360.cn>
|
||||||
|
Suriyaa Sundararuban <isc.suriyaa@gmail.com>
|
||||||
|
Sylvain Laurent <s@6120.eu>
|
||||||
|
Taeik Lim <sibera21@gmail.com>
|
||||||
tamirms <tamir@trello.com>
|
tamirms <tamir@trello.com>
|
||||||
|
Tangui Clairet <tangui.clairet@gmail.com>
|
||||||
|
Tatsuya Shimoda <tacoo@users.noreply.github.com>
|
||||||
Taylor Gerring <taylor.gerring@gmail.com>
|
Taylor Gerring <taylor.gerring@gmail.com>
|
||||||
TColl <38299499+TColl@users.noreply.github.com>
|
TColl <38299499+TColl@users.noreply.github.com>
|
||||||
terasum <terasum@163.com>
|
terasum <terasum@163.com>
|
||||||
|
tgyKomgo <52910426+tgyKomgo@users.noreply.github.com>
|
||||||
|
Thad Guidry <thadguidry@gmail.com>
|
||||||
Thomas Bocek <tom@tomp2p.net>
|
Thomas Bocek <tom@tomp2p.net>
|
||||||
thomasmodeneis <thomas.modeneis@gmail.com>
|
thomasmodeneis <thomas.modeneis@gmail.com>
|
||||||
thumb8432 <thumb8432@gmail.com>
|
thumb8432 <thumb8432@gmail.com>
|
||||||
Ti Zhou <tizhou1986@gmail.com>
|
Ti Zhou <tizhou1986@gmail.com>
|
||||||
|
tia-99 <67107070+tia-99@users.noreply.github.com>
|
||||||
|
Tim Cooijmans <timcooijmans@gmail.com>
|
||||||
|
Tobias Hildebrandt <79341166+tobias-hildebrandt@users.noreply.github.com>
|
||||||
Tosh Camille <tochecamille@gmail.com>
|
Tosh Camille <tochecamille@gmail.com>
|
||||||
tsarpaul <Litvakpol@012.net.il>
|
tsarpaul <Litvakpol@012.net.il>
|
||||||
|
Tyler Chambers <2775339+tylerchambers@users.noreply.github.com>
|
||||||
tzapu <alex@tzapu.com>
|
tzapu <alex@tzapu.com>
|
||||||
|
ucwong <ucwong@126.com>
|
||||||
|
uji <49834542+uji@users.noreply.github.com>
|
||||||
ult-bobonovski <alex@ultiledger.io>
|
ult-bobonovski <alex@ultiledger.io>
|
||||||
|
Valentin Trinqué <ValentinTrinque@users.noreply.github.com>
|
||||||
Valentin Wüstholz <wuestholz@gmail.com>
|
Valentin Wüstholz <wuestholz@gmail.com>
|
||||||
Vedhavyas Singareddi <vedhavyas.singareddi@gmail.com>
|
Vedhavyas Singareddi <vedhavyas.singareddi@gmail.com>
|
||||||
Victor Farazdagi <simple.square@gmail.com>
|
Victor Farazdagi <simple.square@gmail.com>
|
||||||
@@ -330,40 +521,71 @@ Ville Sundell <github@solarius.fi>
|
|||||||
vim88 <vim88vim88@gmail.com>
|
vim88 <vim88vim88@gmail.com>
|
||||||
Vincent G <caktux@gmail.com>
|
Vincent G <caktux@gmail.com>
|
||||||
Vincent Serpoul <vincent@serpoul.com>
|
Vincent Serpoul <vincent@serpoul.com>
|
||||||
|
Vinod Damle <vdamle@users.noreply.github.com>
|
||||||
Vitalik Buterin <v@buterin.com>
|
Vitalik Buterin <v@buterin.com>
|
||||||
Vitaly Bogdanov <vsbogd@gmail.com>
|
Vitaly Bogdanov <vsbogd@gmail.com>
|
||||||
Vitaly V <vvelikodny@gmail.com>
|
Vitaly V <vvelikodny@gmail.com>
|
||||||
Vivek Anand <vivekanand1101@users.noreply.github.com>
|
Vivek Anand <vivekanand1101@users.noreply.github.com>
|
||||||
Vlad <gluk256@gmail.com>
|
|
||||||
Vlad Bokov <razum2um@mail.ru>
|
Vlad Bokov <razum2um@mail.ru>
|
||||||
Vlad Gluhovsky <gluk256@users.noreply.github.com>
|
Vlad Gluhovsky <gluk256@gmail.com>
|
||||||
|
Ward Bradt <wardbradt5@gmail.com>
|
||||||
|
Water <44689567+codeoneline@users.noreply.github.com>
|
||||||
|
wbt <wbt@users.noreply.github.com>
|
||||||
weimumu <934657014@qq.com>
|
weimumu <934657014@qq.com>
|
||||||
Wenbiao Zheng <delweng@gmail.com>
|
Wenbiao Zheng <delweng@gmail.com>
|
||||||
|
Wenshao Zhong <wzhong20@uic.edu>
|
||||||
|
Will Villanueva <hello@willvillanueva.com>
|
||||||
|
William Morriss <wjmelements@gmail.com>
|
||||||
William Setzer <bootstrapsetzer@gmail.com>
|
William Setzer <bootstrapsetzer@gmail.com>
|
||||||
williambannas <wrschwartz@wpi.edu>
|
williambannas <wrschwartz@wpi.edu>
|
||||||
|
wuff1996 <33193253+wuff1996@users.noreply.github.com>
|
||||||
Wuxiang <wuxiangzhou2010@gmail.com>
|
Wuxiang <wuxiangzhou2010@gmail.com>
|
||||||
|
Xiaobing Jiang <s7v7nislands@gmail.com>
|
||||||
xiekeyang <xiekeyang@users.noreply.github.com>
|
xiekeyang <xiekeyang@users.noreply.github.com>
|
||||||
xincaosu <xincaosu@126.com>
|
xincaosu <xincaosu@126.com>
|
||||||
|
xinluyin <31590468+xinluyin@users.noreply.github.com>
|
||||||
|
Xudong Liu <33193253+r1cs@users.noreply.github.com>
|
||||||
|
xwjack <XWJACK@users.noreply.github.com>
|
||||||
yahtoo <yahtoo.ma@gmail.com>
|
yahtoo <yahtoo.ma@gmail.com>
|
||||||
|
Yang Hau <vulxj0j8j8@gmail.com>
|
||||||
YaoZengzeng <yaozengzeng@zju.edu.cn>
|
YaoZengzeng <yaozengzeng@zju.edu.cn>
|
||||||
YH-Zhou <yanhong.zhou05@gmail.com>
|
YH-Zhou <yanhong.zhou05@gmail.com>
|
||||||
|
Yihau Chen <a122092487@gmail.com>
|
||||||
Yohann Léon <sybiload@gmail.com>
|
Yohann Léon <sybiload@gmail.com>
|
||||||
Yoichi Hirai <i@yoichihirai.com>
|
Yoichi Hirai <i@yoichihirai.com>
|
||||||
|
Yole <007yuyue@gmail.com>
|
||||||
Yondon Fu <yondon.fu@gmail.com>
|
Yondon Fu <yondon.fu@gmail.com>
|
||||||
YOSHIDA Masanori <masanori.yoshida@gmail.com>
|
YOSHIDA Masanori <masanori.yoshida@gmail.com>
|
||||||
yoza <yoza.is12s@gmail.com>
|
yoza <yoza.is12s@gmail.com>
|
||||||
|
yumiel yoomee1313 <yumiel.ko@groundx.xyz>
|
||||||
Yusup <awklsgrep@gmail.com>
|
Yusup <awklsgrep@gmail.com>
|
||||||
|
yutianwu <wzxingbupt@gmail.com>
|
||||||
|
ywzqwwt <39263032+ywzqwwt@users.noreply.github.com>
|
||||||
|
zaccoding <zaccoding725@gmail.com>
|
||||||
Zach <zach.ramsay@gmail.com>
|
Zach <zach.ramsay@gmail.com>
|
||||||
|
Zachinquarantine <Zachinquarantine@protonmail.com>
|
||||||
zah <zahary@gmail.com>
|
zah <zahary@gmail.com>
|
||||||
Zahoor Mohamed <zahoor@zahoor.in>
|
Zahoor Mohamed <zahoor@zahoor.in>
|
||||||
Zak Cole <zak@beattiecole.com>
|
Zak Cole <zak@beattiecole.com>
|
||||||
|
zcheng9 <zcheng9@hawk.iit.edu>
|
||||||
zer0to0ne <36526113+zer0to0ne@users.noreply.github.com>
|
zer0to0ne <36526113+zer0to0ne@users.noreply.github.com>
|
||||||
|
zgfzgf <48779939+zgfzgf@users.noreply.github.com>
|
||||||
|
Zhang Zhuo <mycinbrin@gmail.com>
|
||||||
|
zhangsoledad <787953403@qq.com>
|
||||||
|
zhaochonghe <41711151+zhaochonghe@users.noreply.github.com>
|
||||||
Zhenguo Niu <Niu.ZGlinux@gmail.com>
|
Zhenguo Niu <Niu.ZGlinux@gmail.com>
|
||||||
|
zhiqiangxu <652732310@qq.com>
|
||||||
|
Zhou Zhiyao <ZHOU0250@e.ntu.edu.sg>
|
||||||
|
Ziyuan Zhong <zzy.albert@163.com>
|
||||||
Zoe Nolan <github@zoenolan.org>
|
Zoe Nolan <github@zoenolan.org>
|
||||||
|
Zou Guangxian <zouguangxian@gmail.com>
|
||||||
Zsolt Felföldi <zsfelfoldi@gmail.com>
|
Zsolt Felföldi <zsfelfoldi@gmail.com>
|
||||||
Łukasz Kurowski <crackcomm@users.noreply.github.com>
|
Łukasz Kurowski <crackcomm@users.noreply.github.com>
|
||||||
|
Łukasz Zimnoch <lukaszzimnoch1994@gmail.com>
|
||||||
ΞTHΞЯSPHΞЯΞ <{viktor.tron,nagydani,zsfelfoldi}@gmail.com>
|
ΞTHΞЯSPHΞЯΞ <{viktor.tron,nagydani,zsfelfoldi}@gmail.com>
|
||||||
Максим Чусовлянов <mchusovlianov@gmail.com>
|
Максим Чусовлянов <mchusovlianov@gmail.com>
|
||||||
大彬 <hz_stb@163.com>
|
大彬 <hz_stb@163.com>
|
||||||
|
沉风 <myself659@users.noreply.github.com>
|
||||||
贺鹏飞 <hpf@hackerful.cn>
|
贺鹏飞 <hpf@hackerful.cn>
|
||||||
|
陈佳 <chenjiablog@gmail.com>
|
||||||
유용환 <33824408+eric-yoo@users.noreply.github.com>
|
유용환 <33824408+eric-yoo@users.noreply.github.com>
|
||||||
|
|||||||
59
COPYING
59
COPYING
@@ -1,7 +1,7 @@
|
|||||||
GNU GENERAL PUBLIC LICENSE
|
GNU GENERAL PUBLIC LICENSE
|
||||||
Version 3, 29 June 2007
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
Copyright (C) 2014 The go-ethereum Authors.
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
of this license document, but changing it is not allowed.
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
@@ -616,4 +616,59 @@ above cannot be given local legal effect according to their terms,
|
|||||||
reviewing courts shall apply local law that most closely approximates
|
reviewing courts shall apply local law that most closely approximates
|
||||||
an absolute waiver of all civil liability in connection with the
|
an absolute waiver of all civil liability in connection with the
|
||||||
Program, unless a warranty or assumption of liability accompanies a
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
copy of the Program in return for a fee.
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||||
|
|||||||
27
Dockerfile
27
Dockerfile
@@ -1,10 +1,20 @@
|
|||||||
# Build Geth in a stock Go builder container
|
# Support setting various labels on the final image
|
||||||
FROM golang:1.15-alpine as builder
|
ARG COMMIT=""
|
||||||
|
ARG VERSION=""
|
||||||
|
ARG BUILDNUM=""
|
||||||
|
|
||||||
RUN apk add --no-cache make gcc musl-dev linux-headers git
|
# Build Geth in a stock Go builder container
|
||||||
|
FROM golang:1.18-alpine as builder
|
||||||
|
|
||||||
|
RUN apk add --no-cache gcc musl-dev linux-headers git
|
||||||
|
|
||||||
|
# Get dependencies - will also be cached if we won't change go.mod/go.sum
|
||||||
|
COPY go.mod /go-ethereum/
|
||||||
|
COPY go.sum /go-ethereum/
|
||||||
|
RUN cd /go-ethereum && go mod download
|
||||||
|
|
||||||
ADD . /go-ethereum
|
ADD . /go-ethereum
|
||||||
RUN cd /go-ethereum && make geth
|
RUN cd /go-ethereum && go run build/ci.go install ./cmd/geth
|
||||||
|
|
||||||
# Pull Geth into a second stage deploy alpine container
|
# Pull Geth into a second stage deploy alpine container
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
@@ -12,5 +22,12 @@ FROM alpine:latest
|
|||||||
RUN apk add --no-cache ca-certificates
|
RUN apk add --no-cache ca-certificates
|
||||||
COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/
|
COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/
|
||||||
|
|
||||||
EXPOSE 8545 8546 8547 30303 30303/udp
|
EXPOSE 8545 8546 30303 30303/udp
|
||||||
ENTRYPOINT ["geth"]
|
ENTRYPOINT ["geth"]
|
||||||
|
|
||||||
|
# Add some metadata labels to help programatic image consumption
|
||||||
|
ARG COMMIT=""
|
||||||
|
ARG VERSION=""
|
||||||
|
ARG BUILDNUM=""
|
||||||
|
|
||||||
|
LABEL commit="$COMMIT" version="$VERSION" buildnum="$BUILDNUM"
|
||||||
|
|||||||
@@ -1,10 +1,20 @@
|
|||||||
# Build Geth in a stock Go builder container
|
# Support setting various labels on the final image
|
||||||
FROM golang:1.15-alpine as builder
|
ARG COMMIT=""
|
||||||
|
ARG VERSION=""
|
||||||
|
ARG BUILDNUM=""
|
||||||
|
|
||||||
RUN apk add --no-cache make gcc musl-dev linux-headers git
|
# Build Geth in a stock Go builder container
|
||||||
|
FROM golang:1.18-alpine as builder
|
||||||
|
|
||||||
|
RUN apk add --no-cache gcc musl-dev linux-headers git
|
||||||
|
|
||||||
|
# Get dependencies - will also be cached if we won't change go.mod/go.sum
|
||||||
|
COPY go.mod /go-ethereum/
|
||||||
|
COPY go.sum /go-ethereum/
|
||||||
|
RUN cd /go-ethereum && go mod download
|
||||||
|
|
||||||
ADD . /go-ethereum
|
ADD . /go-ethereum
|
||||||
RUN cd /go-ethereum && make all
|
RUN cd /go-ethereum && go run build/ci.go install
|
||||||
|
|
||||||
# Pull all binaries into a second stage deploy alpine container
|
# Pull all binaries into a second stage deploy alpine container
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
@@ -12,4 +22,11 @@ FROM alpine:latest
|
|||||||
RUN apk add --no-cache ca-certificates
|
RUN apk add --no-cache ca-certificates
|
||||||
COPY --from=builder /go-ethereum/build/bin/* /usr/local/bin/
|
COPY --from=builder /go-ethereum/build/bin/* /usr/local/bin/
|
||||||
|
|
||||||
EXPOSE 8545 8546 8547 30303 30303/udp
|
EXPOSE 8545 8546 30303 30303/udp
|
||||||
|
|
||||||
|
# Add some metadata labels to help programatic image consumption
|
||||||
|
ARG COMMIT=""
|
||||||
|
ARG VERSION=""
|
||||||
|
ARG BUILDNUM=""
|
||||||
|
|
||||||
|
LABEL commit="$COMMIT" version="$VERSION" buildnum="$BUILDNUM"
|
||||||
|
|||||||
108
Makefile
108
Makefile
@@ -2,11 +2,7 @@
|
|||||||
# with Go source code. If you know what GOPATH is then you probably
|
# with Go source code. If you know what GOPATH is then you probably
|
||||||
# don't need to bother with make.
|
# don't need to bother with make.
|
||||||
|
|
||||||
.PHONY: geth android ios geth-cross evm all test clean
|
.PHONY: geth android ios evm all test clean
|
||||||
.PHONY: geth-linux geth-linux-386 geth-linux-amd64 geth-linux-mips64 geth-linux-mips64le
|
|
||||||
.PHONY: geth-linux-arm geth-linux-arm-5 geth-linux-arm-6 geth-linux-arm-7 geth-linux-arm64
|
|
||||||
.PHONY: geth-darwin geth-darwin-386 geth-darwin-amd64
|
|
||||||
.PHONY: geth-windows geth-windows-386 geth-windows-amd64
|
|
||||||
|
|
||||||
GOBIN = ./build/bin
|
GOBIN = ./build/bin
|
||||||
GO ?= latest
|
GO ?= latest
|
||||||
@@ -24,6 +20,8 @@ android:
|
|||||||
$(GORUN) build/ci.go aar --local
|
$(GORUN) build/ci.go aar --local
|
||||||
@echo "Done building."
|
@echo "Done building."
|
||||||
@echo "Import \"$(GOBIN)/geth.aar\" to use the library."
|
@echo "Import \"$(GOBIN)/geth.aar\" to use the library."
|
||||||
|
@echo "Import \"$(GOBIN)/geth-sources.jar\" to add javadocs"
|
||||||
|
@echo "For more info see https://stackoverflow.com/questions/20994336/android-studio-how-to-attach-javadoc"
|
||||||
|
|
||||||
ios:
|
ios:
|
||||||
$(GORUN) build/ci.go xcode --local
|
$(GORUN) build/ci.go xcode --local
|
||||||
@@ -44,103 +42,9 @@ clean:
|
|||||||
# You need to put $GOBIN (or $GOPATH/bin) in your PATH to use 'go generate'.
|
# You need to put $GOBIN (or $GOPATH/bin) in your PATH to use 'go generate'.
|
||||||
|
|
||||||
devtools:
|
devtools:
|
||||||
env GOBIN= go get -u golang.org/x/tools/cmd/stringer
|
env GOBIN= go install golang.org/x/tools/cmd/stringer@latest
|
||||||
env GOBIN= go get -u github.com/kevinburke/go-bindata/go-bindata
|
env GOBIN= go install github.com/fjl/gencodec@latest
|
||||||
env GOBIN= go get -u github.com/fjl/gencodec
|
env GOBIN= go install github.com/golang/protobuf/protoc-gen-go@latest
|
||||||
env GOBIN= go get -u github.com/golang/protobuf/protoc-gen-go
|
|
||||||
env GOBIN= go install ./cmd/abigen
|
env GOBIN= go install ./cmd/abigen
|
||||||
@type "npm" 2> /dev/null || echo 'Please install node.js and npm'
|
|
||||||
@type "solc" 2> /dev/null || echo 'Please install solc'
|
@type "solc" 2> /dev/null || echo 'Please install solc'
|
||||||
@type "protoc" 2> /dev/null || echo 'Please install protoc'
|
@type "protoc" 2> /dev/null || echo 'Please install protoc'
|
||||||
|
|
||||||
# Cross Compilation Targets (xgo)
|
|
||||||
|
|
||||||
geth-cross: geth-linux geth-darwin geth-windows geth-android geth-ios
|
|
||||||
@echo "Full cross compilation done:"
|
|
||||||
@ls -ld $(GOBIN)/geth-*
|
|
||||||
|
|
||||||
geth-linux: geth-linux-386 geth-linux-amd64 geth-linux-arm geth-linux-mips64 geth-linux-mips64le
|
|
||||||
@echo "Linux cross compilation done:"
|
|
||||||
@ls -ld $(GOBIN)/geth-linux-*
|
|
||||||
|
|
||||||
geth-linux-386:
|
|
||||||
$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=linux/386 -v ./cmd/geth
|
|
||||||
@echo "Linux 386 cross compilation done:"
|
|
||||||
@ls -ld $(GOBIN)/geth-linux-* | grep 386
|
|
||||||
|
|
||||||
geth-linux-amd64:
|
|
||||||
$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=linux/amd64 -v ./cmd/geth
|
|
||||||
@echo "Linux amd64 cross compilation done:"
|
|
||||||
@ls -ld $(GOBIN)/geth-linux-* | grep amd64
|
|
||||||
|
|
||||||
geth-linux-arm: geth-linux-arm-5 geth-linux-arm-6 geth-linux-arm-7 geth-linux-arm64
|
|
||||||
@echo "Linux ARM cross compilation done:"
|
|
||||||
@ls -ld $(GOBIN)/geth-linux-* | grep arm
|
|
||||||
|
|
||||||
geth-linux-arm-5:
|
|
||||||
$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=linux/arm-5 -v ./cmd/geth
|
|
||||||
@echo "Linux ARMv5 cross compilation done:"
|
|
||||||
@ls -ld $(GOBIN)/geth-linux-* | grep arm-5
|
|
||||||
|
|
||||||
geth-linux-arm-6:
|
|
||||||
$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=linux/arm-6 -v ./cmd/geth
|
|
||||||
@echo "Linux ARMv6 cross compilation done:"
|
|
||||||
@ls -ld $(GOBIN)/geth-linux-* | grep arm-6
|
|
||||||
|
|
||||||
geth-linux-arm-7:
|
|
||||||
$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=linux/arm-7 -v ./cmd/geth
|
|
||||||
@echo "Linux ARMv7 cross compilation done:"
|
|
||||||
@ls -ld $(GOBIN)/geth-linux-* | grep arm-7
|
|
||||||
|
|
||||||
geth-linux-arm64:
|
|
||||||
$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=linux/arm64 -v ./cmd/geth
|
|
||||||
@echo "Linux ARM64 cross compilation done:"
|
|
||||||
@ls -ld $(GOBIN)/geth-linux-* | grep arm64
|
|
||||||
|
|
||||||
geth-linux-mips:
|
|
||||||
$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=linux/mips --ldflags '-extldflags "-static"' -v ./cmd/geth
|
|
||||||
@echo "Linux MIPS cross compilation done:"
|
|
||||||
@ls -ld $(GOBIN)/geth-linux-* | grep mips
|
|
||||||
|
|
||||||
geth-linux-mipsle:
|
|
||||||
$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=linux/mipsle --ldflags '-extldflags "-static"' -v ./cmd/geth
|
|
||||||
@echo "Linux MIPSle cross compilation done:"
|
|
||||||
@ls -ld $(GOBIN)/geth-linux-* | grep mipsle
|
|
||||||
|
|
||||||
geth-linux-mips64:
|
|
||||||
$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=linux/mips64 --ldflags '-extldflags "-static"' -v ./cmd/geth
|
|
||||||
@echo "Linux MIPS64 cross compilation done:"
|
|
||||||
@ls -ld $(GOBIN)/geth-linux-* | grep mips64
|
|
||||||
|
|
||||||
geth-linux-mips64le:
|
|
||||||
$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=linux/mips64le --ldflags '-extldflags "-static"' -v ./cmd/geth
|
|
||||||
@echo "Linux MIPS64le cross compilation done:"
|
|
||||||
@ls -ld $(GOBIN)/geth-linux-* | grep mips64le
|
|
||||||
|
|
||||||
geth-darwin: geth-darwin-386 geth-darwin-amd64
|
|
||||||
@echo "Darwin cross compilation done:"
|
|
||||||
@ls -ld $(GOBIN)/geth-darwin-*
|
|
||||||
|
|
||||||
geth-darwin-386:
|
|
||||||
$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=darwin/386 -v ./cmd/geth
|
|
||||||
@echo "Darwin 386 cross compilation done:"
|
|
||||||
@ls -ld $(GOBIN)/geth-darwin-* | grep 386
|
|
||||||
|
|
||||||
geth-darwin-amd64:
|
|
||||||
$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=darwin/amd64 -v ./cmd/geth
|
|
||||||
@echo "Darwin amd64 cross compilation done:"
|
|
||||||
@ls -ld $(GOBIN)/geth-darwin-* | grep amd64
|
|
||||||
|
|
||||||
geth-windows: geth-windows-386 geth-windows-amd64
|
|
||||||
@echo "Windows cross compilation done:"
|
|
||||||
@ls -ld $(GOBIN)/geth-windows-*
|
|
||||||
|
|
||||||
geth-windows-386:
|
|
||||||
$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=windows/386 -v ./cmd/geth
|
|
||||||
@echo "Windows 386 cross compilation done:"
|
|
||||||
@ls -ld $(GOBIN)/geth-windows-* | grep 386
|
|
||||||
|
|
||||||
geth-windows-amd64:
|
|
||||||
$(GORUN) build/ci.go xgo -- --go=$(GO) --targets=windows/amd64 -v ./cmd/geth
|
|
||||||
@echo "Windows amd64 cross compilation done:"
|
|
||||||
@ls -ld $(GOBIN)/geth-windows-* | grep amd64
|
|
||||||
|
|||||||
70
README.md
70
README.md
@@ -6,7 +6,7 @@ Official Golang implementation of the Ethereum protocol.
|
|||||||
https://camo.githubusercontent.com/915b7be44ada53c290eb157634330494ebe3e30a/68747470733a2f2f676f646f632e6f72672f6769746875622e636f6d2f676f6c616e672f6764646f3f7374617475732e737667
|
https://camo.githubusercontent.com/915b7be44ada53c290eb157634330494ebe3e30a/68747470733a2f2f676f646f632e6f72672f6769746875622e636f6d2f676f6c616e672f6764646f3f7374617475732e737667
|
||||||
)](https://pkg.go.dev/github.com/ethereum/go-ethereum?tab=doc)
|
)](https://pkg.go.dev/github.com/ethereum/go-ethereum?tab=doc)
|
||||||
[](https://goreportcard.com/report/github.com/ethereum/go-ethereum)
|
[](https://goreportcard.com/report/github.com/ethereum/go-ethereum)
|
||||||
[](https://travis-ci.org/ethereum/go-ethereum)
|
[](https://travis-ci.com/ethereum/go-ethereum)
|
||||||
[](https://discord.gg/nthXNEv)
|
[](https://discord.gg/nthXNEv)
|
||||||
|
|
||||||
Automated builds are available for stable releases and the unstable master branch. Binary
|
Automated builds are available for stable releases and the unstable master branch. Binary
|
||||||
@@ -14,9 +14,9 @@ archives are published at https://geth.ethereum.org/downloads/.
|
|||||||
|
|
||||||
## Building the source
|
## Building the source
|
||||||
|
|
||||||
For prerequisites and detailed build instructions please read the [Installation Instructions](https://github.com/ethereum/go-ethereum/wiki/Building-Ethereum) on the wiki.
|
For prerequisites and detailed build instructions please read the [Installation Instructions](https://geth.ethereum.org/docs/install-and-build/installing-geth).
|
||||||
|
|
||||||
Building `geth` requires both a Go (version 1.13 or later) and a C compiler. You can install
|
Building `geth` requires both a Go (version 1.16 or later) and a C compiler. You can install
|
||||||
them using your favourite package manager. Once the dependencies are installed, run
|
them using your favourite package manager. Once the dependencies are installed, run
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
@@ -36,39 +36,57 @@ directory.
|
|||||||
|
|
||||||
| Command | Description |
|
| Command | Description |
|
||||||
| :-----------: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| :-----------: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| **`geth`** | Our main Ethereum CLI client. It is the entry point into the Ethereum network (main-, test- or private net), capable of running as a full node (default), archive node (retaining all historical state) or a light node (retrieving data live). It can be used by other processes as a gateway into the Ethereum network via JSON RPC endpoints exposed on top of HTTP, WebSocket and/or IPC transports. `geth --help` and the [CLI Wiki page](https://github.com/ethereum/go-ethereum/wiki/Command-Line-Options) for command line options. |
|
| **`geth`** | Our main Ethereum CLI client. It is the entry point into the Ethereum network (main-, test- or private net), capable of running as a full node (default), archive node (retaining all historical state) or a light node (retrieving data live). It can be used by other processes as a gateway into the Ethereum network via JSON RPC endpoints exposed on top of HTTP, WebSocket and/or IPC transports. `geth --help` and the [CLI page](https://geth.ethereum.org/docs/interface/command-line-options) for command line options. |
|
||||||
| `abigen` | Source code generator to convert Ethereum contract definitions into easy to use, compile-time type-safe Go packages. It operates on plain [Ethereum contract ABIs](https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI) with expanded functionality if the contract bytecode is also available. However, it also accepts Solidity source files, making development much more streamlined. Please see our [Native DApps](https://github.com/ethereum/go-ethereum/wiki/Native-DApps:-Go-bindings-to-Ethereum-contracts) wiki page for details. |
|
| `clef` | Stand-alone signing tool, which can be used as a backend signer for `geth`. |
|
||||||
|
| `devp2p` | Utilities to interact with nodes on the networking layer, without running a full blockchain. |
|
||||||
|
| `abigen` | Source code generator to convert Ethereum contract definitions into easy to use, compile-time type-safe Go packages. It operates on plain [Ethereum contract ABIs](https://docs.soliditylang.org/en/develop/abi-spec.html) with expanded functionality if the contract bytecode is also available. However, it also accepts Solidity source files, making development much more streamlined. Please see our [Native DApps](https://geth.ethereum.org/docs/dapp/native-bindings) page for details. |
|
||||||
| `bootnode` | Stripped down version of our Ethereum client implementation that only takes part in the network node discovery protocol, but does not run any of the higher level application protocols. It can be used as a lightweight bootstrap node to aid in finding peers in private networks. |
|
| `bootnode` | Stripped down version of our Ethereum client implementation that only takes part in the network node discovery protocol, but does not run any of the higher level application protocols. It can be used as a lightweight bootstrap node to aid in finding peers in private networks. |
|
||||||
| `evm` | Developer utility version of the EVM (Ethereum Virtual Machine) that is capable of running bytecode snippets within a configurable environment and execution mode. Its purpose is to allow isolated, fine-grained debugging of EVM opcodes (e.g. `evm --code 60ff60ff --debug run`). |
|
| `evm` | Developer utility version of the EVM (Ethereum Virtual Machine) that is capable of running bytecode snippets within a configurable environment and execution mode. Its purpose is to allow isolated, fine-grained debugging of EVM opcodes (e.g. `evm --code 60ff60ff --debug run`). |
|
||||||
| `gethrpctest` | Developer utility tool to support our [ethereum/rpc-test](https://github.com/ethereum/rpc-tests) test suite which validates baseline conformity to the [Ethereum JSON RPC](https://github.com/ethereum/wiki/wiki/JSON-RPC) specs. Please see the [test suite's readme](https://github.com/ethereum/rpc-tests/blob/master/README.md) for details. |
|
| `rlpdump` | Developer utility tool to convert binary RLP ([Recursive Length Prefix](https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp)) dumps (data encoding used by the Ethereum protocol both network as well as consensus wise) to user-friendlier hierarchical representation (e.g. `rlpdump --hex CE0183FFFFFFC4C304050583616263`). |
|
||||||
| `rlpdump` | Developer utility tool to convert binary RLP ([Recursive Length Prefix](https://github.com/ethereum/wiki/wiki/RLP)) dumps (data encoding used by the Ethereum protocol both network as well as consensus wise) to user-friendlier hierarchical representation (e.g. `rlpdump --hex CE0183FFFFFFC4C304050583616263`). |
|
|
||||||
| `puppeth` | a CLI wizard that aids in creating a new Ethereum network. |
|
| `puppeth` | a CLI wizard that aids in creating a new Ethereum network. |
|
||||||
|
|
||||||
## Running `geth`
|
## Running `geth`
|
||||||
|
|
||||||
Going through all the possible command line flags is out of scope here (please consult our
|
Going through all the possible command line flags is out of scope here (please consult our
|
||||||
[CLI Wiki page](https://github.com/ethereum/go-ethereum/wiki/Command-Line-Options)),
|
[CLI Wiki page](https://geth.ethereum.org/docs/interface/command-line-options)),
|
||||||
but we've enumerated a few common parameter combos to get you up to speed quickly
|
but we've enumerated a few common parameter combos to get you up to speed quickly
|
||||||
on how you can run your own `geth` instance.
|
on how you can run your own `geth` instance.
|
||||||
|
|
||||||
|
### Hardware Requirements
|
||||||
|
|
||||||
|
Minimum:
|
||||||
|
|
||||||
|
* CPU with 2+ cores
|
||||||
|
* 4GB RAM
|
||||||
|
* 1TB free storage space to sync the Mainnet
|
||||||
|
* 8 MBit/sec download Internet service
|
||||||
|
|
||||||
|
Recommended:
|
||||||
|
|
||||||
|
* Fast CPU with 4+ cores
|
||||||
|
* 16GB+ RAM
|
||||||
|
* High Performance SSD with at least 1TB free space
|
||||||
|
* 25+ MBit/sec download Internet service
|
||||||
|
|
||||||
### Full node on the main Ethereum network
|
### Full node on the main Ethereum network
|
||||||
|
|
||||||
By far the most common scenario is people wanting to simply interact with the Ethereum
|
By far the most common scenario is people wanting to simply interact with the Ethereum
|
||||||
network: create accounts; transfer funds; deploy and interact with contracts. For this
|
network: create accounts; transfer funds; deploy and interact with contracts. For this
|
||||||
particular use-case the user doesn't care about years-old historical data, so we can
|
particular use-case the user doesn't care about years-old historical data, so we can
|
||||||
fast-sync quickly to the current state of the network. To do so:
|
sync quickly to the current state of the network. To do so:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ geth console
|
$ geth console
|
||||||
```
|
```
|
||||||
|
|
||||||
This command will:
|
This command will:
|
||||||
* Start `geth` in fast sync mode (default, can be changed with the `--syncmode` flag),
|
* Start `geth` in snap sync mode (default, can be changed with the `--syncmode` flag),
|
||||||
causing it to download more data in exchange for avoiding processing the entire history
|
causing it to download more data in exchange for avoiding processing the entire history
|
||||||
of the Ethereum network, which is very CPU intensive.
|
of the Ethereum network, which is very CPU intensive.
|
||||||
* Start up `geth`'s built-in interactive [JavaScript console](https://github.com/ethereum/go-ethereum/wiki/JavaScript-Console),
|
* Start up `geth`'s built-in interactive [JavaScript console](https://geth.ethereum.org/docs/interface/javascript-console),
|
||||||
(via the trailing `console` subcommand) through which you can invoke all official [`web3` methods](https://github.com/ethereum/wiki/wiki/JavaScript-API)
|
(via the trailing `console` subcommand) through which you can interact using [`web3` methods](https://github.com/ChainSafe/web3.js/blob/0.20.7/DOCUMENTATION.md)
|
||||||
as well as `geth`'s own [management APIs](https://github.com/ethereum/go-ethereum/wiki/Management-APIs).
|
(note: the `web3` version bundled within `geth` is very old, and not up to date with official docs),
|
||||||
|
as well as `geth`'s own [management APIs](https://geth.ethereum.org/docs/rpc/server).
|
||||||
This tool is optional and if you leave it out you can always attach to an already running
|
This tool is optional and if you leave it out you can always attach to an already running
|
||||||
`geth` instance with `geth attach`.
|
`geth` instance with `geth attach`.
|
||||||
|
|
||||||
@@ -157,21 +175,21 @@ docker run -d --name ethereum-node -v /Users/alice/ethereum:/root \
|
|||||||
ethereum/client-go
|
ethereum/client-go
|
||||||
```
|
```
|
||||||
|
|
||||||
This will start `geth` in fast-sync mode with a DB memory allowance of 1GB just as the
|
This will start `geth` in snap-sync mode with a DB memory allowance of 1GB just as the
|
||||||
above command does. It will also create a persistent volume in your home directory for
|
above command does. It will also create a persistent volume in your home directory for
|
||||||
saving your blockchain as well as map the default ports. There is also an `alpine` tag
|
saving your blockchain as well as map the default ports. There is also an `alpine` tag
|
||||||
available for a slim version of the image.
|
available for a slim version of the image.
|
||||||
|
|
||||||
Do not forget `--http.addr 0.0.0.0`, if you want to access RPC from other containers
|
Do not forget `--http.addr 0.0.0.0`, if you want to access RPC from other containers
|
||||||
and/or hosts. By default, `geth` binds to the local interface and RPC endpoints is not
|
and/or hosts. By default, `geth` binds to the local interface and RPC endpoints are not
|
||||||
accessible from the outside.
|
accessible from the outside.
|
||||||
|
|
||||||
### Programmatically interfacing `geth` nodes
|
### Programmatically interfacing `geth` nodes
|
||||||
|
|
||||||
As a developer, sooner rather than later you'll want to start interacting with `geth` and the
|
As a developer, sooner rather than later you'll want to start interacting with `geth` and the
|
||||||
Ethereum network via your own programs and not manually through the console. To aid
|
Ethereum network via your own programs and not manually through the console. To aid
|
||||||
this, `geth` has built-in support for a JSON-RPC based APIs ([standard APIs](https://github.com/ethereum/wiki/wiki/JSON-RPC)
|
this, `geth` has built-in support for a JSON-RPC based APIs ([standard APIs](https://ethereum.github.io/execution-apis/api-documentation/)
|
||||||
and [`geth` specific APIs](https://github.com/ethereum/go-ethereum/wiki/Management-APIs)).
|
and [`geth` specific APIs](https://geth.ethereum.org/docs/rpc/server)).
|
||||||
These can be exposed via HTTP, WebSockets and IPC (UNIX sockets on UNIX based
|
These can be exposed via HTTP, WebSockets and IPC (UNIX sockets on UNIX based
|
||||||
platforms, and named pipes on Windows).
|
platforms, and named pipes on Windows).
|
||||||
|
|
||||||
@@ -228,7 +246,9 @@ aware of and agree upon. This consists of a small JSON file (e.g. call it `genes
|
|||||||
"byzantiumBlock": 0,
|
"byzantiumBlock": 0,
|
||||||
"constantinopleBlock": 0,
|
"constantinopleBlock": 0,
|
||||||
"petersburgBlock": 0,
|
"petersburgBlock": 0,
|
||||||
"istanbulBlock": 0
|
"istanbulBlock": 0,
|
||||||
|
"berlinBlock": 0,
|
||||||
|
"londonBlock": 0
|
||||||
},
|
},
|
||||||
"alloc": {},
|
"alloc": {},
|
||||||
"coinbase": "0x0000000000000000000000000000000000000000",
|
"coinbase": "0x0000000000000000000000000000000000000000",
|
||||||
@@ -277,7 +297,7 @@ $ bootnode --genkey=boot.key
|
|||||||
$ bootnode --nodekey=boot.key
|
$ bootnode --nodekey=boot.key
|
||||||
```
|
```
|
||||||
|
|
||||||
With the bootnode online, it will display an [`enode` URL](https://github.com/ethereum/wiki/wiki/enode-url-format)
|
With the bootnode online, it will display an [`enode` URL](https://ethereum.org/en/developers/docs/networking-layer/network-addresses/#enode)
|
||||||
that other nodes can use to connect to it and exchange peer information. Make sure to
|
that other nodes can use to connect to it and exchange peer information. Make sure to
|
||||||
replace the displayed IP address information (most probably `[::]`) with your externally
|
replace the displayed IP address information (most probably `[::]`) with your externally
|
||||||
accessible IP to get the actual `enode` URL.
|
accessible IP to get the actual `enode` URL.
|
||||||
@@ -314,13 +334,13 @@ ones either). To start a `geth` instance for mining, run it with all your usual
|
|||||||
by:
|
by:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ geth <usual-flags> --mine --miner.threads=1 --etherbase=0x0000000000000000000000000000000000000000
|
$ geth <usual-flags> --mine --miner.threads=1 --miner.etherbase=0x0000000000000000000000000000000000000000
|
||||||
```
|
```
|
||||||
|
|
||||||
Which will start mining blocks and transactions on a single CPU thread, crediting all
|
Which will start mining blocks and transactions on a single CPU thread, crediting all
|
||||||
proceedings to the account specified by `--etherbase`. You can further tune the mining
|
proceedings to the account specified by `--miner.etherbase`. You can further tune the mining
|
||||||
by changing the default gas limit blocks converge to (`--targetgaslimit`) and the price
|
by changing the default gas limit blocks converge to (`--miner.targetgaslimit`) and the price
|
||||||
transactions are accepted at (`--gasprice`).
|
transactions are accepted at (`--miner.gasprice`).
|
||||||
|
|
||||||
## Contribution
|
## Contribution
|
||||||
|
|
||||||
@@ -329,7 +349,7 @@ from anyone on the internet, and are grateful for even the smallest of fixes!
|
|||||||
|
|
||||||
If you'd like to contribute to go-ethereum, please fork, fix, commit and send a pull request
|
If you'd like to contribute to go-ethereum, please fork, fix, commit and send a pull request
|
||||||
for the maintainers to review and merge into the main code base. If you wish to submit
|
for the maintainers to review and merge into the main code base. If you wish to submit
|
||||||
more complex changes though, please check up with the core devs first on [our gitter channel](https://gitter.im/ethereum/go-ethereum)
|
more complex changes though, please check up with the core devs first on [our Discord Server](https://discord.gg/invite/nthXNEv)
|
||||||
to ensure those changes are in line with the general philosophy of the project and/or get
|
to ensure those changes are in line with the general philosophy of the project and/or get
|
||||||
some early feedback which can make both your efforts much lighter as well as our review
|
some early feedback which can make both your efforts much lighter as well as our review
|
||||||
and merge procedures quick and simple.
|
and merge procedures quick and simple.
|
||||||
@@ -344,7 +364,7 @@ Please make sure your contributions adhere to our coding guidelines:
|
|||||||
* Commit messages should be prefixed with the package(s) they modify.
|
* Commit messages should be prefixed with the package(s) they modify.
|
||||||
* E.g. "eth, rpc: make trace configs optional"
|
* E.g. "eth, rpc: make trace configs optional"
|
||||||
|
|
||||||
Please see the [Developers' Guide](https://github.com/ethereum/go-ethereum/wiki/Developers'-Guide)
|
Please see the [Developers' Guide](https://geth.ethereum.org/docs/developers/devguide)
|
||||||
for more details on configuring your environment, managing project dependencies, and
|
for more details on configuring your environment, managing project dependencies, and
|
||||||
testing procedures.
|
testing procedures.
|
||||||
|
|
||||||
|
|||||||
241
SECURITY.md
241
SECURITY.md
@@ -2,119 +2,174 @@
|
|||||||
|
|
||||||
## Supported Versions
|
## Supported Versions
|
||||||
|
|
||||||
Please see Releases. We recommend to use the most recent released version.
|
Please see [Releases](https://github.com/ethereum/go-ethereum/releases). We recommend using the [most recently released version](https://github.com/ethereum/go-ethereum/releases/latest).
|
||||||
|
|
||||||
## Audit reports
|
## Audit reports
|
||||||
|
|
||||||
Audit reports are published in the `docs` folder: https://github.com/ethereum/go-ethereum/tree/master/docs/audits
|
Audit reports are published in the `docs` folder: https://github.com/ethereum/go-ethereum/tree/master/docs/audits
|
||||||
|
|
||||||
|
|
||||||
| Scope | Date | Report Link |
|
| Scope | Date | Report Link |
|
||||||
| ------- | ------- | ----------- |
|
| ------- | ------- | ----------- |
|
||||||
| `geth` | 20170425 | [pdf](https://github.com/ethereum/go-ethereum/blob/master/docs/audits/2017-04-25_Geth-audit_Truesec.pdf) |
|
| `geth` | 20170425 | [pdf](https://github.com/ethereum/go-ethereum/blob/master/docs/audits/2017-04-25_Geth-audit_Truesec.pdf) |
|
||||||
| `clef` | 20180914 | [pdf](https://github.com/ethereum/go-ethereum/blob/master/docs/audits/2018-09-14_Clef-audit_NCC.pdf) |
|
| `clef` | 20180914 | [pdf](https://github.com/ethereum/go-ethereum/blob/master/docs/audits/2018-09-14_Clef-audit_NCC.pdf) |
|
||||||
|
| `Discv5` | 20191015 | [pdf](https://github.com/ethereum/go-ethereum/blob/master/docs/audits/2019-10-15_Discv5_audit_LeastAuthority.pdf) |
|
||||||
|
| `Discv5` | 20200124 | [pdf](https://github.com/ethereum/go-ethereum/blob/master/docs/audits/2020-01-24_DiscV5_audit_Cure53.pdf) |
|
||||||
|
|
||||||
## Reporting a Vulnerability
|
## Reporting a Vulnerability
|
||||||
|
|
||||||
**Please do not file a public ticket** mentioning the vulnerability.
|
**Please do not file a public ticket** mentioning the vulnerability.
|
||||||
|
|
||||||
To find out how to disclose a vulnerability in Ethereum visit [https://bounty.ethereum.org](https://bounty.ethereum.org) or email bounty@ethereum.org.
|
To find out how to disclose a vulnerability in Ethereum visit [https://bounty.ethereum.org](https://bounty.ethereum.org) or email bounty@ethereum.org. Please read the [disclosure page](https://github.com/ethereum/go-ethereum/security/advisories?state=published) for more information about publicly disclosed security vulnerabilities.
|
||||||
|
|
||||||
|
Use the built-in `geth version-check` feature to check whether the software is affected by any known vulnerability. This command will fetch the latest [`vulnerabilities.json`](https://geth.ethereum.org/docs/vulnerabilities/vulnerabilities.json) file which contains known security vulnerabilities concerning `geth`, and cross-check the data against its own version number.
|
||||||
|
|
||||||
The following key may be used to communicate sensitive information to developers.
|
The following key may be used to communicate sensitive information to developers.
|
||||||
|
|
||||||
Fingerprint: `AE96 ED96 9E47 9B00 84F3 E17F E88D 3334 FA5F 6A0A`
|
Fingerprint: `AE96 ED96 9E47 9B00 84F3 E17F E88D 3334 FA5F 6A0A`
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||||
Version: GnuPG v1
|
Version: SKS 1.1.6
|
||||||
|
Comment: Hostname: pgp.mit.edu
|
||||||
|
|
||||||
mQINBFgl3tgBEAC8A1tUBkD9YV+eLrOmtgy+/JS/H9RoZvkg3K1WZ8IYfj6iIRaY
|
mQINBFgl3tgBEAC8A1tUBkD9YV+eLrOmtgy+/JS/H9RoZvkg3K1WZ8IYfj6iIRaYneAk3Bp1
|
||||||
neAk3Bp182GUPVz/zhKr2g0tMXIScDR3EnaDsY+Qg+JqQl8NOG+Cikr1nnkG2on9
|
82GUPVz/zhKr2g0tMXIScDR3EnaDsY+Qg+JqQl8NOG+Cikr1nnkG2on9L8c8yiqry1ZTCmYM
|
||||||
L8c8yiqry1ZTCmYMqCa2acTFqnyuXJ482aZNtB4QG2BpzfhW4k8YThpegk/EoRUi
|
qCa2acTFqnyuXJ482aZNtB4QG2BpzfhW4k8YThpegk/EoRUim+y7buJDtoNf7YILlhDQXN8q
|
||||||
m+y7buJDtoNf7YILlhDQXN8qlHB02DWOVUihph9tUIFsPK6BvTr9SIr/eG6j6k0b
|
lHB02DWOVUihph9tUIFsPK6BvTr9SIr/eG6j6k0bfUo9pexOn7LS4SojoJmsm/5dp6AoKlac
|
||||||
fUo9pexOn7LS4SojoJmsm/5dp6AoKlac48cZU5zwR9AYcq/nvkrfmf2WkObg/xRd
|
48cZU5zwR9AYcq/nvkrfmf2WkObg/xRdEvKZzn05jRopmAIwmoC3CiLmqCHPmT5a29vEob/y
|
||||||
EvKZzn05jRopmAIwmoC3CiLmqCHPmT5a29vEob/yPFE335k+ujjZCPOu7OwjzDk7
|
PFE335k+ujjZCPOu7OwjzDk7M0zMSfnNfDq8bXh16nn+ueBxJ0NzgD1oC6c2PhM+XRQCXCho
|
||||||
M0zMSfnNfDq8bXh16nn+ueBxJ0NzgD1oC6c2PhM+XRQCXChoyI8vbfp4dGvCvYqv
|
yI8vbfp4dGvCvYqvQAE1bWjqnumZ/7vUPgZN6gDfiAzG2mUxC2SeFBhacgzDvtQls+uuvm+F
|
||||||
QAE1bWjqnumZ/7vUPgZN6gDfiAzG2mUxC2SeFBhacgzDvtQls+uuvm+FnQOUgg2H
|
nQOUgg2Hh8x2zgoZ7kqV29wjaUPFREuew7e+Th5BxielnzOfVycVXeSuvvIn6cd3g/s8mX1c
|
||||||
h8x2zgoZ7kqV29wjaUPFREuew7e+Th5BxielnzOfVycVXeSuvvIn6cd3g/s8mX1c
|
2kLSXJR7+KdWDrIrR5Az0kwAqFZt6B6QTlDrPswu3mxsm5TzMbny0PsbL/HBM+GZEZCjMXxB
|
||||||
2kLSXJR7+KdWDrIrR5Az0kwAqFZt6B6QTlDrPswu3mxsm5TzMbny0PsbL/HBM+GZ
|
8bqV2eSaktjnSlUNX1VXxyOxXA+ZG2jwpr51egi57riVRXokrQARAQABtDRFdGhlcmV1bSBG
|
||||||
EZCjMXxB8bqV2eSaktjnSlUNX1VXxyOxXA+ZG2jwpr51egi57riVRXokrQARAQAB
|
b3VuZGF0aW9uIEJ1ZyBCb3VudHkgPGJvdW50eUBldGhlcmV1bS5vcmc+iQIcBBEBCAAGBQJa
|
||||||
tDlFdGhlcmV1bSBGb3VuZGF0aW9uIFNlY3VyaXR5IFRlYW0gPHNlY3VyaXR5QGV0
|
FCY6AAoJEHoMA3Q0/nfveH8P+gJBPo9BXZL8isUfbUWjwLi81Yi70hZqIJUnz64SWTqBzg5b
|
||||||
aGVyZXVtLm9yZz6JAj4EEwECACgCGwMGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheA
|
mCZ69Ji5637THsxQetS2ARabz0DybQ779FhD/IWnqV9T3KuBM/9RzJtuhLzKCyMrAINPMo28
|
||||||
BQJaCWH6BQkFo2BYAAoJEOiNMzT6X2oK+DEP/3H6dxkm0hvHZKoHLVuuxcu3EHYo
|
rKWdunHHarpuR4m3tL2zWJkle5QVYb+vkZXJJE98PJw+N4IYeKKeCs2ubeqZu636GA0sMzzB
|
||||||
k5sd3MMWPrZSN8qzZnY7ayEDMxnarWOizc+2jfOxfJlzX/g8lR1/fsHdWPFPhPoV
|
Jn3m/dRRA2va+/zzbr6F6b51ynzbMxWKTsJnstjC8gs8EeI+Zcd6otSyelLtCUkk3h5sTvpV
|
||||||
Qk8ygrHn1H8U8+rpw/U03BqmqHpYCDzJ+CIis9UWROniqXw1nuqu/FtWOsdWxNKh
|
Wv67BNSU0BYsMkxyFi9PUyy07Wixgeas89K5jG1oOtDva/FkpRHrTE/WA5OXDRcLrHJM+SwD
|
||||||
jUo6k/0EsaXsxRPzgJv7fEUcVcQ7as/C3x9sy3muc2gvgA4/BKoGPb1/U0GuA8lV
|
CwqcLQqJd09NxwUW1iKeBmPptTiOGu1Gv2o7aEyoaWrHRBO7JuYrQrj6q2B3H1Je0zjAd2qt
|
||||||
fDIDshAggmnSUAg+TuYSAAdoFQ1sKwFMPigcLJF2eyKuK3iUyixJrec/c4LSf3wA
|
09ni2bLwLn4LA+VDpprNTO+eZDprv09s2oFSU6NwziHybovu0y7X4pADGkK2evOM7c86PohX
|
||||||
cGghbeuqI8INP0Y2zvXDQN2cByxsFAuoZG+m0cyKGaDH2MVUvOKKYqn/03qvrf15
|
QRQ1M1T16xLj6wP8/Ykwl6v/LUk7iDPXP3GPILnh4YOkwBR3DsCOPn8098xy7FxEELmupRzt
|
||||||
AWAsW0l0yQwOTCo3FbsNzemClm5Bj/xH0E4XuwXwChcMCMOWJrFoxyvCEI+keoQc
|
Cj9oC7YAoweeShgUjBPzb+nGY1m6OcFfbUPBgFyMMfwF6joHbiVIO+39+Ut2g2ysZa7KF+yp
|
||||||
c08/a8/MtS7vBAABXwOziSmm6CNqmzpWrh/fDrjlJlba9U3MxzvqU3IFlTdMratv
|
XqVDqyEkYXsOLb25OC7brt8IJEPgBPwcHK5GNag6RfLxnQV+iVZ9KNH1yQgSiQI+BBMBAgAo
|
||||||
6V+SgX+L25lCzW4NxxUavoB8fAlvo8lxpHKo24FP+RcLQ8XqkU3RiUsgRjQRFOqQ
|
AhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAUCWglh+gUJBaNgWAAKCRDojTM0+l9qCgQ2
|
||||||
TaJcsp8mimmiYyf24mNu6b48pi+a5c/eQR9w59emeEUZqsJU+nqv8BWIIp7o4Agh
|
D/4udJpV4zGIZW1yNaVvtd3vfKsTLi7GIRJLUBqVb2Yx/uhnN8jTl/tAhCVosCQ1pzvi9kMl
|
||||||
NYnKjkhPlY5e1fLVfAHIADZFynWwRPkPMJSrBiP5EtcOFxQGHGjRxU/KjXkvE0hV
|
s8qO1vu2kw5EWFFkwK96roI8pTql3VIjwhRVQrCkR7oAk/eUd1U/nt2q6J4UTYeVgqbq4dsI
|
||||||
xYb1PB8pWMTu/beeiQI+BBMBAgAoBQJYJd7YAhsDBQkB4TOABgsJCAcDAgYVCAIJ
|
ZZTRyPJMD667YpuAIcaah+w9j/E5xksYQdMeprnDrQkkBCb4FIMqfDzBPKvEa8DcQr949K85
|
||||||
CgsEFgIDAQIeAQIXgAAKCRDojTM0+l9qCplDD/9IZ2i+m1cnqQKtiyHbyFGx32oL
|
kxhr6LDq9i5l4Egxt2JdH8DaR4GLca6+oHy0MyPs/bZOsfmZUObfM2oZgPpqYM96JanhzO1j
|
||||||
fzqPylX2bOG5DPsSTorSUdJMGVfT04oVxXc4S/2DVnNvi7RAbSiLapCWSplgtBOj
|
dpnItyBii2pc+kNx5nMOf4eikE/MBv+WUJ0TttWzApGGmFUzDhtuEvRH9NBjtJ/pMrYspIGu
|
||||||
j1xlblOoXxT3m7s1XHGCX5tENxI9fVSSPVKJn+fQaWpPB2MhBA+1lUI6GJ+11T7K
|
O/QNY5KKOKQTvVIlwGcm8dTsSkqtBDSUwZyWbfKfKOI1/RhM9dC3gj5/BOY57DYYV4rdTK01
|
||||||
J8LrP/fiw1/nOb7rW61HW44Gtyox23sA/d1+DsFVaF8hxJlNj5coPKr8xWzQ8pQl
|
ZtYjuhdfs2bhuP1uF/cgnSSZlv8azvf7Egh7tHPnYxvLjfq1bJAhCIX0hNg0a81/ndPAEFky
|
||||||
juzdjHDukjevuw4rRmRq9vozvj9keEU9XJ5dldyEVXFmdDk7KT0p0Rla9nxYhzf/
|
fSko+JPKvdSvsUcSi2QQ4U2HX//jNBjXRfG4F0utgbJnhXzEckz6gqt7wSDZH2oddVuO8Ssc
|
||||||
r/Bv8Bzy0HCWRb2D31BjXXGG05oVnYmNGxGFxYja4MwgrMmne3ilEVjfUJsapsqi
|
T7sK+CdXthSKnRyuI+sGUpG+6glpKWIfYkWFKNZWuQ+YUatY3QEDHXTIioycSmV8p4d/g/0S
|
||||||
w41BAyQgIdfREulYN7ahsF5PrjVAqBd9IGtE8ULelF2SQxEBQBngEkP0ahP6tRAL
|
V6TegidLxY8bXMkbqz+3n6FArRffv5MH7qt3cYkCPgQTAQIAKAUCWCXhOwIbAwUJAeEzgAYL
|
||||||
i7/CBjPKOyKijtqVny7qrGOnU2ygcA88/WDibexDhrjz0Gx8WmErU7rIWZiZ5u4Y
|
CQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQ6I0zNPpfagrN/w/+Igp3vtYdNunikw3yHnYf
|
||||||
vJYVRo0+6rBCXRPeSJfiP5h1p17Anr2l42boAYslfcrzquB8MHtrNcyn650OLtHG
|
Jkm0MmaMDUM9mtsaXVN6xb9n25N3Xa3GWCpmdsbYZ8334tI/oQ4/NHq/bEI5WFH5F1aFkMkm
|
||||||
nbxgIdniKrpuzGN6Opw+O2id2JhD1/1p4SOemwAmthplr1MIyOHNP3q93rEj2J7h
|
5AJVLuUkipCtmCZ5NkbRPJA9l0uNUUE6uuFXBhf4ddu7jb0jMetRF/kifJHVCCo5fISUNhLp
|
||||||
5zPS/AJuKkMDFUpslPNLQjCOwPXtdzL7/kUZGBSyez1T3TaW1uY6l9XaJJRaSn+v
|
7bwcWq9qgDQNZNYMOo4s9WX5Tl+5x4gTZdd2/cAYt49h/wnkw+huM+Jm0GojpLqIQ1jZiffm
|
||||||
1zPgfp4GJ3lPs4AlAbQ0RXRoZXJldW0gRm91bmRhdGlvbiBCdWcgQm91bnR5IDxi
|
otf5rF4L+JhIIdW0W4IIh1v9BhHVllXw+z9oj0PALstT5h8/DuKoIiirFJ4DejU85GR1KKAS
|
||||||
b3VudHlAZXRoZXJldW0ub3JnPokCPgQTAQIAKAIbAwYLCQgHAwIGFQgCCQoLBBYC
|
DeO19G/lSpWj1rSgFv2N2gAOxq0X+BbQTua2jdcY6JpHR4H1JJ2wzfHsHPgDQcgY1rGlmjVF
|
||||||
AwECHgECF4AFAloJYfoFCQWjYFgACgkQ6I0zNPpfagoENg/+LnSaVeMxiGVtcjWl
|
aqU73WV4/hzXc/HshK/k4Zd8uD4zypv6rFsZ3UemK0aL2zXLVpV8SPWQ61nS03x675SmDlYr
|
||||||
b7Xd73yrEy4uxiESS1AalW9mMf7oZzfI05f7QIQlaLAkNac74vZDJbPKjtb7tpMO
|
A80ENfdqvsn00JQuBVIv4Tv0Ub7NfDraDGJCst8rObjBT/0vnBWTBCebb2EsnS2iStIFkWdz
|
||||||
RFhRZMCveq6CPKU6pd1SI8IUVUKwpEe6AJP3lHdVP57dquieFE2HlYKm6uHbCGWU
|
/WXs4L4Yzre1iJwqRjiuqahZR5jHsjAUf2a0O29HVHE7zlFtCFmLPClml2lGQfQOpm5klGZF
|
||||||
0cjyTA+uu2KbgCHGmofsPY/xOcZLGEHTHqa5w60JJAQm+BSDKnw8wTyrxGvA3EK/
|
rmvus+qZ9rt35UgWHPZezykkwtWrFOwspwuCWaPDto6tgbRJZ4ftitpdYYM3dKW9IGJXBwrt
|
||||||
ePSvOZMYa+iw6vYuZeBIMbdiXR/A2keBi3GuvqB8tDMj7P22TrH5mVDm3zNqGYD6
|
BQrMsu+lp0vDF+yJAlUEEwEIAD8CGwMGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAFiEErpbt
|
||||||
amDPeiWp4cztY3aZyLcgYotqXPpDceZzDn+HopBPzAb/llCdE7bVswKRhphVMw4b
|
lp5HmwCE8+F/6I0zNPpfagoFAmEAEJwFCQycmLgACgkQ6I0zNPpfagpWoBAAhOcbMAUw6Zt0
|
||||||
bhL0R/TQY7Sf6TK2LKSBrjv0DWOSijikE71SJcBnJvHU7EpKrQQ0lMGclm3ynyji
|
GYzT3sR5/c0iatezPzXEXJf9ebzR8M5uPElXcxcnMx1dvXZmGPXPJKCPa99WCu1NZYy8F+Wj
|
||||||
Nf0YTPXQt4I+fwTmOew2GFeK3UytNWbWI7oXX7Nm4bj9bhf3IJ0kmZb/Gs73+xII
|
GTOY9tfIkvSxhys1p/giPAmvid6uQmD+bz7ivktnyzCkDWfMA+l8lsCSEqVlaq6y5T+a6SWB
|
||||||
e7Rz52Mby436tWyQIQiF9ITYNGvNf53TwBBZMn0pKPiTyr3Ur7FHEotkEOFNh1//
|
6TzC2S0MPb/RrC/7DpwyrNYWumvyVJh09adm1Mw/UGgst/sZ8eMaRYEd3X0yyT1CBpX4zp2E
|
||||||
4zQY10XxuBdLrYGyZ4V8xHJM+oKre8Eg2R9qHXVbjvErHE+7CvgnV7YUip0criPr
|
qQj9IEOTizvzv1x2jkHe5ZUeU3+nTBNlhSA+WFHUi0pfBdo2qog3Mv2EC1P2qMKoSdD5tPbA
|
||||||
BlKRvuoJaSliH2JFhSjWVrkPmFGrWN0BAx10yIqMnEplfKeHf4P9Elek3oInS8WP
|
zql1yKoHHnXOMsqdftGwbiv2sYXWvrYvmaCd3Ys/viOyt3HOy9uV2ZEtBd9Yqo9x/NZj8QMA
|
||||||
G1zJG6s/t5+hQK0X37+TB+6rd3GJAj4EEwECACgFAlgl4TsCGwMFCQHhM4AGCwkI
|
nY5k8jjrIXbUC89MqrJsQ6xxWQIg5ikMT7DvY0Ln89ev4oJyVvwIQAwCm4jUzFNm9bZLYDOP
|
||||||
BwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEOiNMzT6X2oKzf8P/iIKd77WHTbp4pMN
|
5lGJCV7tF5NYVU7NxNM8vescKc40mVNK/pygS5mxhK9QYOUjZsIv8gddrl1TkqrFMuxFnTyN
|
||||||
8h52HyZJtDJmjA1DPZrbGl1TesW/Z9uTd12txlgqZnbG2GfN9+LSP6EOPzR6v2xC
|
WvzE29wFu/n4N1DkF+ZBqS70SlRvB+Hjz5LrDgEzF1Wf1eA/wq1dZbvMjjDVIc2VGlYp8Cp2
|
||||||
OVhR+RdWhZDJJuQCVS7lJIqQrZgmeTZG0TyQPZdLjVFBOrrhVwYX+HXbu429IzHr
|
8ob23c1seTtYXTNYgSR5go4EpH+xi+bIWv01bQQ9xGwBbT5sm4WUeWOcmX4QewzLZ3T/wK9+
|
||||||
URf5InyR1QgqOXyElDYS6e28HFqvaoA0DWTWDDqOLPVl+U5fuceIE2XXdv3AGLeP
|
N4Ye/hmU9O34FwWJOY58EIe0OUV0aGVyZXVtIEZvdW5kYXRpb24gU2VjdXJpdHkgVGVhbSA8
|
||||||
Yf8J5MPobjPiZtBqI6S6iENY2Yn35qLX+axeC/iYSCHVtFuCCIdb/QYR1ZZV8Ps/
|
c2VjdXJpdHlAZXRoZXJldW0ub3JnPokCHAQRAQgABgUCWhQmOgAKCRB6DAN0NP5372LSEACT
|
||||||
aI9DwC7LU+YfPw7iqCIoqxSeA3o1PORkdSigEg3jtfRv5UqVo9a0oBb9jdoADsat
|
wZk1TASWZj5QF7rmkIM1GEyBxLE+PundNcMgM9Ktj1315ED8SmiukNI4knVS1MY99OIgXhQl
|
||||||
F/gW0E7mto3XGOiaR0eB9SSdsM3x7Bz4A0HIGNaxpZo1RWqlO91leP4c13Px7ISv
|
D1foF2GKdTomrwwC4012zTNyUYCY60LnPZ6Z511HG+rZgZtZrbkz0IiUpwAlhGQND77lBqem
|
||||||
5OGXfLg+M8qb+qxbGd1HpitGi9s1y1aVfEj1kOtZ0tN8eu+Upg5WKwPNBDX3ar7J
|
J3K+CFX2XpDA/ojui/kqrY4cwMT5P8xPJkwgpRgw/jgdcZyJTsXdHblV9IGU4H1Vd1SgcfAf
|
||||||
9NCULgVSL+E79FG+zXw62gxiQrLfKzm4wU/9L5wVkwQnm29hLJ0tokrSBZFnc/1l
|
Db3YxDUlBtzlp0NkZqxen8irLIXUQvsfuIfRUbUSkWoK/n3U/gOCajAe8ZNF07iX4OWjH4Sw
|
||||||
7OC+GM63tYicKkY4rqmoWUeYx7IwFH9mtDtvR1RxO85RbQhZizwpZpdpRkH0DqZu
|
NDA841WhFWcGE+d8+pfMVfPASU3UPKH72uw86b2VgR46Av6voyMFd1pj+yCA+YAhJuOpV4yL
|
||||||
ZJRmRa5r7rPqmfa7d+VIFhz2Xs8pJMLVqxTsLKcLglmjw7aOrYG0SWeH7YraXWGD
|
QaGg2Z0kVOjuNWK/kBzp1F58DWGh4YBatbhE/UyQOqAAtR7lNf0M3QF9AdrHTxX8oZeqVW3V
|
||||||
N3SlvSBiVwcK7QUKzLLvpadLwxfsuQINBFgl3tgBEACbgq6HTN5gEBi0lkD/MafI
|
Fmi2mk0NwCIUv8SSrZr1dTchp04OtyXe5gZBXSfzncCSRQIUDC8OgNWaOzAaUmK299v4bvye
|
||||||
nmNi+59U5gRGYqk46WlfRjhHudXjDpgD0lolGb4hYontkMaKRlCg2Rvgjvk3Zve0
|
uSCxOysxC7Q1hZtjzFPKdljS81mRlYeUL4fHlJU9R57bg8mriSXLmn7eKrSEDm/EG5T8nRx7
|
||||||
PKWjKw7gr8YBa9fMFY8BhAXI32OdyI9rFhxEZFfWAfwKVmT19BdeAQRFvcfd+8w8
|
TgX2MqJs8sWFxD2+bboVEu75yuFmZ//nmCBApAit9Hr2/sCshGIEpa9MQ6xJCYUxyqeJH+Cc
|
||||||
f1XVc+zddULMJFBTr+xKDlIRWwTkdLPQeWbjo0eHl/g4tuLiLrTxVbnj26bf+2+1
|
Aja0UfXhnK2uvPClpJLIl4RE3gm4OXeE1IkCPgQTAQIAKAIbAwYLCQgHAwIGFQgCCQoLBBYC
|
||||||
DbM/w5VavzPrkviHqvKe/QP/gay4QDViWvFgLb90idfAHIdsPgflp0VDS5rVHFL6
|
AwECHgECF4AFAloJYfoFCQWjYFgACgkQ6I0zNPpfagr4MQ//cfp3GSbSG8dkqgctW67Fy7cQ
|
||||||
D73rSRdIRo3I8c8mYoNjSR4XDuvgOkAKW9LR3pvouFHHjp6Fr0GesRbrbb2EG66i
|
diiTmx3cwxY+tlI3yrNmdjtrIQMzGdqtY6LNz7aN87F8mXNf+DyVHX9+wd1Y8U+E+hVCTzKC
|
||||||
PsR99MQ7FqIL9VMHPm2mtR+XvbnKkH2rYyEqaMbSdk29jGapkAWle4sIhSKk749A
|
sefUfxTz6unD9TTcGqaoelgIPMn4IiKz1RZE6eKpfDWe6q78W1Y6x1bE0qGNSjqT/QSxpezF
|
||||||
4tGkHl08KZ2N9o6GrfUehP/V2eJLaph2DioFL1HxRryrKy80QQKLMJRekxigq8gr
|
E/OAm/t8RRxVxDtqz8LfH2zLea5zaC+ADj8EqgY9vX9TQa4DyVV8MgOyECCCadJQCD5O5hIA
|
||||||
eW8xB4zuf9Mkuou+RHNmo8PebHjFstLigiD6/zP2e+4tUmrT0/JTGOShoGMl8Rt0
|
B2gVDWwrAUw+KBwskXZ7Iq4reJTKLEmt5z9zgtJ/fABwaCFt66ojwg0/RjbO9cNA3ZwHLGwU
|
||||||
VRxdPImKun+4LOXbfOxArOSkY6i35+gsgkkSy1gTJE0BY3S9auT6+YrglY/TWPQ9
|
C6hkb6bRzIoZoMfYxVS84opiqf/Teq+t/XkBYCxbSXTJDA5MKjcVuw3N6YKWbkGP/EfQThe7
|
||||||
IJxWVOKlT+3WIp5wJu2bBKQ420VLqDYzkoWytel/bM1ACUtipMiIVeUs2uFiRjpz
|
BfAKFwwIw5YmsWjHK8IQj6R6hBxzTz9rz8y1Lu8EAAFfA7OJKaboI2qbOlauH98OuOUmVtr1
|
||||||
A1Wy0QHKPTdSuGlJPRrfcQARAQABiQIlBBgBAgAPAhsMBQJaCWIIBQkFo2BYAAoJ
|
TczHO+pTcgWVN0ytq2/pX5KBf4vbmULNbg3HFRq+gHx8CW+jyXGkcqjbgU/5FwtDxeqRTdGJ
|
||||||
EOiNMzT6X2oKgSwQAKKs7BGF8TyZeIEO2EUK7R2bdQDCdSGZY06tqLFg3IHMGxDM
|
SyBGNBEU6pBNolyynyaKaaJjJ/biY27pvjymL5rlz95BH3Dn16Z4RRmqwlT6eq/wFYginujg
|
||||||
b/7FVoa2AEsFgv6xpoebxBB5zkhUk7lslgxvKiSLYjxfNjTBltfiFJ+eQnf+OTs8
|
CCE1icqOSE+Vjl7V8tV8AcgANkXKdbBE+Q8wlKsGI/kS1w4XFAYcaNHFT8qNeS8TSFXFhvU8
|
||||||
KeR51lLa66rvIH2qUzkNDCCTF45H4wIDpV05AXhBjKYkrDCrtey1rQyFp5fxI+0I
|
HylYxO79t56JAj4EEwECACgFAlgl3tgCGwMFCQHhM4AGCwkIBwMCBhUIAgkKCwQWAgMBAh4B
|
||||||
Q1UKKXvzZK4GdxhxDbOUSd38MYy93nqcmclGSGK/gF8XiyuVjeifDCM6+T1NQTX0
|
AheAAAoJEOiNMzT6X2oKmUMP/0hnaL6bVyepAq2LIdvIUbHfagt/Oo/KVfZs4bkM+xJOitJR
|
||||||
K9lneidcqtBDvlggJTLJtQPO33o5EHzXSiud+dKth1uUhZOFEaYRZoye1YE3yB0T
|
0kwZV9PTihXFdzhL/YNWc2+LtEBtKItqkJZKmWC0E6OPXGVuU6hfFPebuzVccYJfm0Q3Ej19
|
||||||
NOOE8fXlvu8iuIAMBSDL9ep6sEIaXYwoD60I2gHdWD0lkP0DOjGQpi4ouXM3Edsd
|
VJI9Uomf59Bpak8HYyEED7WVQjoYn7XVPsonwus/9+LDX+c5vutbrUdbjga3KjHbewD93X4O
|
||||||
5MTi0MDRNTij431kn8T/D0LCgmoUmYYMBgbwFhXr67axPZlKjrqR0z3F/Elv0ZPP
|
wVVoXyHEmU2Plyg8qvzFbNDylCWO7N2McO6SN6+7DitGZGr2+jO+P2R4RT1cnl2V3IRVcWZ0
|
||||||
cVg1tNznsALYQ9Ovl6b5M3cJ5GapbbvNWC7yEE1qScl9HiMxjt/H6aPastH63/7w
|
OTspPSnRGVr2fFiHN/+v8G/wHPLQcJZFvYPfUGNdcYbTmhWdiY0bEYXFiNrgzCCsyad7eKUR
|
||||||
cN0TslW+zRBy05VNJvpWGStQXcngsSUeJtI1Gd992YNjUJq4/Lih6Z1TlwcFVap+
|
WN9QmxqmyqLDjUEDJCAh19ES6Vg3tqGwXk+uNUCoF30ga0TxQt6UXZJDEQFAGeASQ/RqE/q1
|
||||||
cTcDptoUvXYGg/9mRNNPZwErSfIJ0Ibnx9wPVuRN6NiCLOt2mtKp2F1pM6AOQPpZ
|
EAuLv8IGM8o7IqKO2pWfLuqsY6dTbKBwDzz9YOJt7EOGuPPQbHxaYStTushZmJnm7hi8lhVG
|
||||||
85vEh6I8i6OaO0w/Z0UHBwvpY6jDUliaROsWUQsqz78Z34CVj4cy6vPW2EF4
|
jT7qsEJdE95Il+I/mHWnXsCevaXjZugBiyV9yvOq4Hwwe2s1zKfrnQ4u0cadvGAh2eIqum7M
|
||||||
=r6KK
|
Y3o6nD47aJ3YmEPX/WnhI56bACa2GmWvUwjI4c0/er3esSPYnuHnM9L8Am4qQwMVSmyU80tC
|
||||||
-----END PGP PUBLIC KEY BLOCK-----
|
MI7A9e13Mvv+RRkYFLJ7PVPdNpbW5jqX1doklFpKf6/XM+B+ngYneU+zgCUBiQJVBBMBCAA/
|
||||||
|
AhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgBYhBK6W7ZaeR5sAhPPhf+iNMzT6X2oKBQJh
|
||||||
|
ABCQBQkMnJi4AAoJEOiNMzT6X2oKAv0P+gJ3twBp5efNWyVLcIg4h4cOo9uD0NPvz8/fm2gX
|
||||||
|
FoOJL3MeigtPuSVfE9kuTaTuRbArzuFtdvH6G/kcRQvOlO4zyiIRHCk1gDHoIvvtn6RbRhVm
|
||||||
|
/Xo4uGIsFHst7n4A7BjicwEK5Op6Ih5Hoq19xz83YSBgBVk2fYEJIRyJiKFbyPjH0eSYe8v+
|
||||||
|
Ra5/F85ugLx1P6mMVkW+WPzULns89riW7BGTnZmXFHZp8nO2pkUlcI7F3KRG7l4kmlC50ox6
|
||||||
|
DiG/6AJCVulbAClky9C68TmJ/R1RazQxU/9IqVywsydq66tbJQbm5Z7GEti0C5jjbSRJL2oT
|
||||||
|
1xC7Rilr85PMREkPL3vegJdgj5PKlffZ/MocD/0EohiQ7wFpejFD4iTljeh0exRUwCRb6655
|
||||||
|
9ib34JSQgU8Hl4JJu+mEgd9v0ZHD0/1mMD6fnAR84zca+O3cdASbnQmzTOKcGzLIrkE8TEnU
|
||||||
|
+2UZ8Ol7SAAqmBgzY1gKOilUho6dkyCAwNL+QDpvrITDPLEFPsjyB/M2KudZSVEn+Rletju1
|
||||||
|
qkMW31qFMNlsbwzMZw+0USeGcs31Cs0B2/WQsro99CExlhS9auUFkmoVjJmYVTIYOM0zuPa4
|
||||||
|
OyGspqPhRu5hEsmMDPDWD7Aad5k4GTqogQNnuKyRliZjXXrDZqFD5nfsJSL8Ky/sJGEMuQIN
|
||||||
|
BFgl3tgBEACbgq6HTN5gEBi0lkD/MafInmNi+59U5gRGYqk46WlfRjhHudXjDpgD0lolGb4h
|
||||||
|
YontkMaKRlCg2Rvgjvk3Zve0PKWjKw7gr8YBa9fMFY8BhAXI32OdyI9rFhxEZFfWAfwKVmT1
|
||||||
|
9BdeAQRFvcfd+8w8f1XVc+zddULMJFBTr+xKDlIRWwTkdLPQeWbjo0eHl/g4tuLiLrTxVbnj
|
||||||
|
26bf+2+1DbM/w5VavzPrkviHqvKe/QP/gay4QDViWvFgLb90idfAHIdsPgflp0VDS5rVHFL6
|
||||||
|
D73rSRdIRo3I8c8mYoNjSR4XDuvgOkAKW9LR3pvouFHHjp6Fr0GesRbrbb2EG66iPsR99MQ7
|
||||||
|
FqIL9VMHPm2mtR+XvbnKkH2rYyEqaMbSdk29jGapkAWle4sIhSKk749A4tGkHl08KZ2N9o6G
|
||||||
|
rfUehP/V2eJLaph2DioFL1HxRryrKy80QQKLMJRekxigq8greW8xB4zuf9Mkuou+RHNmo8Pe
|
||||||
|
bHjFstLigiD6/zP2e+4tUmrT0/JTGOShoGMl8Rt0VRxdPImKun+4LOXbfOxArOSkY6i35+gs
|
||||||
|
gkkSy1gTJE0BY3S9auT6+YrglY/TWPQ9IJxWVOKlT+3WIp5wJu2bBKQ420VLqDYzkoWytel/
|
||||||
|
bM1ACUtipMiIVeUs2uFiRjpzA1Wy0QHKPTdSuGlJPRrfcQARAQABiQIlBBgBAgAPAhsMBQJa
|
||||||
|
CWIIBQkFo2BYAAoJEOiNMzT6X2oKgSwQAKKs7BGF8TyZeIEO2EUK7R2bdQDCdSGZY06tqLFg
|
||||||
|
3IHMGxDMb/7FVoa2AEsFgv6xpoebxBB5zkhUk7lslgxvKiSLYjxfNjTBltfiFJ+eQnf+OTs8
|
||||||
|
KeR51lLa66rvIH2qUzkNDCCTF45H4wIDpV05AXhBjKYkrDCrtey1rQyFp5fxI+0IQ1UKKXvz
|
||||||
|
ZK4GdxhxDbOUSd38MYy93nqcmclGSGK/gF8XiyuVjeifDCM6+T1NQTX0K9lneidcqtBDvlgg
|
||||||
|
JTLJtQPO33o5EHzXSiud+dKth1uUhZOFEaYRZoye1YE3yB0TNOOE8fXlvu8iuIAMBSDL9ep6
|
||||||
|
sEIaXYwoD60I2gHdWD0lkP0DOjGQpi4ouXM3Edsd5MTi0MDRNTij431kn8T/D0LCgmoUmYYM
|
||||||
|
BgbwFhXr67axPZlKjrqR0z3F/Elv0ZPPcVg1tNznsALYQ9Ovl6b5M3cJ5GapbbvNWC7yEE1q
|
||||||
|
Scl9HiMxjt/H6aPastH63/7wcN0TslW+zRBy05VNJvpWGStQXcngsSUeJtI1Gd992YNjUJq4
|
||||||
|
/Lih6Z1TlwcFVap+cTcDptoUvXYGg/9mRNNPZwErSfIJ0Ibnx9wPVuRN6NiCLOt2mtKp2F1p
|
||||||
|
M6AOQPpZ85vEh6I8i6OaO0w/Z0UHBwvpY6jDUliaROsWUQsqz78Z34CVj4cy6vPW2EF4iQIl
|
||||||
|
BBgBAgAPBQJYJd7YAhsMBQkB4TOAAAoJEOiNMzT6X2oKTjgP/1ojCVyGyvHMLUgnX0zwrR5Q
|
||||||
|
1M5RKFz6kHwKjODVLR3Isp8I935oTQt3DY7yFDI4t0GqbYRQMtxcNEb7maianhK2trCXfhPs
|
||||||
|
6/L04igjDf5iTcmzamXN6xnh5xkz06hZJJCMuu4MvKxC9MQHCVKAwjswl/9H9JqIBXAY3E2l
|
||||||
|
LpX5P+5jDZuPxS86p3+k4Rrdp9KTGXjiuEleM3zGlz5BLWydqovOck7C2aKh27ETFpDYY0z3
|
||||||
|
yQ5AsPJyk1rAr0wrH6+ywmwWlzuQewavnrLnJ2M8iMFXpIhyHeEIU/f7o8f+dQk72rZ9CGzd
|
||||||
|
cqig2za/BS3zawZWgbv2vB2elNsIllYLdir45jxBOxx2yvJvEuu4glz78y4oJTCTAYAbMlle
|
||||||
|
5gVdPkVcGyvvVS9tinnSaiIzuvWrYHKWll1uYPm2Q1CDs06P5I7bUGAXpgQLUh/XQguy/0sX
|
||||||
|
GWqW3FS5JzP+XgcR/7UASvwBdHylubKbeqEpB7G1s+m+8C67qOrc7EQv3Jmy1YDOkhEyNig1
|
||||||
|
rmjplLuir3tC1X+D7dHpn7NJe7nMwFx2b2MpMkLA9jPPAGPp/ekcu5sxCe+E0J/4UF++K+CR
|
||||||
|
XIxgtzU2UJfp8p9x+ygbx5qHinR0tVRdIzv3ZnGsXrfxnWfSOaB582cU3VRN9INzHHax8ETa
|
||||||
|
QVDnGO5uQa+FiQI8BBgBCAAmAhsMFiEErpbtlp5HmwCE8+F/6I0zNPpfagoFAmEAELYFCQyc
|
||||||
|
mN4ACgkQ6I0zNPpfagoqAQ/+MnDjBx8JWMd/XjeFoYKx/Oo0ntkInV+ME61JTBls4PdVk+TB
|
||||||
|
8PWZdPQHw9SnTvRmykFeznXIRzuxkowjrZYXdPXBxY2b1WyD5V3Ati1TM9vqpaR4osyPs2xy
|
||||||
|
I4dzDssh9YvUsIRL99O04/65lGiYeBNuACq+yK/7nD/ErzBkDYJHhMCdadbVWUACxvVIDvro
|
||||||
|
yQeVLKMsHqMCd8BTGD7VDs79NXskPnN77pAFnkzS4Z2b8SNzrlgTc5pUiuZHIXPIpEYmsYzh
|
||||||
|
ucTU6uI3dN1PbSFHK5tG2pHb4ZrPxY3L20Dgc2Tfu5/SDApZzwvvKTqjdO891MEJ++H+ssOz
|
||||||
|
i4O1UeWKs9owWttan9+PI47ozBSKOTxmMqLSQ0f56Np9FJsV0ilGxRKfjhzJ4KniOMUBA7mP
|
||||||
|
+m+TmXfVtthJred4sHlJMTJNpt+sCcT6wLMmyc3keIEAu33gsJj3LTpkEA2q+V+ZiP6Q8HRB
|
||||||
|
402ITklABSArrPSE/fQU9L8hZ5qmy0Z96z0iyILgVMLuRCCfQOMWhwl8yQWIIaf1yPI07xur
|
||||||
|
epy6lH7HmxjjOR7eo0DaSxQGQpThAtFGwkWkFh8yki8j3E42kkrxvEyyYZDXn2YcI3bpqhJx
|
||||||
|
PtwCMZUJ3kc/skOrs6bOI19iBNaEoNX5Dllm7UHjOgWNDQkcCuOCxucKano=
|
||||||
|
=arte
|
||||||
|
-----END PGP PUBLIC KEY BLOCK------
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ type ABI struct {
|
|||||||
Constructor Method
|
Constructor Method
|
||||||
Methods map[string]Method
|
Methods map[string]Method
|
||||||
Events map[string]Event
|
Events map[string]Event
|
||||||
|
Errors map[string]Error
|
||||||
|
|
||||||
// Additional "special" functions introduced in solidity v0.6.0.
|
// Additional "special" functions introduced in solidity v0.6.0.
|
||||||
// It's separated from the original default fallback. Each contract
|
// It's separated from the original default fallback. Each contract
|
||||||
@@ -80,39 +81,59 @@ func (abi ABI) Pack(name string, args ...interface{}) ([]byte, error) {
|
|||||||
return append(method.ID, arguments...), nil
|
return append(method.ID, arguments...), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unpack output in v according to the abi specification
|
func (abi ABI) getArguments(name string, data []byte) (Arguments, error) {
|
||||||
func (abi ABI) Unpack(v interface{}, name string, data []byte) (err error) {
|
|
||||||
// since there can't be naming collisions with contracts and events,
|
// since there can't be naming collisions with contracts and events,
|
||||||
// we need to decide whether we're calling a method or an event
|
// we need to decide whether we're calling a method or an event
|
||||||
|
var args Arguments
|
||||||
if method, ok := abi.Methods[name]; ok {
|
if method, ok := abi.Methods[name]; ok {
|
||||||
if len(data)%32 != 0 {
|
if len(data)%32 != 0 {
|
||||||
return fmt.Errorf("abi: improperly formatted output: %s - Bytes: [%+v]", string(data), data)
|
return nil, fmt.Errorf("abi: improperly formatted output: %s - Bytes: [%+v]", string(data), data)
|
||||||
}
|
}
|
||||||
return method.Outputs.Unpack(v, data)
|
args = method.Outputs
|
||||||
}
|
}
|
||||||
if event, ok := abi.Events[name]; ok {
|
if event, ok := abi.Events[name]; ok {
|
||||||
return event.Inputs.Unpack(v, data)
|
args = event.Inputs
|
||||||
}
|
}
|
||||||
return fmt.Errorf("abi: could not locate named method or event")
|
if args == nil {
|
||||||
|
return nil, errors.New("abi: could not locate named method or event")
|
||||||
|
}
|
||||||
|
return args, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnpackIntoMap unpacks a log into the provided map[string]interface{}
|
// Unpack unpacks the output according to the abi specification.
|
||||||
|
func (abi ABI) Unpack(name string, data []byte) ([]interface{}, error) {
|
||||||
|
args, err := abi.getArguments(name, data)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return args.Unpack(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnpackIntoInterface unpacks the output in v according to the abi specification.
|
||||||
|
// It performs an additional copy. Please only use, if you want to unpack into a
|
||||||
|
// structure that does not strictly conform to the abi structure (e.g. has additional arguments)
|
||||||
|
func (abi ABI) UnpackIntoInterface(v interface{}, name string, data []byte) error {
|
||||||
|
args, err := abi.getArguments(name, data)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
unpacked, err := args.Unpack(data)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return args.Copy(v, unpacked)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnpackIntoMap unpacks a log into the provided map[string]interface{}.
|
||||||
func (abi ABI) UnpackIntoMap(v map[string]interface{}, name string, data []byte) (err error) {
|
func (abi ABI) UnpackIntoMap(v map[string]interface{}, name string, data []byte) (err error) {
|
||||||
// since there can't be naming collisions with contracts and events,
|
args, err := abi.getArguments(name, data)
|
||||||
// we need to decide whether we're calling a method or an event
|
if err != nil {
|
||||||
if method, ok := abi.Methods[name]; ok {
|
return err
|
||||||
if len(data)%32 != 0 {
|
|
||||||
return fmt.Errorf("abi: improperly formatted output")
|
|
||||||
}
|
|
||||||
return method.Outputs.UnpackIntoMap(v, data)
|
|
||||||
}
|
}
|
||||||
if event, ok := abi.Events[name]; ok {
|
return args.UnpackIntoMap(v, data)
|
||||||
return event.Inputs.UnpackIntoMap(v, data)
|
|
||||||
}
|
|
||||||
return fmt.Errorf("abi: could not locate named method or event")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalJSON implements json.Unmarshaler interface
|
// UnmarshalJSON implements json.Unmarshaler interface.
|
||||||
func (abi *ABI) UnmarshalJSON(data []byte) error {
|
func (abi *ABI) UnmarshalJSON(data []byte) error {
|
||||||
var fields []struct {
|
var fields []struct {
|
||||||
Type string
|
Type string
|
||||||
@@ -137,12 +158,13 @@ func (abi *ABI) UnmarshalJSON(data []byte) error {
|
|||||||
}
|
}
|
||||||
abi.Methods = make(map[string]Method)
|
abi.Methods = make(map[string]Method)
|
||||||
abi.Events = make(map[string]Event)
|
abi.Events = make(map[string]Event)
|
||||||
|
abi.Errors = make(map[string]Error)
|
||||||
for _, field := range fields {
|
for _, field := range fields {
|
||||||
switch field.Type {
|
switch field.Type {
|
||||||
case "constructor":
|
case "constructor":
|
||||||
abi.Constructor = NewMethod("", "", Constructor, field.StateMutability, field.Constant, field.Payable, field.Inputs, nil)
|
abi.Constructor = NewMethod("", "", Constructor, field.StateMutability, field.Constant, field.Payable, field.Inputs, nil)
|
||||||
case "function":
|
case "function":
|
||||||
name := abi.overloadedMethodName(field.Name)
|
name := ResolveNameConflict(field.Name, func(s string) bool { _, ok := abi.Methods[s]; return ok })
|
||||||
abi.Methods[name] = NewMethod(name, field.Name, Function, field.StateMutability, field.Constant, field.Payable, field.Inputs, field.Outputs)
|
abi.Methods[name] = NewMethod(name, field.Name, Function, field.StateMutability, field.Constant, field.Payable, field.Inputs, field.Outputs)
|
||||||
case "fallback":
|
case "fallback":
|
||||||
// New introduced function type in v0.6.0, check more detail
|
// New introduced function type in v0.6.0, check more detail
|
||||||
@@ -162,8 +184,12 @@ func (abi *ABI) UnmarshalJSON(data []byte) error {
|
|||||||
}
|
}
|
||||||
abi.Receive = NewMethod("", "", Receive, field.StateMutability, field.Constant, field.Payable, nil, nil)
|
abi.Receive = NewMethod("", "", Receive, field.StateMutability, field.Constant, field.Payable, nil, nil)
|
||||||
case "event":
|
case "event":
|
||||||
name := abi.overloadedEventName(field.Name)
|
name := ResolveNameConflict(field.Name, func(s string) bool { _, ok := abi.Events[s]; return ok })
|
||||||
abi.Events[name] = NewEvent(name, field.Name, field.Anonymous, field.Inputs)
|
abi.Events[name] = NewEvent(name, field.Name, field.Anonymous, field.Inputs)
|
||||||
|
case "error":
|
||||||
|
// Errors cannot be overloaded or overridden but are inherited,
|
||||||
|
// no need to resolve the name conflict here.
|
||||||
|
abi.Errors[field.Name] = NewError(field.Name, field.Inputs)
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("abi: could not recognize type %v of field %v", field.Type, field.Name)
|
return fmt.Errorf("abi: could not recognize type %v of field %v", field.Type, field.Name)
|
||||||
}
|
}
|
||||||
@@ -171,38 +197,8 @@ func (abi *ABI) UnmarshalJSON(data []byte) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// overloadedMethodName returns the next available name for a given function.
|
// MethodById looks up a method by the 4-byte id,
|
||||||
// Needed since solidity allows for function overload.
|
// returns nil if none found.
|
||||||
//
|
|
||||||
// e.g. if the abi contains Methods send, send1
|
|
||||||
// overloadedMethodName would return send2 for input send.
|
|
||||||
func (abi *ABI) overloadedMethodName(rawName string) string {
|
|
||||||
name := rawName
|
|
||||||
_, ok := abi.Methods[name]
|
|
||||||
for idx := 0; ok; idx++ {
|
|
||||||
name = fmt.Sprintf("%s%d", rawName, idx)
|
|
||||||
_, ok = abi.Methods[name]
|
|
||||||
}
|
|
||||||
return name
|
|
||||||
}
|
|
||||||
|
|
||||||
// overloadedEventName returns the next available name for a given event.
|
|
||||||
// Needed since solidity allows for event overload.
|
|
||||||
//
|
|
||||||
// e.g. if the abi contains events received, received1
|
|
||||||
// overloadedEventName would return received2 for input received.
|
|
||||||
func (abi *ABI) overloadedEventName(rawName string) string {
|
|
||||||
name := rawName
|
|
||||||
_, ok := abi.Events[name]
|
|
||||||
for idx := 0; ok; idx++ {
|
|
||||||
name = fmt.Sprintf("%s%d", rawName, idx)
|
|
||||||
_, ok = abi.Events[name]
|
|
||||||
}
|
|
||||||
return name
|
|
||||||
}
|
|
||||||
|
|
||||||
// MethodById looks up a method by the 4-byte id
|
|
||||||
// returns nil if none found
|
|
||||||
func (abi *ABI) MethodById(sigdata []byte) (*Method, error) {
|
func (abi *ABI) MethodById(sigdata []byte) (*Method, error) {
|
||||||
if len(sigdata) < 4 {
|
if len(sigdata) < 4 {
|
||||||
return nil, fmt.Errorf("data too short (%d bytes) for abi method lookup", len(sigdata))
|
return nil, fmt.Errorf("data too short (%d bytes) for abi method lookup", len(sigdata))
|
||||||
@@ -250,10 +246,10 @@ func UnpackRevert(data []byte) (string, error) {
|
|||||||
if !bytes.Equal(data[:4], revertSelector) {
|
if !bytes.Equal(data[:4], revertSelector) {
|
||||||
return "", errors.New("invalid data for unpacking")
|
return "", errors.New("invalid data for unpacking")
|
||||||
}
|
}
|
||||||
var reason string
|
|
||||||
typ, _ := NewType("string", "", nil)
|
typ, _ := NewType("string", "", nil)
|
||||||
if err := (Arguments{{Type: typ}}).Unpack(&reason, data[4:]); err != nil {
|
unpacked, err := (Arguments{{Type: typ}}).Unpack(data[4:])
|
||||||
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
return reason, nil
|
return unpacked[0].(string), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import (
|
|||||||
|
|
||||||
const jsondata = `
|
const jsondata = `
|
||||||
[
|
[
|
||||||
{ "type" : "function", "name" : "", "stateMutability" : "view" },
|
{ "type" : "function", "name" : ""},
|
||||||
{ "type" : "function", "name" : "balance", "stateMutability" : "view" },
|
{ "type" : "function", "name" : "balance", "stateMutability" : "view" },
|
||||||
{ "type" : "function", "name" : "send", "inputs" : [ { "name" : "amount", "type" : "uint256" } ] },
|
{ "type" : "function", "name" : "send", "inputs" : [ { "name" : "amount", "type" : "uint256" } ] },
|
||||||
{ "type" : "function", "name" : "test", "inputs" : [ { "name" : "number", "type" : "uint32" } ] },
|
{ "type" : "function", "name" : "test", "inputs" : [ { "name" : "number", "type" : "uint32" } ] },
|
||||||
@@ -43,6 +43,7 @@ const jsondata = `
|
|||||||
{ "type" : "function", "name" : "uint64[2]", "inputs" : [ { "name" : "inputs", "type" : "uint64[2]" } ] },
|
{ "type" : "function", "name" : "uint64[2]", "inputs" : [ { "name" : "inputs", "type" : "uint64[2]" } ] },
|
||||||
{ "type" : "function", "name" : "uint64[]", "inputs" : [ { "name" : "inputs", "type" : "uint64[]" } ] },
|
{ "type" : "function", "name" : "uint64[]", "inputs" : [ { "name" : "inputs", "type" : "uint64[]" } ] },
|
||||||
{ "type" : "function", "name" : "int8", "inputs" : [ { "name" : "inputs", "type" : "int8" } ] },
|
{ "type" : "function", "name" : "int8", "inputs" : [ { "name" : "inputs", "type" : "int8" } ] },
|
||||||
|
{ "type" : "function", "name" : "bytes32", "inputs" : [ { "name" : "inputs", "type" : "bytes32" } ] },
|
||||||
{ "type" : "function", "name" : "foo", "inputs" : [ { "name" : "inputs", "type" : "uint32" } ] },
|
{ "type" : "function", "name" : "foo", "inputs" : [ { "name" : "inputs", "type" : "uint32" } ] },
|
||||||
{ "type" : "function", "name" : "bar", "inputs" : [ { "name" : "inputs", "type" : "uint32" }, { "name" : "string", "type" : "uint16" } ] },
|
{ "type" : "function", "name" : "bar", "inputs" : [ { "name" : "inputs", "type" : "uint32" }, { "name" : "string", "type" : "uint16" } ] },
|
||||||
{ "type" : "function", "name" : "slice", "inputs" : [ { "name" : "inputs", "type" : "uint32[2]" } ] },
|
{ "type" : "function", "name" : "slice", "inputs" : [ { "name" : "inputs", "type" : "uint32[2]" } ] },
|
||||||
@@ -68,6 +69,7 @@ var (
|
|||||||
String, _ = NewType("string", "", nil)
|
String, _ = NewType("string", "", nil)
|
||||||
Bool, _ = NewType("bool", "", nil)
|
Bool, _ = NewType("bool", "", nil)
|
||||||
Bytes, _ = NewType("bytes", "", nil)
|
Bytes, _ = NewType("bytes", "", nil)
|
||||||
|
Bytes32, _ = NewType("bytes32", "", nil)
|
||||||
Address, _ = NewType("address", "", nil)
|
Address, _ = NewType("address", "", nil)
|
||||||
Uint64Arr, _ = NewType("uint64[]", "", nil)
|
Uint64Arr, _ = NewType("uint64[]", "", nil)
|
||||||
AddressArr, _ = NewType("address[]", "", nil)
|
AddressArr, _ = NewType("address[]", "", nil)
|
||||||
@@ -88,7 +90,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var methods = map[string]Method{
|
var methods = map[string]Method{
|
||||||
"": NewMethod("", "", Function, "view", false, false, nil, nil),
|
"": NewMethod("", "", Function, "", false, false, nil, nil),
|
||||||
"balance": NewMethod("balance", "balance", Function, "view", false, false, nil, nil),
|
"balance": NewMethod("balance", "balance", Function, "view", false, false, nil, nil),
|
||||||
"send": NewMethod("send", "send", Function, "", false, false, []Argument{{"amount", Uint256, false}}, nil),
|
"send": NewMethod("send", "send", Function, "", false, false, []Argument{{"amount", Uint256, false}}, nil),
|
||||||
"test": NewMethod("test", "test", Function, "", false, false, []Argument{{"number", Uint32, false}}, nil),
|
"test": NewMethod("test", "test", Function, "", false, false, []Argument{{"number", Uint32, false}}, nil),
|
||||||
@@ -98,6 +100,7 @@ var methods = map[string]Method{
|
|||||||
"uint64[]": NewMethod("uint64[]", "uint64[]", Function, "", false, false, []Argument{{"inputs", Uint64Arr, false}}, nil),
|
"uint64[]": NewMethod("uint64[]", "uint64[]", Function, "", false, false, []Argument{{"inputs", Uint64Arr, false}}, nil),
|
||||||
"uint64[2]": NewMethod("uint64[2]", "uint64[2]", Function, "", false, false, []Argument{{"inputs", Uint64Arr2, false}}, nil),
|
"uint64[2]": NewMethod("uint64[2]", "uint64[2]", Function, "", false, false, []Argument{{"inputs", Uint64Arr2, false}}, nil),
|
||||||
"int8": NewMethod("int8", "int8", Function, "", false, false, []Argument{{"inputs", Int8, false}}, nil),
|
"int8": NewMethod("int8", "int8", Function, "", false, false, []Argument{{"inputs", Int8, false}}, nil),
|
||||||
|
"bytes32": NewMethod("bytes32", "bytes32", Function, "", false, false, []Argument{{"inputs", Bytes32, false}}, nil),
|
||||||
"foo": NewMethod("foo", "foo", Function, "", false, false, []Argument{{"inputs", Uint32, false}}, nil),
|
"foo": NewMethod("foo", "foo", Function, "", false, false, []Argument{{"inputs", Uint32, false}}, nil),
|
||||||
"bar": NewMethod("bar", "bar", Function, "", false, false, []Argument{{"inputs", Uint32, false}, {"string", Uint16, false}}, nil),
|
"bar": NewMethod("bar", "bar", Function, "", false, false, []Argument{{"inputs", Uint32, false}, {"string", Uint16, false}}, nil),
|
||||||
"slice": NewMethod("slice", "slice", Function, "", false, false, []Argument{{"inputs", Uint32Arr2, false}}, nil),
|
"slice": NewMethod("slice", "slice", Function, "", false, false, []Argument{{"inputs", Uint32Arr2, false}}, nil),
|
||||||
@@ -181,18 +184,15 @@ func TestConstructor(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
v := struct {
|
unpacked, err := abi.Constructor.Inputs.Unpack(packed)
|
||||||
A *big.Int
|
if err != nil {
|
||||||
B *big.Int
|
|
||||||
}{new(big.Int), new(big.Int)}
|
|
||||||
//abi.Unpack(&v, "", packed)
|
|
||||||
if err := abi.Constructor.Inputs.Unpack(&v, packed); err != nil {
|
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(v.A, big.NewInt(1)) {
|
|
||||||
|
if !reflect.DeepEqual(unpacked[0], big.NewInt(1)) {
|
||||||
t.Error("Unable to pack/unpack from constructor")
|
t.Error("Unable to pack/unpack from constructor")
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(v.B, big.NewInt(2)) {
|
if !reflect.DeepEqual(unpacked[1], big.NewInt(2)) {
|
||||||
t.Error("Unable to pack/unpack from constructor")
|
t.Error("Unable to pack/unpack from constructor")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -295,6 +295,20 @@ func TestOverloadedMethodSignature(t *testing.T) {
|
|||||||
check("bar0", "bar(uint256,uint256)", false)
|
check("bar0", "bar(uint256,uint256)", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCustomErrors(t *testing.T) {
|
||||||
|
json := `[{ "inputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ],"name": "MyError", "type": "error"} ]`
|
||||||
|
abi, err := JSON(strings.NewReader(json))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
check := func(name string, expect string) {
|
||||||
|
if abi.Errors[name].Sig != expect {
|
||||||
|
t.Fatalf("The signature of overloaded method mismatch, want %s, have %s", expect, abi.Methods[name].Sig)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
check("MyError", "MyError(uint256)")
|
||||||
|
}
|
||||||
|
|
||||||
func TestMultiPack(t *testing.T) {
|
func TestMultiPack(t *testing.T) {
|
||||||
abi, err := JSON(strings.NewReader(jsondata))
|
abi, err := JSON(strings.NewReader(jsondata))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -743,7 +757,7 @@ func TestUnpackEvent(t *testing.T) {
|
|||||||
}
|
}
|
||||||
var ev ReceivedEvent
|
var ev ReceivedEvent
|
||||||
|
|
||||||
err = abi.Unpack(&ev, "received", data)
|
err = abi.UnpackIntoInterface(&ev, "received", data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
@@ -752,7 +766,7 @@ func TestUnpackEvent(t *testing.T) {
|
|||||||
Sender common.Address
|
Sender common.Address
|
||||||
}
|
}
|
||||||
var receivedAddrEv ReceivedAddrEvent
|
var receivedAddrEv ReceivedAddrEvent
|
||||||
err = abi.Unpack(&receivedAddrEv, "receivedAddr", data)
|
err = abi.UnpackIntoInterface(&receivedAddrEv, "receivedAddr", data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
@@ -1024,9 +1038,7 @@ func TestABI_EventById(t *testing.T) {
|
|||||||
}
|
}
|
||||||
if event == nil {
|
if event == nil {
|
||||||
t.Errorf("We should find a event for topic %s, test #%d", topicID.Hex(), testnum)
|
t.Errorf("We should find a event for topic %s, test #%d", topicID.Hex(), testnum)
|
||||||
}
|
} else if event.ID != topicID {
|
||||||
|
|
||||||
if event.ID != topicID {
|
|
||||||
t.Errorf("Event id %s does not match topic %s, test #%d", event.ID.Hex(), topicID.Hex(), testnum)
|
t.Errorf("Event id %s does not match topic %s, test #%d", event.ID.Hex(), topicID.Hex(), testnum)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1092,7 +1104,7 @@ func TestDoubleDuplicateEventNames(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TestUnnamedEventParam checks that an event with unnamed parameters is
|
// TestUnnamedEventParam checks that an event with unnamed parameters is
|
||||||
// correctly handled
|
// correctly handled.
|
||||||
// The test runs the abi of the following contract.
|
// The test runs the abi of the following contract.
|
||||||
// contract TestEvent {
|
// contract TestEvent {
|
||||||
// event send(uint256, uint256);
|
// event send(uint256, uint256);
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ type ArgumentMarshaling struct {
|
|||||||
Indexed bool
|
Indexed bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalJSON implements json.Unmarshaler interface
|
// UnmarshalJSON implements json.Unmarshaler interface.
|
||||||
func (argument *Argument) UnmarshalJSON(data []byte) error {
|
func (argument *Argument) UnmarshalJSON(data []byte) error {
|
||||||
var arg ArgumentMarshaling
|
var arg ArgumentMarshaling
|
||||||
err := json.Unmarshal(data, &arg)
|
err := json.Unmarshal(data, &arg)
|
||||||
@@ -59,7 +59,7 @@ func (argument *Argument) UnmarshalJSON(data []byte) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NonIndexed returns the arguments with indexed arguments filtered out
|
// NonIndexed returns the arguments with indexed arguments filtered out.
|
||||||
func (arguments Arguments) NonIndexed() Arguments {
|
func (arguments Arguments) NonIndexed() Arguments {
|
||||||
var ret []Argument
|
var ret []Argument
|
||||||
for _, arg := range arguments {
|
for _, arg := range arguments {
|
||||||
@@ -70,44 +70,30 @@ func (arguments Arguments) NonIndexed() Arguments {
|
|||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
// isTuple returns true for non-atomic constructs, like (uint,uint) or uint[]
|
// isTuple returns true for non-atomic constructs, like (uint,uint) or uint[].
|
||||||
func (arguments Arguments) isTuple() bool {
|
func (arguments Arguments) isTuple() bool {
|
||||||
return len(arguments) > 1
|
return len(arguments) > 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unpack performs the operation hexdata -> Go format
|
// Unpack performs the operation hexdata -> Go format.
|
||||||
func (arguments Arguments) Unpack(v interface{}, data []byte) error {
|
func (arguments Arguments) Unpack(data []byte) ([]interface{}, error) {
|
||||||
if len(data) == 0 {
|
if len(data) == 0 {
|
||||||
if len(arguments) != 0 {
|
if len(arguments.NonIndexed()) != 0 {
|
||||||
return fmt.Errorf("abi: attempting to unmarshall an empty string while arguments are expected")
|
return nil, fmt.Errorf("abi: attempting to unmarshall an empty string while arguments are expected")
|
||||||
}
|
}
|
||||||
return nil // Nothing to unmarshal, return
|
return make([]interface{}, 0), nil
|
||||||
}
|
}
|
||||||
// make sure the passed value is arguments pointer
|
return arguments.UnpackValues(data)
|
||||||
if reflect.Ptr != reflect.ValueOf(v).Kind() {
|
|
||||||
return fmt.Errorf("abi: Unpack(non-pointer %T)", v)
|
|
||||||
}
|
|
||||||
marshalledValues, err := arguments.UnpackValues(data)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if len(marshalledValues) == 0 {
|
|
||||||
return fmt.Errorf("abi: Unpack(no-values unmarshalled %T)", v)
|
|
||||||
}
|
|
||||||
if arguments.isTuple() {
|
|
||||||
return arguments.unpackTuple(v, marshalledValues)
|
|
||||||
}
|
|
||||||
return arguments.unpackAtomic(v, marshalledValues[0])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnpackIntoMap performs the operation hexdata -> mapping of argument name to argument value
|
// UnpackIntoMap performs the operation hexdata -> mapping of argument name to argument value.
|
||||||
func (arguments Arguments) UnpackIntoMap(v map[string]interface{}, data []byte) error {
|
func (arguments Arguments) UnpackIntoMap(v map[string]interface{}, data []byte) error {
|
||||||
// Make sure map is not nil
|
// Make sure map is not nil
|
||||||
if v == nil {
|
if v == nil {
|
||||||
return fmt.Errorf("abi: cannot unpack into a nil map")
|
return fmt.Errorf("abi: cannot unpack into a nil map")
|
||||||
}
|
}
|
||||||
if len(data) == 0 {
|
if len(data) == 0 {
|
||||||
if len(arguments) != 0 {
|
if len(arguments.NonIndexed()) != 0 {
|
||||||
return fmt.Errorf("abi: attempting to unmarshall an empty string while arguments are expected")
|
return fmt.Errorf("abi: attempting to unmarshall an empty string while arguments are expected")
|
||||||
}
|
}
|
||||||
return nil // Nothing to unmarshal, return
|
return nil // Nothing to unmarshal, return
|
||||||
@@ -122,19 +108,37 @@ func (arguments Arguments) UnpackIntoMap(v map[string]interface{}, data []byte)
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Copy performs the operation go format -> provided struct.
|
||||||
|
func (arguments Arguments) Copy(v interface{}, values []interface{}) error {
|
||||||
|
// make sure the passed value is arguments pointer
|
||||||
|
if reflect.Ptr != reflect.ValueOf(v).Kind() {
|
||||||
|
return fmt.Errorf("abi: Unpack(non-pointer %T)", v)
|
||||||
|
}
|
||||||
|
if len(values) == 0 {
|
||||||
|
if len(arguments.NonIndexed()) != 0 {
|
||||||
|
return fmt.Errorf("abi: attempting to copy no values while arguments are expected")
|
||||||
|
}
|
||||||
|
return nil // Nothing to copy, return
|
||||||
|
}
|
||||||
|
if arguments.isTuple() {
|
||||||
|
return arguments.copyTuple(v, values)
|
||||||
|
}
|
||||||
|
return arguments.copyAtomic(v, values[0])
|
||||||
|
}
|
||||||
|
|
||||||
// unpackAtomic unpacks ( hexdata -> go ) a single value
|
// unpackAtomic unpacks ( hexdata -> go ) a single value
|
||||||
func (arguments Arguments) unpackAtomic(v interface{}, marshalledValues interface{}) error {
|
func (arguments Arguments) copyAtomic(v interface{}, marshalledValues interface{}) error {
|
||||||
dst := reflect.ValueOf(v).Elem()
|
dst := reflect.ValueOf(v).Elem()
|
||||||
src := reflect.ValueOf(marshalledValues)
|
src := reflect.ValueOf(marshalledValues)
|
||||||
|
|
||||||
if dst.Kind() == reflect.Struct && src.Kind() != reflect.Struct {
|
if dst.Kind() == reflect.Struct {
|
||||||
return set(dst.Field(0), src)
|
return set(dst.Field(0), src)
|
||||||
}
|
}
|
||||||
return set(dst, src)
|
return set(dst, src)
|
||||||
}
|
}
|
||||||
|
|
||||||
// unpackTuple unpacks ( hexdata -> go ) a batch of values.
|
// copyTuple copies a batch of values from marshalledValues to v.
|
||||||
func (arguments Arguments) unpackTuple(v interface{}, marshalledValues []interface{}) error {
|
func (arguments Arguments) copyTuple(v interface{}, marshalledValues []interface{}) error {
|
||||||
value := reflect.ValueOf(v).Elem()
|
value := reflect.ValueOf(v).Elem()
|
||||||
nonIndexedArgs := arguments.NonIndexed()
|
nonIndexedArgs := arguments.NonIndexed()
|
||||||
|
|
||||||
@@ -207,13 +211,13 @@ func (arguments Arguments) UnpackValues(data []byte) ([]interface{}, error) {
|
|||||||
return retval, nil
|
return retval, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PackValues performs the operation Go format -> Hexdata
|
// PackValues performs the operation Go format -> Hexdata.
|
||||||
// It is the semantic opposite of UnpackValues
|
// It is the semantic opposite of UnpackValues.
|
||||||
func (arguments Arguments) PackValues(args []interface{}) ([]byte, error) {
|
func (arguments Arguments) PackValues(args []interface{}) ([]byte, error) {
|
||||||
return arguments.Pack(args...)
|
return arguments.Pack(args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pack performs the operation Go format -> Hexdata
|
// Pack performs the operation Go format -> Hexdata.
|
||||||
func (arguments Arguments) Pack(args ...interface{}) ([]byte, error) {
|
func (arguments Arguments) Pack(args ...interface{}) ([]byte, error) {
|
||||||
// Make sure arguments match up and pack them
|
// Make sure arguments match up and pack them
|
||||||
abiArgs := arguments
|
abiArgs := arguments
|
||||||
|
|||||||
@@ -17,10 +17,11 @@
|
|||||||
package bind
|
package bind
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"math/big"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/accounts"
|
"github.com/ethereum/go-ethereum/accounts"
|
||||||
"github.com/ethereum/go-ethereum/accounts/external"
|
"github.com/ethereum/go-ethereum/accounts/external"
|
||||||
@@ -28,12 +29,22 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
|
"github.com/ethereum/go-ethereum/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ErrNoChainID is returned whenever the user failed to specify a chain id.
|
||||||
|
var ErrNoChainID = errors.New("no chain id specified")
|
||||||
|
|
||||||
|
// ErrNotAuthorized is returned when an account is not properly unlocked.
|
||||||
|
var ErrNotAuthorized = errors.New("not authorized to sign this account")
|
||||||
|
|
||||||
// NewTransactor is a utility method to easily create a transaction signer from
|
// NewTransactor is a utility method to easily create a transaction signer from
|
||||||
// an encrypted json key stream and the associated passphrase.
|
// an encrypted json key stream and the associated passphrase.
|
||||||
|
//
|
||||||
|
// Deprecated: Use NewTransactorWithChainID instead.
|
||||||
func NewTransactor(keyin io.Reader, passphrase string) (*TransactOpts, error) {
|
func NewTransactor(keyin io.Reader, passphrase string) (*TransactOpts, error) {
|
||||||
json, err := ioutil.ReadAll(keyin)
|
log.Warn("WARNING: NewTransactor has been deprecated in favour of NewTransactorWithChainID")
|
||||||
|
json, err := io.ReadAll(keyin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -45,13 +56,17 @@ func NewTransactor(keyin io.Reader, passphrase string) (*TransactOpts, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewKeyStoreTransactor is a utility method to easily create a transaction signer from
|
// NewKeyStoreTransactor is a utility method to easily create a transaction signer from
|
||||||
// an decrypted key from a keystore
|
// an decrypted key from a keystore.
|
||||||
|
//
|
||||||
|
// Deprecated: Use NewKeyStoreTransactorWithChainID instead.
|
||||||
func NewKeyStoreTransactor(keystore *keystore.KeyStore, account accounts.Account) (*TransactOpts, error) {
|
func NewKeyStoreTransactor(keystore *keystore.KeyStore, account accounts.Account) (*TransactOpts, error) {
|
||||||
|
log.Warn("WARNING: NewKeyStoreTransactor has been deprecated in favour of NewTransactorWithChainID")
|
||||||
|
signer := types.HomesteadSigner{}
|
||||||
return &TransactOpts{
|
return &TransactOpts{
|
||||||
From: account.Address,
|
From: account.Address,
|
||||||
Signer: func(signer types.Signer, address common.Address, tx *types.Transaction) (*types.Transaction, error) {
|
Signer: func(address common.Address, tx *types.Transaction) (*types.Transaction, error) {
|
||||||
if address != account.Address {
|
if address != account.Address {
|
||||||
return nil, errors.New("not authorized to sign this account")
|
return nil, ErrNotAuthorized
|
||||||
}
|
}
|
||||||
signature, err := keystore.SignHash(account, signer.Hash(tx).Bytes())
|
signature, err := keystore.SignHash(account, signer.Hash(tx).Bytes())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -59,18 +74,23 @@ func NewKeyStoreTransactor(keystore *keystore.KeyStore, account accounts.Account
|
|||||||
}
|
}
|
||||||
return tx.WithSignature(signer, signature)
|
return tx.WithSignature(signer, signature)
|
||||||
},
|
},
|
||||||
|
Context: context.Background(),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewKeyedTransactor is a utility method to easily create a transaction signer
|
// NewKeyedTransactor is a utility method to easily create a transaction signer
|
||||||
// from a single private key.
|
// from a single private key.
|
||||||
|
//
|
||||||
|
// Deprecated: Use NewKeyedTransactorWithChainID instead.
|
||||||
func NewKeyedTransactor(key *ecdsa.PrivateKey) *TransactOpts {
|
func NewKeyedTransactor(key *ecdsa.PrivateKey) *TransactOpts {
|
||||||
|
log.Warn("WARNING: NewKeyedTransactor has been deprecated in favour of NewKeyedTransactorWithChainID")
|
||||||
keyAddr := crypto.PubkeyToAddress(key.PublicKey)
|
keyAddr := crypto.PubkeyToAddress(key.PublicKey)
|
||||||
|
signer := types.HomesteadSigner{}
|
||||||
return &TransactOpts{
|
return &TransactOpts{
|
||||||
From: keyAddr,
|
From: keyAddr,
|
||||||
Signer: func(signer types.Signer, address common.Address, tx *types.Transaction) (*types.Transaction, error) {
|
Signer: func(address common.Address, tx *types.Transaction) (*types.Transaction, error) {
|
||||||
if address != keyAddr {
|
if address != keyAddr {
|
||||||
return nil, errors.New("not authorized to sign this account")
|
return nil, ErrNotAuthorized
|
||||||
}
|
}
|
||||||
signature, err := crypto.Sign(signer.Hash(tx).Bytes(), key)
|
signature, err := crypto.Sign(signer.Hash(tx).Bytes(), key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -78,19 +98,82 @@ func NewKeyedTransactor(key *ecdsa.PrivateKey) *TransactOpts {
|
|||||||
}
|
}
|
||||||
return tx.WithSignature(signer, signature)
|
return tx.WithSignature(signer, signature)
|
||||||
},
|
},
|
||||||
|
Context: context.Background(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewTransactorWithChainID is a utility method to easily create a transaction signer from
|
||||||
|
// an encrypted json key stream and the associated passphrase.
|
||||||
|
func NewTransactorWithChainID(keyin io.Reader, passphrase string, chainID *big.Int) (*TransactOpts, error) {
|
||||||
|
json, err := io.ReadAll(keyin)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
key, err := keystore.DecryptKey(json, passphrase)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return NewKeyedTransactorWithChainID(key.PrivateKey, chainID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewKeyStoreTransactorWithChainID is a utility method to easily create a transaction signer from
|
||||||
|
// an decrypted key from a keystore.
|
||||||
|
func NewKeyStoreTransactorWithChainID(keystore *keystore.KeyStore, account accounts.Account, chainID *big.Int) (*TransactOpts, error) {
|
||||||
|
if chainID == nil {
|
||||||
|
return nil, ErrNoChainID
|
||||||
|
}
|
||||||
|
signer := types.LatestSignerForChainID(chainID)
|
||||||
|
return &TransactOpts{
|
||||||
|
From: account.Address,
|
||||||
|
Signer: func(address common.Address, tx *types.Transaction) (*types.Transaction, error) {
|
||||||
|
if address != account.Address {
|
||||||
|
return nil, ErrNotAuthorized
|
||||||
|
}
|
||||||
|
signature, err := keystore.SignHash(account, signer.Hash(tx).Bytes())
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return tx.WithSignature(signer, signature)
|
||||||
|
},
|
||||||
|
Context: context.Background(),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewKeyedTransactorWithChainID is a utility method to easily create a transaction signer
|
||||||
|
// from a single private key.
|
||||||
|
func NewKeyedTransactorWithChainID(key *ecdsa.PrivateKey, chainID *big.Int) (*TransactOpts, error) {
|
||||||
|
keyAddr := crypto.PubkeyToAddress(key.PublicKey)
|
||||||
|
if chainID == nil {
|
||||||
|
return nil, ErrNoChainID
|
||||||
|
}
|
||||||
|
signer := types.LatestSignerForChainID(chainID)
|
||||||
|
return &TransactOpts{
|
||||||
|
From: keyAddr,
|
||||||
|
Signer: func(address common.Address, tx *types.Transaction) (*types.Transaction, error) {
|
||||||
|
if address != keyAddr {
|
||||||
|
return nil, ErrNotAuthorized
|
||||||
|
}
|
||||||
|
signature, err := crypto.Sign(signer.Hash(tx).Bytes(), key)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return tx.WithSignature(signer, signature)
|
||||||
|
},
|
||||||
|
Context: context.Background(),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
// NewClefTransactor is a utility method to easily create a transaction signer
|
// NewClefTransactor is a utility method to easily create a transaction signer
|
||||||
// with a clef backend.
|
// with a clef backend.
|
||||||
func NewClefTransactor(clef *external.ExternalSigner, account accounts.Account) *TransactOpts {
|
func NewClefTransactor(clef *external.ExternalSigner, account accounts.Account) *TransactOpts {
|
||||||
return &TransactOpts{
|
return &TransactOpts{
|
||||||
From: account.Address,
|
From: account.Address,
|
||||||
Signer: func(signer types.Signer, address common.Address, transaction *types.Transaction) (*types.Transaction, error) {
|
Signer: func(address common.Address, transaction *types.Transaction) (*types.Transaction, error) {
|
||||||
if address != account.Address {
|
if address != account.Address {
|
||||||
return nil, errors.New("not authorized to sign this account")
|
return nil, ErrNotAuthorized
|
||||||
}
|
}
|
||||||
return clef.SignTx(account, transaction, nil) // Clef enforces its own chain id
|
return clef.SignTx(account, transaction, nil) // Clef enforces its own chain id
|
||||||
},
|
},
|
||||||
|
Context: context.Background(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,22 +32,23 @@ var (
|
|||||||
// have any code associated with it (i.e. suicided).
|
// have any code associated with it (i.e. suicided).
|
||||||
ErrNoCode = errors.New("no contract code at given address")
|
ErrNoCode = errors.New("no contract code at given address")
|
||||||
|
|
||||||
// This error is raised when attempting to perform a pending state action
|
// ErrNoPendingState is raised when attempting to perform a pending state action
|
||||||
// on a backend that doesn't implement PendingContractCaller.
|
// on a backend that doesn't implement PendingContractCaller.
|
||||||
ErrNoPendingState = errors.New("backend does not support pending state")
|
ErrNoPendingState = errors.New("backend does not support pending state")
|
||||||
|
|
||||||
// This error is returned by WaitDeployed if contract creation leaves an
|
// ErrNoCodeAfterDeploy is returned by WaitDeployed if contract creation leaves
|
||||||
// empty contract behind.
|
// an empty contract behind.
|
||||||
ErrNoCodeAfterDeploy = errors.New("no contract code after deployment")
|
ErrNoCodeAfterDeploy = errors.New("no contract code after deployment")
|
||||||
)
|
)
|
||||||
|
|
||||||
// ContractCaller defines the methods needed to allow operating with contract on a read
|
// ContractCaller defines the methods needed to allow operating with a contract on a read
|
||||||
// only basis.
|
// only basis.
|
||||||
type ContractCaller interface {
|
type ContractCaller interface {
|
||||||
// CodeAt returns the code of the given account. This is needed to differentiate
|
// CodeAt returns the code of the given account. This is needed to differentiate
|
||||||
// between contract internal errors and the local chain being out of sync.
|
// between contract internal errors and the local chain being out of sync.
|
||||||
CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error)
|
CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error)
|
||||||
// ContractCall executes an Ethereum contract call with the specified data as the
|
|
||||||
|
// CallContract executes an Ethereum contract call with the specified data as the
|
||||||
// input.
|
// input.
|
||||||
CallContract(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
|
CallContract(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
|
||||||
}
|
}
|
||||||
@@ -58,28 +59,41 @@ type ContractCaller interface {
|
|||||||
type PendingContractCaller interface {
|
type PendingContractCaller interface {
|
||||||
// PendingCodeAt returns the code of the given account in the pending state.
|
// PendingCodeAt returns the code of the given account in the pending state.
|
||||||
PendingCodeAt(ctx context.Context, contract common.Address) ([]byte, error)
|
PendingCodeAt(ctx context.Context, contract common.Address) ([]byte, error)
|
||||||
|
|
||||||
// PendingCallContract executes an Ethereum contract call against the pending state.
|
// PendingCallContract executes an Ethereum contract call against the pending state.
|
||||||
PendingCallContract(ctx context.Context, call ethereum.CallMsg) ([]byte, error)
|
PendingCallContract(ctx context.Context, call ethereum.CallMsg) ([]byte, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContractTransactor defines the methods needed to allow operating with contract
|
// ContractTransactor defines the methods needed to allow operating with a contract
|
||||||
// on a write only basis. Beside the transacting method, the remainder are helpers
|
// on a write only basis. Besides the transacting method, the remainder are helpers
|
||||||
// used when the user does not provide some needed values, but rather leaves it up
|
// used when the user does not provide some needed values, but rather leaves it up
|
||||||
// to the transactor to decide.
|
// to the transactor to decide.
|
||||||
type ContractTransactor interface {
|
type ContractTransactor interface {
|
||||||
|
// HeaderByNumber returns a block header from the current canonical chain. If
|
||||||
|
// number is nil, the latest known header is returned.
|
||||||
|
HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
|
||||||
|
|
||||||
// PendingCodeAt returns the code of the given account in the pending state.
|
// PendingCodeAt returns the code of the given account in the pending state.
|
||||||
PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error)
|
PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error)
|
||||||
|
|
||||||
// PendingNonceAt retrieves the current pending nonce associated with an account.
|
// PendingNonceAt retrieves the current pending nonce associated with an account.
|
||||||
PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
|
PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
|
||||||
|
|
||||||
// SuggestGasPrice retrieves the currently suggested gas price to allow a timely
|
// SuggestGasPrice retrieves the currently suggested gas price to allow a timely
|
||||||
// execution of a transaction.
|
// execution of a transaction.
|
||||||
SuggestGasPrice(ctx context.Context) (*big.Int, error)
|
SuggestGasPrice(ctx context.Context) (*big.Int, error)
|
||||||
|
|
||||||
|
// SuggestGasTipCap retrieves the currently suggested 1559 priority fee to allow
|
||||||
|
// a timely execution of a transaction.
|
||||||
|
SuggestGasTipCap(ctx context.Context) (*big.Int, error)
|
||||||
|
|
||||||
// EstimateGas tries to estimate the gas needed to execute a specific
|
// EstimateGas tries to estimate the gas needed to execute a specific
|
||||||
// transaction based on the current pending state of the backend blockchain.
|
// transaction based on the current pending state of the backend blockchain.
|
||||||
// There is no guarantee that this is the true gas limit requirement as other
|
// There is no guarantee that this is the true gas limit requirement as other
|
||||||
// transactions may be added or removed by miners, but it should provide a basis
|
// transactions may be added or removed by miners, but it should provide a basis
|
||||||
// for setting a reasonable default.
|
// for setting a reasonable default.
|
||||||
EstimateGas(ctx context.Context, call ethereum.CallMsg) (gas uint64, err error)
|
EstimateGas(ctx context.Context, call ethereum.CallMsg) (gas uint64, err error)
|
||||||
|
|
||||||
// SendTransaction injects the transaction into the pending pool for execution.
|
// SendTransaction injects the transaction into the pending pool for execution.
|
||||||
SendTransaction(ctx context.Context, tx *types.Transaction) error
|
SendTransaction(ctx context.Context, tx *types.Transaction) error
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,9 +63,10 @@ type SimulatedBackend struct {
|
|||||||
database ethdb.Database // In memory database to store our testing data
|
database ethdb.Database // In memory database to store our testing data
|
||||||
blockchain *core.BlockChain // Ethereum blockchain to handle the consensus
|
blockchain *core.BlockChain // Ethereum blockchain to handle the consensus
|
||||||
|
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
pendingBlock *types.Block // Currently pending block that will be imported on request
|
pendingBlock *types.Block // Currently pending block that will be imported on request
|
||||||
pendingState *state.StateDB // Currently pending state that will be the active on request
|
pendingState *state.StateDB // Currently pending state that will be the active on request
|
||||||
|
pendingReceipts types.Receipts // Currently receipts for the pending block
|
||||||
|
|
||||||
events *filters.EventSystem // Event system for filtering log events live
|
events *filters.EventSystem // Event system for filtering log events live
|
||||||
|
|
||||||
@@ -74,6 +75,7 @@ type SimulatedBackend struct {
|
|||||||
|
|
||||||
// NewSimulatedBackendWithDatabase creates a new binding backend based on the given database
|
// NewSimulatedBackendWithDatabase creates a new binding backend based on the given database
|
||||||
// and uses a simulated blockchain for testing purposes.
|
// and uses a simulated blockchain for testing purposes.
|
||||||
|
// A simulated backend always uses chainID 1337.
|
||||||
func NewSimulatedBackendWithDatabase(database ethdb.Database, alloc core.GenesisAlloc, gasLimit uint64) *SimulatedBackend {
|
func NewSimulatedBackendWithDatabase(database ethdb.Database, alloc core.GenesisAlloc, gasLimit uint64) *SimulatedBackend {
|
||||||
genesis := core.Genesis{Config: params.AllEthashProtocolChanges, GasLimit: gasLimit, Alloc: alloc}
|
genesis := core.Genesis{Config: params.AllEthashProtocolChanges, GasLimit: gasLimit, Alloc: alloc}
|
||||||
genesis.MustCommit(database)
|
genesis.MustCommit(database)
|
||||||
@@ -83,14 +85,15 @@ func NewSimulatedBackendWithDatabase(database ethdb.Database, alloc core.Genesis
|
|||||||
database: database,
|
database: database,
|
||||||
blockchain: blockchain,
|
blockchain: blockchain,
|
||||||
config: genesis.Config,
|
config: genesis.Config,
|
||||||
events: filters.NewEventSystem(&filterBackend{database, blockchain}, false),
|
|
||||||
}
|
}
|
||||||
backend.rollback()
|
backend.events = filters.NewEventSystem(&filterBackend{database, blockchain, backend}, false)
|
||||||
|
backend.rollback(blockchain.CurrentBlock())
|
||||||
return backend
|
return backend
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewSimulatedBackend creates a new binding backend using a simulated blockchain
|
// NewSimulatedBackend creates a new binding backend using a simulated blockchain
|
||||||
// for testing purposes.
|
// for testing purposes.
|
||||||
|
// A simulated backend always uses chainID 1337.
|
||||||
func NewSimulatedBackend(alloc core.GenesisAlloc, gasLimit uint64) *SimulatedBackend {
|
func NewSimulatedBackend(alloc core.GenesisAlloc, gasLimit uint64) *SimulatedBackend {
|
||||||
return NewSimulatedBackendWithDatabase(rawdb.NewMemoryDatabase(), alloc, gasLimit)
|
return NewSimulatedBackendWithDatabase(rawdb.NewMemoryDatabase(), alloc, gasLimit)
|
||||||
}
|
}
|
||||||
@@ -110,7 +113,9 @@ func (b *SimulatedBackend) Commit() {
|
|||||||
if _, err := b.blockchain.InsertChain([]*types.Block{b.pendingBlock}); err != nil {
|
if _, err := b.blockchain.InsertChain([]*types.Block{b.pendingBlock}); err != nil {
|
||||||
panic(err) // This cannot happen unless the simulator is wrong, fail in that case
|
panic(err) // This cannot happen unless the simulator is wrong, fail in that case
|
||||||
}
|
}
|
||||||
b.rollback()
|
// Using the last inserted block here makes it possible to build on a side
|
||||||
|
// chain after a fork.
|
||||||
|
b.rollback(b.pendingBlock)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rollback aborts all pending transactions, reverting to the last committed state.
|
// Rollback aborts all pending transactions, reverting to the last committed state.
|
||||||
@@ -118,15 +123,41 @@ func (b *SimulatedBackend) Rollback() {
|
|||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
defer b.mu.Unlock()
|
defer b.mu.Unlock()
|
||||||
|
|
||||||
b.rollback()
|
b.rollback(b.blockchain.CurrentBlock())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *SimulatedBackend) rollback() {
|
func (b *SimulatedBackend) rollback(parent *types.Block) {
|
||||||
blocks, _ := core.GenerateChain(b.config, b.blockchain.CurrentBlock(), ethash.NewFaker(), b.database, 1, func(int, *core.BlockGen) {})
|
blocks, _ := core.GenerateChain(b.config, parent, ethash.NewFaker(), b.database, 1, func(int, *core.BlockGen) {})
|
||||||
stateDB, _ := b.blockchain.State()
|
|
||||||
|
|
||||||
b.pendingBlock = blocks[0]
|
b.pendingBlock = blocks[0]
|
||||||
b.pendingState, _ = state.New(b.pendingBlock.Root(), stateDB.Database(), nil)
|
b.pendingState, _ = state.New(b.pendingBlock.Root(), b.blockchain.StateCache(), nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fork creates a side-chain that can be used to simulate reorgs.
|
||||||
|
//
|
||||||
|
// This function should be called with the ancestor block where the new side
|
||||||
|
// chain should be started. Transactions (old and new) can then be applied on
|
||||||
|
// top and Commit-ed.
|
||||||
|
//
|
||||||
|
// Note, the side-chain will only become canonical (and trigger the events) when
|
||||||
|
// it becomes longer. Until then CallContract will still operate on the current
|
||||||
|
// canonical chain.
|
||||||
|
//
|
||||||
|
// There is a % chance that the side chain becomes canonical at the same length
|
||||||
|
// to simulate live network behavior.
|
||||||
|
func (b *SimulatedBackend) Fork(ctx context.Context, parent common.Hash) error {
|
||||||
|
b.mu.Lock()
|
||||||
|
defer b.mu.Unlock()
|
||||||
|
|
||||||
|
if len(b.pendingBlock.Transactions()) != 0 {
|
||||||
|
return errors.New("pending block dirty")
|
||||||
|
}
|
||||||
|
block, err := b.blockByHash(ctx, parent)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
b.rollback(block)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// stateByBlockNumber retrieves a state by a given blocknumber.
|
// stateByBlockNumber retrieves a state by a given blocknumber.
|
||||||
@@ -134,7 +165,7 @@ func (b *SimulatedBackend) stateByBlockNumber(ctx context.Context, blockNumber *
|
|||||||
if blockNumber == nil || blockNumber.Cmp(b.blockchain.CurrentBlock().Number()) == 0 {
|
if blockNumber == nil || blockNumber.Cmp(b.blockchain.CurrentBlock().Number()) == 0 {
|
||||||
return b.blockchain.State()
|
return b.blockchain.State()
|
||||||
}
|
}
|
||||||
block, err := b.blockByNumberNoLock(ctx, blockNumber)
|
block, err := b.blockByNumber(ctx, blockNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -195,11 +226,14 @@ func (b *SimulatedBackend) StorageAt(ctx context.Context, contract common.Addres
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TransactionReceipt returns the receipt of a transaction.
|
// TransactionReceipt returns the receipt of a transaction.
|
||||||
func (b *SimulatedBackend) TransactionReceipt(_ context.Context, txHash common.Hash) (*types.Receipt, error) {
|
func (b *SimulatedBackend) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error) {
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
defer b.mu.Unlock()
|
defer b.mu.Unlock()
|
||||||
|
|
||||||
receipt, _, _, _ := rawdb.ReadReceipt(b.database, txHash, b.config)
|
receipt, _, _, _ := rawdb.ReadReceipt(b.database, txHash, b.config)
|
||||||
|
if receipt == nil {
|
||||||
|
return nil, ethereum.NotFound
|
||||||
|
}
|
||||||
return receipt, nil
|
return receipt, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,7 +241,7 @@ func (b *SimulatedBackend) TransactionReceipt(_ context.Context, txHash common.H
|
|||||||
// blockchain. The isPending return value indicates whether the transaction has been
|
// blockchain. The isPending return value indicates whether the transaction has been
|
||||||
// mined yet. Note that the transaction may not be part of the canonical chain even if
|
// mined yet. Note that the transaction may not be part of the canonical chain even if
|
||||||
// it's not pending.
|
// it's not pending.
|
||||||
func (b *SimulatedBackend) TransactionByHash(_ context.Context, txHash common.Hash) (*types.Transaction, bool, error) {
|
func (b *SimulatedBackend) TransactionByHash(ctx context.Context, txHash common.Hash) (*types.Transaction, bool, error) {
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
defer b.mu.Unlock()
|
defer b.mu.Unlock()
|
||||||
|
|
||||||
@@ -223,10 +257,15 @@ func (b *SimulatedBackend) TransactionByHash(_ context.Context, txHash common.Ha
|
|||||||
}
|
}
|
||||||
|
|
||||||
// BlockByHash retrieves a block based on the block hash.
|
// BlockByHash retrieves a block based on the block hash.
|
||||||
func (b *SimulatedBackend) BlockByHash(_ context.Context, hash common.Hash) (*types.Block, error) {
|
func (b *SimulatedBackend) BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error) {
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
defer b.mu.Unlock()
|
defer b.mu.Unlock()
|
||||||
|
|
||||||
|
return b.blockByHash(ctx, hash)
|
||||||
|
}
|
||||||
|
|
||||||
|
// blockByHash retrieves a block based on the block hash without Locking.
|
||||||
|
func (b *SimulatedBackend) blockByHash(ctx context.Context, hash common.Hash) (*types.Block, error) {
|
||||||
if hash == b.pendingBlock.Hash() {
|
if hash == b.pendingBlock.Hash() {
|
||||||
return b.pendingBlock, nil
|
return b.pendingBlock, nil
|
||||||
}
|
}
|
||||||
@@ -245,12 +284,12 @@ func (b *SimulatedBackend) BlockByNumber(ctx context.Context, number *big.Int) (
|
|||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
defer b.mu.Unlock()
|
defer b.mu.Unlock()
|
||||||
|
|
||||||
return b.blockByNumberNoLock(ctx, number)
|
return b.blockByNumber(ctx, number)
|
||||||
}
|
}
|
||||||
|
|
||||||
// blockByNumberNoLock retrieves a block from the database by number, caching it
|
// blockByNumber retrieves a block from the database by number, caching it
|
||||||
// (associated with its hash) if found without Lock.
|
// (associated with its hash) if found without Lock.
|
||||||
func (b *SimulatedBackend) blockByNumberNoLock(_ context.Context, number *big.Int) (*types.Block, error) {
|
func (b *SimulatedBackend) blockByNumber(ctx context.Context, number *big.Int) (*types.Block, error) {
|
||||||
if number == nil || number.Cmp(b.pendingBlock.Number()) == 0 {
|
if number == nil || number.Cmp(b.pendingBlock.Number()) == 0 {
|
||||||
return b.blockchain.CurrentBlock(), nil
|
return b.blockchain.CurrentBlock(), nil
|
||||||
}
|
}
|
||||||
@@ -264,7 +303,7 @@ func (b *SimulatedBackend) blockByNumberNoLock(_ context.Context, number *big.In
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HeaderByHash returns a block header from the current canonical chain.
|
// HeaderByHash returns a block header from the current canonical chain.
|
||||||
func (b *SimulatedBackend) HeaderByHash(_ context.Context, hash common.Hash) (*types.Header, error) {
|
func (b *SimulatedBackend) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error) {
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
defer b.mu.Unlock()
|
defer b.mu.Unlock()
|
||||||
|
|
||||||
@@ -282,7 +321,7 @@ func (b *SimulatedBackend) HeaderByHash(_ context.Context, hash common.Hash) (*t
|
|||||||
|
|
||||||
// HeaderByNumber returns a block header from the current canonical chain. If number is
|
// HeaderByNumber returns a block header from the current canonical chain. If number is
|
||||||
// nil, the latest known header is returned.
|
// nil, the latest known header is returned.
|
||||||
func (b *SimulatedBackend) HeaderByNumber(_ context.Context, block *big.Int) (*types.Header, error) {
|
func (b *SimulatedBackend) HeaderByNumber(ctx context.Context, block *big.Int) (*types.Header, error) {
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
defer b.mu.Unlock()
|
defer b.mu.Unlock()
|
||||||
|
|
||||||
@@ -294,7 +333,7 @@ func (b *SimulatedBackend) HeaderByNumber(_ context.Context, block *big.Int) (*t
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TransactionCount returns the number of transactions in a given block.
|
// TransactionCount returns the number of transactions in a given block.
|
||||||
func (b *SimulatedBackend) TransactionCount(_ context.Context, blockHash common.Hash) (uint, error) {
|
func (b *SimulatedBackend) TransactionCount(ctx context.Context, blockHash common.Hash) (uint, error) {
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
defer b.mu.Unlock()
|
defer b.mu.Unlock()
|
||||||
|
|
||||||
@@ -311,7 +350,7 @@ func (b *SimulatedBackend) TransactionCount(_ context.Context, blockHash common.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TransactionInBlock returns the transaction for a specific block at a specific index.
|
// TransactionInBlock returns the transaction for a specific block at a specific index.
|
||||||
func (b *SimulatedBackend) TransactionInBlock(_ context.Context, blockHash common.Hash, index uint) (*types.Transaction, error) {
|
func (b *SimulatedBackend) TransactionInBlock(ctx context.Context, blockHash common.Hash, index uint) (*types.Transaction, error) {
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
defer b.mu.Unlock()
|
defer b.mu.Unlock()
|
||||||
|
|
||||||
@@ -338,7 +377,7 @@ func (b *SimulatedBackend) TransactionInBlock(_ context.Context, blockHash commo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PendingCodeAt returns the code associated with an account in the pending state.
|
// PendingCodeAt returns the code associated with an account in the pending state.
|
||||||
func (b *SimulatedBackend) PendingCodeAt(_ context.Context, contract common.Address) ([]byte, error) {
|
func (b *SimulatedBackend) PendingCodeAt(ctx context.Context, contract common.Address) ([]byte, error) {
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
defer b.mu.Unlock()
|
defer b.mu.Unlock()
|
||||||
|
|
||||||
@@ -417,7 +456,7 @@ func (b *SimulatedBackend) PendingCallContract(ctx context.Context, call ethereu
|
|||||||
|
|
||||||
// PendingNonceAt implements PendingStateReader.PendingNonceAt, retrieving
|
// PendingNonceAt implements PendingStateReader.PendingNonceAt, retrieving
|
||||||
// the nonce currently pending for the account.
|
// the nonce currently pending for the account.
|
||||||
func (b *SimulatedBackend) PendingNonceAt(_ context.Context, account common.Address) (uint64, error) {
|
func (b *SimulatedBackend) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error) {
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
defer b.mu.Unlock()
|
defer b.mu.Unlock()
|
||||||
|
|
||||||
@@ -426,7 +465,19 @@ func (b *SimulatedBackend) PendingNonceAt(_ context.Context, account common.Addr
|
|||||||
|
|
||||||
// SuggestGasPrice implements ContractTransactor.SuggestGasPrice. Since the simulated
|
// SuggestGasPrice implements ContractTransactor.SuggestGasPrice. Since the simulated
|
||||||
// chain doesn't have miners, we just return a gas price of 1 for any call.
|
// chain doesn't have miners, we just return a gas price of 1 for any call.
|
||||||
func (b *SimulatedBackend) SuggestGasPrice(_ context.Context) (*big.Int, error) {
|
func (b *SimulatedBackend) SuggestGasPrice(ctx context.Context) (*big.Int, error) {
|
||||||
|
b.mu.Lock()
|
||||||
|
defer b.mu.Unlock()
|
||||||
|
|
||||||
|
if b.pendingBlock.Header().BaseFee != nil {
|
||||||
|
return b.pendingBlock.Header().BaseFee, nil
|
||||||
|
}
|
||||||
|
return big.NewInt(1), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SuggestGasTipCap implements ContractTransactor.SuggestGasTipCap. Since the simulated
|
||||||
|
// chain doesn't have miners, we just return a gas tip of 1 for any call.
|
||||||
|
func (b *SimulatedBackend) SuggestGasTipCap(ctx context.Context) (*big.Int, error) {
|
||||||
return big.NewInt(1), nil
|
return big.NewInt(1), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -447,8 +498,19 @@ func (b *SimulatedBackend) EstimateGas(ctx context.Context, call ethereum.CallMs
|
|||||||
} else {
|
} else {
|
||||||
hi = b.pendingBlock.GasLimit()
|
hi = b.pendingBlock.GasLimit()
|
||||||
}
|
}
|
||||||
|
// Normalize the max fee per gas the call is willing to spend.
|
||||||
|
var feeCap *big.Int
|
||||||
|
if call.GasPrice != nil && (call.GasFeeCap != nil || call.GasTipCap != nil) {
|
||||||
|
return 0, errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified")
|
||||||
|
} else if call.GasPrice != nil {
|
||||||
|
feeCap = call.GasPrice
|
||||||
|
} else if call.GasFeeCap != nil {
|
||||||
|
feeCap = call.GasFeeCap
|
||||||
|
} else {
|
||||||
|
feeCap = common.Big0
|
||||||
|
}
|
||||||
// Recap the highest gas allowance with account's balance.
|
// Recap the highest gas allowance with account's balance.
|
||||||
if call.GasPrice != nil && call.GasPrice.BitLen() != 0 {
|
if feeCap.BitLen() != 0 {
|
||||||
balance := b.pendingState.GetBalance(call.From) // from can't be nil
|
balance := b.pendingState.GetBalance(call.From) // from can't be nil
|
||||||
available := new(big.Int).Set(balance)
|
available := new(big.Int).Set(balance)
|
||||||
if call.Value != nil {
|
if call.Value != nil {
|
||||||
@@ -457,14 +519,14 @@ func (b *SimulatedBackend) EstimateGas(ctx context.Context, call ethereum.CallMs
|
|||||||
}
|
}
|
||||||
available.Sub(available, call.Value)
|
available.Sub(available, call.Value)
|
||||||
}
|
}
|
||||||
allowance := new(big.Int).Div(available, call.GasPrice)
|
allowance := new(big.Int).Div(available, feeCap)
|
||||||
if allowance.IsUint64() && hi > allowance.Uint64() {
|
if allowance.IsUint64() && hi > allowance.Uint64() {
|
||||||
transfer := call.Value
|
transfer := call.Value
|
||||||
if transfer == nil {
|
if transfer == nil {
|
||||||
transfer = new(big.Int)
|
transfer = new(big.Int)
|
||||||
}
|
}
|
||||||
log.Warn("Gas estimation capped by limited funds", "original", hi, "balance", balance,
|
log.Warn("Gas estimation capped by limited funds", "original", hi, "balance", balance,
|
||||||
"sent", transfer, "gasprice", call.GasPrice, "fundable", allowance)
|
"sent", transfer, "feecap", feeCap, "fundable", allowance)
|
||||||
hi = allowance.Uint64()
|
hi = allowance.Uint64()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -479,7 +541,7 @@ func (b *SimulatedBackend) EstimateGas(ctx context.Context, call ethereum.CallMs
|
|||||||
b.pendingState.RevertToSnapshot(snapshot)
|
b.pendingState.RevertToSnapshot(snapshot)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == core.ErrIntrinsicGas {
|
if errors.Is(err, core.ErrIntrinsicGas) {
|
||||||
return true, nil, nil // Special case, raise gas limit
|
return true, nil, nil // Special case, raise gas limit
|
||||||
}
|
}
|
||||||
return true, nil, err // Bail out
|
return true, nil, err // Bail out
|
||||||
@@ -525,11 +587,39 @@ func (b *SimulatedBackend) EstimateGas(ctx context.Context, call ethereum.CallMs
|
|||||||
|
|
||||||
// callContract implements common code between normal and pending contract calls.
|
// callContract implements common code between normal and pending contract calls.
|
||||||
// state is modified during execution, make sure to copy it if necessary.
|
// state is modified during execution, make sure to copy it if necessary.
|
||||||
func (b *SimulatedBackend) callContract(_ context.Context, call ethereum.CallMsg, block *types.Block, stateDB *state.StateDB) (*core.ExecutionResult, error) {
|
func (b *SimulatedBackend) callContract(ctx context.Context, call ethereum.CallMsg, block *types.Block, stateDB *state.StateDB) (*core.ExecutionResult, error) {
|
||||||
// Ensure message is initialized properly.
|
// Gas prices post 1559 need to be initialized
|
||||||
if call.GasPrice == nil {
|
if call.GasPrice != nil && (call.GasFeeCap != nil || call.GasTipCap != nil) {
|
||||||
call.GasPrice = big.NewInt(1)
|
return nil, errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified")
|
||||||
}
|
}
|
||||||
|
head := b.blockchain.CurrentHeader()
|
||||||
|
if !b.blockchain.Config().IsLondon(head.Number) {
|
||||||
|
// If there's no basefee, then it must be a non-1559 execution
|
||||||
|
if call.GasPrice == nil {
|
||||||
|
call.GasPrice = new(big.Int)
|
||||||
|
}
|
||||||
|
call.GasFeeCap, call.GasTipCap = call.GasPrice, call.GasPrice
|
||||||
|
} else {
|
||||||
|
// A basefee is provided, necessitating 1559-type execution
|
||||||
|
if call.GasPrice != nil {
|
||||||
|
// User specified the legacy gas field, convert to 1559 gas typing
|
||||||
|
call.GasFeeCap, call.GasTipCap = call.GasPrice, call.GasPrice
|
||||||
|
} else {
|
||||||
|
// User specified 1559 gas feilds (or none), use those
|
||||||
|
if call.GasFeeCap == nil {
|
||||||
|
call.GasFeeCap = new(big.Int)
|
||||||
|
}
|
||||||
|
if call.GasTipCap == nil {
|
||||||
|
call.GasTipCap = new(big.Int)
|
||||||
|
}
|
||||||
|
// Backfill the legacy gasPrice for EVM execution, unless we're all zeroes
|
||||||
|
call.GasPrice = new(big.Int)
|
||||||
|
if call.GasFeeCap.BitLen() > 0 || call.GasTipCap.BitLen() > 0 {
|
||||||
|
call.GasPrice = math.BigMin(new(big.Int).Add(call.GasTipCap, head.BaseFee), call.GasFeeCap)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Ensure message is initialized properly.
|
||||||
if call.Gas == 0 {
|
if call.Gas == 0 {
|
||||||
call.Gas = 50000000
|
call.Gas = 50000000
|
||||||
}
|
}
|
||||||
@@ -542,31 +632,38 @@ func (b *SimulatedBackend) callContract(_ context.Context, call ethereum.CallMsg
|
|||||||
// Execute the call.
|
// Execute the call.
|
||||||
msg := callMsg{call}
|
msg := callMsg{call}
|
||||||
|
|
||||||
evmContext := core.NewEVMContext(msg, block.Header(), b.blockchain, nil)
|
txContext := core.NewEVMTxContext(msg)
|
||||||
|
evmContext := core.NewEVMBlockContext(block.Header(), b.blockchain, nil)
|
||||||
// Create a new environment which holds all relevant information
|
// Create a new environment which holds all relevant information
|
||||||
// about the transaction and calling mechanisms.
|
// about the transaction and calling mechanisms.
|
||||||
vmEnv := vm.NewEVM(evmContext, stateDB, b.config, vm.Config{})
|
vmEnv := vm.NewEVM(evmContext, txContext, stateDB, b.config, vm.Config{NoBaseFee: true})
|
||||||
gasPool := new(core.GasPool).AddGas(math.MaxUint64)
|
gasPool := new(core.GasPool).AddGas(math.MaxUint64)
|
||||||
|
|
||||||
return core.NewStateTransition(vmEnv, msg, gasPool).TransitionDb()
|
return core.NewStateTransition(vmEnv, msg, gasPool).TransitionDb()
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendTransaction updates the pending block to include the given transaction.
|
// SendTransaction updates the pending block to include the given transaction.
|
||||||
// It panics if the transaction is invalid.
|
func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transaction) error {
|
||||||
func (b *SimulatedBackend) SendTransaction(_ context.Context, tx *types.Transaction) error {
|
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
defer b.mu.Unlock()
|
defer b.mu.Unlock()
|
||||||
|
|
||||||
sender, err := types.Sender(types.NewEIP155Signer(b.config.ChainID), tx)
|
// Get the last block
|
||||||
|
block, err := b.blockByHash(ctx, b.pendingBlock.ParentHash())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Errorf("invalid transaction: %v", err))
|
return fmt.Errorf("could not fetch parent")
|
||||||
|
}
|
||||||
|
// Check transaction validity
|
||||||
|
signer := types.MakeSigner(b.blockchain.Config(), block.Number())
|
||||||
|
sender, err := types.Sender(signer, tx)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("invalid transaction: %v", err)
|
||||||
}
|
}
|
||||||
nonce := b.pendingState.GetNonce(sender)
|
nonce := b.pendingState.GetNonce(sender)
|
||||||
if tx.Nonce() != nonce {
|
if tx.Nonce() != nonce {
|
||||||
panic(fmt.Errorf("invalid transaction nonce: got %d, want %d", tx.Nonce(), nonce))
|
return fmt.Errorf("invalid transaction nonce: got %d, want %d", tx.Nonce(), nonce)
|
||||||
}
|
}
|
||||||
|
// Include tx in chain
|
||||||
blocks, _ := core.GenerateChain(b.config, b.blockchain.CurrentBlock(), ethash.NewFaker(), b.database, 1, func(number int, block *core.BlockGen) {
|
blocks, receipts := core.GenerateChain(b.config, block, ethash.NewFaker(), b.database, 1, func(number int, block *core.BlockGen) {
|
||||||
for _, tx := range b.pendingBlock.Transactions() {
|
for _, tx := range b.pendingBlock.Transactions() {
|
||||||
block.AddTxWithChain(b.blockchain, tx)
|
block.AddTxWithChain(b.blockchain, tx)
|
||||||
}
|
}
|
||||||
@@ -576,6 +673,7 @@ func (b *SimulatedBackend) SendTransaction(_ context.Context, tx *types.Transact
|
|||||||
|
|
||||||
b.pendingBlock = blocks[0]
|
b.pendingBlock = blocks[0]
|
||||||
b.pendingState, _ = state.New(b.pendingBlock.Root(), stateDB.Database(), nil)
|
b.pendingState, _ = state.New(b.pendingBlock.Root(), stateDB.Database(), nil)
|
||||||
|
b.pendingReceipts = receipts[0]
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -587,7 +685,7 @@ func (b *SimulatedBackend) FilterLogs(ctx context.Context, query ethereum.Filter
|
|||||||
var filter *filters.Filter
|
var filter *filters.Filter
|
||||||
if query.BlockHash != nil {
|
if query.BlockHash != nil {
|
||||||
// Block filter requested, construct a single-shot filter
|
// Block filter requested, construct a single-shot filter
|
||||||
filter = filters.NewBlockFilter(&filterBackend{b.database, b.blockchain}, *query.BlockHash, query.Addresses, query.Topics)
|
filter = filters.NewBlockFilter(&filterBackend{b.database, b.blockchain, b}, *query.BlockHash, query.Addresses, query.Topics)
|
||||||
} else {
|
} else {
|
||||||
// Initialize unset filter boundaries to run from genesis to chain head
|
// Initialize unset filter boundaries to run from genesis to chain head
|
||||||
from := int64(0)
|
from := int64(0)
|
||||||
@@ -599,7 +697,7 @@ func (b *SimulatedBackend) FilterLogs(ctx context.Context, query ethereum.Filter
|
|||||||
to = query.ToBlock.Int64()
|
to = query.ToBlock.Int64()
|
||||||
}
|
}
|
||||||
// Construct the range filter
|
// Construct the range filter
|
||||||
filter = filters.NewRangeFilter(&filterBackend{b.database, b.blockchain}, from, to, query.Addresses, query.Topics)
|
filter = filters.NewRangeFilter(&filterBackend{b.database, b.blockchain, b}, from, to, query.Addresses, query.Topics)
|
||||||
}
|
}
|
||||||
// Run the filter and return all the logs
|
// Run the filter and return all the logs
|
||||||
logs, err := filter.Logs(ctx)
|
logs, err := filter.Logs(ctx)
|
||||||
@@ -615,7 +713,7 @@ func (b *SimulatedBackend) FilterLogs(ctx context.Context, query ethereum.Filter
|
|||||||
|
|
||||||
// SubscribeFilterLogs creates a background log filtering operation, returning a
|
// SubscribeFilterLogs creates a background log filtering operation, returning a
|
||||||
// subscription immediately, which can be used to stream the found events.
|
// subscription immediately, which can be used to stream the found events.
|
||||||
func (b *SimulatedBackend) SubscribeFilterLogs(_ context.Context, query ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error) {
|
func (b *SimulatedBackend) SubscribeFilterLogs(ctx context.Context, query ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error) {
|
||||||
// Subscribe to contract events
|
// Subscribe to contract events
|
||||||
sink := make(chan []*types.Log)
|
sink := make(chan []*types.Log)
|
||||||
|
|
||||||
@@ -648,7 +746,7 @@ func (b *SimulatedBackend) SubscribeFilterLogs(_ context.Context, query ethereum
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SubscribeNewHead returns an event subscription for a new header.
|
// SubscribeNewHead returns an event subscription for a new header.
|
||||||
func (b *SimulatedBackend) SubscribeNewHead(_ context.Context, ch chan<- *types.Header) (ethereum.Subscription, error) {
|
func (b *SimulatedBackend) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (ethereum.Subscription, error) {
|
||||||
// subscribe to a new head
|
// subscribe to a new head
|
||||||
sink := make(chan *types.Header)
|
sink := make(chan *types.Header)
|
||||||
sub := b.events.SubscribeNewHeads(sink)
|
sub := b.events.SubscribeNewHeads(sink)
|
||||||
@@ -705,37 +803,45 @@ type callMsg struct {
|
|||||||
ethereum.CallMsg
|
ethereum.CallMsg
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m callMsg) From() common.Address { return m.CallMsg.From }
|
func (m callMsg) From() common.Address { return m.CallMsg.From }
|
||||||
func (m callMsg) Nonce() uint64 { return 0 }
|
func (m callMsg) Nonce() uint64 { return 0 }
|
||||||
func (m callMsg) CheckNonce() bool { return false }
|
func (m callMsg) IsFake() bool { return true }
|
||||||
func (m callMsg) To() *common.Address { return m.CallMsg.To }
|
func (m callMsg) To() *common.Address { return m.CallMsg.To }
|
||||||
func (m callMsg) GasPrice() *big.Int { return m.CallMsg.GasPrice }
|
func (m callMsg) GasPrice() *big.Int { return m.CallMsg.GasPrice }
|
||||||
func (m callMsg) Gas() uint64 { return m.CallMsg.Gas }
|
func (m callMsg) GasFeeCap() *big.Int { return m.CallMsg.GasFeeCap }
|
||||||
func (m callMsg) Value() *big.Int { return m.CallMsg.Value }
|
func (m callMsg) GasTipCap() *big.Int { return m.CallMsg.GasTipCap }
|
||||||
func (m callMsg) Data() []byte { return m.CallMsg.Data }
|
func (m callMsg) Gas() uint64 { return m.CallMsg.Gas }
|
||||||
|
func (m callMsg) Value() *big.Int { return m.CallMsg.Value }
|
||||||
|
func (m callMsg) Data() []byte { return m.CallMsg.Data }
|
||||||
|
func (m callMsg) AccessList() types.AccessList { return m.CallMsg.AccessList }
|
||||||
|
|
||||||
// filterBackend implements filters.Backend to support filtering for logs without
|
// filterBackend implements filters.Backend to support filtering for logs without
|
||||||
// taking bloom-bits acceleration structures into account.
|
// taking bloom-bits acceleration structures into account.
|
||||||
type filterBackend struct {
|
type filterBackend struct {
|
||||||
db ethdb.Database
|
db ethdb.Database
|
||||||
bc *core.BlockChain
|
bc *core.BlockChain
|
||||||
|
backend *SimulatedBackend
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fb *filterBackend) ChainDb() ethdb.Database { return fb.db }
|
func (fb *filterBackend) ChainDb() ethdb.Database { return fb.db }
|
||||||
func (fb *filterBackend) EventMux() *event.TypeMux { panic("not supported") }
|
func (fb *filterBackend) EventMux() *event.TypeMux { panic("not supported") }
|
||||||
|
|
||||||
func (fb *filterBackend) HeaderByNumber(_ context.Context, block rpc.BlockNumber) (*types.Header, error) {
|
func (fb *filterBackend) HeaderByNumber(ctx context.Context, block rpc.BlockNumber) (*types.Header, error) {
|
||||||
if block == rpc.LatestBlockNumber {
|
if block == rpc.LatestBlockNumber {
|
||||||
return fb.bc.CurrentHeader(), nil
|
return fb.bc.CurrentHeader(), nil
|
||||||
}
|
}
|
||||||
return fb.bc.GetHeaderByNumber(uint64(block.Int64())), nil
|
return fb.bc.GetHeaderByNumber(uint64(block.Int64())), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fb *filterBackend) HeaderByHash(_ context.Context, hash common.Hash) (*types.Header, error) {
|
func (fb *filterBackend) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error) {
|
||||||
return fb.bc.GetHeaderByHash(hash), nil
|
return fb.bc.GetHeaderByHash(hash), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fb *filterBackend) GetReceipts(_ context.Context, hash common.Hash) (types.Receipts, error) {
|
func (fb *filterBackend) PendingBlockAndReceipts() (*types.Block, types.Receipts) {
|
||||||
|
return fb.backend.pendingBlock, fb.backend.pendingReceipts
|
||||||
|
}
|
||||||
|
|
||||||
|
func (fb *filterBackend) GetReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error) {
|
||||||
number := rawdb.ReadHeaderNumber(fb.db, hash)
|
number := rawdb.ReadHeaderNumber(fb.db, hash)
|
||||||
if number == nil {
|
if number == nil {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
@@ -743,7 +849,7 @@ func (fb *filterBackend) GetReceipts(_ context.Context, hash common.Hash) (types
|
|||||||
return rawdb.ReadReceipts(fb.db, hash, *number, fb.bc.Config()), nil
|
return rawdb.ReadReceipts(fb.db, hash, *number, fb.bc.Config()), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fb *filterBackend) GetLogs(_ context.Context, hash common.Hash) ([][]*types.Log, error) {
|
func (fb *filterBackend) GetLogs(ctx context.Context, hash common.Hash) ([][]*types.Log, error) {
|
||||||
number := rawdb.ReadHeaderNumber(fb.db, hash)
|
number := rawdb.ReadHeaderNumber(fb.db, hash)
|
||||||
if number == nil {
|
if number == nil {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
@@ -759,7 +865,7 @@ func (fb *filterBackend) GetLogs(_ context.Context, hash common.Hash) ([][]*type
|
|||||||
return logs, nil
|
return logs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fb *filterBackend) SubscribeNewTxsEvent(_ chan<- core.NewTxsEvent) event.Subscription {
|
func (fb *filterBackend) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) event.Subscription {
|
||||||
return nullSubscription()
|
return nullSubscription()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -775,13 +881,13 @@ func (fb *filterBackend) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscr
|
|||||||
return fb.bc.SubscribeLogsEvent(ch)
|
return fb.bc.SubscribeLogsEvent(ch)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fb *filterBackend) SubscribePendingLogsEvent(_ chan<- []*types.Log) event.Subscription {
|
func (fb *filterBackend) SubscribePendingLogsEvent(ch chan<- []*types.Log) event.Subscription {
|
||||||
return nullSubscription()
|
return nullSubscription()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fb *filterBackend) BloomStatus() (uint64, uint64) { return 4096, 0 }
|
func (fb *filterBackend) BloomStatus() (uint64, uint64) { return 4096, 0 }
|
||||||
|
|
||||||
func (fb *filterBackend) ServiceFilter(_ context.Context, _ *bloombits.MatcherSession) {
|
func (fb *filterBackend) ServiceFilter(ctx context.Context, ms *bloombits.MatcherSession) {
|
||||||
panic("not supported")
|
panic("not supported")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
"math/rand"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -39,7 +40,7 @@ import (
|
|||||||
func TestSimulatedBackend(t *testing.T) {
|
func TestSimulatedBackend(t *testing.T) {
|
||||||
var gasLimit uint64 = 8000029
|
var gasLimit uint64 = 8000029
|
||||||
key, _ := crypto.GenerateKey() // nolint: gosec
|
key, _ := crypto.GenerateKey() // nolint: gosec
|
||||||
auth := bind.NewKeyedTransactor(key)
|
auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
|
||||||
genAlloc := make(core.GenesisAlloc)
|
genAlloc := make(core.GenesisAlloc)
|
||||||
genAlloc[auth.From] = core.GenesisAccount{Balance: big.NewInt(9223372036854775807)}
|
genAlloc[auth.From] = core.GenesisAccount{Balance: big.NewInt(9223372036854775807)}
|
||||||
|
|
||||||
@@ -58,9 +59,12 @@ func TestSimulatedBackend(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// generate a transaction and confirm you can retrieve it
|
// generate a transaction and confirm you can retrieve it
|
||||||
|
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
||||||
|
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
|
||||||
|
|
||||||
code := `6060604052600a8060106000396000f360606040526008565b00`
|
code := `6060604052600a8060106000396000f360606040526008565b00`
|
||||||
var gas uint64 = 3000000
|
var gas uint64 = 3000000
|
||||||
tx := types.NewContractCreation(0, big.NewInt(0), gas, big.NewInt(1), common.FromHex(code))
|
tx := types.NewContractCreation(0, big.NewInt(0), gas, gasPrice, common.FromHex(code))
|
||||||
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, key)
|
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, key)
|
||||||
|
|
||||||
err = sim.SendTransaction(context.Background(), tx)
|
err = sim.SendTransaction(context.Background(), tx)
|
||||||
@@ -110,14 +114,14 @@ var expectedReturn = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
|||||||
func simTestBackend(testAddr common.Address) *SimulatedBackend {
|
func simTestBackend(testAddr common.Address) *SimulatedBackend {
|
||||||
return NewSimulatedBackend(
|
return NewSimulatedBackend(
|
||||||
core.GenesisAlloc{
|
core.GenesisAlloc{
|
||||||
testAddr: {Balance: big.NewInt(10000000000)},
|
testAddr: {Balance: big.NewInt(10000000000000000)},
|
||||||
}, 10000000,
|
}, 10000000,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNewSimulatedBackend(t *testing.T) {
|
func TestNewSimulatedBackend(t *testing.T) {
|
||||||
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
||||||
expectedBal := big.NewInt(10000000000)
|
expectedBal := big.NewInt(10000000000000000)
|
||||||
sim := simTestBackend(testAddr)
|
sim := simTestBackend(testAddr)
|
||||||
defer sim.Close()
|
defer sim.Close()
|
||||||
|
|
||||||
@@ -136,7 +140,7 @@ func TestNewSimulatedBackend(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSimulatedBackend_AdjustTime(t *testing.T) {
|
func TestAdjustTime(t *testing.T) {
|
||||||
sim := NewSimulatedBackend(
|
sim := NewSimulatedBackend(
|
||||||
core.GenesisAlloc{}, 10000000,
|
core.GenesisAlloc{}, 10000000,
|
||||||
)
|
)
|
||||||
@@ -153,11 +157,15 @@ func TestSimulatedBackend_AdjustTime(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNewSimulatedBackend_AdjustTimeFail(t *testing.T) {
|
func TestNewAdjustTimeFail(t *testing.T) {
|
||||||
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
||||||
sim := simTestBackend(testAddr)
|
sim := simTestBackend(testAddr)
|
||||||
|
|
||||||
// Create tx and send
|
// Create tx and send
|
||||||
tx := types.NewTransaction(0, testAddr, big.NewInt(1000), params.TxGas, big.NewInt(1), nil)
|
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
||||||
|
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
|
||||||
|
|
||||||
|
tx := types.NewTransaction(0, testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
|
||||||
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not sign tx: %v", err)
|
t.Errorf("could not sign tx: %v", err)
|
||||||
@@ -178,7 +186,7 @@ func TestNewSimulatedBackend_AdjustTimeFail(t *testing.T) {
|
|||||||
t.Errorf("adjusted time not equal to a minute. prev: %v, new: %v", prevTime, newTime)
|
t.Errorf("adjusted time not equal to a minute. prev: %v, new: %v", prevTime, newTime)
|
||||||
}
|
}
|
||||||
// Put a transaction after adjusting time
|
// Put a transaction after adjusting time
|
||||||
tx2 := types.NewTransaction(1, testAddr, big.NewInt(1000), params.TxGas, big.NewInt(1), nil)
|
tx2 := types.NewTransaction(1, testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
|
||||||
signedTx2, err := types.SignTx(tx2, types.HomesteadSigner{}, testKey)
|
signedTx2, err := types.SignTx(tx2, types.HomesteadSigner{}, testKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not sign tx: %v", err)
|
t.Errorf("could not sign tx: %v", err)
|
||||||
@@ -191,9 +199,9 @@ func TestNewSimulatedBackend_AdjustTimeFail(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSimulatedBackend_BalanceAt(t *testing.T) {
|
func TestBalanceAt(t *testing.T) {
|
||||||
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
||||||
expectedBal := big.NewInt(10000000000)
|
expectedBal := big.NewInt(10000000000000000)
|
||||||
sim := simTestBackend(testAddr)
|
sim := simTestBackend(testAddr)
|
||||||
defer sim.Close()
|
defer sim.Close()
|
||||||
bgCtx := context.Background()
|
bgCtx := context.Background()
|
||||||
@@ -208,7 +216,7 @@ func TestSimulatedBackend_BalanceAt(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSimulatedBackend_BlockByHash(t *testing.T) {
|
func TestBlockByHash(t *testing.T) {
|
||||||
sim := NewSimulatedBackend(
|
sim := NewSimulatedBackend(
|
||||||
core.GenesisAlloc{}, 10000000,
|
core.GenesisAlloc{}, 10000000,
|
||||||
)
|
)
|
||||||
@@ -229,7 +237,7 @@ func TestSimulatedBackend_BlockByHash(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSimulatedBackend_BlockByNumber(t *testing.T) {
|
func TestBlockByNumber(t *testing.T) {
|
||||||
sim := NewSimulatedBackend(
|
sim := NewSimulatedBackend(
|
||||||
core.GenesisAlloc{}, 10000000,
|
core.GenesisAlloc{}, 10000000,
|
||||||
)
|
)
|
||||||
@@ -264,7 +272,7 @@ func TestSimulatedBackend_BlockByNumber(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSimulatedBackend_NonceAt(t *testing.T) {
|
func TestNonceAt(t *testing.T) {
|
||||||
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
||||||
|
|
||||||
sim := simTestBackend(testAddr)
|
sim := simTestBackend(testAddr)
|
||||||
@@ -281,7 +289,10 @@ func TestSimulatedBackend_NonceAt(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create a signed transaction to send
|
// create a signed transaction to send
|
||||||
tx := types.NewTransaction(nonce, testAddr, big.NewInt(1000), params.TxGas, big.NewInt(1), nil)
|
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
||||||
|
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
|
||||||
|
|
||||||
|
tx := types.NewTransaction(nonce, testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
|
||||||
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not sign tx: %v", err)
|
t.Errorf("could not sign tx: %v", err)
|
||||||
@@ -314,7 +325,7 @@ func TestSimulatedBackend_NonceAt(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSimulatedBackend_SendTransaction(t *testing.T) {
|
func TestSendTransaction(t *testing.T) {
|
||||||
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
||||||
|
|
||||||
sim := simTestBackend(testAddr)
|
sim := simTestBackend(testAddr)
|
||||||
@@ -322,7 +333,10 @@ func TestSimulatedBackend_SendTransaction(t *testing.T) {
|
|||||||
bgCtx := context.Background()
|
bgCtx := context.Background()
|
||||||
|
|
||||||
// create a signed transaction to send
|
// create a signed transaction to send
|
||||||
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, big.NewInt(1), nil)
|
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
||||||
|
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
|
||||||
|
|
||||||
|
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
|
||||||
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not sign tx: %v", err)
|
t.Errorf("could not sign tx: %v", err)
|
||||||
@@ -345,19 +359,22 @@ func TestSimulatedBackend_SendTransaction(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSimulatedBackend_TransactionByHash(t *testing.T) {
|
func TestTransactionByHash(t *testing.T) {
|
||||||
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
||||||
|
|
||||||
sim := NewSimulatedBackend(
|
sim := NewSimulatedBackend(
|
||||||
core.GenesisAlloc{
|
core.GenesisAlloc{
|
||||||
testAddr: {Balance: big.NewInt(10000000000)},
|
testAddr: {Balance: big.NewInt(10000000000000000)},
|
||||||
}, 10000000,
|
}, 10000000,
|
||||||
)
|
)
|
||||||
defer sim.Close()
|
defer sim.Close()
|
||||||
bgCtx := context.Background()
|
bgCtx := context.Background()
|
||||||
|
|
||||||
// create a signed transaction to send
|
// create a signed transaction to send
|
||||||
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, big.NewInt(1), nil)
|
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
||||||
|
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
|
||||||
|
|
||||||
|
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
|
||||||
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not sign tx: %v", err)
|
t.Errorf("could not sign tx: %v", err)
|
||||||
@@ -396,7 +413,7 @@ func TestSimulatedBackend_TransactionByHash(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSimulatedBackend_EstimateGas(t *testing.T) {
|
func TestEstimateGas(t *testing.T) {
|
||||||
/*
|
/*
|
||||||
pragma solidity ^0.6.4;
|
pragma solidity ^0.6.4;
|
||||||
contract GasEstimation {
|
contract GasEstimation {
|
||||||
@@ -411,7 +428,7 @@ func TestSimulatedBackend_EstimateGas(t *testing.T) {
|
|||||||
|
|
||||||
key, _ := crypto.GenerateKey()
|
key, _ := crypto.GenerateKey()
|
||||||
addr := crypto.PubkeyToAddress(key.PublicKey)
|
addr := crypto.PubkeyToAddress(key.PublicKey)
|
||||||
opts := bind.NewKeyedTransactor(key)
|
opts, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
|
||||||
|
|
||||||
sim := NewSimulatedBackend(core.GenesisAlloc{addr: {Balance: big.NewInt(params.Ether)}}, 10000000)
|
sim := NewSimulatedBackend(core.GenesisAlloc{addr: {Balance: big.NewInt(params.Ether)}}, 10000000)
|
||||||
defer sim.Close()
|
defer sim.Close()
|
||||||
@@ -479,7 +496,7 @@ func TestSimulatedBackend_EstimateGas(t *testing.T) {
|
|||||||
GasPrice: big.NewInt(0),
|
GasPrice: big.NewInt(0),
|
||||||
Value: nil,
|
Value: nil,
|
||||||
Data: common.Hex2Bytes("b9b046f9"),
|
Data: common.Hex2Bytes("b9b046f9"),
|
||||||
}, 0, errors.New("invalid opcode: opcode 0xfe not defined"), nil},
|
}, 0, errors.New("invalid opcode: INVALID"), nil},
|
||||||
|
|
||||||
{"Valid", ethereum.CallMsg{
|
{"Valid", ethereum.CallMsg{
|
||||||
From: addr,
|
From: addr,
|
||||||
@@ -514,7 +531,7 @@ func TestSimulatedBackend_EstimateGas(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSimulatedBackend_EstimateGasWithPrice(t *testing.T) {
|
func TestEstimateGasWithPrice(t *testing.T) {
|
||||||
key, _ := crypto.GenerateKey()
|
key, _ := crypto.GenerateKey()
|
||||||
addr := crypto.PubkeyToAddress(key.PublicKey)
|
addr := crypto.PubkeyToAddress(key.PublicKey)
|
||||||
|
|
||||||
@@ -533,7 +550,7 @@ func TestSimulatedBackend_EstimateGasWithPrice(t *testing.T) {
|
|||||||
To: &recipient,
|
To: &recipient,
|
||||||
Gas: 0,
|
Gas: 0,
|
||||||
GasPrice: big.NewInt(0),
|
GasPrice: big.NewInt(0),
|
||||||
Value: big.NewInt(1000),
|
Value: big.NewInt(100000000000),
|
||||||
Data: nil,
|
Data: nil,
|
||||||
}, 21000, nil},
|
}, 21000, nil},
|
||||||
|
|
||||||
@@ -541,8 +558,8 @@ func TestSimulatedBackend_EstimateGasWithPrice(t *testing.T) {
|
|||||||
From: addr,
|
From: addr,
|
||||||
To: &recipient,
|
To: &recipient,
|
||||||
Gas: 0,
|
Gas: 0,
|
||||||
GasPrice: big.NewInt(1000),
|
GasPrice: big.NewInt(100000000000),
|
||||||
Value: big.NewInt(1000),
|
Value: big.NewInt(100000000000),
|
||||||
Data: nil,
|
Data: nil,
|
||||||
}, 21000, nil},
|
}, 21000, nil},
|
||||||
|
|
||||||
@@ -560,28 +577,51 @@ func TestSimulatedBackend_EstimateGasWithPrice(t *testing.T) {
|
|||||||
To: &recipient,
|
To: &recipient,
|
||||||
Gas: 0,
|
Gas: 0,
|
||||||
GasPrice: big.NewInt(2e14), // gascost = 4.2ether
|
GasPrice: big.NewInt(2e14), // gascost = 4.2ether
|
||||||
Value: big.NewInt(1000),
|
Value: big.NewInt(100000000000),
|
||||||
Data: nil,
|
Data: nil,
|
||||||
}, 21000, errors.New("gas required exceeds allowance (10999)")}, // 10999=(2.2ether-1000wei)/(2e14)
|
}, 21000, errors.New("gas required exceeds allowance (10999)")}, // 10999=(2.2ether-1000wei)/(2e14)
|
||||||
|
|
||||||
|
{"EstimateEIP1559WithHighFees", ethereum.CallMsg{
|
||||||
|
From: addr,
|
||||||
|
To: &addr,
|
||||||
|
Gas: 0,
|
||||||
|
GasFeeCap: big.NewInt(1e14), // maxgascost = 2.1ether
|
||||||
|
GasTipCap: big.NewInt(1),
|
||||||
|
Value: big.NewInt(1e17), // the remaining balance for fee is 2.1ether
|
||||||
|
Data: nil,
|
||||||
|
}, params.TxGas, nil},
|
||||||
|
|
||||||
|
{"EstimateEIP1559WithSuperHighFees", ethereum.CallMsg{
|
||||||
|
From: addr,
|
||||||
|
To: &addr,
|
||||||
|
Gas: 0,
|
||||||
|
GasFeeCap: big.NewInt(1e14), // maxgascost = 2.1ether
|
||||||
|
GasTipCap: big.NewInt(1),
|
||||||
|
Value: big.NewInt(1e17 + 1), // the remaining balance for fee is 2.1ether
|
||||||
|
Data: nil,
|
||||||
|
}, params.TxGas, errors.New("gas required exceeds allowance (20999)")}, // 20999=(2.2ether-0.1ether-1wei)/(1e14)
|
||||||
}
|
}
|
||||||
for _, c := range cases {
|
for i, c := range cases {
|
||||||
got, err := sim.EstimateGas(context.Background(), c.message)
|
got, err := sim.EstimateGas(context.Background(), c.message)
|
||||||
if c.expectError != nil {
|
if c.expectError != nil {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("Expect error, got nil")
|
t.Fatalf("test %d: expect error, got nil", i)
|
||||||
}
|
}
|
||||||
if c.expectError.Error() != err.Error() {
|
if c.expectError.Error() != err.Error() {
|
||||||
t.Fatalf("Expect error, want %v, got %v", c.expectError, err)
|
t.Fatalf("test %d: expect error, want %v, got %v", i, c.expectError, err)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if c.expectError == nil && err != nil {
|
||||||
|
t.Fatalf("test %d: didn't expect error, got %v", i, err)
|
||||||
|
}
|
||||||
if got != c.expect {
|
if got != c.expect {
|
||||||
t.Fatalf("Gas estimation mismatch, want %d, got %d", c.expect, got)
|
t.Fatalf("test %d: gas estimation mismatch, want %d, got %d", i, c.expect, got)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSimulatedBackend_HeaderByHash(t *testing.T) {
|
func TestHeaderByHash(t *testing.T) {
|
||||||
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
||||||
|
|
||||||
sim := simTestBackend(testAddr)
|
sim := simTestBackend(testAddr)
|
||||||
@@ -602,7 +642,7 @@ func TestSimulatedBackend_HeaderByHash(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSimulatedBackend_HeaderByNumber(t *testing.T) {
|
func TestHeaderByNumber(t *testing.T) {
|
||||||
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
||||||
|
|
||||||
sim := simTestBackend(testAddr)
|
sim := simTestBackend(testAddr)
|
||||||
@@ -615,8 +655,7 @@ func TestSimulatedBackend_HeaderByNumber(t *testing.T) {
|
|||||||
}
|
}
|
||||||
if latestBlockHeader == nil {
|
if latestBlockHeader == nil {
|
||||||
t.Errorf("received a nil block header")
|
t.Errorf("received a nil block header")
|
||||||
}
|
} else if latestBlockHeader.Number.Uint64() != uint64(0) {
|
||||||
if latestBlockHeader.Number.Uint64() != uint64(0) {
|
|
||||||
t.Errorf("expected block header number 0, instead got %v", latestBlockHeader.Number.Uint64())
|
t.Errorf("expected block header number 0, instead got %v", latestBlockHeader.Number.Uint64())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -649,7 +688,7 @@ func TestSimulatedBackend_HeaderByNumber(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSimulatedBackend_TransactionCount(t *testing.T) {
|
func TestTransactionCount(t *testing.T) {
|
||||||
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
||||||
|
|
||||||
sim := simTestBackend(testAddr)
|
sim := simTestBackend(testAddr)
|
||||||
@@ -668,9 +707,11 @@ func TestSimulatedBackend_TransactionCount(t *testing.T) {
|
|||||||
if count != 0 {
|
if count != 0 {
|
||||||
t.Errorf("expected transaction count of %v does not match actual count of %v", 0, count)
|
t.Errorf("expected transaction count of %v does not match actual count of %v", 0, count)
|
||||||
}
|
}
|
||||||
|
|
||||||
// create a signed transaction to send
|
// create a signed transaction to send
|
||||||
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, big.NewInt(1), nil)
|
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
||||||
|
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
|
||||||
|
|
||||||
|
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
|
||||||
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not sign tx: %v", err)
|
t.Errorf("could not sign tx: %v", err)
|
||||||
@@ -699,7 +740,7 @@ func TestSimulatedBackend_TransactionCount(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSimulatedBackend_TransactionInBlock(t *testing.T) {
|
func TestTransactionInBlock(t *testing.T) {
|
||||||
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
||||||
|
|
||||||
sim := simTestBackend(testAddr)
|
sim := simTestBackend(testAddr)
|
||||||
@@ -723,9 +764,11 @@ func TestSimulatedBackend_TransactionInBlock(t *testing.T) {
|
|||||||
if pendingNonce != uint64(0) {
|
if pendingNonce != uint64(0) {
|
||||||
t.Errorf("expected pending nonce of 0 got %v", pendingNonce)
|
t.Errorf("expected pending nonce of 0 got %v", pendingNonce)
|
||||||
}
|
}
|
||||||
|
|
||||||
// create a signed transaction to send
|
// create a signed transaction to send
|
||||||
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, big.NewInt(1), nil)
|
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
||||||
|
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
|
||||||
|
|
||||||
|
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
|
||||||
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not sign tx: %v", err)
|
t.Errorf("could not sign tx: %v", err)
|
||||||
@@ -762,7 +805,7 @@ func TestSimulatedBackend_TransactionInBlock(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSimulatedBackend_PendingNonceAt(t *testing.T) {
|
func TestPendingNonceAt(t *testing.T) {
|
||||||
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
||||||
|
|
||||||
sim := simTestBackend(testAddr)
|
sim := simTestBackend(testAddr)
|
||||||
@@ -780,7 +823,10 @@ func TestSimulatedBackend_PendingNonceAt(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create a signed transaction to send
|
// create a signed transaction to send
|
||||||
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, big.NewInt(1), nil)
|
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
||||||
|
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
|
||||||
|
|
||||||
|
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
|
||||||
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not sign tx: %v", err)
|
t.Errorf("could not sign tx: %v", err)
|
||||||
@@ -803,7 +849,7 @@ func TestSimulatedBackend_PendingNonceAt(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// make a new transaction with a nonce of 1
|
// make a new transaction with a nonce of 1
|
||||||
tx = types.NewTransaction(uint64(1), testAddr, big.NewInt(1000), params.TxGas, big.NewInt(1), nil)
|
tx = types.NewTransaction(uint64(1), testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
|
||||||
signedTx, err = types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
signedTx, err = types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not sign tx: %v", err)
|
t.Errorf("could not sign tx: %v", err)
|
||||||
@@ -824,7 +870,7 @@ func TestSimulatedBackend_PendingNonceAt(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSimulatedBackend_TransactionReceipt(t *testing.T) {
|
func TestTransactionReceipt(t *testing.T) {
|
||||||
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
||||||
|
|
||||||
sim := simTestBackend(testAddr)
|
sim := simTestBackend(testAddr)
|
||||||
@@ -832,7 +878,10 @@ func TestSimulatedBackend_TransactionReceipt(t *testing.T) {
|
|||||||
bgCtx := context.Background()
|
bgCtx := context.Background()
|
||||||
|
|
||||||
// create a signed transaction to send
|
// create a signed transaction to send
|
||||||
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, big.NewInt(1), nil)
|
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
||||||
|
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
|
||||||
|
|
||||||
|
tx := types.NewTransaction(uint64(0), testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
|
||||||
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
signedTx, err := types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not sign tx: %v", err)
|
t.Errorf("could not sign tx: %v", err)
|
||||||
@@ -855,7 +904,7 @@ func TestSimulatedBackend_TransactionReceipt(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSimulatedBackend_SuggestGasPrice(t *testing.T) {
|
func TestSuggestGasPrice(t *testing.T) {
|
||||||
sim := NewSimulatedBackend(
|
sim := NewSimulatedBackend(
|
||||||
core.GenesisAlloc{},
|
core.GenesisAlloc{},
|
||||||
10000000,
|
10000000,
|
||||||
@@ -866,12 +915,12 @@ func TestSimulatedBackend_SuggestGasPrice(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not get gas price: %v", err)
|
t.Errorf("could not get gas price: %v", err)
|
||||||
}
|
}
|
||||||
if gasPrice.Uint64() != uint64(1) {
|
if gasPrice.Uint64() != sim.pendingBlock.Header().BaseFee.Uint64() {
|
||||||
t.Errorf("gas price was not expected value of 1. actual: %v", gasPrice.Uint64())
|
t.Errorf("gas price was not expected value of %v. actual: %v", sim.pendingBlock.Header().BaseFee.Uint64(), gasPrice.Uint64())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSimulatedBackend_PendingCodeAt(t *testing.T) {
|
func TestPendingCodeAt(t *testing.T) {
|
||||||
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
||||||
sim := simTestBackend(testAddr)
|
sim := simTestBackend(testAddr)
|
||||||
defer sim.Close()
|
defer sim.Close()
|
||||||
@@ -888,7 +937,7 @@ func TestSimulatedBackend_PendingCodeAt(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not get code at test addr: %v", err)
|
t.Errorf("could not get code at test addr: %v", err)
|
||||||
}
|
}
|
||||||
auth := bind.NewKeyedTransactor(testKey)
|
auth, _ := bind.NewKeyedTransactorWithChainID(testKey, big.NewInt(1337))
|
||||||
contractAddr, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(abiBin), sim)
|
contractAddr, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(abiBin), sim)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not deploy contract: %v tx: %v contract: %v", err, tx, contract)
|
t.Errorf("could not deploy contract: %v tx: %v contract: %v", err, tx, contract)
|
||||||
@@ -907,7 +956,7 @@ func TestSimulatedBackend_PendingCodeAt(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSimulatedBackend_CodeAt(t *testing.T) {
|
func TestCodeAt(t *testing.T) {
|
||||||
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
||||||
sim := simTestBackend(testAddr)
|
sim := simTestBackend(testAddr)
|
||||||
defer sim.Close()
|
defer sim.Close()
|
||||||
@@ -924,7 +973,7 @@ func TestSimulatedBackend_CodeAt(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not get code at test addr: %v", err)
|
t.Errorf("could not get code at test addr: %v", err)
|
||||||
}
|
}
|
||||||
auth := bind.NewKeyedTransactor(testKey)
|
auth, _ := bind.NewKeyedTransactorWithChainID(testKey, big.NewInt(1337))
|
||||||
contractAddr, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(abiBin), sim)
|
contractAddr, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(abiBin), sim)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not deploy contract: %v tx: %v contract: %v", err, tx, contract)
|
t.Errorf("could not deploy contract: %v tx: %v contract: %v", err, tx, contract)
|
||||||
@@ -946,7 +995,7 @@ func TestSimulatedBackend_CodeAt(t *testing.T) {
|
|||||||
|
|
||||||
// When receive("X") is called with sender 0x00... and value 1, it produces this tx receipt:
|
// When receive("X") is called with sender 0x00... and value 1, it produces this tx receipt:
|
||||||
// receipt{status=1 cgas=23949 bloom=00000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000040200000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 logs=[log: b6818c8064f645cd82d99b59a1a267d6d61117ef [75fd880d39c1daf53b6547ab6cb59451fc6452d27caa90e5b6649dd8293b9eed] 000000000000000000000000376c47978271565f56deb45495afa69e59c16ab200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000158 9ae378b6d4409eada347a5dc0c180f186cb62dc68fcc0f043425eb917335aa28 0 95d429d309bb9d753954195fe2d69bd140b4ae731b9b5b605c34323de162cf00 0]}
|
// receipt{status=1 cgas=23949 bloom=00000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000040200000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 logs=[log: b6818c8064f645cd82d99b59a1a267d6d61117ef [75fd880d39c1daf53b6547ab6cb59451fc6452d27caa90e5b6649dd8293b9eed] 000000000000000000000000376c47978271565f56deb45495afa69e59c16ab200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000158 9ae378b6d4409eada347a5dc0c180f186cb62dc68fcc0f043425eb917335aa28 0 95d429d309bb9d753954195fe2d69bd140b4ae731b9b5b605c34323de162cf00 0]}
|
||||||
func TestSimulatedBackend_PendingAndCallContract(t *testing.T) {
|
func TestPendingAndCallContract(t *testing.T) {
|
||||||
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
||||||
sim := simTestBackend(testAddr)
|
sim := simTestBackend(testAddr)
|
||||||
defer sim.Close()
|
defer sim.Close()
|
||||||
@@ -956,7 +1005,7 @@ func TestSimulatedBackend_PendingAndCallContract(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not get code at test addr: %v", err)
|
t.Errorf("could not get code at test addr: %v", err)
|
||||||
}
|
}
|
||||||
contractAuth := bind.NewKeyedTransactor(testKey)
|
contractAuth, _ := bind.NewKeyedTransactorWithChainID(testKey, big.NewInt(1337))
|
||||||
addr, _, _, err := bind.DeployContract(contractAuth, parsed, common.FromHex(abiBin), sim)
|
addr, _, _, err := bind.DeployContract(contractAuth, parsed, common.FromHex(abiBin), sim)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not deploy contract: %v", err)
|
t.Errorf("could not deploy contract: %v", err)
|
||||||
@@ -1030,7 +1079,7 @@ contract Reverter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
func TestSimulatedBackend_CallContractRevert(t *testing.T) {
|
func TestCallContractRevert(t *testing.T) {
|
||||||
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
||||||
sim := simTestBackend(testAddr)
|
sim := simTestBackend(testAddr)
|
||||||
defer sim.Close()
|
defer sim.Close()
|
||||||
@@ -1043,7 +1092,7 @@ func TestSimulatedBackend_CallContractRevert(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not get code at test addr: %v", err)
|
t.Errorf("could not get code at test addr: %v", err)
|
||||||
}
|
}
|
||||||
contractAuth := bind.NewKeyedTransactor(testKey)
|
contractAuth, _ := bind.NewKeyedTransactorWithChainID(testKey, big.NewInt(1337))
|
||||||
addr, _, _, err := bind.DeployContract(contractAuth, parsed, common.FromHex(reverterBin), sim)
|
addr, _, _, err := bind.DeployContract(contractAuth, parsed, common.FromHex(reverterBin), sim)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not deploy contract: %v", err)
|
t.Errorf("could not deploy contract: %v", err)
|
||||||
@@ -1086,12 +1135,12 @@ func TestSimulatedBackend_CallContractRevert(t *testing.T) {
|
|||||||
t.Errorf("result from %v was not nil: %v", key, res)
|
t.Errorf("result from %v was not nil: %v", key, res)
|
||||||
}
|
}
|
||||||
if val != nil {
|
if val != nil {
|
||||||
rErr, ok := err.(*revertError)
|
rerr, ok := err.(*revertError)
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Errorf("expect revert error")
|
t.Errorf("expect revert error")
|
||||||
}
|
}
|
||||||
if rErr.Error() != "execution reverted: "+val.(string) {
|
if rerr.Error() != "execution reverted: "+val.(string) {
|
||||||
t.Errorf("error was malformed: got %v want %v", rErr.Error(), val)
|
t.Errorf("error was malformed: got %v want %v", rerr.Error(), val)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// revert(0x0,0x0)
|
// revert(0x0,0x0)
|
||||||
@@ -1114,3 +1163,175 @@ func TestSimulatedBackend_CallContractRevert(t *testing.T) {
|
|||||||
sim.Commit()
|
sim.Commit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestFork check that the chain length after a reorg is correct.
|
||||||
|
// Steps:
|
||||||
|
// 1. Save the current block which will serve as parent for the fork.
|
||||||
|
// 2. Mine n blocks with n ∈ [0, 20].
|
||||||
|
// 3. Assert that the chain length is n.
|
||||||
|
// 4. Fork by using the parent block as ancestor.
|
||||||
|
// 5. Mine n+1 blocks which should trigger a reorg.
|
||||||
|
// 6. Assert that the chain length is n+1.
|
||||||
|
// Since Commit() was called 2n+1 times in total,
|
||||||
|
// having a chain length of just n+1 means that a reorg occurred.
|
||||||
|
func TestFork(t *testing.T) {
|
||||||
|
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
||||||
|
sim := simTestBackend(testAddr)
|
||||||
|
defer sim.Close()
|
||||||
|
// 1.
|
||||||
|
parent := sim.blockchain.CurrentBlock()
|
||||||
|
// 2.
|
||||||
|
n := int(rand.Int31n(21))
|
||||||
|
for i := 0; i < n; i++ {
|
||||||
|
sim.Commit()
|
||||||
|
}
|
||||||
|
// 3.
|
||||||
|
if sim.blockchain.CurrentBlock().NumberU64() != uint64(n) {
|
||||||
|
t.Error("wrong chain length")
|
||||||
|
}
|
||||||
|
// 4.
|
||||||
|
sim.Fork(context.Background(), parent.Hash())
|
||||||
|
// 5.
|
||||||
|
for i := 0; i < n+1; i++ {
|
||||||
|
sim.Commit()
|
||||||
|
}
|
||||||
|
// 6.
|
||||||
|
if sim.blockchain.CurrentBlock().NumberU64() != uint64(n+1) {
|
||||||
|
t.Error("wrong chain length")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Example contract to test event emission:
|
||||||
|
|
||||||
|
pragma solidity >=0.7.0 <0.9.0;
|
||||||
|
contract Callable {
|
||||||
|
event Called();
|
||||||
|
function Call() public { emit Called(); }
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
const callableAbi = "[{\"anonymous\":false,\"inputs\":[],\"name\":\"Called\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"Call\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]"
|
||||||
|
|
||||||
|
const callableBin = "6080604052348015600f57600080fd5b5060998061001e6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c806334e2292114602d575b600080fd5b60336035565b005b7f81fab7a4a0aa961db47eefc81f143a5220e8c8495260dd65b1356f1d19d3c7b860405160405180910390a156fea2646970667358221220029436d24f3ac598ceca41d4d712e13ced6d70727f4cdc580667de66d2f51d8b64736f6c63430008010033"
|
||||||
|
|
||||||
|
// TestForkLogsReborn check that the simulated reorgs
|
||||||
|
// correctly remove and reborn logs.
|
||||||
|
// Steps:
|
||||||
|
// 1. Deploy the Callable contract.
|
||||||
|
// 2. Set up an event subscription.
|
||||||
|
// 3. Save the current block which will serve as parent for the fork.
|
||||||
|
// 4. Send a transaction.
|
||||||
|
// 5. Check that the event was included.
|
||||||
|
// 6. Fork by using the parent block as ancestor.
|
||||||
|
// 7. Mine two blocks to trigger a reorg.
|
||||||
|
// 8. Check that the event was removed.
|
||||||
|
// 9. Re-send the transaction and mine a block.
|
||||||
|
// 10. Check that the event was reborn.
|
||||||
|
func TestForkLogsReborn(t *testing.T) {
|
||||||
|
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
||||||
|
sim := simTestBackend(testAddr)
|
||||||
|
defer sim.Close()
|
||||||
|
// 1.
|
||||||
|
parsed, _ := abi.JSON(strings.NewReader(callableAbi))
|
||||||
|
auth, _ := bind.NewKeyedTransactorWithChainID(testKey, big.NewInt(1337))
|
||||||
|
_, _, contract, err := bind.DeployContract(auth, parsed, common.FromHex(callableBin), sim)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("deploying contract: %v", err)
|
||||||
|
}
|
||||||
|
sim.Commit()
|
||||||
|
// 2.
|
||||||
|
logs, sub, err := contract.WatchLogs(nil, "Called")
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("watching logs: %v", err)
|
||||||
|
}
|
||||||
|
defer sub.Unsubscribe()
|
||||||
|
// 3.
|
||||||
|
parent := sim.blockchain.CurrentBlock()
|
||||||
|
// 4.
|
||||||
|
tx, err := contract.Transact(auth, "Call")
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("transacting: %v", err)
|
||||||
|
}
|
||||||
|
sim.Commit()
|
||||||
|
// 5.
|
||||||
|
log := <-logs
|
||||||
|
if log.TxHash != tx.Hash() {
|
||||||
|
t.Error("wrong event tx hash")
|
||||||
|
}
|
||||||
|
if log.Removed {
|
||||||
|
t.Error("Event should be included")
|
||||||
|
}
|
||||||
|
// 6.
|
||||||
|
if err := sim.Fork(context.Background(), parent.Hash()); err != nil {
|
||||||
|
t.Errorf("forking: %v", err)
|
||||||
|
}
|
||||||
|
// 7.
|
||||||
|
sim.Commit()
|
||||||
|
sim.Commit()
|
||||||
|
// 8.
|
||||||
|
log = <-logs
|
||||||
|
if log.TxHash != tx.Hash() {
|
||||||
|
t.Error("wrong event tx hash")
|
||||||
|
}
|
||||||
|
if !log.Removed {
|
||||||
|
t.Error("Event should be removed")
|
||||||
|
}
|
||||||
|
// 9.
|
||||||
|
if err := sim.SendTransaction(context.Background(), tx); err != nil {
|
||||||
|
t.Errorf("sending transaction: %v", err)
|
||||||
|
}
|
||||||
|
sim.Commit()
|
||||||
|
// 10.
|
||||||
|
log = <-logs
|
||||||
|
if log.TxHash != tx.Hash() {
|
||||||
|
t.Error("wrong event tx hash")
|
||||||
|
}
|
||||||
|
if log.Removed {
|
||||||
|
t.Error("Event should be included")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestForkResendTx checks that re-sending a TX after a fork
|
||||||
|
// is possible and does not cause a "nonce mismatch" panic.
|
||||||
|
// Steps:
|
||||||
|
// 1. Save the current block which will serve as parent for the fork.
|
||||||
|
// 2. Send a transaction.
|
||||||
|
// 3. Check that the TX is included in block 1.
|
||||||
|
// 4. Fork by using the parent block as ancestor.
|
||||||
|
// 5. Mine a block, Re-send the transaction and mine another one.
|
||||||
|
// 6. Check that the TX is now included in block 2.
|
||||||
|
func TestForkResendTx(t *testing.T) {
|
||||||
|
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
||||||
|
sim := simTestBackend(testAddr)
|
||||||
|
defer sim.Close()
|
||||||
|
// 1.
|
||||||
|
parent := sim.blockchain.CurrentBlock()
|
||||||
|
// 2.
|
||||||
|
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
||||||
|
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
|
||||||
|
|
||||||
|
_tx := types.NewTransaction(0, testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
|
||||||
|
tx, _ := types.SignTx(_tx, types.HomesteadSigner{}, testKey)
|
||||||
|
sim.SendTransaction(context.Background(), tx)
|
||||||
|
sim.Commit()
|
||||||
|
// 3.
|
||||||
|
receipt, _ := sim.TransactionReceipt(context.Background(), tx.Hash())
|
||||||
|
if h := receipt.BlockNumber.Uint64(); h != 1 {
|
||||||
|
t.Errorf("TX included in wrong block: %d", h)
|
||||||
|
}
|
||||||
|
// 4.
|
||||||
|
if err := sim.Fork(context.Background(), parent.Hash()); err != nil {
|
||||||
|
t.Errorf("forking: %v", err)
|
||||||
|
}
|
||||||
|
// 5.
|
||||||
|
sim.Commit()
|
||||||
|
if err := sim.SendTransaction(context.Background(), tx); err != nil {
|
||||||
|
t.Errorf("sending transaction: %v", err)
|
||||||
|
}
|
||||||
|
sim.Commit()
|
||||||
|
// 6.
|
||||||
|
receipt, _ = sim.TransactionReceipt(context.Background(), tx.Hash())
|
||||||
|
if h := receipt.BlockNumber.Uint64(); h != 2 {
|
||||||
|
t.Errorf("TX included in wrong block: %d", h)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum"
|
"github.com/ethereum/go-ethereum"
|
||||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||||
@@ -32,7 +34,7 @@ import (
|
|||||||
|
|
||||||
// SignerFn is a signer function callback when a contract requires a method to
|
// SignerFn is a signer function callback when a contract requires a method to
|
||||||
// sign the transaction before submission.
|
// sign the transaction before submission.
|
||||||
type SignerFn func(types.Signer, common.Address, *types.Transaction) (*types.Transaction, error)
|
type SignerFn func(common.Address, *types.Transaction) (*types.Transaction, error)
|
||||||
|
|
||||||
// CallOpts is the collection of options to fine tune a contract call request.
|
// CallOpts is the collection of options to fine tune a contract call request.
|
||||||
type CallOpts struct {
|
type CallOpts struct {
|
||||||
@@ -49,11 +51,15 @@ type TransactOpts struct {
|
|||||||
Nonce *big.Int // Nonce to use for the transaction execution (nil = use pending state)
|
Nonce *big.Int // Nonce to use for the transaction execution (nil = use pending state)
|
||||||
Signer SignerFn // Method to use for signing the transaction (mandatory)
|
Signer SignerFn // Method to use for signing the transaction (mandatory)
|
||||||
|
|
||||||
Value *big.Int // Funds to transfer along the transaction (nil = 0 = no funds)
|
Value *big.Int // Funds to transfer along the transaction (nil = 0 = no funds)
|
||||||
GasPrice *big.Int // Gas price to use for the transaction execution (nil = gas price oracle)
|
GasPrice *big.Int // Gas price to use for the transaction execution (nil = gas price oracle)
|
||||||
GasLimit uint64 // Gas limit to set for the transaction execution (0 = estimate)
|
GasFeeCap *big.Int // Gas fee cap to use for the 1559 transaction execution (nil = gas price oracle)
|
||||||
|
GasTipCap *big.Int // Gas priority fee cap to use for the 1559 transaction execution (nil = gas price oracle)
|
||||||
|
GasLimit uint64 // Gas limit to set for the transaction execution (0 = estimate)
|
||||||
|
|
||||||
Context context.Context // Network context to support cancellation and timeouts (nil = no timeout)
|
Context context.Context // Network context to support cancellation and timeouts (nil = no timeout)
|
||||||
|
|
||||||
|
NoSend bool // Do all transact steps but do not send the transaction
|
||||||
}
|
}
|
||||||
|
|
||||||
// FilterOpts is the collection of options to fine tune filtering for events
|
// FilterOpts is the collection of options to fine tune filtering for events
|
||||||
@@ -72,6 +78,29 @@ type WatchOpts struct {
|
|||||||
Context context.Context // Network context to support cancellation and timeouts (nil = no timeout)
|
Context context.Context // Network context to support cancellation and timeouts (nil = no timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MetaData collects all metadata for a bound contract.
|
||||||
|
type MetaData struct {
|
||||||
|
mu sync.Mutex
|
||||||
|
Sigs map[string]string
|
||||||
|
Bin string
|
||||||
|
ABI string
|
||||||
|
ab *abi.ABI
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MetaData) GetAbi() (*abi.ABI, error) {
|
||||||
|
m.mu.Lock()
|
||||||
|
defer m.mu.Unlock()
|
||||||
|
if m.ab != nil {
|
||||||
|
return m.ab, nil
|
||||||
|
}
|
||||||
|
if parsed, err := abi.JSON(strings.NewReader(m.ABI)); err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else {
|
||||||
|
m.ab = &parsed
|
||||||
|
}
|
||||||
|
return m.ab, nil
|
||||||
|
}
|
||||||
|
|
||||||
// BoundContract is the base wrapper object that reflects a contract on the
|
// BoundContract is the base wrapper object that reflects a contract on the
|
||||||
// Ethereum network. It contains a collection of methods that are used by the
|
// Ethereum network. It contains a collection of methods that are used by the
|
||||||
// higher level contract bindings to operate.
|
// higher level contract bindings to operate.
|
||||||
@@ -117,11 +146,14 @@ func DeployContract(opts *TransactOpts, abi abi.ABI, bytecode []byte, backend Co
|
|||||||
// sets the output to result. The result type might be a single field for simple
|
// sets the output to result. The result type might be a single field for simple
|
||||||
// returns, a slice of interfaces for anonymous returns and a struct for named
|
// returns, a slice of interfaces for anonymous returns and a struct for named
|
||||||
// returns.
|
// returns.
|
||||||
func (c *BoundContract) Call(opts *CallOpts, result interface{}, method string, params ...interface{}) error {
|
func (c *BoundContract) Call(opts *CallOpts, results *[]interface{}, method string, params ...interface{}) error {
|
||||||
// Don't crash on a lazy user
|
// Don't crash on a lazy user
|
||||||
if opts == nil {
|
if opts == nil {
|
||||||
opts = new(CallOpts)
|
opts = new(CallOpts)
|
||||||
}
|
}
|
||||||
|
if results == nil {
|
||||||
|
results = new([]interface{})
|
||||||
|
}
|
||||||
// Pack the input, call and unpack the results
|
// Pack the input, call and unpack the results
|
||||||
input, err := c.abi.Pack(method, params...)
|
input, err := c.abi.Pack(method, params...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -139,7 +171,10 @@ func (c *BoundContract) Call(opts *CallOpts, result interface{}, method string,
|
|||||||
return ErrNoPendingState
|
return ErrNoPendingState
|
||||||
}
|
}
|
||||||
output, err = pb.PendingCallContract(ctx, msg)
|
output, err = pb.PendingCallContract(ctx, msg)
|
||||||
if err == nil && len(output) == 0 {
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if len(output) == 0 {
|
||||||
// Make sure we have a contract to operate on, and bail out otherwise.
|
// Make sure we have a contract to operate on, and bail out otherwise.
|
||||||
if code, err = pb.PendingCodeAt(ctx, c.address); err != nil {
|
if code, err = pb.PendingCodeAt(ctx, c.address); err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -149,7 +184,10 @@ func (c *BoundContract) Call(opts *CallOpts, result interface{}, method string,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
output, err = c.caller.CallContract(ctx, msg, opts.BlockNumber)
|
output, err = c.caller.CallContract(ctx, msg, opts.BlockNumber)
|
||||||
if err == nil && len(output) == 0 {
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if len(output) == 0 {
|
||||||
// Make sure we have a contract to operate on, and bail out otherwise.
|
// Make sure we have a contract to operate on, and bail out otherwise.
|
||||||
if code, err = c.caller.CodeAt(ctx, c.address, opts.BlockNumber); err != nil {
|
if code, err = c.caller.CodeAt(ctx, c.address, opts.BlockNumber); err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -158,10 +196,14 @@ func (c *BoundContract) Call(opts *CallOpts, result interface{}, method string,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err != nil {
|
|
||||||
|
if len(*results) == 0 {
|
||||||
|
res, err := c.abi.Unpack(method, output)
|
||||||
|
*results = res
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return c.abi.Unpack(result, method, output)
|
res := *results
|
||||||
|
return c.abi.UnpackIntoInterface(res[0], method, output)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transact invokes the (paid) contract method with params as input values.
|
// Transact invokes the (paid) contract method with params as input values.
|
||||||
@@ -177,7 +219,7 @@ func (c *BoundContract) Transact(opts *TransactOpts, method string, params ...in
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RawTransact initiates a transaction with the given raw calldata as the input.
|
// RawTransact initiates a transaction with the given raw calldata as the input.
|
||||||
// It's usually used to initiates transaction for invoking **Fallback** function.
|
// It's usually used to initiate transactions for invoking **Fallback** function.
|
||||||
func (c *BoundContract) RawTransact(opts *TransactOpts, calldata []byte) (*types.Transaction, error) {
|
func (c *BoundContract) RawTransact(opts *TransactOpts, calldata []byte) (*types.Transaction, error) {
|
||||||
// todo(rjl493456442) check the method is payable or not,
|
// todo(rjl493456442) check the method is payable or not,
|
||||||
// reject invalid transaction at the first place
|
// reject invalid transaction at the first place
|
||||||
@@ -192,64 +234,168 @@ func (c *BoundContract) Transfer(opts *TransactOpts) (*types.Transaction, error)
|
|||||||
return c.transact(opts, &c.address, nil)
|
return c.transact(opts, &c.address, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// transact executes an actual transaction invocation, first deriving any missing
|
func (c *BoundContract) createDynamicTx(opts *TransactOpts, contract *common.Address, input []byte, head *types.Header) (*types.Transaction, error) {
|
||||||
// authorization fields, and then scheduling the transaction for execution.
|
// Normalize value
|
||||||
func (c *BoundContract) transact(opts *TransactOpts, contract *common.Address, input []byte) (*types.Transaction, error) {
|
|
||||||
var err error
|
|
||||||
|
|
||||||
// Ensure a valid value field and resolve the account nonce
|
|
||||||
value := opts.Value
|
value := opts.Value
|
||||||
if value == nil {
|
if value == nil {
|
||||||
value = new(big.Int)
|
value = new(big.Int)
|
||||||
}
|
}
|
||||||
var nonce uint64
|
// Estimate TipCap
|
||||||
if opts.Nonce == nil {
|
gasTipCap := opts.GasTipCap
|
||||||
nonce, err = c.transactor.PendingNonceAt(ensureContext(opts.Context), opts.From)
|
if gasTipCap == nil {
|
||||||
|
tip, err := c.transactor.SuggestGasTipCap(ensureContext(opts.Context))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to retrieve account nonce: %v", err)
|
return nil, err
|
||||||
}
|
}
|
||||||
} else {
|
gasTipCap = tip
|
||||||
nonce = opts.Nonce.Uint64()
|
|
||||||
}
|
}
|
||||||
// Figure out the gas allowance and gas price values
|
// Estimate FeeCap
|
||||||
|
gasFeeCap := opts.GasFeeCap
|
||||||
|
if gasFeeCap == nil {
|
||||||
|
gasFeeCap = new(big.Int).Add(
|
||||||
|
gasTipCap,
|
||||||
|
new(big.Int).Mul(head.BaseFee, big.NewInt(2)),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if gasFeeCap.Cmp(gasTipCap) < 0 {
|
||||||
|
return nil, fmt.Errorf("maxFeePerGas (%v) < maxPriorityFeePerGas (%v)", gasFeeCap, gasTipCap)
|
||||||
|
}
|
||||||
|
// Estimate GasLimit
|
||||||
|
gasLimit := opts.GasLimit
|
||||||
|
if opts.GasLimit == 0 {
|
||||||
|
var err error
|
||||||
|
gasLimit, err = c.estimateGasLimit(opts, contract, input, nil, gasTipCap, gasFeeCap, value)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// create the transaction
|
||||||
|
nonce, err := c.getNonce(opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
baseTx := &types.DynamicFeeTx{
|
||||||
|
To: contract,
|
||||||
|
Nonce: nonce,
|
||||||
|
GasFeeCap: gasFeeCap,
|
||||||
|
GasTipCap: gasTipCap,
|
||||||
|
Gas: gasLimit,
|
||||||
|
Value: value,
|
||||||
|
Data: input,
|
||||||
|
}
|
||||||
|
return types.NewTx(baseTx), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *BoundContract) createLegacyTx(opts *TransactOpts, contract *common.Address, input []byte) (*types.Transaction, error) {
|
||||||
|
if opts.GasFeeCap != nil || opts.GasTipCap != nil {
|
||||||
|
return nil, errors.New("maxFeePerGas or maxPriorityFeePerGas specified but london is not active yet")
|
||||||
|
}
|
||||||
|
// Normalize value
|
||||||
|
value := opts.Value
|
||||||
|
if value == nil {
|
||||||
|
value = new(big.Int)
|
||||||
|
}
|
||||||
|
// Estimate GasPrice
|
||||||
gasPrice := opts.GasPrice
|
gasPrice := opts.GasPrice
|
||||||
if gasPrice == nil {
|
if gasPrice == nil {
|
||||||
gasPrice, err = c.transactor.SuggestGasPrice(ensureContext(opts.Context))
|
price, err := c.transactor.SuggestGasPrice(ensureContext(opts.Context))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to suggest gas price: %v", err)
|
return nil, err
|
||||||
}
|
}
|
||||||
|
gasPrice = price
|
||||||
}
|
}
|
||||||
|
// Estimate GasLimit
|
||||||
gasLimit := opts.GasLimit
|
gasLimit := opts.GasLimit
|
||||||
if gasLimit == 0 {
|
if opts.GasLimit == 0 {
|
||||||
// Gas estimation cannot succeed without code for method invocations
|
var err error
|
||||||
if contract != nil {
|
gasLimit, err = c.estimateGasLimit(opts, contract, input, gasPrice, nil, nil, value)
|
||||||
if code, err := c.transactor.PendingCodeAt(ensureContext(opts.Context), c.address); err != nil {
|
|
||||||
return nil, err
|
|
||||||
} else if len(code) == 0 {
|
|
||||||
return nil, ErrNoCode
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// If the contract surely has code (or code is not needed), estimate the transaction
|
|
||||||
msg := ethereum.CallMsg{From: opts.From, To: contract, GasPrice: gasPrice, Value: value, Data: input}
|
|
||||||
gasLimit, err = c.transactor.EstimateGas(ensureContext(opts.Context), msg)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to estimate gas needed: %v", err)
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Create the transaction, sign it and schedule it for execution
|
// create the transaction
|
||||||
var rawTx *types.Transaction
|
nonce, err := c.getNonce(opts)
|
||||||
if contract == nil {
|
if err != nil {
|
||||||
rawTx = types.NewContractCreation(nonce, value, gasLimit, gasPrice, input)
|
return nil, err
|
||||||
} else {
|
|
||||||
rawTx = types.NewTransaction(nonce, c.address, value, gasLimit, gasPrice, input)
|
|
||||||
}
|
}
|
||||||
|
baseTx := &types.LegacyTx{
|
||||||
|
To: contract,
|
||||||
|
Nonce: nonce,
|
||||||
|
GasPrice: gasPrice,
|
||||||
|
Gas: gasLimit,
|
||||||
|
Value: value,
|
||||||
|
Data: input,
|
||||||
|
}
|
||||||
|
return types.NewTx(baseTx), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *BoundContract) estimateGasLimit(opts *TransactOpts, contract *common.Address, input []byte, gasPrice, gasTipCap, gasFeeCap, value *big.Int) (uint64, error) {
|
||||||
|
if contract != nil {
|
||||||
|
// Gas estimation cannot succeed without code for method invocations.
|
||||||
|
if code, err := c.transactor.PendingCodeAt(ensureContext(opts.Context), c.address); err != nil {
|
||||||
|
return 0, err
|
||||||
|
} else if len(code) == 0 {
|
||||||
|
return 0, ErrNoCode
|
||||||
|
}
|
||||||
|
}
|
||||||
|
msg := ethereum.CallMsg{
|
||||||
|
From: opts.From,
|
||||||
|
To: contract,
|
||||||
|
GasPrice: gasPrice,
|
||||||
|
GasTipCap: gasTipCap,
|
||||||
|
GasFeeCap: gasFeeCap,
|
||||||
|
Value: value,
|
||||||
|
Data: input,
|
||||||
|
}
|
||||||
|
return c.transactor.EstimateGas(ensureContext(opts.Context), msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *BoundContract) getNonce(opts *TransactOpts) (uint64, error) {
|
||||||
|
if opts.Nonce == nil {
|
||||||
|
return c.transactor.PendingNonceAt(ensureContext(opts.Context), opts.From)
|
||||||
|
} else {
|
||||||
|
return opts.Nonce.Uint64(), nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// transact executes an actual transaction invocation, first deriving any missing
|
||||||
|
// authorization fields, and then scheduling the transaction for execution.
|
||||||
|
func (c *BoundContract) transact(opts *TransactOpts, contract *common.Address, input []byte) (*types.Transaction, error) {
|
||||||
|
if opts.GasPrice != nil && (opts.GasFeeCap != nil || opts.GasTipCap != nil) {
|
||||||
|
return nil, errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified")
|
||||||
|
}
|
||||||
|
// Create the transaction
|
||||||
|
var (
|
||||||
|
rawTx *types.Transaction
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
if opts.GasPrice != nil {
|
||||||
|
rawTx, err = c.createLegacyTx(opts, contract, input)
|
||||||
|
} else {
|
||||||
|
// Only query for basefee if gasPrice not specified
|
||||||
|
if head, errHead := c.transactor.HeaderByNumber(ensureContext(opts.Context), nil); errHead != nil {
|
||||||
|
return nil, errHead
|
||||||
|
} else if head.BaseFee != nil {
|
||||||
|
rawTx, err = c.createDynamicTx(opts, contract, input, head)
|
||||||
|
} else {
|
||||||
|
// Chain is not London ready -> use legacy transaction
|
||||||
|
rawTx, err = c.createLegacyTx(opts, contract, input)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
// Sign the transaction and schedule it for execution
|
||||||
if opts.Signer == nil {
|
if opts.Signer == nil {
|
||||||
return nil, errors.New("no signer to authorize the transaction with")
|
return nil, errors.New("no signer to authorize the transaction with")
|
||||||
}
|
}
|
||||||
signedTx, err := opts.Signer(types.HomesteadSigner{}, opts.From, rawTx)
|
signedTx, err := opts.Signer(opts.From, rawTx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if opts.NoSend {
|
||||||
|
return signedTx, nil
|
||||||
|
}
|
||||||
if err := c.transactor.SendTransaction(ensureContext(opts.Context), signedTx); err != nil {
|
if err := c.transactor.SendTransaction(ensureContext(opts.Context), signedTx); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -338,8 +484,11 @@ func (c *BoundContract) WatchLogs(opts *WatchOpts, name string, query ...[]inter
|
|||||||
|
|
||||||
// UnpackLog unpacks a retrieved log into the provided output structure.
|
// UnpackLog unpacks a retrieved log into the provided output structure.
|
||||||
func (c *BoundContract) UnpackLog(out interface{}, event string, log types.Log) error {
|
func (c *BoundContract) UnpackLog(out interface{}, event string, log types.Log) error {
|
||||||
|
if log.Topics[0] != c.abi.Events[event].ID {
|
||||||
|
return fmt.Errorf("event signature mismatch")
|
||||||
|
}
|
||||||
if len(log.Data) > 0 {
|
if len(log.Data) > 0 {
|
||||||
if err := c.abi.Unpack(out, event, log.Data); err != nil {
|
if err := c.abi.UnpackIntoInterface(out, event, log.Data); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -354,6 +503,9 @@ func (c *BoundContract) UnpackLog(out interface{}, event string, log types.Log)
|
|||||||
|
|
||||||
// UnpackLogIntoMap unpacks a retrieved log into the provided map.
|
// UnpackLogIntoMap unpacks a retrieved log into the provided map.
|
||||||
func (c *BoundContract) UnpackLogIntoMap(out map[string]interface{}, event string, log types.Log) error {
|
func (c *BoundContract) UnpackLogIntoMap(out map[string]interface{}, event string, log types.Log) error {
|
||||||
|
if log.Topics[0] != c.abi.Events[event].ID {
|
||||||
|
return fmt.Errorf("event signature mismatch")
|
||||||
|
}
|
||||||
if len(log.Data) > 0 {
|
if len(log.Data) > 0 {
|
||||||
if err := c.abi.UnpackIntoMap(out, event, log.Data); err != nil {
|
if err := c.abi.UnpackIntoMap(out, event, log.Data); err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -372,7 +524,7 @@ func (c *BoundContract) UnpackLogIntoMap(out map[string]interface{}, event strin
|
|||||||
// user specified it as such.
|
// user specified it as such.
|
||||||
func ensureContext(ctx context.Context) context.Context {
|
func ensureContext(ctx context.Context) context.Context {
|
||||||
if ctx == nil {
|
if ctx == nil {
|
||||||
return context.TODO()
|
return context.Background()
|
||||||
}
|
}
|
||||||
return ctx
|
return ctx
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package bind_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"math/big"
|
"math/big"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -31,37 +32,95 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func mockSign(addr common.Address, tx *types.Transaction) (*types.Transaction, error) { return tx, nil }
|
||||||
|
|
||||||
|
type mockTransactor struct {
|
||||||
|
baseFee *big.Int
|
||||||
|
gasTipCap *big.Int
|
||||||
|
gasPrice *big.Int
|
||||||
|
suggestGasTipCapCalled bool
|
||||||
|
suggestGasPriceCalled bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mt *mockTransactor) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error) {
|
||||||
|
return &types.Header{BaseFee: mt.baseFee}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mt *mockTransactor) PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error) {
|
||||||
|
return []byte{1}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mt *mockTransactor) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error) {
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mt *mockTransactor) SuggestGasPrice(ctx context.Context) (*big.Int, error) {
|
||||||
|
mt.suggestGasPriceCalled = true
|
||||||
|
return mt.gasPrice, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mt *mockTransactor) SuggestGasTipCap(ctx context.Context) (*big.Int, error) {
|
||||||
|
mt.suggestGasTipCapCalled = true
|
||||||
|
return mt.gasTipCap, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mt *mockTransactor) EstimateGas(ctx context.Context, call ethereum.CallMsg) (gas uint64, err error) {
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mt *mockTransactor) SendTransaction(ctx context.Context, tx *types.Transaction) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
type mockCaller struct {
|
type mockCaller struct {
|
||||||
codeAtBlockNumber *big.Int
|
codeAtBlockNumber *big.Int
|
||||||
callContractBlockNumber *big.Int
|
callContractBlockNumber *big.Int
|
||||||
pendingCodeAtCalled bool
|
callContractBytes []byte
|
||||||
pendingCallContractCalled bool
|
callContractErr error
|
||||||
|
codeAtBytes []byte
|
||||||
|
codeAtErr error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mc *mockCaller) CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error) {
|
func (mc *mockCaller) CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error) {
|
||||||
mc.codeAtBlockNumber = blockNumber
|
mc.codeAtBlockNumber = blockNumber
|
||||||
return []byte{1, 2, 3}, nil
|
return mc.codeAtBytes, mc.codeAtErr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mc *mockCaller) CallContract(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) ([]byte, error) {
|
func (mc *mockCaller) CallContract(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) ([]byte, error) {
|
||||||
mc.callContractBlockNumber = blockNumber
|
mc.callContractBlockNumber = blockNumber
|
||||||
return nil, nil
|
return mc.callContractBytes, mc.callContractErr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mc *mockCaller) PendingCodeAt(ctx context.Context, contract common.Address) ([]byte, error) {
|
type mockPendingCaller struct {
|
||||||
|
*mockCaller
|
||||||
|
pendingCodeAtBytes []byte
|
||||||
|
pendingCodeAtErr error
|
||||||
|
pendingCodeAtCalled bool
|
||||||
|
pendingCallContractCalled bool
|
||||||
|
pendingCallContractBytes []byte
|
||||||
|
pendingCallContractErr error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mc *mockPendingCaller) PendingCodeAt(ctx context.Context, contract common.Address) ([]byte, error) {
|
||||||
mc.pendingCodeAtCalled = true
|
mc.pendingCodeAtCalled = true
|
||||||
return nil, nil
|
return mc.pendingCodeAtBytes, mc.pendingCodeAtErr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mc *mockCaller) PendingCallContract(ctx context.Context, call ethereum.CallMsg) ([]byte, error) {
|
func (mc *mockPendingCaller) PendingCallContract(ctx context.Context, call ethereum.CallMsg) ([]byte, error) {
|
||||||
mc.pendingCallContractCalled = true
|
mc.pendingCallContractCalled = true
|
||||||
return nil, nil
|
return mc.pendingCallContractBytes, mc.pendingCallContractErr
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPassingBlockNumber(t *testing.T) {
|
func TestPassingBlockNumber(t *testing.T) {
|
||||||
|
|
||||||
mc := &mockCaller{}
|
mc := &mockPendingCaller{
|
||||||
|
mockCaller: &mockCaller{
|
||||||
|
codeAtBytes: []byte{1, 2, 3},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
bc := bind.NewBoundContract(common.HexToAddress("0x0"), abi.ABI{
|
bc := bind.NewBoundContract(common.HexToAddress("0x0"), abi.ABI{
|
||||||
Methods: map[string]abi.Method{
|
Methods: map[string]abi.Method{
|
||||||
@@ -71,11 +130,10 @@ func TestPassingBlockNumber(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, mc, nil, nil)
|
}, mc, nil, nil)
|
||||||
var ret string
|
|
||||||
|
|
||||||
blockNumber := big.NewInt(42)
|
blockNumber := big.NewInt(42)
|
||||||
|
|
||||||
bc.Call(&bind.CallOpts{BlockNumber: blockNumber}, &ret, "something")
|
bc.Call(&bind.CallOpts{BlockNumber: blockNumber}, nil, "something")
|
||||||
|
|
||||||
if mc.callContractBlockNumber != blockNumber {
|
if mc.callContractBlockNumber != blockNumber {
|
||||||
t.Fatalf("CallContract() was not passed the block number")
|
t.Fatalf("CallContract() was not passed the block number")
|
||||||
@@ -85,7 +143,7 @@ func TestPassingBlockNumber(t *testing.T) {
|
|||||||
t.Fatalf("CodeAt() was not passed the block number")
|
t.Fatalf("CodeAt() was not passed the block number")
|
||||||
}
|
}
|
||||||
|
|
||||||
bc.Call(&bind.CallOpts{}, &ret, "something")
|
bc.Call(&bind.CallOpts{}, nil, "something")
|
||||||
|
|
||||||
if mc.callContractBlockNumber != nil {
|
if mc.callContractBlockNumber != nil {
|
||||||
t.Fatalf("CallContract() was passed a block number when it should not have been")
|
t.Fatalf("CallContract() was passed a block number when it should not have been")
|
||||||
@@ -95,7 +153,7 @@ func TestPassingBlockNumber(t *testing.T) {
|
|||||||
t.Fatalf("CodeAt() was passed a block number when it should not have been")
|
t.Fatalf("CodeAt() was passed a block number when it should not have been")
|
||||||
}
|
}
|
||||||
|
|
||||||
bc.Call(&bind.CallOpts{BlockNumber: blockNumber, Pending: true}, &ret, "something")
|
bc.Call(&bind.CallOpts{BlockNumber: blockNumber, Pending: true}, nil, "something")
|
||||||
|
|
||||||
if !mc.pendingCallContractCalled {
|
if !mc.pendingCallContractCalled {
|
||||||
t.Fatalf("CallContract() was not passed the block number")
|
t.Fatalf("CallContract() was not passed the block number")
|
||||||
@@ -111,7 +169,7 @@ const hexData = "0x000000000000000000000000376c47978271565f56deb45495afa69e59c16
|
|||||||
func TestUnpackIndexedStringTyLogIntoMap(t *testing.T) {
|
func TestUnpackIndexedStringTyLogIntoMap(t *testing.T) {
|
||||||
hash := crypto.Keccak256Hash([]byte("testName"))
|
hash := crypto.Keccak256Hash([]byte("testName"))
|
||||||
topics := []common.Hash{
|
topics := []common.Hash{
|
||||||
common.HexToHash("0x0"),
|
crypto.Keccak256Hash([]byte("received(string,address,uint256,bytes)")),
|
||||||
hash,
|
hash,
|
||||||
}
|
}
|
||||||
mockLog := newMockLog(topics, common.HexToHash("0x0"))
|
mockLog := newMockLog(topics, common.HexToHash("0x0"))
|
||||||
@@ -136,7 +194,7 @@ func TestUnpackIndexedSliceTyLogIntoMap(t *testing.T) {
|
|||||||
}
|
}
|
||||||
hash := crypto.Keccak256Hash(sliceBytes)
|
hash := crypto.Keccak256Hash(sliceBytes)
|
||||||
topics := []common.Hash{
|
topics := []common.Hash{
|
||||||
common.HexToHash("0x0"),
|
crypto.Keccak256Hash([]byte("received(string[],address,uint256,bytes)")),
|
||||||
hash,
|
hash,
|
||||||
}
|
}
|
||||||
mockLog := newMockLog(topics, common.HexToHash("0x0"))
|
mockLog := newMockLog(topics, common.HexToHash("0x0"))
|
||||||
@@ -161,7 +219,7 @@ func TestUnpackIndexedArrayTyLogIntoMap(t *testing.T) {
|
|||||||
}
|
}
|
||||||
hash := crypto.Keccak256Hash(arrBytes)
|
hash := crypto.Keccak256Hash(arrBytes)
|
||||||
topics := []common.Hash{
|
topics := []common.Hash{
|
||||||
common.HexToHash("0x0"),
|
crypto.Keccak256Hash([]byte("received(address[2],address,uint256,bytes)")),
|
||||||
hash,
|
hash,
|
||||||
}
|
}
|
||||||
mockLog := newMockLog(topics, common.HexToHash("0x0"))
|
mockLog := newMockLog(topics, common.HexToHash("0x0"))
|
||||||
@@ -188,7 +246,7 @@ func TestUnpackIndexedFuncTyLogIntoMap(t *testing.T) {
|
|||||||
var functionTy [24]byte
|
var functionTy [24]byte
|
||||||
copy(functionTy[:], functionTyBytes[0:24])
|
copy(functionTy[:], functionTyBytes[0:24])
|
||||||
topics := []common.Hash{
|
topics := []common.Hash{
|
||||||
common.HexToHash("0x99b5620489b6ef926d4518936cfec15d305452712b88bd59da2d9c10fb0953e8"),
|
crypto.Keccak256Hash([]byte("received(function,address,uint256,bytes)")),
|
||||||
common.BytesToHash(functionTyBytes),
|
common.BytesToHash(functionTyBytes),
|
||||||
}
|
}
|
||||||
mockLog := newMockLog(topics, common.HexToHash("0x5c698f13940a2153440c6d19660878bc90219d9298fdcf37365aa8d88d40fc42"))
|
mockLog := newMockLog(topics, common.HexToHash("0x5c698f13940a2153440c6d19660878bc90219d9298fdcf37365aa8d88d40fc42"))
|
||||||
@@ -209,7 +267,7 @@ func TestUnpackIndexedBytesTyLogIntoMap(t *testing.T) {
|
|||||||
bytes := []byte{1, 2, 3, 4, 5}
|
bytes := []byte{1, 2, 3, 4, 5}
|
||||||
hash := crypto.Keccak256Hash(bytes)
|
hash := crypto.Keccak256Hash(bytes)
|
||||||
topics := []common.Hash{
|
topics := []common.Hash{
|
||||||
common.HexToHash("0x99b5620489b6ef926d4518936cfec15d305452712b88bd59da2d9c10fb0953e8"),
|
crypto.Keccak256Hash([]byte("received(bytes,address,uint256,bytes)")),
|
||||||
hash,
|
hash,
|
||||||
}
|
}
|
||||||
mockLog := newMockLog(topics, common.HexToHash("0x5c698f13940a2153440c6d19660878bc90219d9298fdcf37365aa8d88d40fc42"))
|
mockLog := newMockLog(topics, common.HexToHash("0x5c698f13940a2153440c6d19660878bc90219d9298fdcf37365aa8d88d40fc42"))
|
||||||
@@ -227,6 +285,51 @@ func TestUnpackIndexedBytesTyLogIntoMap(t *testing.T) {
|
|||||||
unpackAndCheck(t, bc, expectedReceivedMap, mockLog)
|
unpackAndCheck(t, bc, expectedReceivedMap, mockLog)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestTransactGasFee(t *testing.T) {
|
||||||
|
assert := assert.New(t)
|
||||||
|
|
||||||
|
// GasTipCap and GasFeeCap
|
||||||
|
// When opts.GasTipCap and opts.GasFeeCap are nil
|
||||||
|
mt := &mockTransactor{baseFee: big.NewInt(100), gasTipCap: big.NewInt(5)}
|
||||||
|
bc := bind.NewBoundContract(common.Address{}, abi.ABI{}, nil, mt, nil)
|
||||||
|
opts := &bind.TransactOpts{Signer: mockSign}
|
||||||
|
tx, err := bc.Transact(opts, "")
|
||||||
|
assert.Nil(err)
|
||||||
|
assert.Equal(big.NewInt(5), tx.GasTipCap())
|
||||||
|
assert.Equal(big.NewInt(205), tx.GasFeeCap())
|
||||||
|
assert.Nil(opts.GasTipCap)
|
||||||
|
assert.Nil(opts.GasFeeCap)
|
||||||
|
assert.True(mt.suggestGasTipCapCalled)
|
||||||
|
|
||||||
|
// Second call to Transact should use latest suggested GasTipCap
|
||||||
|
mt.gasTipCap = big.NewInt(6)
|
||||||
|
mt.suggestGasTipCapCalled = false
|
||||||
|
tx, err = bc.Transact(opts, "")
|
||||||
|
assert.Nil(err)
|
||||||
|
assert.Equal(big.NewInt(6), tx.GasTipCap())
|
||||||
|
assert.Equal(big.NewInt(206), tx.GasFeeCap())
|
||||||
|
assert.True(mt.suggestGasTipCapCalled)
|
||||||
|
|
||||||
|
// GasPrice
|
||||||
|
// When opts.GasPrice is nil
|
||||||
|
mt = &mockTransactor{gasPrice: big.NewInt(5)}
|
||||||
|
bc = bind.NewBoundContract(common.Address{}, abi.ABI{}, nil, mt, nil)
|
||||||
|
opts = &bind.TransactOpts{Signer: mockSign}
|
||||||
|
tx, err = bc.Transact(opts, "")
|
||||||
|
assert.Nil(err)
|
||||||
|
assert.Equal(big.NewInt(5), tx.GasPrice())
|
||||||
|
assert.Nil(opts.GasPrice)
|
||||||
|
assert.True(mt.suggestGasPriceCalled)
|
||||||
|
|
||||||
|
// Second call to Transact should use latest suggested GasPrice
|
||||||
|
mt.gasPrice = big.NewInt(6)
|
||||||
|
mt.suggestGasPriceCalled = false
|
||||||
|
tx, err = bc.Transact(opts, "")
|
||||||
|
assert.Nil(err)
|
||||||
|
assert.Equal(big.NewInt(6), tx.GasPrice())
|
||||||
|
assert.True(mt.suggestGasPriceCalled)
|
||||||
|
}
|
||||||
|
|
||||||
func unpackAndCheck(t *testing.T, bc *bind.BoundContract, expected map[string]interface{}, mockLog types.Log) {
|
func unpackAndCheck(t *testing.T, bc *bind.BoundContract, expected map[string]interface{}, mockLog types.Log) {
|
||||||
received := make(map[string]interface{})
|
received := make(map[string]interface{})
|
||||||
if err := bc.UnpackLogIntoMap(received, "received", mockLog); err != nil {
|
if err := bc.UnpackLogIntoMap(received, "received", mockLog); err != nil {
|
||||||
@@ -256,3 +359,140 @@ func newMockLog(topics []common.Hash, txHash common.Hash) types.Log {
|
|||||||
Removed: false,
|
Removed: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCall(t *testing.T) {
|
||||||
|
var method, methodWithArg = "something", "somethingArrrrg"
|
||||||
|
tests := []struct {
|
||||||
|
name, method string
|
||||||
|
opts *bind.CallOpts
|
||||||
|
mc bind.ContractCaller
|
||||||
|
results *[]interface{}
|
||||||
|
wantErr bool
|
||||||
|
wantErrExact error
|
||||||
|
}{{
|
||||||
|
name: "ok not pending",
|
||||||
|
mc: &mockCaller{
|
||||||
|
codeAtBytes: []byte{0},
|
||||||
|
},
|
||||||
|
method: method,
|
||||||
|
}, {
|
||||||
|
name: "ok pending",
|
||||||
|
mc: &mockPendingCaller{
|
||||||
|
pendingCodeAtBytes: []byte{0},
|
||||||
|
},
|
||||||
|
opts: &bind.CallOpts{
|
||||||
|
Pending: true,
|
||||||
|
},
|
||||||
|
method: method,
|
||||||
|
}, {
|
||||||
|
name: "pack error, no method",
|
||||||
|
mc: new(mockCaller),
|
||||||
|
method: "else",
|
||||||
|
wantErr: true,
|
||||||
|
}, {
|
||||||
|
name: "interface error, pending but not a PendingContractCaller",
|
||||||
|
mc: new(mockCaller),
|
||||||
|
opts: &bind.CallOpts{
|
||||||
|
Pending: true,
|
||||||
|
},
|
||||||
|
method: method,
|
||||||
|
wantErrExact: bind.ErrNoPendingState,
|
||||||
|
}, {
|
||||||
|
name: "pending call canceled",
|
||||||
|
mc: &mockPendingCaller{
|
||||||
|
pendingCallContractErr: context.DeadlineExceeded,
|
||||||
|
},
|
||||||
|
opts: &bind.CallOpts{
|
||||||
|
Pending: true,
|
||||||
|
},
|
||||||
|
method: method,
|
||||||
|
wantErrExact: context.DeadlineExceeded,
|
||||||
|
}, {
|
||||||
|
name: "pending code at error",
|
||||||
|
mc: &mockPendingCaller{
|
||||||
|
pendingCodeAtErr: errors.New(""),
|
||||||
|
},
|
||||||
|
opts: &bind.CallOpts{
|
||||||
|
Pending: true,
|
||||||
|
},
|
||||||
|
method: method,
|
||||||
|
wantErr: true,
|
||||||
|
}, {
|
||||||
|
name: "no pending code at",
|
||||||
|
mc: new(mockPendingCaller),
|
||||||
|
opts: &bind.CallOpts{
|
||||||
|
Pending: true,
|
||||||
|
},
|
||||||
|
method: method,
|
||||||
|
wantErrExact: bind.ErrNoCode,
|
||||||
|
}, {
|
||||||
|
name: "call contract error",
|
||||||
|
mc: &mockCaller{
|
||||||
|
callContractErr: context.DeadlineExceeded,
|
||||||
|
},
|
||||||
|
method: method,
|
||||||
|
wantErrExact: context.DeadlineExceeded,
|
||||||
|
}, {
|
||||||
|
name: "code at error",
|
||||||
|
mc: &mockCaller{
|
||||||
|
codeAtErr: errors.New(""),
|
||||||
|
},
|
||||||
|
method: method,
|
||||||
|
wantErr: true,
|
||||||
|
}, {
|
||||||
|
name: "no code at",
|
||||||
|
mc: new(mockCaller),
|
||||||
|
method: method,
|
||||||
|
wantErrExact: bind.ErrNoCode,
|
||||||
|
}, {
|
||||||
|
name: "unpack error missing arg",
|
||||||
|
mc: &mockCaller{
|
||||||
|
codeAtBytes: []byte{0},
|
||||||
|
},
|
||||||
|
method: methodWithArg,
|
||||||
|
wantErr: true,
|
||||||
|
}, {
|
||||||
|
name: "interface unpack error",
|
||||||
|
mc: &mockCaller{
|
||||||
|
codeAtBytes: []byte{0},
|
||||||
|
},
|
||||||
|
method: method,
|
||||||
|
results: &[]interface{}{0},
|
||||||
|
wantErr: true,
|
||||||
|
}}
|
||||||
|
for _, test := range tests {
|
||||||
|
bc := bind.NewBoundContract(common.HexToAddress("0x0"), abi.ABI{
|
||||||
|
Methods: map[string]abi.Method{
|
||||||
|
method: {
|
||||||
|
Name: method,
|
||||||
|
Outputs: abi.Arguments{},
|
||||||
|
},
|
||||||
|
methodWithArg: {
|
||||||
|
Name: methodWithArg,
|
||||||
|
Outputs: abi.Arguments{abi.Argument{}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}, test.mc, nil, nil)
|
||||||
|
err := bc.Call(test.opts, test.results, test.method)
|
||||||
|
if test.wantErr || test.wantErrExact != nil {
|
||||||
|
if err == nil {
|
||||||
|
t.Fatalf("%q expected error", test.name)
|
||||||
|
}
|
||||||
|
if test.wantErrExact != nil && !errors.Is(err, test.wantErrExact) {
|
||||||
|
t.Fatalf("%q expected error %q but got %q", test.name, test.wantErrExact, err)
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("%q unexpected error: %v", test.name, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestCrashers contains some strings which previously caused the abi codec to crash.
|
||||||
|
func TestCrashers(t *testing.T) {
|
||||||
|
abi.JSON(strings.NewReader(`[{"inputs":[{"type":"tuple[]","components":[{"type":"bool","name":"_1"}]}]}]`))
|
||||||
|
abi.JSON(strings.NewReader(`[{"inputs":[{"type":"tuple[]","components":[{"type":"bool","name":"&"}]}]}]`))
|
||||||
|
abi.JSON(strings.NewReader(`[{"inputs":[{"type":"tuple[]","components":[{"type":"bool","name":"----"}]}]}]`))
|
||||||
|
abi.JSON(strings.NewReader(`[{"inputs":[{"type":"tuple[]","components":[{"type":"bool","name":"foo.Bar"}]}]}]`))
|
||||||
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]
|
|||||||
// contracts is the map of each individual contract requested binding
|
// contracts is the map of each individual contract requested binding
|
||||||
contracts = make(map[string]*tmplContract)
|
contracts = make(map[string]*tmplContract)
|
||||||
|
|
||||||
// structs is the map of all reclared structs shared by passed contracts.
|
// structs is the map of all redeclared structs shared by passed contracts.
|
||||||
structs = make(map[string]*tmplStruct)
|
structs = make(map[string]*tmplStruct)
|
||||||
|
|
||||||
// isLib is the map used to flag each encountered library as such
|
// isLib is the map used to flag each encountered library as such
|
||||||
@@ -80,18 +80,26 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]
|
|||||||
fallback *tmplMethod
|
fallback *tmplMethod
|
||||||
receive *tmplMethod
|
receive *tmplMethod
|
||||||
|
|
||||||
// identifiers are used to detect duplicated identifier of function
|
// identifiers are used to detect duplicated identifiers of functions
|
||||||
// and event. For all calls, transacts and events, abigen will generate
|
// and events. For all calls, transacts and events, abigen will generate
|
||||||
// corresponding bindings. However we have to ensure there is no
|
// corresponding bindings. However we have to ensure there is no
|
||||||
// identifier coliision in the bindings of these categories.
|
// identifier collisions in the bindings of these categories.
|
||||||
callIdentifiers = make(map[string]bool)
|
callIdentifiers = make(map[string]bool)
|
||||||
transactIdentifiers = make(map[string]bool)
|
transactIdentifiers = make(map[string]bool)
|
||||||
eventIdentifiers = make(map[string]bool)
|
eventIdentifiers = make(map[string]bool)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
for _, input := range evmABI.Constructor.Inputs {
|
||||||
|
if hasStruct(input.Type) {
|
||||||
|
bindStructType[lang](input.Type, structs)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for _, original := range evmABI.Methods {
|
for _, original := range evmABI.Methods {
|
||||||
// Normalize the method for capital cases and non-anonymous inputs/outputs
|
// Normalize the method for capital cases and non-anonymous inputs/outputs
|
||||||
normalized := original
|
normalized := original
|
||||||
normalizedName := methodNormalizer[lang](alias(aliases, original.Name))
|
normalizedName := methodNormalizer[lang](alias(aliases, original.Name))
|
||||||
|
|
||||||
// Ensure there is no duplicated identifier
|
// Ensure there is no duplicated identifier
|
||||||
var identifiers = callIdentifiers
|
var identifiers = callIdentifiers
|
||||||
if !original.IsConstant() {
|
if !original.IsConstant() {
|
||||||
@@ -101,6 +109,7 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]
|
|||||||
return "", fmt.Errorf("duplicated identifier \"%s\"(normalized \"%s\"), use --alias for renaming", original.Name, normalizedName)
|
return "", fmt.Errorf("duplicated identifier \"%s\"(normalized \"%s\"), use --alias for renaming", original.Name, normalizedName)
|
||||||
}
|
}
|
||||||
identifiers[normalizedName] = true
|
identifiers[normalizedName] = true
|
||||||
|
|
||||||
normalized.Name = normalizedName
|
normalized.Name = normalizedName
|
||||||
normalized.Inputs = make([]abi.Argument, len(original.Inputs))
|
normalized.Inputs = make([]abi.Argument, len(original.Inputs))
|
||||||
copy(normalized.Inputs, original.Inputs)
|
copy(normalized.Inputs, original.Inputs)
|
||||||
@@ -145,12 +154,22 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]
|
|||||||
eventIdentifiers[normalizedName] = true
|
eventIdentifiers[normalizedName] = true
|
||||||
normalized.Name = normalizedName
|
normalized.Name = normalizedName
|
||||||
|
|
||||||
|
used := make(map[string]bool)
|
||||||
normalized.Inputs = make([]abi.Argument, len(original.Inputs))
|
normalized.Inputs = make([]abi.Argument, len(original.Inputs))
|
||||||
copy(normalized.Inputs, original.Inputs)
|
copy(normalized.Inputs, original.Inputs)
|
||||||
for j, input := range normalized.Inputs {
|
for j, input := range normalized.Inputs {
|
||||||
if input.Name == "" {
|
if input.Name == "" {
|
||||||
normalized.Inputs[j].Name = fmt.Sprintf("arg%d", j)
|
normalized.Inputs[j].Name = fmt.Sprintf("arg%d", j)
|
||||||
}
|
}
|
||||||
|
// Event is a bit special, we need to define event struct in binding,
|
||||||
|
// ensure there is no camel-case-style name conflict.
|
||||||
|
for index := 0; ; index++ {
|
||||||
|
if !used[capitalise(normalized.Inputs[j].Name)] {
|
||||||
|
used[capitalise(normalized.Inputs[j].Name)] = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
normalized.Inputs[j].Name = fmt.Sprintf("%s%d", normalized.Inputs[j].Name, index)
|
||||||
|
}
|
||||||
if hasStruct(input.Type) {
|
if hasStruct(input.Type) {
|
||||||
bindStructType[lang](input.Type, structs)
|
bindStructType[lang](input.Type, structs)
|
||||||
}
|
}
|
||||||
@@ -172,7 +191,7 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]
|
|||||||
|
|
||||||
contracts[types[i]] = &tmplContract{
|
contracts[types[i]] = &tmplContract{
|
||||||
Type: capitalise(types[i]),
|
Type: capitalise(types[i]),
|
||||||
InputABI: strings.Replace(strippedABI, "\"", "\\\"", -1),
|
InputABI: strings.ReplaceAll(strippedABI, "\"", "\\\""),
|
||||||
InputBin: strings.TrimPrefix(strings.TrimSpace(bytecodes[i]), "0x"),
|
InputBin: strings.TrimPrefix(strings.TrimSpace(bytecodes[i]), "0x"),
|
||||||
Constructor: evmABI.Constructor,
|
Constructor: evmABI.Constructor,
|
||||||
Calls: calls,
|
Calls: calls,
|
||||||
@@ -246,7 +265,7 @@ var bindType = map[Lang]func(kind abi.Type, structs map[string]*tmplStruct) stri
|
|||||||
LangJava: bindTypeJava,
|
LangJava: bindTypeJava,
|
||||||
}
|
}
|
||||||
|
|
||||||
// bindBasicTypeGo converts basic solidity types(except array, slice and tuple) to Go one.
|
// bindBasicTypeGo converts basic solidity types(except array, slice and tuple) to Go ones.
|
||||||
func bindBasicTypeGo(kind abi.Type) string {
|
func bindBasicTypeGo(kind abi.Type) string {
|
||||||
switch kind.T {
|
switch kind.T {
|
||||||
case abi.AddressTy:
|
case abi.AddressTy:
|
||||||
@@ -286,7 +305,7 @@ func bindTypeGo(kind abi.Type, structs map[string]*tmplStruct) string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// bindBasicTypeJava converts basic solidity types(except array, slice and tuple) to Java one.
|
// bindBasicTypeJava converts basic solidity types(except array, slice and tuple) to Java ones.
|
||||||
func bindBasicTypeJava(kind abi.Type) string {
|
func bindBasicTypeJava(kind abi.Type) string {
|
||||||
switch kind.T {
|
switch kind.T {
|
||||||
case abi.AddressTy:
|
case abi.AddressTy:
|
||||||
@@ -330,7 +349,7 @@ func bindBasicTypeJava(kind abi.Type) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// pluralizeJavaType explicitly converts multidimensional types to predefined
|
// pluralizeJavaType explicitly converts multidimensional types to predefined
|
||||||
// type in go side.
|
// types in go side.
|
||||||
func pluralizeJavaType(typ string) string {
|
func pluralizeJavaType(typ string) string {
|
||||||
switch typ {
|
switch typ {
|
||||||
case "boolean":
|
case "boolean":
|
||||||
@@ -369,7 +388,7 @@ var bindTopicType = map[Lang]func(kind abi.Type, structs map[string]*tmplStruct)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// bindTopicTypeGo converts a Solidity topic type to a Go one. It is almost the same
|
// bindTopicTypeGo converts a Solidity topic type to a Go one. It is almost the same
|
||||||
// funcionality as for simple types, but dynamic types get converted to hashes.
|
// functionality as for simple types, but dynamic types get converted to hashes.
|
||||||
func bindTopicTypeGo(kind abi.Type, structs map[string]*tmplStruct) string {
|
func bindTopicTypeGo(kind abi.Type, structs map[string]*tmplStruct) string {
|
||||||
bound := bindTypeGo(kind, structs)
|
bound := bindTypeGo(kind, structs)
|
||||||
|
|
||||||
@@ -386,7 +405,7 @@ func bindTopicTypeGo(kind abi.Type, structs map[string]*tmplStruct) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// bindTopicTypeJava converts a Solidity topic type to a Java one. It is almost the same
|
// bindTopicTypeJava converts a Solidity topic type to a Java one. It is almost the same
|
||||||
// funcionality as for simple types, but dynamic types get converted to hashes.
|
// functionality as for simple types, but dynamic types get converted to hashes.
|
||||||
func bindTopicTypeJava(kind abi.Type, structs map[string]*tmplStruct) string {
|
func bindTopicTypeJava(kind abi.Type, structs map[string]*tmplStruct) string {
|
||||||
bound := bindTypeJava(kind, structs)
|
bound := bindTypeJava(kind, structs)
|
||||||
|
|
||||||
@@ -394,7 +413,7 @@ func bindTopicTypeJava(kind abi.Type, structs map[string]*tmplStruct) string {
|
|||||||
// parameters that are not value types i.e. arrays and structs are not
|
// parameters that are not value types i.e. arrays and structs are not
|
||||||
// stored directly but instead a keccak256-hash of an encoding is stored.
|
// stored directly but instead a keccak256-hash of an encoding is stored.
|
||||||
//
|
//
|
||||||
// We only convert stringS and bytes to hash, still need to deal with
|
// We only convert strings and bytes to hash, still need to deal with
|
||||||
// array(both fixed-size and dynamic-size) and struct.
|
// array(both fixed-size and dynamic-size) and struct.
|
||||||
if bound == "String" || bound == "byte[]" {
|
if bound == "String" || bound == "byte[]" {
|
||||||
bound = "Hash"
|
bound = "Hash"
|
||||||
@@ -415,7 +434,7 @@ var bindStructType = map[Lang]func(kind abi.Type, structs map[string]*tmplStruct
|
|||||||
func bindStructTypeGo(kind abi.Type, structs map[string]*tmplStruct) string {
|
func bindStructTypeGo(kind abi.Type, structs map[string]*tmplStruct) string {
|
||||||
switch kind.T {
|
switch kind.T {
|
||||||
case abi.TupleTy:
|
case abi.TupleTy:
|
||||||
// We compose raw struct name and canonical parameter expression
|
// We compose a raw struct name and a canonical parameter expression
|
||||||
// together here. The reason is before solidity v0.5.11, kind.TupleRawName
|
// together here. The reason is before solidity v0.5.11, kind.TupleRawName
|
||||||
// is empty, so we use canonical parameter expression to distinguish
|
// is empty, so we use canonical parameter expression to distinguish
|
||||||
// different struct definition. From the consideration of backward
|
// different struct definition. From the consideration of backward
|
||||||
@@ -425,15 +444,22 @@ func bindStructTypeGo(kind abi.Type, structs map[string]*tmplStruct) string {
|
|||||||
if s, exist := structs[id]; exist {
|
if s, exist := structs[id]; exist {
|
||||||
return s.Name
|
return s.Name
|
||||||
}
|
}
|
||||||
var fields []*tmplField
|
var (
|
||||||
|
names = make(map[string]bool)
|
||||||
|
fields []*tmplField
|
||||||
|
)
|
||||||
for i, elem := range kind.TupleElems {
|
for i, elem := range kind.TupleElems {
|
||||||
field := bindStructTypeGo(*elem, structs)
|
name := capitalise(kind.TupleRawNames[i])
|
||||||
fields = append(fields, &tmplField{Type: field, Name: capitalise(kind.TupleRawNames[i]), SolKind: *elem})
|
name = abi.ResolveNameConflict(name, func(s string) bool { return names[s] })
|
||||||
|
names[name] = true
|
||||||
|
fields = append(fields, &tmplField{Type: bindStructTypeGo(*elem, structs), Name: name, SolKind: *elem})
|
||||||
}
|
}
|
||||||
name := kind.TupleRawName
|
name := kind.TupleRawName
|
||||||
if name == "" {
|
if name == "" {
|
||||||
name = fmt.Sprintf("Struct%d", len(structs))
|
name = fmt.Sprintf("Struct%d", len(structs))
|
||||||
}
|
}
|
||||||
|
name = capitalise(name)
|
||||||
|
|
||||||
structs[id] = &tmplStruct{
|
structs[id] = &tmplStruct{
|
||||||
Name: name,
|
Name: name,
|
||||||
Fields: fields,
|
Fields: fields,
|
||||||
@@ -454,7 +480,7 @@ func bindStructTypeGo(kind abi.Type, structs map[string]*tmplStruct) string {
|
|||||||
func bindStructTypeJava(kind abi.Type, structs map[string]*tmplStruct) string {
|
func bindStructTypeJava(kind abi.Type, structs map[string]*tmplStruct) string {
|
||||||
switch kind.T {
|
switch kind.T {
|
||||||
case abi.TupleTy:
|
case abi.TupleTy:
|
||||||
// We compose raw struct name and canonical parameter expression
|
// We compose a raw struct name and a canonical parameter expression
|
||||||
// together here. The reason is before solidity v0.5.11, kind.TupleRawName
|
// together here. The reason is before solidity v0.5.11, kind.TupleRawName
|
||||||
// is empty, so we use canonical parameter expression to distinguish
|
// is empty, so we use canonical parameter expression to distinguish
|
||||||
// different struct definition. From the consideration of backward
|
// different struct definition. From the consideration of backward
|
||||||
@@ -486,7 +512,7 @@ func bindStructTypeJava(kind abi.Type, structs map[string]*tmplStruct) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// namedType is a set of functions that transform language specific types to
|
// namedType is a set of functions that transform language specific types to
|
||||||
// named versions that my be used inside method names.
|
// named versions that may be used inside method names.
|
||||||
var namedType = map[Lang]func(string, abi.Type) string{
|
var namedType = map[Lang]func(string, abi.Type) string{
|
||||||
LangGo: func(string, abi.Type) string { panic("this shouldn't be needed") },
|
LangGo: func(string, abi.Type) string { panic("this shouldn't be needed") },
|
||||||
LangJava: namedTypeJava,
|
LangJava: namedTypeJava,
|
||||||
@@ -528,7 +554,7 @@ func alias(aliases map[string]string, n string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// methodNormalizer is a name transformer that modifies Solidity method names to
|
// methodNormalizer is a name transformer that modifies Solidity method names to
|
||||||
// conform to target language naming concentions.
|
// conform to target language naming conventions.
|
||||||
var methodNormalizer = map[Lang]func(string) string{
|
var methodNormalizer = map[Lang]func(string) string{
|
||||||
LangGo: abi.ToCamelCase,
|
LangGo: abi.ToCamelCase,
|
||||||
LangJava: decapitalise,
|
LangJava: decapitalise,
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ package bind
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -296,9 +295,9 @@ var bindTests = []struct {
|
|||||||
`
|
`
|
||||||
// Generate a new random account and a funded simulator
|
// Generate a new random account and a funded simulator
|
||||||
key, _ := crypto.GenerateKey()
|
key, _ := crypto.GenerateKey()
|
||||||
auth := bind.NewKeyedTransactor(key)
|
auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
|
||||||
|
|
||||||
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
|
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000)
|
||||||
defer sim.Close()
|
defer sim.Close()
|
||||||
|
|
||||||
// Deploy an interaction tester contract and call a transaction on it
|
// Deploy an interaction tester contract and call a transaction on it
|
||||||
@@ -351,9 +350,9 @@ var bindTests = []struct {
|
|||||||
`
|
`
|
||||||
// Generate a new random account and a funded simulator
|
// Generate a new random account and a funded simulator
|
||||||
key, _ := crypto.GenerateKey()
|
key, _ := crypto.GenerateKey()
|
||||||
auth := bind.NewKeyedTransactor(key)
|
auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
|
||||||
|
|
||||||
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
|
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000)
|
||||||
defer sim.Close()
|
defer sim.Close()
|
||||||
|
|
||||||
// Deploy a tuple tester contract and execute a structured call on it
|
// Deploy a tuple tester contract and execute a structured call on it
|
||||||
@@ -397,9 +396,9 @@ var bindTests = []struct {
|
|||||||
`
|
`
|
||||||
// Generate a new random account and a funded simulator
|
// Generate a new random account and a funded simulator
|
||||||
key, _ := crypto.GenerateKey()
|
key, _ := crypto.GenerateKey()
|
||||||
auth := bind.NewKeyedTransactor(key)
|
auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
|
||||||
|
|
||||||
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
|
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000)
|
||||||
defer sim.Close()
|
defer sim.Close()
|
||||||
|
|
||||||
// Deploy a tuple tester contract and execute a structured call on it
|
// Deploy a tuple tester contract and execute a structured call on it
|
||||||
@@ -455,9 +454,9 @@ var bindTests = []struct {
|
|||||||
`
|
`
|
||||||
// Generate a new random account and a funded simulator
|
// Generate a new random account and a funded simulator
|
||||||
key, _ := crypto.GenerateKey()
|
key, _ := crypto.GenerateKey()
|
||||||
auth := bind.NewKeyedTransactor(key)
|
auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
|
||||||
|
|
||||||
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
|
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000)
|
||||||
defer sim.Close()
|
defer sim.Close()
|
||||||
|
|
||||||
// Deploy a slice tester contract and execute a n array call on it
|
// Deploy a slice tester contract and execute a n array call on it
|
||||||
@@ -503,9 +502,9 @@ var bindTests = []struct {
|
|||||||
`
|
`
|
||||||
// Generate a new random account and a funded simulator
|
// Generate a new random account and a funded simulator
|
||||||
key, _ := crypto.GenerateKey()
|
key, _ := crypto.GenerateKey()
|
||||||
auth := bind.NewKeyedTransactor(key)
|
auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
|
||||||
|
|
||||||
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
|
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000)
|
||||||
defer sim.Close()
|
defer sim.Close()
|
||||||
|
|
||||||
// Deploy a default method invoker contract and execute its default method
|
// Deploy a default method invoker contract and execute its default method
|
||||||
@@ -529,6 +528,70 @@ var bindTests = []struct {
|
|||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
},
|
},
|
||||||
|
// Tests that structs are correctly unpacked
|
||||||
|
{
|
||||||
|
|
||||||
|
`Structs`,
|
||||||
|
`
|
||||||
|
pragma solidity ^0.6.5;
|
||||||
|
pragma experimental ABIEncoderV2;
|
||||||
|
contract Structs {
|
||||||
|
struct A {
|
||||||
|
bytes32 B;
|
||||||
|
}
|
||||||
|
|
||||||
|
function F() public view returns (A[] memory a, uint256[] memory c, bool[] memory d) {
|
||||||
|
A[] memory a = new A[](2);
|
||||||
|
a[0].B = bytes32(uint256(1234) << 96);
|
||||||
|
uint256[] memory c;
|
||||||
|
bool[] memory d;
|
||||||
|
return (a, c, d);
|
||||||
|
}
|
||||||
|
|
||||||
|
function G() public view returns (A[] memory a) {
|
||||||
|
A[] memory a = new A[](2);
|
||||||
|
a[0].B = bytes32(uint256(1234) << 96);
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
[]string{`608060405234801561001057600080fd5b50610278806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c806328811f591461003b5780636fecb6231461005b575b600080fd5b610043610070565b604051610052939291906101a0565b60405180910390f35b6100636100d6565b6040516100529190610186565b604080516002808252606082810190935282918291829190816020015b610095610131565b81526020019060019003908161008d575050805190915061026960611b9082906000906100be57fe5b60209081029190910101515293606093508392509050565b6040805160028082526060828101909352829190816020015b6100f7610131565b8152602001906001900390816100ef575050805190915061026960611b90829060009061012057fe5b602090810291909101015152905090565b60408051602081019091526000815290565b815260200190565b6000815180845260208085019450808401835b8381101561017b578151518752958201959082019060010161015e565b509495945050505050565b600060208252610199602083018461014b565b9392505050565b6000606082526101b3606083018661014b565b6020838203818501528186516101c98185610239565b91508288019350845b818110156101f3576101e5838651610143565b9484019492506001016101d2565b505084810360408601528551808252908201925081860190845b8181101561022b57825115158552938301939183019160010161020d565b509298975050505050505050565b9081526020019056fea2646970667358221220eb85327e285def14230424c52893aebecec1e387a50bb6b75fc4fdbed647f45f64736f6c63430006050033`},
|
||||||
|
[]string{`[{"inputs":[],"name":"F","outputs":[{"components":[{"internalType":"bytes32","name":"B","type":"bytes32"}],"internalType":"structStructs.A[]","name":"a","type":"tuple[]"},{"internalType":"uint256[]","name":"c","type":"uint256[]"},{"internalType":"bool[]","name":"d","type":"bool[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"G","outputs":[{"components":[{"internalType":"bytes32","name":"B","type":"bytes32"}],"internalType":"structStructs.A[]","name":"a","type":"tuple[]"}],"stateMutability":"view","type":"function"}]`},
|
||||||
|
`
|
||||||
|
"math/big"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||||
|
"github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
|
||||||
|
"github.com/ethereum/go-ethereum/core"
|
||||||
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
|
`,
|
||||||
|
`
|
||||||
|
// Generate a new random account and a funded simulator
|
||||||
|
key, _ := crypto.GenerateKey()
|
||||||
|
auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
|
||||||
|
|
||||||
|
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000)
|
||||||
|
defer sim.Close()
|
||||||
|
|
||||||
|
// Deploy a structs method invoker contract and execute its default method
|
||||||
|
_, _, structs, err := DeployStructs(auth, sim)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to deploy defaulter contract: %v", err)
|
||||||
|
}
|
||||||
|
sim.Commit()
|
||||||
|
opts := bind.CallOpts{}
|
||||||
|
if _, err := structs.F(&opts); err != nil {
|
||||||
|
t.Fatalf("Failed to invoke F method: %v", err)
|
||||||
|
}
|
||||||
|
if _, err := structs.G(&opts); err != nil {
|
||||||
|
t.Fatalf("Failed to invoke G method: %v", err)
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
nil,
|
||||||
|
nil,
|
||||||
|
nil,
|
||||||
|
nil,
|
||||||
|
},
|
||||||
// Tests that non-existent contracts are reported as such (though only simulator test)
|
// Tests that non-existent contracts are reported as such (though only simulator test)
|
||||||
{
|
{
|
||||||
`NonExistent`,
|
`NonExistent`,
|
||||||
@@ -569,6 +632,45 @@ var bindTests = []struct {
|
|||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
`NonExistentStruct`,
|
||||||
|
`
|
||||||
|
contract NonExistentStruct {
|
||||||
|
function Struct() public view returns(uint256 a, uint256 b) {
|
||||||
|
return (10, 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
[]string{`6080604052348015600f57600080fd5b5060888061001e6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063d5f6622514602d575b600080fd5b6033604c565b6040805192835260208301919091528051918290030190f35b600a809156fea264697066735822beefbeefbeefbeefbeefbeefbeefbeefbeefbeefbeefbeefbeefbeefbeefbeefbeef64736f6c6343decafe0033`},
|
||||||
|
[]string{`[{"inputs":[],"name":"Struct","outputs":[{"internalType":"uint256","name":"a","type":"uint256"},{"internalType":"uint256","name":"b","type":"uint256"}],"stateMutability":"pure","type":"function"}]`},
|
||||||
|
`
|
||||||
|
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||||
|
"github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/core"
|
||||||
|
`,
|
||||||
|
`
|
||||||
|
// Create a simulator and wrap a non-deployed contract
|
||||||
|
|
||||||
|
sim := backends.NewSimulatedBackend(core.GenesisAlloc{}, uint64(10000000000))
|
||||||
|
defer sim.Close()
|
||||||
|
|
||||||
|
nonexistent, err := NewNonExistentStruct(common.Address{}, sim)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to access non-existent contract: %v", err)
|
||||||
|
}
|
||||||
|
// Ensure that contract calls fail with the appropriate error
|
||||||
|
if res, err := nonexistent.Struct(nil); err == nil {
|
||||||
|
t.Fatalf("Call succeeded on non-existent contract: %v", res)
|
||||||
|
} else if (err != bind.ErrNoCode) {
|
||||||
|
t.Fatalf("Error mismatch: have %v, want %v", err, bind.ErrNoCode)
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
nil,
|
||||||
|
nil,
|
||||||
|
nil,
|
||||||
|
nil,
|
||||||
|
},
|
||||||
// Tests that gas estimation works for contracts with weird gas mechanics too.
|
// Tests that gas estimation works for contracts with weird gas mechanics too.
|
||||||
{
|
{
|
||||||
`FunkyGasPattern`,
|
`FunkyGasPattern`,
|
||||||
@@ -598,9 +700,9 @@ var bindTests = []struct {
|
|||||||
`
|
`
|
||||||
// Generate a new random account and a funded simulator
|
// Generate a new random account and a funded simulator
|
||||||
key, _ := crypto.GenerateKey()
|
key, _ := crypto.GenerateKey()
|
||||||
auth := bind.NewKeyedTransactor(key)
|
auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
|
||||||
|
|
||||||
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
|
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000)
|
||||||
defer sim.Close()
|
defer sim.Close()
|
||||||
|
|
||||||
// Deploy a funky gas pattern contract
|
// Deploy a funky gas pattern contract
|
||||||
@@ -648,9 +750,9 @@ var bindTests = []struct {
|
|||||||
`
|
`
|
||||||
// Generate a new random account and a funded simulator
|
// Generate a new random account and a funded simulator
|
||||||
key, _ := crypto.GenerateKey()
|
key, _ := crypto.GenerateKey()
|
||||||
auth := bind.NewKeyedTransactor(key)
|
auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
|
||||||
|
|
||||||
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
|
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000)
|
||||||
defer sim.Close()
|
defer sim.Close()
|
||||||
|
|
||||||
// Deploy a sender tester contract and execute a structured call on it
|
// Deploy a sender tester contract and execute a structured call on it
|
||||||
@@ -723,9 +825,9 @@ var bindTests = []struct {
|
|||||||
`
|
`
|
||||||
// Generate a new random account and a funded simulator
|
// Generate a new random account and a funded simulator
|
||||||
key, _ := crypto.GenerateKey()
|
key, _ := crypto.GenerateKey()
|
||||||
auth := bind.NewKeyedTransactor(key)
|
auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
|
||||||
|
|
||||||
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
|
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000)
|
||||||
defer sim.Close()
|
defer sim.Close()
|
||||||
|
|
||||||
// Deploy a underscorer tester contract and execute a structured call on it
|
// Deploy a underscorer tester contract and execute a structured call on it
|
||||||
@@ -817,9 +919,9 @@ var bindTests = []struct {
|
|||||||
`
|
`
|
||||||
// Generate a new random account and a funded simulator
|
// Generate a new random account and a funded simulator
|
||||||
key, _ := crypto.GenerateKey()
|
key, _ := crypto.GenerateKey()
|
||||||
auth := bind.NewKeyedTransactor(key)
|
auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
|
||||||
|
|
||||||
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
|
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000)
|
||||||
defer sim.Close()
|
defer sim.Close()
|
||||||
|
|
||||||
// Deploy an eventer contract
|
// Deploy an eventer contract
|
||||||
@@ -1007,9 +1109,9 @@ var bindTests = []struct {
|
|||||||
`
|
`
|
||||||
// Generate a new random account and a funded simulator
|
// Generate a new random account and a funded simulator
|
||||||
key, _ := crypto.GenerateKey()
|
key, _ := crypto.GenerateKey()
|
||||||
auth := bind.NewKeyedTransactor(key)
|
auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
|
||||||
|
|
||||||
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
|
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000)
|
||||||
defer sim.Close()
|
defer sim.Close()
|
||||||
|
|
||||||
//deploy the test contract
|
//deploy the test contract
|
||||||
@@ -1142,9 +1244,9 @@ var bindTests = []struct {
|
|||||||
|
|
||||||
`
|
`
|
||||||
key, _ := crypto.GenerateKey()
|
key, _ := crypto.GenerateKey()
|
||||||
auth := bind.NewKeyedTransactor(key)
|
auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
|
||||||
|
|
||||||
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
|
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000)
|
||||||
defer sim.Close()
|
defer sim.Close()
|
||||||
|
|
||||||
_, _, contract, err := DeployTuple(auth, sim)
|
_, _, contract, err := DeployTuple(auth, sim)
|
||||||
@@ -1284,9 +1386,9 @@ var bindTests = []struct {
|
|||||||
`
|
`
|
||||||
// Generate a new random account and a funded simulator
|
// Generate a new random account and a funded simulator
|
||||||
key, _ := crypto.GenerateKey()
|
key, _ := crypto.GenerateKey()
|
||||||
auth := bind.NewKeyedTransactor(key)
|
auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
|
||||||
|
|
||||||
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
|
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000)
|
||||||
defer sim.Close()
|
defer sim.Close()
|
||||||
|
|
||||||
//deploy the test contract
|
//deploy the test contract
|
||||||
@@ -1350,8 +1452,8 @@ var bindTests = []struct {
|
|||||||
`
|
`
|
||||||
// Initialize test accounts
|
// Initialize test accounts
|
||||||
key, _ := crypto.GenerateKey()
|
key, _ := crypto.GenerateKey()
|
||||||
auth := bind.NewKeyedTransactor(key)
|
auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
|
||||||
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
|
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000)
|
||||||
defer sim.Close()
|
defer sim.Close()
|
||||||
|
|
||||||
// deploy the test contract
|
// deploy the test contract
|
||||||
@@ -1441,10 +1543,10 @@ var bindTests = []struct {
|
|||||||
addr := crypto.PubkeyToAddress(key.PublicKey)
|
addr := crypto.PubkeyToAddress(key.PublicKey)
|
||||||
|
|
||||||
// Deploy registrar contract
|
// Deploy registrar contract
|
||||||
sim := backends.NewSimulatedBackend(core.GenesisAlloc{addr: {Balance: big.NewInt(1000000000)}}, 10000000)
|
sim := backends.NewSimulatedBackend(core.GenesisAlloc{addr: {Balance: big.NewInt(10000000000000000)}}, 10000000)
|
||||||
defer sim.Close()
|
defer sim.Close()
|
||||||
|
|
||||||
transactOpts := bind.NewKeyedTransactor(key)
|
transactOpts, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
|
||||||
_, _, _, err := DeployIdentifierCollision(transactOpts, sim)
|
_, _, _, err := DeployIdentifierCollision(transactOpts, sim)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to deploy contract: %v", err)
|
t.Fatalf("failed to deploy contract: %v", err)
|
||||||
@@ -1503,10 +1605,10 @@ var bindTests = []struct {
|
|||||||
addr := crypto.PubkeyToAddress(key.PublicKey)
|
addr := crypto.PubkeyToAddress(key.PublicKey)
|
||||||
|
|
||||||
// Deploy registrar contract
|
// Deploy registrar contract
|
||||||
sim := backends.NewSimulatedBackend(core.GenesisAlloc{addr: {Balance: big.NewInt(1000000000)}}, 10000000)
|
sim := backends.NewSimulatedBackend(core.GenesisAlloc{addr: {Balance: big.NewInt(10000000000000000)}}, 10000000)
|
||||||
defer sim.Close()
|
defer sim.Close()
|
||||||
|
|
||||||
transactOpts := bind.NewKeyedTransactor(key)
|
transactOpts, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
|
||||||
_, _, c1, err := DeployContractOne(transactOpts, sim)
|
_, _, c1, err := DeployContractOne(transactOpts, sim)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Failed to deploy contract")
|
t.Fatal("Failed to deploy contract")
|
||||||
@@ -1563,9 +1665,9 @@ var bindTests = []struct {
|
|||||||
`
|
`
|
||||||
// Generate a new random account and a funded simulator
|
// Generate a new random account and a funded simulator
|
||||||
key, _ := crypto.GenerateKey()
|
key, _ := crypto.GenerateKey()
|
||||||
auth := bind.NewKeyedTransactor(key)
|
auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
|
||||||
|
|
||||||
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
|
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000)
|
||||||
defer sim.Close()
|
defer sim.Close()
|
||||||
|
|
||||||
// Deploy a tester contract and execute a structured call on it
|
// Deploy a tester contract and execute a structured call on it
|
||||||
@@ -1601,11 +1703,7 @@ var bindTests = []struct {
|
|||||||
contract NewFallbacks {
|
contract NewFallbacks {
|
||||||
event Fallback(bytes data);
|
event Fallback(bytes data);
|
||||||
fallback() external {
|
fallback() external {
|
||||||
bytes memory data;
|
emit Fallback(msg.data);
|
||||||
assembly {
|
|
||||||
calldatacopy(data, 0, calldatasize())
|
|
||||||
}
|
|
||||||
emit Fallback(data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
event Received(address addr, uint value);
|
event Received(address addr, uint value);
|
||||||
@@ -1614,7 +1712,7 @@ var bindTests = []struct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
[]string{"60806040523480156100115760006000fd5b50610017565b61016e806100266000396000f3fe60806040526004361061000d575b36610081575b7f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f885258743334604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a15b005b34801561008e5760006000fd5b505b606036600082377f9043988963722edecc2099c75b0af0ff76af14ffca42ed6bce059a20a2a9f986816040518080602001828103825283818151815260200191508051906020019080838360005b838110156100fa5780820151818401525b6020810190506100de565b50505050905090810190601f1680156101275780820380516001836020036101000a031916815260200191505b509250505060405180910390a1505b00fea26469706673582212205643ca37f40c2b352dc541f42e9e6720de065de756324b7fcc9fb1d67eda4a7d64736f6c63430006040033"},
|
[]string{"6080604052348015600f57600080fd5b506101078061001f6000396000f3fe608060405236605f577f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f885258743334604051808373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a1005b348015606a57600080fd5b507f9043988963722edecc2099c75b0af0ff76af14ffca42ed6bce059a20a2a9f98660003660405180806020018281038252848482818152602001925080828437600081840152601f19601f820116905080830192505050935050505060405180910390a100fea26469706673582212201f994dcfbc53bf610b19176f9a361eafa77b447fd9c796fa2c615dfd0aaf3b8b64736f6c634300060c0033"},
|
||||||
[]string{`[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"Fallback","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"addr","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Received","type":"event"},{"stateMutability":"nonpayable","type":"fallback"},{"stateMutability":"payable","type":"receive"}]`},
|
[]string{`[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"Fallback","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"addr","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Received","type":"event"},{"stateMutability":"nonpayable","type":"fallback"},{"stateMutability":"payable","type":"receive"}]`},
|
||||||
`
|
`
|
||||||
"bytes"
|
"bytes"
|
||||||
@@ -1629,10 +1727,10 @@ var bindTests = []struct {
|
|||||||
key, _ := crypto.GenerateKey()
|
key, _ := crypto.GenerateKey()
|
||||||
addr := crypto.PubkeyToAddress(key.PublicKey)
|
addr := crypto.PubkeyToAddress(key.PublicKey)
|
||||||
|
|
||||||
sim := backends.NewSimulatedBackend(core.GenesisAlloc{addr: {Balance: big.NewInt(1000000000)}}, 1000000)
|
sim := backends.NewSimulatedBackend(core.GenesisAlloc{addr: {Balance: big.NewInt(10000000000000000)}}, 1000000)
|
||||||
defer sim.Close()
|
defer sim.Close()
|
||||||
|
|
||||||
opts := bind.NewKeyedTransactor(key)
|
opts, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
|
||||||
_, _, c, err := DeployNewFallbacks(opts, sim)
|
_, _, c, err := DeployNewFallbacks(opts, sim)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to deploy contract: %v", err)
|
t.Fatalf("Failed to deploy contract: %v", err)
|
||||||
@@ -1662,6 +1760,7 @@ var bindTests = []struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Test fallback function
|
// Test fallback function
|
||||||
|
gotEvent = false
|
||||||
opts.Value = nil
|
opts.Value = nil
|
||||||
calldata := []byte{0x01, 0x02, 0x03}
|
calldata := []byte{0x01, 0x02, 0x03}
|
||||||
c.Fallback(opts, calldata)
|
c.Fallback(opts, calldata)
|
||||||
@@ -1685,6 +1784,224 @@ var bindTests = []struct {
|
|||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
},
|
},
|
||||||
|
// Test resolving single struct argument
|
||||||
|
{
|
||||||
|
`NewSingleStructArgument`,
|
||||||
|
`
|
||||||
|
pragma solidity ^0.8.0;
|
||||||
|
|
||||||
|
contract NewSingleStructArgument {
|
||||||
|
struct MyStruct{
|
||||||
|
uint256 a;
|
||||||
|
uint256 b;
|
||||||
|
}
|
||||||
|
event StructEvent(MyStruct s);
|
||||||
|
function TestEvent() public {
|
||||||
|
emit StructEvent(MyStruct({a: 1, b: 2}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
[]string{"608060405234801561001057600080fd5b50610113806100206000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c806324ec1d3f14602d575b600080fd5b60336035565b005b7fb4b2ff75e30cb4317eaae16dd8a187dd89978df17565104caa6c2797caae27d460405180604001604052806001815260200160028152506040516078919060ba565b60405180910390a1565b6040820160008201516096600085018260ad565b50602082015160a7602085018260ad565b50505050565b60b48160d3565b82525050565b600060408201905060cd60008301846082565b92915050565b600081905091905056fea26469706673582212208823628796125bf9941ce4eda18da1be3cf2931b231708ab848e1bd7151c0c9a64736f6c63430008070033"},
|
||||||
|
[]string{`[{"anonymous":false,"inputs":[{"components":[{"internalType":"uint256","name":"a","type":"uint256"},{"internalType":"uint256","name":"b","type":"uint256"}],"indexed":false,"internalType":"struct Test.MyStruct","name":"s","type":"tuple"}],"name":"StructEvent","type":"event"},{"inputs":[],"name":"TestEvent","outputs":[],"stateMutability":"nonpayable","type":"function"}]`},
|
||||||
|
`
|
||||||
|
"math/big"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||||
|
"github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
|
||||||
|
"github.com/ethereum/go-ethereum/core"
|
||||||
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
|
"github.com/ethereum/go-ethereum/eth/ethconfig"
|
||||||
|
`,
|
||||||
|
`
|
||||||
|
var (
|
||||||
|
key, _ = crypto.GenerateKey()
|
||||||
|
user, _ = bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
|
||||||
|
sim = backends.NewSimulatedBackend(core.GenesisAlloc{user.From: {Balance: big.NewInt(1000000000000000000)}}, ethconfig.Defaults.Miner.GasCeil)
|
||||||
|
)
|
||||||
|
defer sim.Close()
|
||||||
|
|
||||||
|
_, _, d, err := DeployNewSingleStructArgument(user, sim)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to deploy contract %v", err)
|
||||||
|
}
|
||||||
|
sim.Commit()
|
||||||
|
|
||||||
|
_, err = d.TestEvent(user)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to call contract %v", err)
|
||||||
|
}
|
||||||
|
sim.Commit()
|
||||||
|
|
||||||
|
it, err := d.FilterStructEvent(nil)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to filter contract event %v", err)
|
||||||
|
}
|
||||||
|
var count int
|
||||||
|
for it.Next() {
|
||||||
|
if it.Event.S.A.Cmp(big.NewInt(1)) != 0 {
|
||||||
|
t.Fatal("Unexpected contract event")
|
||||||
|
}
|
||||||
|
if it.Event.S.B.Cmp(big.NewInt(2)) != 0 {
|
||||||
|
t.Fatal("Unexpected contract event")
|
||||||
|
}
|
||||||
|
count += 1
|
||||||
|
}
|
||||||
|
if count != 1 {
|
||||||
|
t.Fatal("Unexpected contract event number")
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
nil,
|
||||||
|
nil,
|
||||||
|
nil,
|
||||||
|
nil,
|
||||||
|
},
|
||||||
|
// Test errors introduced in v0.8.4
|
||||||
|
{
|
||||||
|
`NewErrors`,
|
||||||
|
`
|
||||||
|
pragma solidity >0.8.4;
|
||||||
|
|
||||||
|
contract NewErrors {
|
||||||
|
error MyError(uint256);
|
||||||
|
error MyError1(uint256);
|
||||||
|
error MyError2(uint256, uint256);
|
||||||
|
error MyError3(uint256 a, uint256 b, uint256 c);
|
||||||
|
function Error() public pure {
|
||||||
|
revert MyError3(1,2,3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
[]string{"0x6080604052348015600f57600080fd5b5060998061001e6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063726c638214602d575b600080fd5b60336035565b005b60405163024876cd60e61b815260016004820152600260248201526003604482015260640160405180910390fdfea264697066735822122093f786a1bc60216540cd999fbb4a6109e0fef20abcff6e9107fb2817ca968f3c64736f6c63430008070033"},
|
||||||
|
[]string{`[{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"MyError","type":"error"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"MyError1","type":"error"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"MyError2","type":"error"},{"inputs":[{"internalType":"uint256","name":"a","type":"uint256"},{"internalType":"uint256","name":"b","type":"uint256"},{"internalType":"uint256","name":"c","type":"uint256"}],"name":"MyError3","type":"error"},{"inputs":[],"name":"Error","outputs":[],"stateMutability":"pure","type":"function"}]`},
|
||||||
|
`
|
||||||
|
"math/big"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||||
|
"github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
|
||||||
|
"github.com/ethereum/go-ethereum/core"
|
||||||
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
|
"github.com/ethereum/go-ethereum/eth/ethconfig"
|
||||||
|
`,
|
||||||
|
`
|
||||||
|
var (
|
||||||
|
key, _ = crypto.GenerateKey()
|
||||||
|
user, _ = bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
|
||||||
|
sim = backends.NewSimulatedBackend(core.GenesisAlloc{user.From: {Balance: big.NewInt(1000000000000000000)}}, ethconfig.Defaults.Miner.GasCeil)
|
||||||
|
)
|
||||||
|
defer sim.Close()
|
||||||
|
|
||||||
|
_, tx, contract, err := DeployNewErrors(user, sim)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
sim.Commit()
|
||||||
|
_, err = bind.WaitDeployed(nil, sim, tx)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
if err := contract.Error(new(bind.CallOpts)); err == nil {
|
||||||
|
t.Fatalf("expected contract to throw error")
|
||||||
|
}
|
||||||
|
// TODO (MariusVanDerWijden unpack error using abigen
|
||||||
|
// once that is implemented
|
||||||
|
`,
|
||||||
|
nil,
|
||||||
|
nil,
|
||||||
|
nil,
|
||||||
|
nil,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: `ConstructorWithStructParam`,
|
||||||
|
contract: `
|
||||||
|
pragma solidity >=0.8.0 <0.9.0;
|
||||||
|
|
||||||
|
contract ConstructorWithStructParam {
|
||||||
|
struct StructType {
|
||||||
|
uint256 field;
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(StructType memory st) {}
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
bytecode: []string{`0x608060405234801561001057600080fd5b506040516101c43803806101c48339818101604052810190610032919061014a565b50610177565b6000604051905090565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6100958261004c565b810181811067ffffffffffffffff821117156100b4576100b361005d565b5b80604052505050565b60006100c7610038565b90506100d3828261008c565b919050565b6000819050919050565b6100eb816100d8565b81146100f657600080fd5b50565b600081519050610108816100e2565b92915050565b60006020828403121561012457610123610047565b5b61012e60206100bd565b9050600061013e848285016100f9565b60008301525092915050565b6000602082840312156101605761015f610042565b5b600061016e8482850161010e565b91505092915050565b603f806101856000396000f3fe6080604052600080fdfea2646970667358221220cdffa667affecefac5561f65f4a4ba914204a8d4eb859d8cd426fb306e5c12a364736f6c634300080a0033`},
|
||||||
|
abi: []string{`[{"inputs":[{"components":[{"internalType":"uint256","name":"field","type":"uint256"}],"internalType":"struct ConstructorWithStructParam.StructType","name":"st","type":"tuple"}],"stateMutability":"nonpayable","type":"constructor"}]`},
|
||||||
|
imports: `
|
||||||
|
"math/big"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||||
|
"github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
|
||||||
|
"github.com/ethereum/go-ethereum/core"
|
||||||
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
|
"github.com/ethereum/go-ethereum/eth/ethconfig"
|
||||||
|
`,
|
||||||
|
tester: `
|
||||||
|
var (
|
||||||
|
key, _ = crypto.GenerateKey()
|
||||||
|
user, _ = bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
|
||||||
|
sim = backends.NewSimulatedBackend(core.GenesisAlloc{user.From: {Balance: big.NewInt(1000000000000000000)}}, ethconfig.Defaults.Miner.GasCeil)
|
||||||
|
)
|
||||||
|
defer sim.Close()
|
||||||
|
|
||||||
|
_, tx, _, err := DeployConstructorWithStructParam(user, sim, ConstructorWithStructParamStructType{Field: big.NewInt(42)})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("DeployConstructorWithStructParam() got err %v; want nil err", err)
|
||||||
|
}
|
||||||
|
sim.Commit()
|
||||||
|
|
||||||
|
if _, err = bind.WaitDeployed(nil, sim, tx); err != nil {
|
||||||
|
t.Logf("Deployment tx: %+v", tx)
|
||||||
|
t.Errorf("bind.WaitDeployed(nil, %T, <deployment tx>) got err %v; want nil err", sim, err)
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: `NameConflict`,
|
||||||
|
contract: `
|
||||||
|
// SPDX-License-Identifier: GPL-3.0
|
||||||
|
pragma solidity >=0.4.22 <0.9.0;
|
||||||
|
contract oracle {
|
||||||
|
struct request {
|
||||||
|
bytes data;
|
||||||
|
bytes _data;
|
||||||
|
}
|
||||||
|
event log (int msg, int _msg);
|
||||||
|
function addRequest(request memory req) public pure {}
|
||||||
|
function getRequest() pure public returns (request memory) {
|
||||||
|
return request("", "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
bytecode: []string{`0x608060405234801561001057600080fd5b5061042b806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063c2bb515f1461003b578063cce7b04814610059575b600080fd5b610043610075565b60405161005091906101af565b60405180910390f35b610073600480360381019061006e91906103ac565b6100b5565b005b61007d6100b8565b604051806040016040528060405180602001604052806000815250815260200160405180602001604052806000815250815250905090565b50565b604051806040016040528060608152602001606081525090565b600081519050919050565b600082825260208201905092915050565b60005b8381101561010c5780820151818401526020810190506100f1565b8381111561011b576000848401525b50505050565b6000601f19601f8301169050919050565b600061013d826100d2565b61014781856100dd565b93506101578185602086016100ee565b61016081610121565b840191505092915050565b600060408301600083015184820360008601526101888282610132565b915050602083015184820360208601526101a28282610132565b9150508091505092915050565b600060208201905081810360008301526101c9818461016b565b905092915050565b6000604051905090565b600080fd5b600080fd5b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61022282610121565b810181811067ffffffffffffffff82111715610241576102406101ea565b5b80604052505050565b60006102546101d1565b90506102608282610219565b919050565b600080fd5b600080fd5b600080fd5b600067ffffffffffffffff82111561028f5761028e6101ea565b5b61029882610121565b9050602081019050919050565b82818337600083830152505050565b60006102c76102c284610274565b61024a565b9050828152602081018484840111156102e3576102e261026f565b5b6102ee8482856102a5565b509392505050565b600082601f83011261030b5761030a61026a565b5b813561031b8482602086016102b4565b91505092915050565b60006040828403121561033a576103396101e5565b5b610344604061024a565b9050600082013567ffffffffffffffff81111561036457610363610265565b5b610370848285016102f6565b600083015250602082013567ffffffffffffffff81111561039457610393610265565b5b6103a0848285016102f6565b60208301525092915050565b6000602082840312156103c2576103c16101db565b5b600082013567ffffffffffffffff8111156103e0576103df6101e0565b5b6103ec84828501610324565b9150509291505056fea264697066735822122033bca1606af9b6aeba1673f98c52003cec19338539fb44b86690ce82c51483b564736f6c634300080e0033`},
|
||||||
|
abi: []string{`[ { "anonymous": false, "inputs": [ { "indexed": false, "internalType": "int256", "name": "msg", "type": "int256" }, { "indexed": false, "internalType": "int256", "name": "_msg", "type": "int256" } ], "name": "log", "type": "event" }, { "inputs": [ { "components": [ { "internalType": "bytes", "name": "data", "type": "bytes" }, { "internalType": "bytes", "name": "_data", "type": "bytes" } ], "internalType": "struct oracle.request", "name": "req", "type": "tuple" } ], "name": "addRequest", "outputs": [], "stateMutability": "pure", "type": "function" }, { "inputs": [], "name": "getRequest", "outputs": [ { "components": [ { "internalType": "bytes", "name": "data", "type": "bytes" }, { "internalType": "bytes", "name": "_data", "type": "bytes" } ], "internalType": "struct oracle.request", "name": "", "type": "tuple" } ], "stateMutability": "pure", "type": "function" } ]`},
|
||||||
|
imports: `
|
||||||
|
"math/big"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||||
|
"github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
|
||||||
|
"github.com/ethereum/go-ethereum/core"
|
||||||
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
|
"github.com/ethereum/go-ethereum/eth/ethconfig"
|
||||||
|
`,
|
||||||
|
tester: `
|
||||||
|
var (
|
||||||
|
key, _ = crypto.GenerateKey()
|
||||||
|
user, _ = bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
|
||||||
|
sim = backends.NewSimulatedBackend(core.GenesisAlloc{user.From: {Balance: big.NewInt(1000000000000000000)}}, ethconfig.Defaults.Miner.GasCeil)
|
||||||
|
)
|
||||||
|
defer sim.Close()
|
||||||
|
|
||||||
|
_, tx, _, err := DeployNameConflict(user, sim)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("DeployNameConflict() got err %v; want nil err", err)
|
||||||
|
}
|
||||||
|
sim.Commit()
|
||||||
|
|
||||||
|
if _, err = bind.WaitDeployed(nil, sim, tx); err != nil {
|
||||||
|
t.Logf("Deployment tx: %+v", tx)
|
||||||
|
t.Errorf("bind.WaitDeployed(nil, %T, <deployment tx>) got err %v; want nil err", sim, err)
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that packages generated by the binder can be successfully compiled and
|
// Tests that packages generated by the binder can be successfully compiled and
|
||||||
@@ -1696,34 +2013,31 @@ func TestGolangBindings(t *testing.T) {
|
|||||||
t.Skip("go sdk not found for testing")
|
t.Skip("go sdk not found for testing")
|
||||||
}
|
}
|
||||||
// Create a temporary workspace for the test suite
|
// Create a temporary workspace for the test suite
|
||||||
ws, err := ioutil.TempDir("", "")
|
ws := t.TempDir()
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("failed to create temporary workspace: %v", err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(ws)
|
|
||||||
|
|
||||||
pkg := filepath.Join(ws, "bindtest")
|
pkg := filepath.Join(ws, "bindtest")
|
||||||
if err = os.MkdirAll(pkg, 0700); err != nil {
|
if err := os.MkdirAll(pkg, 0700); err != nil {
|
||||||
t.Fatalf("failed to create package: %v", err)
|
t.Fatalf("failed to create package: %v", err)
|
||||||
}
|
}
|
||||||
// Generate the test suite for all the contracts
|
// Generate the test suite for all the contracts
|
||||||
for i, tt := range bindTests {
|
for i, tt := range bindTests {
|
||||||
var types []string
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
if tt.types != nil {
|
var types []string
|
||||||
types = tt.types
|
if tt.types != nil {
|
||||||
} else {
|
types = tt.types
|
||||||
types = []string{tt.name}
|
} else {
|
||||||
}
|
types = []string{tt.name}
|
||||||
// Generate the binding and create a Go source file in the workspace
|
}
|
||||||
bind, err := Bind(types, tt.abi, tt.bytecode, tt.fsigs, "bindtest", LangGo, tt.libs, tt.aliases)
|
// Generate the binding and create a Go source file in the workspace
|
||||||
if err != nil {
|
bind, err := Bind(types, tt.abi, tt.bytecode, tt.fsigs, "bindtest", LangGo, tt.libs, tt.aliases)
|
||||||
t.Fatalf("test %d: failed to generate binding: %v", i, err)
|
if err != nil {
|
||||||
}
|
t.Fatalf("test %d: failed to generate binding: %v", i, err)
|
||||||
if err = ioutil.WriteFile(filepath.Join(pkg, strings.ToLower(tt.name)+".go"), []byte(bind), 0600); err != nil {
|
}
|
||||||
t.Fatalf("test %d: failed to write binding: %v", i, err)
|
if err = os.WriteFile(filepath.Join(pkg, strings.ToLower(tt.name)+".go"), []byte(bind), 0600); err != nil {
|
||||||
}
|
t.Fatalf("test %d: failed to write binding: %v", i, err)
|
||||||
// Generate the test file with the injected test code
|
}
|
||||||
code := fmt.Sprintf(`
|
// Generate the test file with the injected test code
|
||||||
|
code := fmt.Sprintf(`
|
||||||
package bindtest
|
package bindtest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -1735,9 +2049,10 @@ func TestGolangBindings(t *testing.T) {
|
|||||||
%s
|
%s
|
||||||
}
|
}
|
||||||
`, tt.imports, tt.name, tt.tester)
|
`, tt.imports, tt.name, tt.tester)
|
||||||
if err := ioutil.WriteFile(filepath.Join(pkg, strings.ToLower(tt.name)+"_test.go"), []byte(code), 0600); err != nil {
|
if err := os.WriteFile(filepath.Join(pkg, strings.ToLower(tt.name)+"_test.go"), []byte(code), 0600); err != nil {
|
||||||
t.Fatalf("test %d: failed to write tests: %v", i, err)
|
t.Fatalf("test %d: failed to write tests: %v", i, err)
|
||||||
}
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
// Convert the package to go modules and use the current source for go-ethereum
|
// Convert the package to go modules and use the current source for go-ethereum
|
||||||
moder := exec.Command(gocmd, "mod", "init", "bindtest")
|
moder := exec.Command(gocmd, "mod", "init", "bindtest")
|
||||||
@@ -1746,11 +2061,16 @@ func TestGolangBindings(t *testing.T) {
|
|||||||
t.Fatalf("failed to convert binding test to modules: %v\n%s", err, out)
|
t.Fatalf("failed to convert binding test to modules: %v\n%s", err, out)
|
||||||
}
|
}
|
||||||
pwd, _ := os.Getwd()
|
pwd, _ := os.Getwd()
|
||||||
replacer := exec.Command(gocmd, "mod", "edit", "-replace", "github.com/ethereum/go-ethereum="+filepath.Join(pwd, "..", "..", "..")) // Repo root
|
replacer := exec.Command(gocmd, "mod", "edit", "-x", "-require", "github.com/ethereum/go-ethereum@v0.0.0", "-replace", "github.com/ethereum/go-ethereum="+filepath.Join(pwd, "..", "..", "..")) // Repo root
|
||||||
replacer.Dir = pkg
|
replacer.Dir = pkg
|
||||||
if out, err := replacer.CombinedOutput(); err != nil {
|
if out, err := replacer.CombinedOutput(); err != nil {
|
||||||
t.Fatalf("failed to replace binding test dependency to current source tree: %v\n%s", err, out)
|
t.Fatalf("failed to replace binding test dependency to current source tree: %v\n%s", err, out)
|
||||||
}
|
}
|
||||||
|
tidier := exec.Command(gocmd, "mod", "tidy")
|
||||||
|
tidier.Dir = pkg
|
||||||
|
if out, err := tidier.CombinedOutput(); err != nil {
|
||||||
|
t.Fatalf("failed to tidy Go module file: %v\n%s", err, out)
|
||||||
|
}
|
||||||
// Test the entire package and report any failures
|
// Test the entire package and report any failures
|
||||||
cmd := exec.Command(gocmd, "test", "-v", "-count", "1")
|
cmd := exec.Command(gocmd, "test", "-v", "-count", "1")
|
||||||
cmd.Dir = pkg
|
cmd.Dir = pkg
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ type tmplData struct {
|
|||||||
type tmplContract struct {
|
type tmplContract struct {
|
||||||
Type string // Type name of the main contract binding
|
Type string // Type name of the main contract binding
|
||||||
InputABI string // JSON ABI used as the input to generate the binding from
|
InputABI string // JSON ABI used as the input to generate the binding from
|
||||||
InputBin string // Optional EVM bytecode used to denetare deploy code from
|
InputBin string // Optional EVM bytecode used to generate deploy code from
|
||||||
FuncSigs map[string]string // Optional map: string signature -> 4-byte signature
|
FuncSigs map[string]string // Optional map: string signature -> 4-byte signature
|
||||||
Constructor abi.Method // Contract constructor for deploy parametrization
|
Constructor abi.Method // Contract constructor for deploy parametrization
|
||||||
Calls map[string]*tmplMethod // Contract calls that only read state data
|
Calls map[string]*tmplMethod // Contract calls that only read state data
|
||||||
@@ -50,7 +50,8 @@ type tmplMethod struct {
|
|||||||
Structured bool // Whether the returns should be accumulated into a struct
|
Structured bool // Whether the returns should be accumulated into a struct
|
||||||
}
|
}
|
||||||
|
|
||||||
// tmplEvent is a wrapper around an a
|
// tmplEvent is a wrapper around an abi.Event that contains a few preprocessed
|
||||||
|
// and cached data fields.
|
||||||
type tmplEvent struct {
|
type tmplEvent struct {
|
||||||
Original abi.Event // Original event as parsed by the abi package
|
Original abi.Event // Original event as parsed by the abi package
|
||||||
Normalized abi.Event // Normalized version of the parsed fields
|
Normalized abi.Event // Normalized version of the parsed fields
|
||||||
@@ -64,7 +65,7 @@ type tmplField struct {
|
|||||||
SolKind abi.Type // Raw abi type information
|
SolKind abi.Type // Raw abi type information
|
||||||
}
|
}
|
||||||
|
|
||||||
// tmplStruct is a wrapper around an abi.tuple contains an auto-generated
|
// tmplStruct is a wrapper around an abi.tuple and contains an auto-generated
|
||||||
// struct name.
|
// struct name.
|
||||||
type tmplStruct struct {
|
type tmplStruct struct {
|
||||||
Name string // Auto-generated struct name(before solidity v0.5.11) or raw name.
|
Name string // Auto-generated struct name(before solidity v0.5.11) or raw name.
|
||||||
@@ -78,8 +79,8 @@ var tmplSource = map[Lang]string{
|
|||||||
LangJava: tmplSourceJava,
|
LangJava: tmplSourceJava,
|
||||||
}
|
}
|
||||||
|
|
||||||
// tmplSourceGo is the Go source template use to generate the contract binding
|
// tmplSourceGo is the Go source template that the generated Go contract binding
|
||||||
// based on.
|
// is based on.
|
||||||
const tmplSourceGo = `
|
const tmplSourceGo = `
|
||||||
// Code generated - DO NOT EDIT.
|
// Code generated - DO NOT EDIT.
|
||||||
// This file is a generated binding and any manual changes will be lost.
|
// This file is a generated binding and any manual changes will be lost.
|
||||||
@@ -89,6 +90,7 @@ package {{.Package}}
|
|||||||
import (
|
import (
|
||||||
"math/big"
|
"math/big"
|
||||||
"strings"
|
"strings"
|
||||||
|
"errors"
|
||||||
|
|
||||||
ethereum "github.com/ethereum/go-ethereum"
|
ethereum "github.com/ethereum/go-ethereum"
|
||||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||||
@@ -100,6 +102,7 @@ import (
|
|||||||
|
|
||||||
// Reference imports to suppress errors if they are not otherwise used.
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
var (
|
var (
|
||||||
|
_ = errors.New
|
||||||
_ = big.NewInt
|
_ = big.NewInt
|
||||||
_ = strings.NewReader
|
_ = strings.NewReader
|
||||||
_ = ethereum.NotFound
|
_ = ethereum.NotFound
|
||||||
@@ -119,32 +122,48 @@ var (
|
|||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{range $contract := .Contracts}}
|
{{range $contract := .Contracts}}
|
||||||
// {{.Type}}ABI is the input ABI used to generate the binding from.
|
// {{.Type}}MetaData contains all meta data concerning the {{.Type}} contract.
|
||||||
const {{.Type}}ABI = "{{.InputABI}}"
|
var {{.Type}}MetaData = &bind.MetaData{
|
||||||
|
ABI: "{{.InputABI}}",
|
||||||
{{if $contract.FuncSigs}}
|
{{if $contract.FuncSigs -}}
|
||||||
// {{.Type}}FuncSigs maps the 4-byte function signature to its string representation.
|
Sigs: map[string]string{
|
||||||
var {{.Type}}FuncSigs = map[string]string{
|
|
||||||
{{range $strsig, $binsig := .FuncSigs}}"{{$binsig}}": "{{$strsig}}",
|
{{range $strsig, $binsig := .FuncSigs}}"{{$binsig}}": "{{$strsig}}",
|
||||||
{{end}}
|
{{end}}
|
||||||
}
|
},
|
||||||
|
{{end -}}
|
||||||
|
{{if .InputBin -}}
|
||||||
|
Bin: "0x{{.InputBin}}",
|
||||||
|
{{end}}
|
||||||
|
}
|
||||||
|
// {{.Type}}ABI is the input ABI used to generate the binding from.
|
||||||
|
// Deprecated: Use {{.Type}}MetaData.ABI instead.
|
||||||
|
var {{.Type}}ABI = {{.Type}}MetaData.ABI
|
||||||
|
|
||||||
|
{{if $contract.FuncSigs}}
|
||||||
|
// Deprecated: Use {{.Type}}MetaData.Sigs instead.
|
||||||
|
// {{.Type}}FuncSigs maps the 4-byte function signature to its string representation.
|
||||||
|
var {{.Type}}FuncSigs = {{.Type}}MetaData.Sigs
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{if .InputBin}}
|
{{if .InputBin}}
|
||||||
// {{.Type}}Bin is the compiled bytecode used for deploying new contracts.
|
// {{.Type}}Bin is the compiled bytecode used for deploying new contracts.
|
||||||
var {{.Type}}Bin = "0x{{.InputBin}}"
|
// Deprecated: Use {{.Type}}MetaData.Bin instead.
|
||||||
|
var {{.Type}}Bin = {{.Type}}MetaData.Bin
|
||||||
|
|
||||||
// Deploy{{.Type}} deploys a new Ethereum contract, binding an instance of {{.Type}} to it.
|
// Deploy{{.Type}} deploys a new Ethereum contract, binding an instance of {{.Type}} to it.
|
||||||
func Deploy{{.Type}}(auth *bind.TransactOpts, backend bind.ContractBackend {{range .Constructor.Inputs}}, {{.Name}} {{bindtype .Type $structs}}{{end}}) (common.Address, *types.Transaction, *{{.Type}}, error) {
|
func Deploy{{.Type}}(auth *bind.TransactOpts, backend bind.ContractBackend {{range .Constructor.Inputs}}, {{.Name}} {{bindtype .Type $structs}}{{end}}) (common.Address, *types.Transaction, *{{.Type}}, error) {
|
||||||
parsed, err := abi.JSON(strings.NewReader({{.Type}}ABI))
|
parsed, err := {{.Type}}MetaData.GetAbi()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return common.Address{}, nil, nil, err
|
return common.Address{}, nil, nil, err
|
||||||
}
|
}
|
||||||
|
if parsed == nil {
|
||||||
|
return common.Address{}, nil, nil, errors.New("GetABI returned nil")
|
||||||
|
}
|
||||||
{{range $pattern, $name := .Libraries}}
|
{{range $pattern, $name := .Libraries}}
|
||||||
{{decapitalise $name}}Addr, _, _, _ := Deploy{{capitalise $name}}(auth, backend)
|
{{decapitalise $name}}Addr, _, _, _ := Deploy{{capitalise $name}}(auth, backend)
|
||||||
{{$contract.Type}}Bin = strings.Replace({{$contract.Type}}Bin, "__${{$pattern}}$__", {{decapitalise $name}}Addr.String()[2:], -1)
|
{{$contract.Type}}Bin = strings.ReplaceAll({{$contract.Type}}Bin, "__${{$pattern}}$__", {{decapitalise $name}}Addr.String()[2:])
|
||||||
{{end}}
|
{{end}}
|
||||||
address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex({{.Type}}Bin), backend {{range .Constructor.Inputs}}, {{.Name}}{{end}})
|
address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex({{.Type}}Bin), backend {{range .Constructor.Inputs}}, {{.Name}}{{end}})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return common.Address{}, nil, nil, err
|
return common.Address{}, nil, nil, err
|
||||||
}
|
}
|
||||||
@@ -260,7 +279,7 @@ var (
|
|||||||
// sets the output to result. The result type might be a single field for simple
|
// sets the output to result. The result type might be a single field for simple
|
||||||
// returns, a slice of interfaces for anonymous returns and a struct for named
|
// returns, a slice of interfaces for anonymous returns and a struct for named
|
||||||
// returns.
|
// returns.
|
||||||
func (_{{$contract.Type}} *{{$contract.Type}}Raw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error {
|
func (_{{$contract.Type}} *{{$contract.Type}}Raw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
|
||||||
return _{{$contract.Type}}.Contract.{{$contract.Type}}Caller.contract.Call(opts, result, method, params...)
|
return _{{$contract.Type}}.Contract.{{$contract.Type}}Caller.contract.Call(opts, result, method, params...)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,7 +298,7 @@ var (
|
|||||||
// sets the output to result. The result type might be a single field for simple
|
// sets the output to result. The result type might be a single field for simple
|
||||||
// returns, a slice of interfaces for anonymous returns and a struct for named
|
// returns, a slice of interfaces for anonymous returns and a struct for named
|
||||||
// returns.
|
// returns.
|
||||||
func (_{{$contract.Type}} *{{$contract.Type}}CallerRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error {
|
func (_{{$contract.Type}} *{{$contract.Type}}CallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
|
||||||
return _{{$contract.Type}}.Contract.contract.Call(opts, result, method, params...)
|
return _{{$contract.Type}}.Contract.contract.Call(opts, result, method, params...)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,19 +318,26 @@ var (
|
|||||||
//
|
//
|
||||||
// Solidity: {{.Original.String}}
|
// Solidity: {{.Original.String}}
|
||||||
func (_{{$contract.Type}} *{{$contract.Type}}Caller) {{.Normalized.Name}}(opts *bind.CallOpts {{range .Normalized.Inputs}}, {{.Name}} {{bindtype .Type $structs}} {{end}}) ({{if .Structured}}struct{ {{range .Normalized.Outputs}}{{.Name}} {{bindtype .Type $structs}};{{end}} },{{else}}{{range .Normalized.Outputs}}{{bindtype .Type $structs}},{{end}}{{end}} error) {
|
func (_{{$contract.Type}} *{{$contract.Type}}Caller) {{.Normalized.Name}}(opts *bind.CallOpts {{range .Normalized.Inputs}}, {{.Name}} {{bindtype .Type $structs}} {{end}}) ({{if .Structured}}struct{ {{range .Normalized.Outputs}}{{.Name}} {{bindtype .Type $structs}};{{end}} },{{else}}{{range .Normalized.Outputs}}{{bindtype .Type $structs}},{{end}}{{end}} error) {
|
||||||
{{if .Structured}}ret := new(struct{
|
var out []interface{}
|
||||||
{{range .Normalized.Outputs}}{{.Name}} {{bindtype .Type $structs}}
|
err := _{{$contract.Type}}.contract.Call(opts, &out, "{{.Original.Name}}" {{range .Normalized.Inputs}}, {{.Name}}{{end}})
|
||||||
{{end}}
|
{{if .Structured}}
|
||||||
}){{else}}var (
|
outstruct := new(struct{ {{range .Normalized.Outputs}} {{.Name}} {{bindtype .Type $structs}}; {{end}} })
|
||||||
{{range $i, $_ := .Normalized.Outputs}}ret{{$i}} = new({{bindtype .Type $structs}})
|
if err != nil {
|
||||||
{{end}}
|
return *outstruct, err
|
||||||
){{end}}
|
}
|
||||||
out := {{if .Structured}}ret{{else}}{{if eq (len .Normalized.Outputs) 1}}ret0{{else}}&[]interface{}{
|
{{range $i, $t := .Normalized.Outputs}}
|
||||||
{{range $i, $_ := .Normalized.Outputs}}ret{{$i}},
|
outstruct.{{.Name}} = *abi.ConvertType(out[{{$i}}], new({{bindtype .Type $structs}})).(*{{bindtype .Type $structs}}){{end}}
|
||||||
{{end}}
|
|
||||||
}{{end}}{{end}}
|
return *outstruct, err
|
||||||
err := _{{$contract.Type}}.contract.Call(opts, out, "{{.Original.Name}}" {{range .Normalized.Inputs}}, {{.Name}}{{end}})
|
{{else}}
|
||||||
return {{if .Structured}}*ret,{{else}}{{range $i, $_ := .Normalized.Outputs}}*ret{{$i}},{{end}}{{end}} err
|
if err != nil {
|
||||||
|
return {{range $i, $_ := .Normalized.Outputs}}*new({{bindtype .Type $structs}}), {{end}} err
|
||||||
|
}
|
||||||
|
{{range $i, $t := .Normalized.Outputs}}
|
||||||
|
out{{$i}} := *abi.ConvertType(out[{{$i}}], new({{bindtype .Type $structs}})).(*{{bindtype .Type $structs}}){{end}}
|
||||||
|
|
||||||
|
return {{range $i, $t := .Normalized.Outputs}}out{{$i}}, {{end}} err
|
||||||
|
{{end}}
|
||||||
}
|
}
|
||||||
|
|
||||||
// {{.Normalized.Name}} is a free data retrieval call binding the contract method 0x{{printf "%x" .Original.ID}}.
|
// {{.Normalized.Name}} is a free data retrieval call binding the contract method 0x{{printf "%x" .Original.ID}}.
|
||||||
@@ -536,6 +562,7 @@ var (
|
|||||||
if err := _{{$contract.Type}}.contract.UnpackLog(event, "{{.Original.Name}}", log); err != nil {
|
if err := _{{$contract.Type}}.contract.UnpackLog(event, "{{.Original.Name}}", log); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
event.Raw = log
|
||||||
return event, nil
|
return event, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -543,8 +570,8 @@ var (
|
|||||||
{{end}}
|
{{end}}
|
||||||
`
|
`
|
||||||
|
|
||||||
// tmplSourceJava is the Java source template use to generate the contract binding
|
// tmplSourceJava is the Java source template that the generated Java contract binding
|
||||||
// based on.
|
// is based on.
|
||||||
const tmplSourceJava = `
|
const tmplSourceJava = `
|
||||||
// This file is an automatically generated Java binding. Do not modify as any
|
// This file is an automatically generated Java binding. Do not modify as any
|
||||||
// change will likely be lost upon the next re-generation!
|
// change will likely be lost upon the next re-generation!
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
@@ -35,14 +36,16 @@ func WaitMined(ctx context.Context, b DeployBackend, tx *types.Transaction) (*ty
|
|||||||
logger := log.New("hash", tx.Hash())
|
logger := log.New("hash", tx.Hash())
|
||||||
for {
|
for {
|
||||||
receipt, err := b.TransactionReceipt(ctx, tx.Hash())
|
receipt, err := b.TransactionReceipt(ctx, tx.Hash())
|
||||||
if receipt != nil {
|
if err == nil {
|
||||||
return receipt, nil
|
return receipt, nil
|
||||||
}
|
}
|
||||||
if err != nil {
|
|
||||||
logger.Trace("Receipt retrieval failed", "err", err)
|
if errors.Is(err, ethereum.NotFound) {
|
||||||
} else {
|
|
||||||
logger.Trace("Transaction not yet mined")
|
logger.Trace("Transaction not yet mined")
|
||||||
|
} else {
|
||||||
|
logger.Trace("Receipt retrieval failed", "err", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for the next round.
|
// Wait for the next round.
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
|
|||||||
@@ -56,14 +56,17 @@ func TestWaitDeployed(t *testing.T) {
|
|||||||
for name, test := range waitDeployedTests {
|
for name, test := range waitDeployedTests {
|
||||||
backend := backends.NewSimulatedBackend(
|
backend := backends.NewSimulatedBackend(
|
||||||
core.GenesisAlloc{
|
core.GenesisAlloc{
|
||||||
crypto.PubkeyToAddress(testKey.PublicKey): {Balance: big.NewInt(10000000000)},
|
crypto.PubkeyToAddress(testKey.PublicKey): {Balance: big.NewInt(10000000000000000)},
|
||||||
},
|
},
|
||||||
10000000,
|
10000000,
|
||||||
)
|
)
|
||||||
defer backend.Close()
|
defer backend.Close()
|
||||||
|
|
||||||
// Create the transaction.
|
// Create the transaction
|
||||||
tx := types.NewContractCreation(0, big.NewInt(0), test.gas, big.NewInt(1), common.FromHex(test.code))
|
head, _ := backend.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
||||||
|
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
|
||||||
|
|
||||||
|
tx := types.NewContractCreation(0, big.NewInt(0), test.gas, gasPrice, common.FromHex(test.code))
|
||||||
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
|
|
||||||
// Wait for it to get mined in the background.
|
// Wait for it to get mined in the background.
|
||||||
@@ -99,15 +102,18 @@ func TestWaitDeployed(t *testing.T) {
|
|||||||
func TestWaitDeployedCornerCases(t *testing.T) {
|
func TestWaitDeployedCornerCases(t *testing.T) {
|
||||||
backend := backends.NewSimulatedBackend(
|
backend := backends.NewSimulatedBackend(
|
||||||
core.GenesisAlloc{
|
core.GenesisAlloc{
|
||||||
crypto.PubkeyToAddress(testKey.PublicKey): {Balance: big.NewInt(10000000000)},
|
crypto.PubkeyToAddress(testKey.PublicKey): {Balance: big.NewInt(10000000000000000)},
|
||||||
},
|
},
|
||||||
10000000,
|
10000000,
|
||||||
)
|
)
|
||||||
defer backend.Close()
|
defer backend.Close()
|
||||||
|
|
||||||
|
head, _ := backend.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
||||||
|
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
|
||||||
|
|
||||||
// Create a transaction to an account.
|
// Create a transaction to an account.
|
||||||
code := "6060604052600a8060106000396000f360606040526008565b00"
|
code := "6060604052600a8060106000396000f360606040526008565b00"
|
||||||
tx := types.NewTransaction(0, common.HexToAddress("0x01"), big.NewInt(0), 3000000, big.NewInt(1), common.FromHex(code))
|
tx := types.NewTransaction(0, common.HexToAddress("0x01"), big.NewInt(0), 3000000, gasPrice, common.FromHex(code))
|
||||||
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
@@ -119,7 +125,7 @@ func TestWaitDeployedCornerCases(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create a transaction that is not mined.
|
// Create a transaction that is not mined.
|
||||||
tx = types.NewContractCreation(1, big.NewInt(0), 3000000, big.NewInt(1), common.FromHex(code))
|
tx = types.NewContractCreation(1, big.NewInt(0), 3000000, gasPrice, common.FromHex(code))
|
||||||
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
|||||||
@@ -17,66 +17,77 @@
|
|||||||
package abi
|
package abi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
type Error struct {
|
||||||
errBadBool = errors.New("abi: improperly encoded boolean value")
|
Name string
|
||||||
)
|
Inputs Arguments
|
||||||
|
str string
|
||||||
|
|
||||||
// formatSliceString formats the reflection kind with the given slice size
|
// Sig contains the string signature according to the ABI spec.
|
||||||
// and returns a formatted string representation.
|
// e.g. error foo(uint32 a, int b) = "foo(uint32,int256)"
|
||||||
func formatSliceString(kind reflect.Kind, sliceSize int) string {
|
// Please note that "int" is substitute for its canonical representation "int256"
|
||||||
if sliceSize == -1 {
|
Sig string
|
||||||
return fmt.Sprintf("[]%v", kind)
|
|
||||||
}
|
// ID returns the canonical representation of the error's signature used by the
|
||||||
return fmt.Sprintf("[%d]%v", sliceSize, kind)
|
// abi definition to identify event names and types.
|
||||||
|
ID common.Hash
|
||||||
}
|
}
|
||||||
|
|
||||||
// sliceTypeCheck checks that the given slice can by assigned to the reflection
|
func NewError(name string, inputs Arguments) Error {
|
||||||
// type in t.
|
// sanitize inputs to remove inputs without names
|
||||||
func sliceTypeCheck(t Type, val reflect.Value) error {
|
// and precompute string and sig representation.
|
||||||
if val.Kind() != reflect.Slice && val.Kind() != reflect.Array {
|
names := make([]string, len(inputs))
|
||||||
return typeErr(formatSliceString(t.GetType().Kind(), t.Size), val.Type())
|
types := make([]string, len(inputs))
|
||||||
}
|
for i, input := range inputs {
|
||||||
|
if input.Name == "" {
|
||||||
if t.T == ArrayTy && val.Len() != t.Size {
|
inputs[i] = Argument{
|
||||||
return typeErr(formatSliceString(t.Elem.GetType().Kind(), t.Size), formatSliceString(val.Type().Elem().Kind(), val.Len()))
|
Name: fmt.Sprintf("arg%d", i),
|
||||||
}
|
Indexed: input.Indexed,
|
||||||
|
Type: input.Type,
|
||||||
if t.Elem.T == SliceTy || t.Elem.T == ArrayTy {
|
}
|
||||||
if val.Len() > 0 {
|
} else {
|
||||||
return sliceTypeCheck(*t.Elem, val.Index(0))
|
inputs[i] = input
|
||||||
}
|
}
|
||||||
|
// string representation
|
||||||
|
names[i] = fmt.Sprintf("%v %v", input.Type, inputs[i].Name)
|
||||||
|
if input.Indexed {
|
||||||
|
names[i] = fmt.Sprintf("%v indexed %v", input.Type, inputs[i].Name)
|
||||||
|
}
|
||||||
|
// sig representation
|
||||||
|
types[i] = input.Type.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
if elemKind := val.Type().Elem().Kind(); elemKind != t.Elem.GetType().Kind() {
|
str := fmt.Sprintf("error %v(%v)", name, strings.Join(names, ", "))
|
||||||
return typeErr(formatSliceString(t.Elem.GetType().Kind(), t.Size), val.Type())
|
sig := fmt.Sprintf("%v(%v)", name, strings.Join(types, ","))
|
||||||
|
id := common.BytesToHash(crypto.Keccak256([]byte(sig)))
|
||||||
|
|
||||||
|
return Error{
|
||||||
|
Name: name,
|
||||||
|
Inputs: inputs,
|
||||||
|
str: str,
|
||||||
|
Sig: sig,
|
||||||
|
ID: id,
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// typeCheck checks that the given reflection value can be assigned to the reflection
|
func (e *Error) String() string {
|
||||||
// type in t.
|
return e.str
|
||||||
func typeCheck(t Type, value reflect.Value) error {
|
|
||||||
if t.T == SliceTy || t.T == ArrayTy {
|
|
||||||
return sliceTypeCheck(t, value)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check base type validity. Element types will be checked later on.
|
|
||||||
if t.GetType().Kind() != value.Kind() {
|
|
||||||
return typeErr(t.GetType().Kind(), value.Kind())
|
|
||||||
} else if t.T == FixedBytesTy && t.Size != value.Len() {
|
|
||||||
return typeErr(t.GetType(), value.Type())
|
|
||||||
} else {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// typeErr returns a formatted type casting error.
|
func (e *Error) Unpack(data []byte) (interface{}, error) {
|
||||||
func typeErr(expected, got interface{}) error {
|
if len(data) < 4 {
|
||||||
return fmt.Errorf("abi: cannot use %v as type %v as argument", got, expected)
|
return "", errors.New("invalid data for unpacking")
|
||||||
|
}
|
||||||
|
if !bytes.Equal(data[:4], e.ID[:4]) {
|
||||||
|
return "", errors.New("invalid data for unpacking")
|
||||||
|
}
|
||||||
|
return e.Inputs.Unpack(data[4:])
|
||||||
}
|
}
|
||||||
|
|||||||
82
accounts/abi/error_handling.go
Normal file
82
accounts/abi/error_handling.go
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
// Copyright 2016 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package abi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"reflect"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
errBadBool = errors.New("abi: improperly encoded boolean value")
|
||||||
|
)
|
||||||
|
|
||||||
|
// formatSliceString formats the reflection kind with the given slice size
|
||||||
|
// and returns a formatted string representation.
|
||||||
|
func formatSliceString(kind reflect.Kind, sliceSize int) string {
|
||||||
|
if sliceSize == -1 {
|
||||||
|
return fmt.Sprintf("[]%v", kind)
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("[%d]%v", sliceSize, kind)
|
||||||
|
}
|
||||||
|
|
||||||
|
// sliceTypeCheck checks that the given slice can by assigned to the reflection
|
||||||
|
// type in t.
|
||||||
|
func sliceTypeCheck(t Type, val reflect.Value) error {
|
||||||
|
if val.Kind() != reflect.Slice && val.Kind() != reflect.Array {
|
||||||
|
return typeErr(formatSliceString(t.GetType().Kind(), t.Size), val.Type())
|
||||||
|
}
|
||||||
|
|
||||||
|
if t.T == ArrayTy && val.Len() != t.Size {
|
||||||
|
return typeErr(formatSliceString(t.Elem.GetType().Kind(), t.Size), formatSliceString(val.Type().Elem().Kind(), val.Len()))
|
||||||
|
}
|
||||||
|
|
||||||
|
if t.Elem.T == SliceTy || t.Elem.T == ArrayTy {
|
||||||
|
if val.Len() > 0 {
|
||||||
|
return sliceTypeCheck(*t.Elem, val.Index(0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if val.Type().Elem().Kind() != t.Elem.GetType().Kind() {
|
||||||
|
return typeErr(formatSliceString(t.Elem.GetType().Kind(), t.Size), val.Type())
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// typeCheck checks that the given reflection value can be assigned to the reflection
|
||||||
|
// type in t.
|
||||||
|
func typeCheck(t Type, value reflect.Value) error {
|
||||||
|
if t.T == SliceTy || t.T == ArrayTy {
|
||||||
|
return sliceTypeCheck(t, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check base type validity. Element types will be checked later on.
|
||||||
|
if t.GetType().Kind() != value.Kind() {
|
||||||
|
return typeErr(t.GetType().Kind(), value.Kind())
|
||||||
|
} else if t.T == FixedBytesTy && t.Size != value.Len() {
|
||||||
|
return typeErr(t.GetType(), value.Type())
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// typeErr returns a formatted type casting error.
|
||||||
|
func typeErr(expected, got interface{}) error {
|
||||||
|
return fmt.Errorf("abi: cannot use %v as type %v as argument", got, expected)
|
||||||
|
}
|
||||||
@@ -29,24 +29,27 @@ import (
|
|||||||
// don't get the signature canonical representation as the first LOG topic.
|
// don't get the signature canonical representation as the first LOG topic.
|
||||||
type Event struct {
|
type Event struct {
|
||||||
// Name is the event name used for internal representation. It's derived from
|
// Name is the event name used for internal representation. It's derived from
|
||||||
// the raw name and a suffix will be added in the case of a event overload.
|
// the raw name and a suffix will be added in the case of event overloading.
|
||||||
//
|
//
|
||||||
// e.g.
|
// e.g.
|
||||||
// There are two events have same name:
|
// These are two events that have the same name:
|
||||||
// * foo(int,int)
|
// * foo(int,int)
|
||||||
// * foo(uint,uint)
|
// * foo(uint,uint)
|
||||||
// The event name of the first one wll be resolved as foo while the second one
|
// The event name of the first one will be resolved as foo while the second one
|
||||||
// will be resolved as foo0.
|
// will be resolved as foo0.
|
||||||
Name string
|
Name string
|
||||||
|
|
||||||
// RawName is the raw event name parsed from ABI.
|
// RawName is the raw event name parsed from ABI.
|
||||||
RawName string
|
RawName string
|
||||||
Anonymous bool
|
Anonymous bool
|
||||||
Inputs Arguments
|
Inputs Arguments
|
||||||
str string
|
str string
|
||||||
|
|
||||||
// Sig contains the string signature according to the ABI spec.
|
// Sig contains the string signature according to the ABI spec.
|
||||||
// e.g. event foo(uint32 a, int b) = "foo(uint32,int256)"
|
// e.g. event foo(uint32 a, int b) = "foo(uint32,int256)"
|
||||||
// Please note that "int" is substitute for its canonical representation "int256"
|
// Please note that "int" is substitute for its canonical representation "int256"
|
||||||
Sig string
|
Sig string
|
||||||
|
|
||||||
// ID returns the canonical representation of the event's signature used by the
|
// ID returns the canonical representation of the event's signature used by the
|
||||||
// abi definition to identify event names and types.
|
// abi definition to identify event names and types.
|
||||||
ID common.Hash
|
ID common.Hash
|
||||||
|
|||||||
@@ -147,10 +147,6 @@ func TestEventString(t *testing.T) {
|
|||||||
// TestEventMultiValueWithArrayUnpack verifies that array fields will be counted after parsing array.
|
// TestEventMultiValueWithArrayUnpack verifies that array fields will be counted after parsing array.
|
||||||
func TestEventMultiValueWithArrayUnpack(t *testing.T) {
|
func TestEventMultiValueWithArrayUnpack(t *testing.T) {
|
||||||
definition := `[{"name": "test", "type": "event", "inputs": [{"indexed": false, "name":"value1", "type":"uint8[2]"},{"indexed": false, "name":"value2", "type":"uint8"}]}]`
|
definition := `[{"name": "test", "type": "event", "inputs": [{"indexed": false, "name":"value1", "type":"uint8[2]"},{"indexed": false, "name":"value2", "type":"uint8"}]}]`
|
||||||
type testStruct struct {
|
|
||||||
Value1 [2]uint8
|
|
||||||
Value2 uint8
|
|
||||||
}
|
|
||||||
abi, err := JSON(strings.NewReader(definition))
|
abi, err := JSON(strings.NewReader(definition))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
var b bytes.Buffer
|
var b bytes.Buffer
|
||||||
@@ -158,10 +154,10 @@ func TestEventMultiValueWithArrayUnpack(t *testing.T) {
|
|||||||
for ; i <= 3; i++ {
|
for ; i <= 3; i++ {
|
||||||
b.Write(packNum(reflect.ValueOf(i)))
|
b.Write(packNum(reflect.ValueOf(i)))
|
||||||
}
|
}
|
||||||
var rst testStruct
|
unpacked, err := abi.Unpack("test", b.Bytes())
|
||||||
require.NoError(t, abi.Unpack(&rst, "test", b.Bytes()))
|
require.NoError(t, err)
|
||||||
require.Equal(t, [2]uint8{1, 2}, rst.Value1)
|
require.Equal(t, [2]uint8{1, 2}, unpacked[0])
|
||||||
require.Equal(t, uint8(3), rst.Value2)
|
require.Equal(t, uint8(3), unpacked[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEventTupleUnpack(t *testing.T) {
|
func TestEventTupleUnpack(t *testing.T) {
|
||||||
@@ -351,14 +347,14 @@ func unpackTestEventData(dest interface{}, hexData string, jsonEvent []byte, ass
|
|||||||
var e Event
|
var e Event
|
||||||
assert.NoError(json.Unmarshal(jsonEvent, &e), "Should be able to unmarshal event ABI")
|
assert.NoError(json.Unmarshal(jsonEvent, &e), "Should be able to unmarshal event ABI")
|
||||||
a := ABI{Events: map[string]Event{"e": e}}
|
a := ABI{Events: map[string]Event{"e": e}}
|
||||||
return a.Unpack(dest, "e", data)
|
return a.UnpackIntoInterface(dest, "e", data)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestEventUnpackIndexed verifies that indexed field will be skipped by event decoder.
|
// TestEventUnpackIndexed verifies that indexed field will be skipped by event decoder.
|
||||||
func TestEventUnpackIndexed(t *testing.T) {
|
func TestEventUnpackIndexed(t *testing.T) {
|
||||||
definition := `[{"name": "test", "type": "event", "inputs": [{"indexed": true, "name":"value1", "type":"uint8"},{"indexed": false, "name":"value2", "type":"uint8"}]}]`
|
definition := `[{"name": "test", "type": "event", "inputs": [{"indexed": true, "name":"value1", "type":"uint8"},{"indexed": false, "name":"value2", "type":"uint8"}]}]`
|
||||||
type testStruct struct {
|
type testStruct struct {
|
||||||
Value1 uint8
|
Value1 uint8 // indexed
|
||||||
Value2 uint8
|
Value2 uint8
|
||||||
}
|
}
|
||||||
abi, err := JSON(strings.NewReader(definition))
|
abi, err := JSON(strings.NewReader(definition))
|
||||||
@@ -366,16 +362,16 @@ func TestEventUnpackIndexed(t *testing.T) {
|
|||||||
var b bytes.Buffer
|
var b bytes.Buffer
|
||||||
b.Write(packNum(reflect.ValueOf(uint8(8))))
|
b.Write(packNum(reflect.ValueOf(uint8(8))))
|
||||||
var rst testStruct
|
var rst testStruct
|
||||||
require.NoError(t, abi.Unpack(&rst, "test", b.Bytes()))
|
require.NoError(t, abi.UnpackIntoInterface(&rst, "test", b.Bytes()))
|
||||||
require.Equal(t, uint8(0), rst.Value1)
|
require.Equal(t, uint8(0), rst.Value1)
|
||||||
require.Equal(t, uint8(8), rst.Value2)
|
require.Equal(t, uint8(8), rst.Value2)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestEventIndexedWithArrayUnpack verifies that decoder will not overlow when static array is indexed input.
|
// TestEventIndexedWithArrayUnpack verifies that decoder will not overflow when static array is indexed input.
|
||||||
func TestEventIndexedWithArrayUnpack(t *testing.T) {
|
func TestEventIndexedWithArrayUnpack(t *testing.T) {
|
||||||
definition := `[{"name": "test", "type": "event", "inputs": [{"indexed": true, "name":"value1", "type":"uint8[2]"},{"indexed": false, "name":"value2", "type":"string"}]}]`
|
definition := `[{"name": "test", "type": "event", "inputs": [{"indexed": true, "name":"value1", "type":"uint8[2]"},{"indexed": false, "name":"value2", "type":"string"}]}]`
|
||||||
type testStruct struct {
|
type testStruct struct {
|
||||||
Value1 [2]uint8
|
Value1 [2]uint8 // indexed
|
||||||
Value2 string
|
Value2 string
|
||||||
}
|
}
|
||||||
abi, err := JSON(strings.NewReader(definition))
|
abi, err := JSON(strings.NewReader(definition))
|
||||||
@@ -388,7 +384,7 @@ func TestEventIndexedWithArrayUnpack(t *testing.T) {
|
|||||||
b.Write(common.RightPadBytes([]byte(stringOut), 32))
|
b.Write(common.RightPadBytes([]byte(stringOut), 32))
|
||||||
|
|
||||||
var rst testStruct
|
var rst testStruct
|
||||||
require.NoError(t, abi.Unpack(&rst, "test", b.Bytes()))
|
require.NoError(t, abi.UnpackIntoInterface(&rst, "test", b.Bytes()))
|
||||||
require.Equal(t, [2]uint8{0, 0}, rst.Value1)
|
require.Equal(t, [2]uint8{0, 0}, rst.Value1)
|
||||||
require.Equal(t, stringOut, rst.Value2)
|
require.Equal(t, stringOut, rst.Value2)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ const (
|
|||||||
// If the method is `Const` no transaction needs to be created for this
|
// If the method is `Const` no transaction needs to be created for this
|
||||||
// particular Method call. It can easily be simulated using a local VM.
|
// particular Method call. It can easily be simulated using a local VM.
|
||||||
// For example a `Balance()` method only needs to retrieve something
|
// For example a `Balance()` method only needs to retrieve something
|
||||||
// from the storage and therefore requires no Tx to be send to the
|
// from the storage and therefore requires no Tx to be sent to the
|
||||||
// network. A method such as `Transact` does require a Tx and thus will
|
// network. A method such as `Transact` does require a Tx and thus will
|
||||||
// be flagged `false`.
|
// be flagged `false`.
|
||||||
// Input specifies the required input parameters for this gives method.
|
// Input specifies the required input parameters for this gives method.
|
||||||
@@ -54,7 +54,7 @@ type Method struct {
|
|||||||
// the raw name and a suffix will be added in the case of a function overload.
|
// the raw name and a suffix will be added in the case of a function overload.
|
||||||
//
|
//
|
||||||
// e.g.
|
// e.g.
|
||||||
// There are two functions have same name:
|
// These are two functions that have the same name:
|
||||||
// * foo(int,int)
|
// * foo(int,int)
|
||||||
// * foo(uint,uint)
|
// * foo(uint,uint)
|
||||||
// The method name of the first one will be resolved as foo while the second one
|
// The method name of the first one will be resolved as foo while the second one
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
package abi
|
package abi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
@@ -25,7 +27,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// packBytesSlice packs the given bytes as [L, V] as the canonical representation
|
// packBytesSlice packs the given bytes as [L, V] as the canonical representation
|
||||||
// bytes slice
|
// bytes slice.
|
||||||
func packBytesSlice(bytes []byte, l int) []byte {
|
func packBytesSlice(bytes []byte, l int) []byte {
|
||||||
len := packNum(reflect.ValueOf(l))
|
len := packNum(reflect.ValueOf(l))
|
||||||
return append(len, common.RightPadBytes(bytes, (l+31)/32*32)...)
|
return append(len, common.RightPadBytes(bytes, (l+31)/32*32)...)
|
||||||
@@ -33,39 +35,42 @@ func packBytesSlice(bytes []byte, l int) []byte {
|
|||||||
|
|
||||||
// packElement packs the given reflect value according to the abi specification in
|
// packElement packs the given reflect value according to the abi specification in
|
||||||
// t.
|
// t.
|
||||||
func packElement(t Type, reflectValue reflect.Value) []byte {
|
func packElement(t Type, reflectValue reflect.Value) ([]byte, error) {
|
||||||
switch t.T {
|
switch t.T {
|
||||||
case IntTy, UintTy:
|
case IntTy, UintTy:
|
||||||
return packNum(reflectValue)
|
return packNum(reflectValue), nil
|
||||||
case StringTy:
|
case StringTy:
|
||||||
return packBytesSlice([]byte(reflectValue.String()), reflectValue.Len())
|
return packBytesSlice([]byte(reflectValue.String()), reflectValue.Len()), nil
|
||||||
case AddressTy:
|
case AddressTy:
|
||||||
if reflectValue.Kind() == reflect.Array {
|
if reflectValue.Kind() == reflect.Array {
|
||||||
reflectValue = mustArrayToByteSlice(reflectValue)
|
reflectValue = mustArrayToByteSlice(reflectValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
return common.LeftPadBytes(reflectValue.Bytes(), 32)
|
return common.LeftPadBytes(reflectValue.Bytes(), 32), nil
|
||||||
case BoolTy:
|
case BoolTy:
|
||||||
if reflectValue.Bool() {
|
if reflectValue.Bool() {
|
||||||
return math.PaddedBigBytes(common.Big1, 32)
|
return math.PaddedBigBytes(common.Big1, 32), nil
|
||||||
}
|
}
|
||||||
return math.PaddedBigBytes(common.Big0, 32)
|
return math.PaddedBigBytes(common.Big0, 32), nil
|
||||||
case BytesTy:
|
case BytesTy:
|
||||||
if reflectValue.Kind() == reflect.Array {
|
if reflectValue.Kind() == reflect.Array {
|
||||||
reflectValue = mustArrayToByteSlice(reflectValue)
|
reflectValue = mustArrayToByteSlice(reflectValue)
|
||||||
}
|
}
|
||||||
return packBytesSlice(reflectValue.Bytes(), reflectValue.Len())
|
if reflectValue.Type() != reflect.TypeOf([]byte{}) {
|
||||||
|
return []byte{}, errors.New("Bytes type is neither slice nor array")
|
||||||
|
}
|
||||||
|
return packBytesSlice(reflectValue.Bytes(), reflectValue.Len()), nil
|
||||||
case FixedBytesTy, FunctionTy:
|
case FixedBytesTy, FunctionTy:
|
||||||
if reflectValue.Kind() == reflect.Array {
|
if reflectValue.Kind() == reflect.Array {
|
||||||
reflectValue = mustArrayToByteSlice(reflectValue)
|
reflectValue = mustArrayToByteSlice(reflectValue)
|
||||||
}
|
}
|
||||||
return common.RightPadBytes(reflectValue.Bytes(), 32)
|
return common.RightPadBytes(reflectValue.Bytes(), 32), nil
|
||||||
default:
|
default:
|
||||||
panic("abi: fatal error")
|
return []byte{}, fmt.Errorf("Could not pack element, unknown type: %v", t.T)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// packNum packs the given number (using the reflect value) and will cast it to appropriate number representation
|
// packNum packs the given number (using the reflect value) and will cast it to appropriate number representation.
|
||||||
func packNum(value reflect.Value) []byte {
|
func packNum(value reflect.Value) []byte {
|
||||||
switch kind := value.Kind(); kind {
|
switch kind := value.Kind(); kind {
|
||||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
|
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
|
||||||
@@ -77,5 +82,4 @@ func packNum(value reflect.Value) []byte {
|
|||||||
default:
|
default:
|
||||||
panic("abi: fatal error")
|
panic("abi: fatal error")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,18 +44,7 @@ func TestPack(t *testing.T) {
|
|||||||
t.Fatalf("invalid ABI definition %s, %v", inDef, err)
|
t.Fatalf("invalid ABI definition %s, %v", inDef, err)
|
||||||
}
|
}
|
||||||
var packed []byte
|
var packed []byte
|
||||||
if reflect.TypeOf(test.unpacked).Kind() != reflect.Struct {
|
packed, err = inAbi.Pack("method", test.unpacked)
|
||||||
packed, err = inAbi.Pack("method", test.unpacked)
|
|
||||||
} else {
|
|
||||||
// if want is a struct we need to use the components.
|
|
||||||
elem := reflect.ValueOf(test.unpacked)
|
|
||||||
var values []interface{}
|
|
||||||
for i := 0; i < elem.NumField(); i++ {
|
|
||||||
field := elem.Field(i)
|
|
||||||
values = append(values, field.Interface())
|
|
||||||
}
|
|
||||||
packed, err = inAbi.Pack("method", values...)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("test %d (%v) failed: %v", i, test.def, err)
|
t.Fatalf("test %d (%v) failed: %v", i, test.def, err)
|
||||||
|
|||||||
@@ -620,7 +620,7 @@ var packUnpackTests = []packUnpackTest{
|
|||||||
|
|
||||||
{
|
{
|
||||||
def: `[{"type": "bytes32[]"}]`,
|
def: `[{"type": "bytes32[]"}]`,
|
||||||
unpacked: []common.Hash{{1}, {2}},
|
unpacked: [][32]byte{{1}, {2}},
|
||||||
packed: "0000000000000000000000000000000000000000000000000000000000000020" +
|
packed: "0000000000000000000000000000000000000000000000000000000000000020" +
|
||||||
"0000000000000000000000000000000000000000000000000000000000000002" +
|
"0000000000000000000000000000000000000000000000000000000000000002" +
|
||||||
"0100000000000000000000000000000000000000000000000000000000000000" +
|
"0100000000000000000000000000000000000000000000000000000000000000" +
|
||||||
@@ -722,7 +722,7 @@ var packUnpackTests = []packUnpackTest{
|
|||||||
},
|
},
|
||||||
// struct outputs
|
// struct outputs
|
||||||
{
|
{
|
||||||
def: `[{"name":"int1","type":"int256"},{"name":"int2","type":"int256"}]`,
|
def: `[{"components": [{"name":"int1","type":"int256"},{"name":"int2","type":"int256"}], "type":"tuple"}]`,
|
||||||
packed: "0000000000000000000000000000000000000000000000000000000000000001" +
|
packed: "0000000000000000000000000000000000000000000000000000000000000001" +
|
||||||
"0000000000000000000000000000000000000000000000000000000000000002",
|
"0000000000000000000000000000000000000000000000000000000000000002",
|
||||||
unpacked: struct {
|
unpacked: struct {
|
||||||
@@ -731,28 +731,28 @@ var packUnpackTests = []packUnpackTest{
|
|||||||
}{big.NewInt(1), big.NewInt(2)},
|
}{big.NewInt(1), big.NewInt(2)},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
def: `[{"name":"int_one","type":"int256"}]`,
|
def: `[{"components": [{"name":"int_one","type":"int256"}], "type":"tuple"}]`,
|
||||||
packed: "0000000000000000000000000000000000000000000000000000000000000001",
|
packed: "0000000000000000000000000000000000000000000000000000000000000001",
|
||||||
unpacked: struct {
|
unpacked: struct {
|
||||||
IntOne *big.Int
|
IntOne *big.Int
|
||||||
}{big.NewInt(1)},
|
}{big.NewInt(1)},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
def: `[{"name":"int__one","type":"int256"}]`,
|
def: `[{"components": [{"name":"int__one","type":"int256"}], "type":"tuple"}]`,
|
||||||
packed: "0000000000000000000000000000000000000000000000000000000000000001",
|
packed: "0000000000000000000000000000000000000000000000000000000000000001",
|
||||||
unpacked: struct {
|
unpacked: struct {
|
||||||
IntOne *big.Int
|
IntOne *big.Int
|
||||||
}{big.NewInt(1)},
|
}{big.NewInt(1)},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
def: `[{"name":"int_one_","type":"int256"}]`,
|
def: `[{"components": [{"name":"int_one_","type":"int256"}], "type":"tuple"}]`,
|
||||||
packed: "0000000000000000000000000000000000000000000000000000000000000001",
|
packed: "0000000000000000000000000000000000000000000000000000000000000001",
|
||||||
unpacked: struct {
|
unpacked: struct {
|
||||||
IntOne *big.Int
|
IntOne *big.Int
|
||||||
}{big.NewInt(1)},
|
}{big.NewInt(1)},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
def: `[{"name":"int_one","type":"int256"}, {"name":"intone","type":"int256"}]`,
|
def: `[{"components": [{"name":"int_one","type":"int256"}, {"name":"intone","type":"int256"}], "type":"tuple"}]`,
|
||||||
packed: "0000000000000000000000000000000000000000000000000000000000000001" +
|
packed: "0000000000000000000000000000000000000000000000000000000000000001" +
|
||||||
"0000000000000000000000000000000000000000000000000000000000000002",
|
"0000000000000000000000000000000000000000000000000000000000000002",
|
||||||
unpacked: struct {
|
unpacked: struct {
|
||||||
@@ -831,11 +831,11 @@ var packUnpackTests = []packUnpackTest{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
// static tuple
|
// static tuple
|
||||||
def: `[{"name":"a","type":"int64"},
|
def: `[{"components": [{"name":"a","type":"int64"},
|
||||||
{"name":"b","type":"int256"},
|
{"name":"b","type":"int256"},
|
||||||
{"name":"c","type":"int256"},
|
{"name":"c","type":"int256"},
|
||||||
{"name":"d","type":"bool"},
|
{"name":"d","type":"bool"},
|
||||||
{"name":"e","type":"bytes32[3][2]"}]`,
|
{"name":"e","type":"bytes32[3][2]"}], "type":"tuple"}]`,
|
||||||
unpacked: struct {
|
unpacked: struct {
|
||||||
A int64
|
A int64
|
||||||
B *big.Int
|
B *big.Int
|
||||||
@@ -855,21 +855,22 @@ var packUnpackTests = []packUnpackTest{
|
|||||||
"0500000000000000000000000000000000000000000000000000000000000000", // struct[e] array[1][2]
|
"0500000000000000000000000000000000000000000000000000000000000000", // struct[e] array[1][2]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
def: `[{"name":"a","type":"string"},
|
def: `[{"components": [{"name":"a","type":"string"},
|
||||||
{"name":"b","type":"int64"},
|
{"name":"b","type":"int64"},
|
||||||
{"name":"c","type":"bytes"},
|
{"name":"c","type":"bytes"},
|
||||||
{"name":"d","type":"string[]"},
|
{"name":"d","type":"string[]"},
|
||||||
{"name":"e","type":"int256[]"},
|
{"name":"e","type":"int256[]"},
|
||||||
{"name":"f","type":"address[]"}]`,
|
{"name":"f","type":"address[]"}], "type":"tuple"}]`,
|
||||||
unpacked: struct {
|
unpacked: struct {
|
||||||
FieldA string `abi:"a"` // Test whether abi tag works
|
A string
|
||||||
FieldB int64 `abi:"b"`
|
B int64
|
||||||
C []byte
|
C []byte
|
||||||
D []string
|
D []string
|
||||||
E []*big.Int
|
E []*big.Int
|
||||||
F []common.Address
|
F []common.Address
|
||||||
}{"foobar", 1, []byte{1}, []string{"foo", "bar"}, []*big.Int{big.NewInt(1), big.NewInt(-1)}, []common.Address{{1}, {2}}},
|
}{"foobar", 1, []byte{1}, []string{"foo", "bar"}, []*big.Int{big.NewInt(1), big.NewInt(-1)}, []common.Address{{1}, {2}}},
|
||||||
packed: "00000000000000000000000000000000000000000000000000000000000000c0" + // struct[a] offset
|
packed: "0000000000000000000000000000000000000000000000000000000000000020" + // struct a
|
||||||
|
"00000000000000000000000000000000000000000000000000000000000000c0" + // struct[a] offset
|
||||||
"0000000000000000000000000000000000000000000000000000000000000001" + // struct[b]
|
"0000000000000000000000000000000000000000000000000000000000000001" + // struct[b]
|
||||||
"0000000000000000000000000000000000000000000000000000000000000100" + // struct[c] offset
|
"0000000000000000000000000000000000000000000000000000000000000100" + // struct[c] offset
|
||||||
"0000000000000000000000000000000000000000000000000000000000000140" + // struct[d] offset
|
"0000000000000000000000000000000000000000000000000000000000000140" + // struct[d] offset
|
||||||
@@ -894,23 +895,24 @@ var packUnpackTests = []packUnpackTest{
|
|||||||
"0000000000000000000000000200000000000000000000000000000000000000", // common.Address{2}
|
"0000000000000000000000000200000000000000000000000000000000000000", // common.Address{2}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
def: `[{"components": [{"name": "a","type": "uint256"},
|
def: `[{"components": [{ "type": "tuple","components": [{"name": "a","type": "uint256"},
|
||||||
{"name": "b","type": "uint256[]"}],
|
{"name": "b","type": "uint256[]"}],
|
||||||
"name": "a","type": "tuple"},
|
"name": "a","type": "tuple"},
|
||||||
{"name": "b","type": "uint256[]"}]`,
|
{"name": "b","type": "uint256[]"}], "type": "tuple"}]`,
|
||||||
unpacked: struct {
|
unpacked: struct {
|
||||||
A struct {
|
A struct {
|
||||||
FieldA *big.Int `abi:"a"`
|
A *big.Int
|
||||||
B []*big.Int
|
B []*big.Int
|
||||||
}
|
}
|
||||||
B []*big.Int
|
B []*big.Int
|
||||||
}{
|
}{
|
||||||
A: struct {
|
A: struct {
|
||||||
FieldA *big.Int `abi:"a"` // Test whether abi tag works for nested tuple
|
A *big.Int
|
||||||
B []*big.Int
|
B []*big.Int
|
||||||
}{big.NewInt(1), []*big.Int{big.NewInt(1), big.NewInt(2)}},
|
}{big.NewInt(1), []*big.Int{big.NewInt(1), big.NewInt(2)}},
|
||||||
B: []*big.Int{big.NewInt(1), big.NewInt(2)}},
|
B: []*big.Int{big.NewInt(1), big.NewInt(2)}},
|
||||||
packed: "0000000000000000000000000000000000000000000000000000000000000040" + // a offset
|
packed: "0000000000000000000000000000000000000000000000000000000000000020" + // struct a
|
||||||
|
"0000000000000000000000000000000000000000000000000000000000000040" + // a offset
|
||||||
"00000000000000000000000000000000000000000000000000000000000000e0" + // b offset
|
"00000000000000000000000000000000000000000000000000000000000000e0" + // b offset
|
||||||
"0000000000000000000000000000000000000000000000000000000000000001" + // a.a value
|
"0000000000000000000000000000000000000000000000000000000000000001" + // a.a value
|
||||||
"0000000000000000000000000000000000000000000000000000000000000040" + // a.b offset
|
"0000000000000000000000000000000000000000000000000000000000000040" + // a.b offset
|
||||||
|
|||||||
@@ -24,6 +24,29 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ConvertType converts an interface of a runtime type into a interface of the
|
||||||
|
// given type
|
||||||
|
// e.g. turn
|
||||||
|
// var fields []reflect.StructField
|
||||||
|
// fields = append(fields, reflect.StructField{
|
||||||
|
// Name: "X",
|
||||||
|
// Type: reflect.TypeOf(new(big.Int)),
|
||||||
|
// Tag: reflect.StructTag("json:\"" + "x" + "\""),
|
||||||
|
// }
|
||||||
|
// into
|
||||||
|
// type TupleT struct { X *big.Int }
|
||||||
|
func ConvertType(in interface{}, proto interface{}) interface{} {
|
||||||
|
protoType := reflect.TypeOf(proto)
|
||||||
|
if reflect.TypeOf(in).ConvertibleTo(protoType) {
|
||||||
|
return reflect.ValueOf(in).Convert(protoType).Interface()
|
||||||
|
}
|
||||||
|
// Use set as a last ditch effort
|
||||||
|
if err := set(reflect.ValueOf(proto), reflect.ValueOf(in)); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return proto
|
||||||
|
}
|
||||||
|
|
||||||
// indirect recursively dereferences the value until it either gets the value
|
// indirect recursively dereferences the value until it either gets the value
|
||||||
// or finds a big.Int
|
// or finds a big.Int
|
||||||
func indirect(v reflect.Value) reflect.Value {
|
func indirect(v reflect.Value) reflect.Value {
|
||||||
@@ -61,7 +84,7 @@ func reflectIntType(unsigned bool, size int) reflect.Type {
|
|||||||
return reflect.TypeOf(&big.Int{})
|
return reflect.TypeOf(&big.Int{})
|
||||||
}
|
}
|
||||||
|
|
||||||
// mustArrayToBytesSlice creates a new byte slice with the exact same size as value
|
// mustArrayToByteSlice creates a new byte slice with the exact same size as value
|
||||||
// and copies the bytes in value to the new slice.
|
// and copies the bytes in value to the new slice.
|
||||||
func mustArrayToByteSlice(value reflect.Value) reflect.Value {
|
func mustArrayToByteSlice(value reflect.Value) reflect.Value {
|
||||||
slice := reflect.MakeSlice(reflect.TypeOf([]byte{}), value.Len(), value.Len())
|
slice := reflect.MakeSlice(reflect.TypeOf([]byte{}), value.Len(), value.Len())
|
||||||
@@ -100,15 +123,8 @@ func set(dst, src reflect.Value) error {
|
|||||||
func setSlice(dst, src reflect.Value) error {
|
func setSlice(dst, src reflect.Value) error {
|
||||||
slice := reflect.MakeSlice(dst.Type(), src.Len(), src.Len())
|
slice := reflect.MakeSlice(dst.Type(), src.Len(), src.Len())
|
||||||
for i := 0; i < src.Len(); i++ {
|
for i := 0; i < src.Len(); i++ {
|
||||||
if src.Index(i).Kind() == reflect.Struct {
|
if err := set(slice.Index(i), src.Index(i)); err != nil {
|
||||||
if err := set(slice.Index(i), src.Index(i)); err != nil {
|
return err
|
||||||
return err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// e.g. [][32]uint8 to []common.Hash
|
|
||||||
if err := set(slice.Index(i), src.Index(i)); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if dst.CanSet() {
|
if dst.CanSet() {
|
||||||
@@ -119,6 +135,9 @@ func setSlice(dst, src reflect.Value) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func setArray(dst, src reflect.Value) error {
|
func setArray(dst, src reflect.Value) error {
|
||||||
|
if src.Kind() == reflect.Ptr {
|
||||||
|
return set(dst, indirect(src))
|
||||||
|
}
|
||||||
array := reflect.New(dst.Type()).Elem()
|
array := reflect.New(dst.Type()).Elem()
|
||||||
min := src.Len()
|
min := src.Len()
|
||||||
if src.Len() > dst.Len() {
|
if src.Len() > dst.Len() {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package abi
|
package abi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"math/big"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
@@ -189,3 +190,72 @@ func TestReflectNameToStruct(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestConvertType(t *testing.T) {
|
||||||
|
// Test Basic Struct
|
||||||
|
type T struct {
|
||||||
|
X *big.Int
|
||||||
|
Y *big.Int
|
||||||
|
}
|
||||||
|
// Create on-the-fly structure
|
||||||
|
var fields []reflect.StructField
|
||||||
|
fields = append(fields, reflect.StructField{
|
||||||
|
Name: "X",
|
||||||
|
Type: reflect.TypeOf(new(big.Int)),
|
||||||
|
Tag: "json:\"" + "x" + "\"",
|
||||||
|
})
|
||||||
|
fields = append(fields, reflect.StructField{
|
||||||
|
Name: "Y",
|
||||||
|
Type: reflect.TypeOf(new(big.Int)),
|
||||||
|
Tag: "json:\"" + "y" + "\"",
|
||||||
|
})
|
||||||
|
val := reflect.New(reflect.StructOf(fields))
|
||||||
|
val.Elem().Field(0).Set(reflect.ValueOf(big.NewInt(1)))
|
||||||
|
val.Elem().Field(1).Set(reflect.ValueOf(big.NewInt(2)))
|
||||||
|
// ConvertType
|
||||||
|
out := *ConvertType(val.Interface(), new(T)).(*T)
|
||||||
|
if out.X.Cmp(big.NewInt(1)) != 0 {
|
||||||
|
t.Errorf("ConvertType failed, got %v want %v", out.X, big.NewInt(1))
|
||||||
|
}
|
||||||
|
if out.Y.Cmp(big.NewInt(2)) != 0 {
|
||||||
|
t.Errorf("ConvertType failed, got %v want %v", out.Y, big.NewInt(2))
|
||||||
|
}
|
||||||
|
// Slice Type
|
||||||
|
val2 := reflect.MakeSlice(reflect.SliceOf(reflect.StructOf(fields)), 2, 2)
|
||||||
|
val2.Index(0).Field(0).Set(reflect.ValueOf(big.NewInt(1)))
|
||||||
|
val2.Index(0).Field(1).Set(reflect.ValueOf(big.NewInt(2)))
|
||||||
|
val2.Index(1).Field(0).Set(reflect.ValueOf(big.NewInt(3)))
|
||||||
|
val2.Index(1).Field(1).Set(reflect.ValueOf(big.NewInt(4)))
|
||||||
|
out2 := *ConvertType(val2.Interface(), new([]T)).(*[]T)
|
||||||
|
if out2[0].X.Cmp(big.NewInt(1)) != 0 {
|
||||||
|
t.Errorf("ConvertType failed, got %v want %v", out2[0].X, big.NewInt(1))
|
||||||
|
}
|
||||||
|
if out2[0].Y.Cmp(big.NewInt(2)) != 0 {
|
||||||
|
t.Errorf("ConvertType failed, got %v want %v", out2[1].Y, big.NewInt(2))
|
||||||
|
}
|
||||||
|
if out2[1].X.Cmp(big.NewInt(3)) != 0 {
|
||||||
|
t.Errorf("ConvertType failed, got %v want %v", out2[0].X, big.NewInt(1))
|
||||||
|
}
|
||||||
|
if out2[1].Y.Cmp(big.NewInt(4)) != 0 {
|
||||||
|
t.Errorf("ConvertType failed, got %v want %v", out2[1].Y, big.NewInt(2))
|
||||||
|
}
|
||||||
|
// Array Type
|
||||||
|
val3 := reflect.New(reflect.ArrayOf(2, reflect.StructOf(fields)))
|
||||||
|
val3.Elem().Index(0).Field(0).Set(reflect.ValueOf(big.NewInt(1)))
|
||||||
|
val3.Elem().Index(0).Field(1).Set(reflect.ValueOf(big.NewInt(2)))
|
||||||
|
val3.Elem().Index(1).Field(0).Set(reflect.ValueOf(big.NewInt(3)))
|
||||||
|
val3.Elem().Index(1).Field(1).Set(reflect.ValueOf(big.NewInt(4)))
|
||||||
|
out3 := *ConvertType(val3.Interface(), new([2]T)).(*[2]T)
|
||||||
|
if out3[0].X.Cmp(big.NewInt(1)) != 0 {
|
||||||
|
t.Errorf("ConvertType failed, got %v want %v", out3[0].X, big.NewInt(1))
|
||||||
|
}
|
||||||
|
if out3[0].Y.Cmp(big.NewInt(2)) != 0 {
|
||||||
|
t.Errorf("ConvertType failed, got %v want %v", out3[1].Y, big.NewInt(2))
|
||||||
|
}
|
||||||
|
if out3[1].X.Cmp(big.NewInt(3)) != 0 {
|
||||||
|
t.Errorf("ConvertType failed, got %v want %v", out3[0].X, big.NewInt(1))
|
||||||
|
}
|
||||||
|
if out3[1].Y.Cmp(big.NewInt(4)) != 0 {
|
||||||
|
t.Errorf("ConvertType failed, got %v want %v", out3[1].Y, big.NewInt(2))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
176
accounts/abi/selector_parser.go
Normal file
176
accounts/abi/selector_parser.go
Normal file
@@ -0,0 +1,176 @@
|
|||||||
|
// Copyright 2022 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package abi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SelectorMarshaling struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
Inputs []ArgumentMarshaling `json:"inputs"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func isDigit(c byte) bool {
|
||||||
|
return c >= '0' && c <= '9'
|
||||||
|
}
|
||||||
|
|
||||||
|
func isAlpha(c byte) bool {
|
||||||
|
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
|
||||||
|
}
|
||||||
|
|
||||||
|
func isIdentifierSymbol(c byte) bool {
|
||||||
|
return c == '$' || c == '_'
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseToken(unescapedSelector string, isIdent bool) (string, string, error) {
|
||||||
|
if len(unescapedSelector) == 0 {
|
||||||
|
return "", "", fmt.Errorf("empty token")
|
||||||
|
}
|
||||||
|
firstChar := unescapedSelector[0]
|
||||||
|
position := 1
|
||||||
|
if !(isAlpha(firstChar) || (isIdent && isIdentifierSymbol(firstChar))) {
|
||||||
|
return "", "", fmt.Errorf("invalid token start: %c", firstChar)
|
||||||
|
}
|
||||||
|
for position < len(unescapedSelector) {
|
||||||
|
char := unescapedSelector[position]
|
||||||
|
if !(isAlpha(char) || isDigit(char) || (isIdent && isIdentifierSymbol(char))) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
position++
|
||||||
|
}
|
||||||
|
return unescapedSelector[:position], unescapedSelector[position:], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseIdentifier(unescapedSelector string) (string, string, error) {
|
||||||
|
return parseToken(unescapedSelector, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseElementaryType(unescapedSelector string) (string, string, error) {
|
||||||
|
parsedType, rest, err := parseToken(unescapedSelector, false)
|
||||||
|
if err != nil {
|
||||||
|
return "", "", fmt.Errorf("failed to parse elementary type: %v", err)
|
||||||
|
}
|
||||||
|
// handle arrays
|
||||||
|
for len(rest) > 0 && rest[0] == '[' {
|
||||||
|
parsedType = parsedType + string(rest[0])
|
||||||
|
rest = rest[1:]
|
||||||
|
for len(rest) > 0 && isDigit(rest[0]) {
|
||||||
|
parsedType = parsedType + string(rest[0])
|
||||||
|
rest = rest[1:]
|
||||||
|
}
|
||||||
|
if len(rest) == 0 || rest[0] != ']' {
|
||||||
|
return "", "", fmt.Errorf("failed to parse array: expected ']', got %c", unescapedSelector[0])
|
||||||
|
}
|
||||||
|
parsedType = parsedType + string(rest[0])
|
||||||
|
rest = rest[1:]
|
||||||
|
}
|
||||||
|
return parsedType, rest, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseCompositeType(unescapedSelector string) ([]interface{}, string, error) {
|
||||||
|
if len(unescapedSelector) == 0 || unescapedSelector[0] != '(' {
|
||||||
|
return nil, "", fmt.Errorf("expected '(', got %c", unescapedSelector[0])
|
||||||
|
}
|
||||||
|
parsedType, rest, err := parseType(unescapedSelector[1:])
|
||||||
|
if err != nil {
|
||||||
|
return nil, "", fmt.Errorf("failed to parse type: %v", err)
|
||||||
|
}
|
||||||
|
result := []interface{}{parsedType}
|
||||||
|
for len(rest) > 0 && rest[0] != ')' {
|
||||||
|
parsedType, rest, err = parseType(rest[1:])
|
||||||
|
if err != nil {
|
||||||
|
return nil, "", fmt.Errorf("failed to parse type: %v", err)
|
||||||
|
}
|
||||||
|
result = append(result, parsedType)
|
||||||
|
}
|
||||||
|
if len(rest) == 0 || rest[0] != ')' {
|
||||||
|
return nil, "", fmt.Errorf("expected ')', got '%s'", rest)
|
||||||
|
}
|
||||||
|
if len(rest) >= 3 && rest[1] == '[' && rest[2] == ']' {
|
||||||
|
return append(result, "[]"), rest[3:], nil
|
||||||
|
}
|
||||||
|
return result, rest[1:], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseType(unescapedSelector string) (interface{}, string, error) {
|
||||||
|
if len(unescapedSelector) == 0 {
|
||||||
|
return nil, "", fmt.Errorf("empty type")
|
||||||
|
}
|
||||||
|
if unescapedSelector[0] == '(' {
|
||||||
|
return parseCompositeType(unescapedSelector)
|
||||||
|
} else {
|
||||||
|
return parseElementaryType(unescapedSelector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func assembleArgs(args []interface{}) ([]ArgumentMarshaling, error) {
|
||||||
|
arguments := make([]ArgumentMarshaling, 0)
|
||||||
|
for i, arg := range args {
|
||||||
|
// generate dummy name to avoid unmarshal issues
|
||||||
|
name := fmt.Sprintf("name%d", i)
|
||||||
|
if s, ok := arg.(string); ok {
|
||||||
|
arguments = append(arguments, ArgumentMarshaling{name, s, s, nil, false})
|
||||||
|
} else if components, ok := arg.([]interface{}); ok {
|
||||||
|
subArgs, err := assembleArgs(components)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to assemble components: %v", err)
|
||||||
|
}
|
||||||
|
tupleType := "tuple"
|
||||||
|
if len(subArgs) != 0 && subArgs[len(subArgs)-1].Type == "[]" {
|
||||||
|
subArgs = subArgs[:len(subArgs)-1]
|
||||||
|
tupleType = "tuple[]"
|
||||||
|
}
|
||||||
|
arguments = append(arguments, ArgumentMarshaling{name, tupleType, tupleType, subArgs, false})
|
||||||
|
} else {
|
||||||
|
return nil, fmt.Errorf("failed to assemble args: unexpected type %T", arg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return arguments, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseSelector converts a method selector into a struct that can be JSON encoded
|
||||||
|
// and consumed by other functions in this package.
|
||||||
|
// Note, although uppercase letters are not part of the ABI spec, this function
|
||||||
|
// still accepts it as the general format is valid.
|
||||||
|
func ParseSelector(unescapedSelector string) (SelectorMarshaling, error) {
|
||||||
|
name, rest, err := parseIdentifier(unescapedSelector)
|
||||||
|
if err != nil {
|
||||||
|
return SelectorMarshaling{}, fmt.Errorf("failed to parse selector '%s': %v", unescapedSelector, err)
|
||||||
|
}
|
||||||
|
args := []interface{}{}
|
||||||
|
if len(rest) >= 2 && rest[0] == '(' && rest[1] == ')' {
|
||||||
|
rest = rest[2:]
|
||||||
|
} else {
|
||||||
|
args, rest, err = parseCompositeType(rest)
|
||||||
|
if err != nil {
|
||||||
|
return SelectorMarshaling{}, fmt.Errorf("failed to parse selector '%s': %v", unescapedSelector, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(rest) > 0 {
|
||||||
|
return SelectorMarshaling{}, fmt.Errorf("failed to parse selector '%s': unexpected string '%s'", unescapedSelector, rest)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reassemble the fake ABI and constuct the JSON
|
||||||
|
fakeArgs, err := assembleArgs(args)
|
||||||
|
if err != nil {
|
||||||
|
return SelectorMarshaling{}, fmt.Errorf("failed to parse selector: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return SelectorMarshaling{name, "function", fakeArgs}, nil
|
||||||
|
}
|
||||||
79
accounts/abi/selector_parser_test.go
Normal file
79
accounts/abi/selector_parser_test.go
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
// Copyright 2022 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package abi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"reflect"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestParseSelector(t *testing.T) {
|
||||||
|
mkType := func(types ...interface{}) []ArgumentMarshaling {
|
||||||
|
var result []ArgumentMarshaling
|
||||||
|
for i, typeOrComponents := range types {
|
||||||
|
name := fmt.Sprintf("name%d", i)
|
||||||
|
if typeName, ok := typeOrComponents.(string); ok {
|
||||||
|
result = append(result, ArgumentMarshaling{name, typeName, typeName, nil, false})
|
||||||
|
} else if components, ok := typeOrComponents.([]ArgumentMarshaling); ok {
|
||||||
|
result = append(result, ArgumentMarshaling{name, "tuple", "tuple", components, false})
|
||||||
|
} else if components, ok := typeOrComponents.([][]ArgumentMarshaling); ok {
|
||||||
|
result = append(result, ArgumentMarshaling{name, "tuple[]", "tuple[]", components[0], false})
|
||||||
|
} else {
|
||||||
|
log.Fatalf("unexpected type %T", typeOrComponents)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
tests := []struct {
|
||||||
|
input string
|
||||||
|
name string
|
||||||
|
args []ArgumentMarshaling
|
||||||
|
}{
|
||||||
|
{"noargs()", "noargs", []ArgumentMarshaling{}},
|
||||||
|
{"simple(uint256,uint256,uint256)", "simple", mkType("uint256", "uint256", "uint256")},
|
||||||
|
{"other(uint256,address)", "other", mkType("uint256", "address")},
|
||||||
|
{"withArray(uint256[],address[2],uint8[4][][5])", "withArray", mkType("uint256[]", "address[2]", "uint8[4][][5]")},
|
||||||
|
{"singleNest(bytes32,uint8,(uint256,uint256),address)", "singleNest", mkType("bytes32", "uint8", mkType("uint256", "uint256"), "address")},
|
||||||
|
{"multiNest(address,(uint256[],uint256),((address,bytes32),uint256))", "multiNest",
|
||||||
|
mkType("address", mkType("uint256[]", "uint256"), mkType(mkType("address", "bytes32"), "uint256"))},
|
||||||
|
{"arrayNest((uint256,uint256)[],bytes32)", "arrayNest", mkType([][]ArgumentMarshaling{mkType("uint256", "uint256")}, "bytes32")},
|
||||||
|
{"multiArrayNest((uint256,uint256)[],(uint256,uint256)[])", "multiArrayNest",
|
||||||
|
mkType([][]ArgumentMarshaling{mkType("uint256", "uint256")}, [][]ArgumentMarshaling{mkType("uint256", "uint256")})},
|
||||||
|
{"singleArrayNestAndArray((uint256,uint256)[],bytes32[])", "singleArrayNestAndArray",
|
||||||
|
mkType([][]ArgumentMarshaling{mkType("uint256", "uint256")}, "bytes32[]")},
|
||||||
|
{"singleArrayNestWithArrayAndArray((uint256[],address[2],uint8[4][][5])[],bytes32[])", "singleArrayNestWithArrayAndArray",
|
||||||
|
mkType([][]ArgumentMarshaling{mkType("uint256[]", "address[2]", "uint8[4][][5]")}, "bytes32[]")},
|
||||||
|
}
|
||||||
|
for i, tt := range tests {
|
||||||
|
selector, err := ParseSelector(tt.input)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("test %d: failed to parse selector '%v': %v", i, tt.input, err)
|
||||||
|
}
|
||||||
|
if selector.Name != tt.name {
|
||||||
|
t.Errorf("test %d: unexpected function name: '%s' != '%s'", i, selector.Name, tt.name)
|
||||||
|
}
|
||||||
|
|
||||||
|
if selector.Type != "function" {
|
||||||
|
t.Errorf("test %d: unexpected type: '%s' != '%s'", i, selector.Type, "function")
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(selector.Inputs, tt.args) {
|
||||||
|
t.Errorf("test %d: unexpected args: '%v' != '%v'", i, selector.Inputs, tt.args)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -102,7 +102,7 @@ func genIntType(rule int64, size uint) []byte {
|
|||||||
var topic [common.HashLength]byte
|
var topic [common.HashLength]byte
|
||||||
if rule < 0 {
|
if rule < 0 {
|
||||||
// if a rule is negative, we need to put it into two's complement.
|
// if a rule is negative, we need to put it into two's complement.
|
||||||
// extended to common.Hashlength bytes.
|
// extended to common.HashLength bytes.
|
||||||
topic = [common.HashLength]byte{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}
|
topic = [common.HashLength]byte{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}
|
||||||
}
|
}
|
||||||
for i := uint(0); i < size; i++ {
|
for i := uint(0); i < size; i++ {
|
||||||
@@ -120,7 +120,7 @@ func ParseTopics(out interface{}, fields Arguments, topics []common.Hash) error
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseTopicsIntoMap converts the indexed topic field-value pairs into map key-value pairs
|
// ParseTopicsIntoMap converts the indexed topic field-value pairs into map key-value pairs.
|
||||||
func ParseTopicsIntoMap(out map[string]interface{}, fields Arguments, topics []common.Hash) error {
|
func ParseTopicsIntoMap(out map[string]interface{}, fields Arguments, topics []common.Hash) error {
|
||||||
return parseTopicWithSetter(fields, topics,
|
return parseTopicWithSetter(fields, topics,
|
||||||
func(arg Argument, reconstr interface{}) {
|
func(arg Argument, reconstr interface{}) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2019 The go-ethereum Authors
|
// Copyright 2020 The go-ethereum Authors
|
||||||
// This file is part of the go-ethereum library.
|
// This file is part of the go-ethereum library.
|
||||||
//
|
//
|
||||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"unicode"
|
||||||
|
"unicode/utf8"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
)
|
)
|
||||||
@@ -44,7 +46,7 @@ const (
|
|||||||
FunctionTy
|
FunctionTy
|
||||||
)
|
)
|
||||||
|
|
||||||
// Type is the reflection of the supported argument type
|
// Type is the reflection of the supported argument type.
|
||||||
type Type struct {
|
type Type struct {
|
||||||
Elem *Type
|
Elem *Type
|
||||||
Size int
|
Size int
|
||||||
@@ -161,19 +163,26 @@ func NewType(t string, internalType string, components []ArgumentMarshaling) (ty
|
|||||||
elems []*Type
|
elems []*Type
|
||||||
names []string
|
names []string
|
||||||
expression string // canonical parameter expression
|
expression string // canonical parameter expression
|
||||||
|
used = make(map[string]bool)
|
||||||
)
|
)
|
||||||
expression += "("
|
expression += "("
|
||||||
overloadedNames := make(map[string]string)
|
|
||||||
for idx, c := range components {
|
for idx, c := range components {
|
||||||
cType, err := NewType(c.Type, c.InternalType, c.Components)
|
cType, err := NewType(c.Type, c.InternalType, c.Components)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Type{}, err
|
return Type{}, err
|
||||||
}
|
}
|
||||||
fieldName, err := overloadedArgName(c.Name, overloadedNames)
|
name := ToCamelCase(c.Name)
|
||||||
|
if name == "" {
|
||||||
|
return Type{}, errors.New("abi: purely anonymous or underscored field is not supported")
|
||||||
|
}
|
||||||
|
fieldName := ResolveNameConflict(name, func(s string) bool { return used[s] })
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Type{}, err
|
return Type{}, err
|
||||||
}
|
}
|
||||||
overloadedNames[fieldName] = fieldName
|
used[fieldName] = true
|
||||||
|
if !isValidFieldName(fieldName) {
|
||||||
|
return Type{}, fmt.Errorf("field %d has invalid name", idx)
|
||||||
|
}
|
||||||
fields = append(fields, reflect.StructField{
|
fields = append(fields, reflect.StructField{
|
||||||
Name: fieldName, // reflect.StructOf will panic for any exported field.
|
Name: fieldName, // reflect.StructOf will panic for any exported field.
|
||||||
Type: cType.GetType(),
|
Type: cType.GetType(),
|
||||||
@@ -201,7 +210,7 @@ func NewType(t string, internalType string, components []ArgumentMarshaling) (ty
|
|||||||
if internalType != "" && strings.HasPrefix(internalType, structPrefix) {
|
if internalType != "" && strings.HasPrefix(internalType, structPrefix) {
|
||||||
// Foo.Bar type definition is not allowed in golang,
|
// Foo.Bar type definition is not allowed in golang,
|
||||||
// convert the format to FooBar
|
// convert the format to FooBar
|
||||||
typ.TupleRawName = strings.Replace(internalType[len(structPrefix):], ".", "", -1)
|
typ.TupleRawName = strings.ReplaceAll(internalType[len(structPrefix):], ".", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
case "function":
|
case "function":
|
||||||
@@ -250,21 +259,7 @@ func (t Type) GetType() reflect.Type {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func overloadedArgName(rawName string, names map[string]string) (string, error) {
|
// String implements Stringer.
|
||||||
fieldName := ToCamelCase(rawName)
|
|
||||||
if fieldName == "" {
|
|
||||||
return "", errors.New("abi: purely anonymous or underscored field is not supported")
|
|
||||||
}
|
|
||||||
// Handle overloaded fieldNames
|
|
||||||
_, ok := names[fieldName]
|
|
||||||
for idx := 0; ok; idx++ {
|
|
||||||
fieldName = fmt.Sprintf("%s%d", ToCamelCase(rawName), idx)
|
|
||||||
_, ok = names[fieldName]
|
|
||||||
}
|
|
||||||
return fieldName, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// String implements Stringer
|
|
||||||
func (t Type) String() (out string) {
|
func (t Type) String() (out string) {
|
||||||
return t.stringKind
|
return t.stringKind
|
||||||
}
|
}
|
||||||
@@ -346,7 +341,7 @@ func (t Type) pack(v reflect.Value) ([]byte, error) {
|
|||||||
return append(ret, tail...), nil
|
return append(ret, tail...), nil
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return packElement(t, v), nil
|
return packElement(t, v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -399,3 +394,30 @@ func getTypeSize(t Type) int {
|
|||||||
}
|
}
|
||||||
return 32
|
return 32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// isLetter reports whether a given 'rune' is classified as a Letter.
|
||||||
|
// This method is copied from reflect/type.go
|
||||||
|
func isLetter(ch rune) bool {
|
||||||
|
return 'a' <= ch && ch <= 'z' || 'A' <= ch && ch <= 'Z' || ch == '_' || ch >= utf8.RuneSelf && unicode.IsLetter(ch)
|
||||||
|
}
|
||||||
|
|
||||||
|
// isValidFieldName checks if a string is a valid (struct) field name or not.
|
||||||
|
//
|
||||||
|
// According to the language spec, a field name should be an identifier.
|
||||||
|
//
|
||||||
|
// identifier = letter { letter | unicode_digit } .
|
||||||
|
// letter = unicode_letter | "_" .
|
||||||
|
// This method is copied from reflect/type.go
|
||||||
|
func isValidFieldName(fieldName string) bool {
|
||||||
|
for i, c := range fieldName {
|
||||||
|
if i == 0 && !isLetter(c) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if !(isLetter(c) || unicode.IsDigit(c)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return len(fieldName) > 0
|
||||||
|
}
|
||||||
|
|||||||
@@ -255,7 +255,7 @@ func TestTypeCheck(t *testing.T) {
|
|||||||
{"bytes", nil, [2]byte{0, 1}, "abi: cannot use array as type slice as argument"},
|
{"bytes", nil, [2]byte{0, 1}, "abi: cannot use array as type slice as argument"},
|
||||||
{"bytes", nil, common.Hash{1}, "abi: cannot use array as type slice as argument"},
|
{"bytes", nil, common.Hash{1}, "abi: cannot use array as type slice as argument"},
|
||||||
{"string", nil, "hello world", ""},
|
{"string", nil, "hello world", ""},
|
||||||
{"string", nil, string(""), ""},
|
{"string", nil, "", ""},
|
||||||
{"string", nil, []byte{}, "abi: cannot use slice as type string as argument"},
|
{"string", nil, []byte{}, "abi: cannot use slice as type string as argument"},
|
||||||
{"bytes32[]", nil, [][32]byte{{}}, ""},
|
{"bytes32[]", nil, [][32]byte{{}}, ""},
|
||||||
{"function", nil, [24]byte{}, ""},
|
{"function", nil, [24]byte{}, ""},
|
||||||
|
|||||||
@@ -26,13 +26,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// MaxUint256 is the maximum value that can be represented by a uint256
|
// MaxUint256 is the maximum value that can be represented by a uint256.
|
||||||
MaxUint256 = new(big.Int).Sub(new(big.Int).Lsh(common.Big1, 256), common.Big1)
|
MaxUint256 = new(big.Int).Sub(new(big.Int).Lsh(common.Big1, 256), common.Big1)
|
||||||
// MaxInt256 is the maximum value that can be represented by a int256
|
// MaxInt256 is the maximum value that can be represented by a int256.
|
||||||
MaxInt256 = new(big.Int).Sub(new(big.Int).Lsh(common.Big1, 255), common.Big1)
|
MaxInt256 = new(big.Int).Sub(new(big.Int).Lsh(common.Big1, 255), common.Big1)
|
||||||
)
|
)
|
||||||
|
|
||||||
// ReadInteger reads the integer based on its kind and returns the appropriate value
|
// ReadInteger reads the integer based on its kind and returns the appropriate value.
|
||||||
func ReadInteger(typ Type, b []byte) interface{} {
|
func ReadInteger(typ Type, b []byte) interface{} {
|
||||||
if typ.T == UintTy {
|
if typ.T == UintTy {
|
||||||
switch typ.Size {
|
switch typ.Size {
|
||||||
@@ -73,7 +73,7 @@ func ReadInteger(typ Type, b []byte) interface{} {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// reads a bool
|
// readBool reads a bool.
|
||||||
func readBool(word []byte) (bool, error) {
|
func readBool(word []byte) (bool, error) {
|
||||||
for _, b := range word[:31] {
|
for _, b := range word[:31] {
|
||||||
if b != 0 {
|
if b != 0 {
|
||||||
@@ -91,7 +91,8 @@ func readBool(word []byte) (bool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// A function type is simply the address with the function selection signature at the end.
|
// A function type is simply the address with the function selection signature at the end.
|
||||||
// This enforces that standard by always presenting it as a 24-array (address + sig = 24 bytes)
|
//
|
||||||
|
// readFunctionType enforces that standard by always presenting it as a 24-array (address + sig = 24 bytes)
|
||||||
func readFunctionType(t Type, word []byte) (funcTy [24]byte, err error) {
|
func readFunctionType(t Type, word []byte) (funcTy [24]byte, err error) {
|
||||||
if t.T != FunctionTy {
|
if t.T != FunctionTy {
|
||||||
return [24]byte{}, fmt.Errorf("abi: invalid type in call to make function type byte array")
|
return [24]byte{}, fmt.Errorf("abi: invalid type in call to make function type byte array")
|
||||||
@@ -104,7 +105,7 @@ func readFunctionType(t Type, word []byte) (funcTy [24]byte, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadFixedBytes uses reflection to create a fixed array to be read from
|
// ReadFixedBytes uses reflection to create a fixed array to be read from.
|
||||||
func ReadFixedBytes(t Type, word []byte) (interface{}, error) {
|
func ReadFixedBytes(t Type, word []byte) (interface{}, error) {
|
||||||
if t.T != FixedBytesTy {
|
if t.T != FixedBytesTy {
|
||||||
return nil, fmt.Errorf("abi: invalid type in call to make fixed byte array")
|
return nil, fmt.Errorf("abi: invalid type in call to make fixed byte array")
|
||||||
@@ -117,7 +118,7 @@ func ReadFixedBytes(t Type, word []byte) (interface{}, error) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// iteratively unpack elements
|
// forEachUnpack iteratively unpack elements.
|
||||||
func forEachUnpack(t Type, output []byte, start, size int) (interface{}, error) {
|
func forEachUnpack(t Type, output []byte, start, size int) (interface{}, error) {
|
||||||
if size < 0 {
|
if size < 0 {
|
||||||
return nil, fmt.Errorf("cannot marshal input to array, size is negative (%d)", size)
|
return nil, fmt.Errorf("cannot marshal input to array, size is negative (%d)", size)
|
||||||
@@ -224,7 +225,10 @@ func toGoType(index int, t Type, output []byte) (interface{}, error) {
|
|||||||
return forEachUnpack(t, output[begin:], 0, length)
|
return forEachUnpack(t, output[begin:], 0, length)
|
||||||
case ArrayTy:
|
case ArrayTy:
|
||||||
if isDynamicType(*t.Elem) {
|
if isDynamicType(*t.Elem) {
|
||||||
offset := int64(binary.BigEndian.Uint64(returnOutput[len(returnOutput)-8:]))
|
offset := binary.BigEndian.Uint64(returnOutput[len(returnOutput)-8:])
|
||||||
|
if offset > uint64(len(output)) {
|
||||||
|
return nil, fmt.Errorf("abi: toGoType offset greater than output length: offset: %d, len(output): %d", offset, len(output))
|
||||||
|
}
|
||||||
return forEachUnpack(t, output[offset:], 0, t.Size)
|
return forEachUnpack(t, output[offset:], 0, t.Size)
|
||||||
}
|
}
|
||||||
return forEachUnpack(t, output[index:], 0, t.Size)
|
return forEachUnpack(t, output[index:], 0, t.Size)
|
||||||
@@ -249,9 +253,9 @@ func toGoType(index int, t Type, output []byte) (interface{}, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// interprets a 32 byte slice as an offset and then determines which indice to look to decode the type.
|
// lengthPrefixPointsTo interprets a 32 byte slice as an offset and then determines which indices to look to decode the type.
|
||||||
func lengthPrefixPointsTo(index int, output []byte) (start int, length int, err error) {
|
func lengthPrefixPointsTo(index int, output []byte) (start int, length int, err error) {
|
||||||
bigOffsetEnd := big.NewInt(0).SetBytes(output[index : index+32])
|
bigOffsetEnd := new(big.Int).SetBytes(output[index : index+32])
|
||||||
bigOffsetEnd.Add(bigOffsetEnd, common.Big32)
|
bigOffsetEnd.Add(bigOffsetEnd, common.Big32)
|
||||||
outputLength := big.NewInt(int64(len(output)))
|
outputLength := big.NewInt(int64(len(output)))
|
||||||
|
|
||||||
@@ -264,11 +268,9 @@ func lengthPrefixPointsTo(index int, output []byte) (start int, length int, err
|
|||||||
}
|
}
|
||||||
|
|
||||||
offsetEnd := int(bigOffsetEnd.Uint64())
|
offsetEnd := int(bigOffsetEnd.Uint64())
|
||||||
lengthBig := big.NewInt(0).SetBytes(output[offsetEnd-32 : offsetEnd])
|
lengthBig := new(big.Int).SetBytes(output[offsetEnd-32 : offsetEnd])
|
||||||
|
|
||||||
totalSize := big.NewInt(0)
|
totalSize := new(big.Int).Add(bigOffsetEnd, lengthBig)
|
||||||
totalSize.Add(totalSize, bigOffsetEnd)
|
|
||||||
totalSize.Add(totalSize, lengthBig)
|
|
||||||
if totalSize.BitLen() > 63 {
|
if totalSize.BitLen() > 63 {
|
||||||
return 0, 0, fmt.Errorf("abi: length larger than int64: %v", totalSize)
|
return 0, 0, fmt.Errorf("abi: length larger than int64: %v", totalSize)
|
||||||
}
|
}
|
||||||
@@ -283,10 +285,10 @@ func lengthPrefixPointsTo(index int, output []byte) (start int, length int, err
|
|||||||
|
|
||||||
// tuplePointsTo resolves the location reference for dynamic tuple.
|
// tuplePointsTo resolves the location reference for dynamic tuple.
|
||||||
func tuplePointsTo(index int, output []byte) (start int, err error) {
|
func tuplePointsTo(index int, output []byte) (start int, err error) {
|
||||||
offset := big.NewInt(0).SetBytes(output[index : index+32])
|
offset := new(big.Int).SetBytes(output[index : index+32])
|
||||||
outputLen := big.NewInt(int64(len(output)))
|
outputLen := big.NewInt(int64(len(output)))
|
||||||
|
|
||||||
if offset.Cmp(big.NewInt(int64(len(output)))) > 0 {
|
if offset.Cmp(outputLen) > 0 {
|
||||||
return 0, fmt.Errorf("abi: cannot marshal in to go slice: offset %v would go over slice boundary (len=%v)", offset, outputLen)
|
return 0, fmt.Errorf("abi: cannot marshal in to go slice: offset %v would go over slice boundary (len=%v)", offset, outputLen)
|
||||||
}
|
}
|
||||||
if offset.BitLen() > 63 {
|
if offset.BitLen() > 63 {
|
||||||
|
|||||||
@@ -44,15 +44,13 @@ func TestUnpack(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("invalid hex %s: %v", test.packed, err)
|
t.Fatalf("invalid hex %s: %v", test.packed, err)
|
||||||
}
|
}
|
||||||
outptr := reflect.New(reflect.TypeOf(test.unpacked))
|
out, err := abi.Unpack("method", encb)
|
||||||
err = abi.Unpack(outptr.Interface(), "method", encb)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("test %d (%v) failed: %v", i, test.def, err)
|
t.Errorf("test %d (%v) failed: %v", i, test.def, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
out := outptr.Elem().Interface()
|
if !reflect.DeepEqual(test.unpacked, ConvertType(out[0], test.unpacked)) {
|
||||||
if !reflect.DeepEqual(test.unpacked, out) {
|
t.Errorf("test %d (%v) failed: expected %v, got %v", i, test.def, test.unpacked, out[0])
|
||||||
t.Errorf("test %d (%v) failed: expected %v, got %v", i, test.def, test.unpacked, out)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -203,6 +201,23 @@ var unpackTests = []unpackTest{
|
|||||||
IntOne *big.Int
|
IntOne *big.Int
|
||||||
}{big.NewInt(1)},
|
}{big.NewInt(1)},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
def: `[{"type":"bool"}]`,
|
||||||
|
enc: "",
|
||||||
|
want: false,
|
||||||
|
err: "abi: attempting to unmarshall an empty string while arguments are expected",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
def: `[{"type":"bytes32","indexed":true},{"type":"uint256","indexed":false}]`,
|
||||||
|
enc: "",
|
||||||
|
want: false,
|
||||||
|
err: "abi: attempting to unmarshall an empty string while arguments are expected",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
def: `[{"type":"bool","indexed":true},{"type":"uint64","indexed":true}]`,
|
||||||
|
enc: "",
|
||||||
|
want: false,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestLocalUnpackTests runs test specially designed only for unpacking.
|
// TestLocalUnpackTests runs test specially designed only for unpacking.
|
||||||
@@ -221,7 +236,7 @@ func TestLocalUnpackTests(t *testing.T) {
|
|||||||
t.Fatalf("invalid hex %s: %v", test.enc, err)
|
t.Fatalf("invalid hex %s: %v", test.enc, err)
|
||||||
}
|
}
|
||||||
outptr := reflect.New(reflect.TypeOf(test.want))
|
outptr := reflect.New(reflect.TypeOf(test.want))
|
||||||
err = abi.Unpack(outptr.Interface(), "method", encb)
|
err = abi.UnpackIntoInterface(outptr.Interface(), "method", encb)
|
||||||
if err := test.checkError(err); err != nil {
|
if err := test.checkError(err); err != nil {
|
||||||
t.Errorf("test %d (%v) failed: %v", i, test.def, err)
|
t.Errorf("test %d (%v) failed: %v", i, test.def, err)
|
||||||
return
|
return
|
||||||
@@ -234,7 +249,7 @@ func TestLocalUnpackTests(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUnpackSetDynamicArrayOutput(t *testing.T) {
|
func TestUnpackIntoInterfaceSetDynamicArrayOutput(t *testing.T) {
|
||||||
abi, err := JSON(strings.NewReader(`[{"constant":true,"inputs":[],"name":"testDynamicFixedBytes15","outputs":[{"name":"","type":"bytes15[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"testDynamicFixedBytes32","outputs":[{"name":"","type":"bytes32[]"}],"payable":false,"stateMutability":"view","type":"function"}]`))
|
abi, err := JSON(strings.NewReader(`[{"constant":true,"inputs":[],"name":"testDynamicFixedBytes15","outputs":[{"name":"","type":"bytes15[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"testDynamicFixedBytes32","outputs":[{"name":"","type":"bytes32[]"}],"payable":false,"stateMutability":"view","type":"function"}]`))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@@ -249,7 +264,7 @@ func TestUnpackSetDynamicArrayOutput(t *testing.T) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// test 32
|
// test 32
|
||||||
err = abi.Unpack(&out32, "testDynamicFixedBytes32", marshalledReturn32)
|
err = abi.UnpackIntoInterface(&out32, "testDynamicFixedBytes32", marshalledReturn32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -266,7 +281,7 @@ func TestUnpackSetDynamicArrayOutput(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// test 15
|
// test 15
|
||||||
err = abi.Unpack(&out15, "testDynamicFixedBytes32", marshalledReturn15)
|
err = abi.UnpackIntoInterface(&out15, "testDynamicFixedBytes32", marshalledReturn15)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -367,7 +382,7 @@ func TestMethodMultiReturn(t *testing.T) {
|
|||||||
tc := tc
|
tc := tc
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
require := require.New(t)
|
require := require.New(t)
|
||||||
err := abi.Unpack(tc.dest, "multi", data)
|
err := abi.UnpackIntoInterface(tc.dest, "multi", data)
|
||||||
if tc.error == "" {
|
if tc.error == "" {
|
||||||
require.Nil(err, "Should be able to unpack method outputs.")
|
require.Nil(err, "Should be able to unpack method outputs.")
|
||||||
require.Equal(tc.expected, tc.dest)
|
require.Equal(tc.expected, tc.dest)
|
||||||
@@ -390,7 +405,7 @@ func TestMultiReturnWithArray(t *testing.T) {
|
|||||||
|
|
||||||
ret1, ret1Exp := new([3]uint64), [3]uint64{9, 9, 9}
|
ret1, ret1Exp := new([3]uint64), [3]uint64{9, 9, 9}
|
||||||
ret2, ret2Exp := new(uint64), uint64(8)
|
ret2, ret2Exp := new(uint64), uint64(8)
|
||||||
if err := abi.Unpack(&[]interface{}{ret1, ret2}, "multi", buff.Bytes()); err != nil {
|
if err := abi.UnpackIntoInterface(&[]interface{}{ret1, ret2}, "multi", buff.Bytes()); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(*ret1, ret1Exp) {
|
if !reflect.DeepEqual(*ret1, ret1Exp) {
|
||||||
@@ -409,12 +424,12 @@ func TestMultiReturnWithStringArray(t *testing.T) {
|
|||||||
}
|
}
|
||||||
buff := new(bytes.Buffer)
|
buff := new(bytes.Buffer)
|
||||||
buff.Write(common.Hex2Bytes("000000000000000000000000000000000000000000000000000000005c1b78ea0000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000001a055690d9db80000000000000000000000000000ab1257528b3782fb40d7ed5f72e624b744dffb2f00000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000008457468657265756d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001048656c6c6f2c20457468657265756d2100000000000000000000000000000000"))
|
buff.Write(common.Hex2Bytes("000000000000000000000000000000000000000000000000000000005c1b78ea0000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000001a055690d9db80000000000000000000000000000ab1257528b3782fb40d7ed5f72e624b744dffb2f00000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000008457468657265756d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001048656c6c6f2c20457468657265756d2100000000000000000000000000000000"))
|
||||||
temp, _ := big.NewInt(0).SetString("30000000000000000000", 10)
|
temp, _ := new(big.Int).SetString("30000000000000000000", 10)
|
||||||
ret1, ret1Exp := new([3]*big.Int), [3]*big.Int{big.NewInt(1545304298), big.NewInt(6), temp}
|
ret1, ret1Exp := new([3]*big.Int), [3]*big.Int{big.NewInt(1545304298), big.NewInt(6), temp}
|
||||||
ret2, ret2Exp := new(common.Address), common.HexToAddress("ab1257528b3782fb40d7ed5f72e624b744dffb2f")
|
ret2, ret2Exp := new(common.Address), common.HexToAddress("ab1257528b3782fb40d7ed5f72e624b744dffb2f")
|
||||||
ret3, ret3Exp := new([2]string), [2]string{"Ethereum", "Hello, Ethereum!"}
|
ret3, ret3Exp := new([2]string), [2]string{"Ethereum", "Hello, Ethereum!"}
|
||||||
ret4, ret4Exp := new(bool), false
|
ret4, ret4Exp := new(bool), false
|
||||||
if err := abi.Unpack(&[]interface{}{ret1, ret2, ret3, ret4}, "multi", buff.Bytes()); err != nil {
|
if err := abi.UnpackIntoInterface(&[]interface{}{ret1, ret2, ret3, ret4}, "multi", buff.Bytes()); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(*ret1, ret1Exp) {
|
if !reflect.DeepEqual(*ret1, ret1Exp) {
|
||||||
@@ -452,7 +467,7 @@ func TestMultiReturnWithStringSlice(t *testing.T) {
|
|||||||
buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000065")) // output[1][1] value
|
buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000065")) // output[1][1] value
|
||||||
ret1, ret1Exp := new([]string), []string{"ethereum", "go-ethereum"}
|
ret1, ret1Exp := new([]string), []string{"ethereum", "go-ethereum"}
|
||||||
ret2, ret2Exp := new([]*big.Int), []*big.Int{big.NewInt(100), big.NewInt(101)}
|
ret2, ret2Exp := new([]*big.Int), []*big.Int{big.NewInt(100), big.NewInt(101)}
|
||||||
if err := abi.Unpack(&[]interface{}{ret1, ret2}, "multi", buff.Bytes()); err != nil {
|
if err := abi.UnpackIntoInterface(&[]interface{}{ret1, ret2}, "multi", buff.Bytes()); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(*ret1, ret1Exp) {
|
if !reflect.DeepEqual(*ret1, ret1Exp) {
|
||||||
@@ -492,7 +507,7 @@ func TestMultiReturnWithDeeplyNestedArray(t *testing.T) {
|
|||||||
{{0x411, 0x412, 0x413}, {0x421, 0x422, 0x423}},
|
{{0x411, 0x412, 0x413}, {0x421, 0x422, 0x423}},
|
||||||
}
|
}
|
||||||
ret2, ret2Exp := new(uint64), uint64(0x9876)
|
ret2, ret2Exp := new(uint64), uint64(0x9876)
|
||||||
if err := abi.Unpack(&[]interface{}{ret1, ret2}, "multi", buff.Bytes()); err != nil {
|
if err := abi.UnpackIntoInterface(&[]interface{}{ret1, ret2}, "multi", buff.Bytes()); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(*ret1, ret1Exp) {
|
if !reflect.DeepEqual(*ret1, ret1Exp) {
|
||||||
@@ -531,7 +546,7 @@ func TestUnmarshal(t *testing.T) {
|
|||||||
buff.Write(common.Hex2Bytes("000000000000000000000000000000000000000000000000000000000000000a"))
|
buff.Write(common.Hex2Bytes("000000000000000000000000000000000000000000000000000000000000000a"))
|
||||||
buff.Write(common.Hex2Bytes("0102000000000000000000000000000000000000000000000000000000000000"))
|
buff.Write(common.Hex2Bytes("0102000000000000000000000000000000000000000000000000000000000000"))
|
||||||
|
|
||||||
err = abi.Unpack(&mixedBytes, "mixedBytes", buff.Bytes())
|
err = abi.UnpackIntoInterface(&mixedBytes, "mixedBytes", buff.Bytes())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
} else {
|
} else {
|
||||||
@@ -546,7 +561,7 @@ func TestUnmarshal(t *testing.T) {
|
|||||||
|
|
||||||
// marshal int
|
// marshal int
|
||||||
var Int *big.Int
|
var Int *big.Int
|
||||||
err = abi.Unpack(&Int, "int", common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000001"))
|
err = abi.UnpackIntoInterface(&Int, "int", common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000001"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
@@ -557,7 +572,7 @@ func TestUnmarshal(t *testing.T) {
|
|||||||
|
|
||||||
// marshal bool
|
// marshal bool
|
||||||
var Bool bool
|
var Bool bool
|
||||||
err = abi.Unpack(&Bool, "bool", common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000001"))
|
err = abi.UnpackIntoInterface(&Bool, "bool", common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000001"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
@@ -574,7 +589,7 @@ func TestUnmarshal(t *testing.T) {
|
|||||||
buff.Write(bytesOut)
|
buff.Write(bytesOut)
|
||||||
|
|
||||||
var Bytes []byte
|
var Bytes []byte
|
||||||
err = abi.Unpack(&Bytes, "bytes", buff.Bytes())
|
err = abi.UnpackIntoInterface(&Bytes, "bytes", buff.Bytes())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
@@ -590,7 +605,7 @@ func TestUnmarshal(t *testing.T) {
|
|||||||
bytesOut = common.RightPadBytes([]byte("hello"), 64)
|
bytesOut = common.RightPadBytes([]byte("hello"), 64)
|
||||||
buff.Write(bytesOut)
|
buff.Write(bytesOut)
|
||||||
|
|
||||||
err = abi.Unpack(&Bytes, "bytes", buff.Bytes())
|
err = abi.UnpackIntoInterface(&Bytes, "bytes", buff.Bytes())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
@@ -606,7 +621,7 @@ func TestUnmarshal(t *testing.T) {
|
|||||||
bytesOut = common.RightPadBytes([]byte("hello"), 64)
|
bytesOut = common.RightPadBytes([]byte("hello"), 64)
|
||||||
buff.Write(bytesOut)
|
buff.Write(bytesOut)
|
||||||
|
|
||||||
err = abi.Unpack(&Bytes, "bytes", buff.Bytes())
|
err = abi.UnpackIntoInterface(&Bytes, "bytes", buff.Bytes())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
@@ -616,7 +631,7 @@ func TestUnmarshal(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// marshal dynamic bytes output empty
|
// marshal dynamic bytes output empty
|
||||||
err = abi.Unpack(&Bytes, "bytes", nil)
|
err = abi.UnpackIntoInterface(&Bytes, "bytes", nil)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Error("expected error")
|
t.Error("expected error")
|
||||||
}
|
}
|
||||||
@@ -627,7 +642,7 @@ func TestUnmarshal(t *testing.T) {
|
|||||||
buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000005"))
|
buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000005"))
|
||||||
buff.Write(common.RightPadBytes([]byte("hello"), 32))
|
buff.Write(common.RightPadBytes([]byte("hello"), 32))
|
||||||
|
|
||||||
err = abi.Unpack(&Bytes, "bytes", buff.Bytes())
|
err = abi.UnpackIntoInterface(&Bytes, "bytes", buff.Bytes())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
@@ -641,7 +656,7 @@ func TestUnmarshal(t *testing.T) {
|
|||||||
buff.Write(common.RightPadBytes([]byte("hello"), 32))
|
buff.Write(common.RightPadBytes([]byte("hello"), 32))
|
||||||
|
|
||||||
var hash common.Hash
|
var hash common.Hash
|
||||||
err = abi.Unpack(&hash, "fixed", buff.Bytes())
|
err = abi.UnpackIntoInterface(&hash, "fixed", buff.Bytes())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
@@ -654,12 +669,12 @@ func TestUnmarshal(t *testing.T) {
|
|||||||
// marshal error
|
// marshal error
|
||||||
buff.Reset()
|
buff.Reset()
|
||||||
buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000020"))
|
buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000020"))
|
||||||
err = abi.Unpack(&Bytes, "bytes", buff.Bytes())
|
err = abi.UnpackIntoInterface(&Bytes, "bytes", buff.Bytes())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Error("expected error")
|
t.Error("expected error")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = abi.Unpack(&Bytes, "multi", make([]byte, 64))
|
err = abi.UnpackIntoInterface(&Bytes, "multi", make([]byte, 64))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Error("expected error")
|
t.Error("expected error")
|
||||||
}
|
}
|
||||||
@@ -670,7 +685,7 @@ func TestUnmarshal(t *testing.T) {
|
|||||||
buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000003"))
|
buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000003"))
|
||||||
// marshal int array
|
// marshal int array
|
||||||
var intArray [3]*big.Int
|
var intArray [3]*big.Int
|
||||||
err = abi.Unpack(&intArray, "intArraySingle", buff.Bytes())
|
err = abi.UnpackIntoInterface(&intArray, "intArraySingle", buff.Bytes())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
@@ -691,7 +706,7 @@ func TestUnmarshal(t *testing.T) {
|
|||||||
buff.Write(common.Hex2Bytes("0000000000000000000000000100000000000000000000000000000000000000"))
|
buff.Write(common.Hex2Bytes("0000000000000000000000000100000000000000000000000000000000000000"))
|
||||||
|
|
||||||
var outAddr []common.Address
|
var outAddr []common.Address
|
||||||
err = abi.Unpack(&outAddr, "addressSliceSingle", buff.Bytes())
|
err = abi.UnpackIntoInterface(&outAddr, "addressSliceSingle", buff.Bytes())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("didn't expect error:", err)
|
t.Fatal("didn't expect error:", err)
|
||||||
}
|
}
|
||||||
@@ -718,7 +733,7 @@ func TestUnmarshal(t *testing.T) {
|
|||||||
A []common.Address
|
A []common.Address
|
||||||
B []common.Address
|
B []common.Address
|
||||||
}
|
}
|
||||||
err = abi.Unpack(&outAddrStruct, "addressSliceDouble", buff.Bytes())
|
err = abi.UnpackIntoInterface(&outAddrStruct, "addressSliceDouble", buff.Bytes())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("didn't expect error:", err)
|
t.Fatal("didn't expect error:", err)
|
||||||
}
|
}
|
||||||
@@ -746,7 +761,7 @@ func TestUnmarshal(t *testing.T) {
|
|||||||
buff.Reset()
|
buff.Reset()
|
||||||
buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000100"))
|
buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000100"))
|
||||||
|
|
||||||
err = abi.Unpack(&outAddr, "addressSliceSingle", buff.Bytes())
|
err = abi.UnpackIntoInterface(&outAddr, "addressSliceSingle", buff.Bytes())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatal("expected error:", err)
|
t.Fatal("expected error:", err)
|
||||||
}
|
}
|
||||||
@@ -764,20 +779,24 @@ func TestUnpackTuple(t *testing.T) {
|
|||||||
buff.Write(common.Hex2Bytes("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) // ret[b] = -1
|
buff.Write(common.Hex2Bytes("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) // ret[b] = -1
|
||||||
|
|
||||||
// If the result is single tuple, use struct as return value container directly.
|
// If the result is single tuple, use struct as return value container directly.
|
||||||
v := struct {
|
type v struct {
|
||||||
A *big.Int
|
A *big.Int
|
||||||
B *big.Int
|
B *big.Int
|
||||||
}{new(big.Int), new(big.Int)}
|
}
|
||||||
|
type r struct {
|
||||||
|
Result v
|
||||||
|
}
|
||||||
|
var ret0 = new(r)
|
||||||
|
err = abi.UnpackIntoInterface(ret0, "tuple", buff.Bytes())
|
||||||
|
|
||||||
err = abi.Unpack(&v, "tuple", buff.Bytes())
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
} else {
|
} else {
|
||||||
if v.A.Cmp(big.NewInt(1)) != 0 {
|
if ret0.Result.A.Cmp(big.NewInt(1)) != 0 {
|
||||||
t.Errorf("unexpected value unpacked: want %x, got %x", 1, v.A)
|
t.Errorf("unexpected value unpacked: want %x, got %x", 1, ret0.Result.A)
|
||||||
}
|
}
|
||||||
if v.B.Cmp(big.NewInt(-1)) != 0 {
|
if ret0.Result.B.Cmp(big.NewInt(-1)) != 0 {
|
||||||
t.Errorf("unexpected value unpacked: want %x, got %x", -1, v.B)
|
t.Errorf("unexpected value unpacked: want %x, got %x", -1, ret0.Result.B)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -841,7 +860,7 @@ func TestUnpackTuple(t *testing.T) {
|
|||||||
A: big.NewInt(1),
|
A: big.NewInt(1),
|
||||||
}
|
}
|
||||||
|
|
||||||
err = abi.Unpack(&ret, "tuple", buff.Bytes())
|
err = abi.UnpackIntoInterface(&ret, "tuple", buff.Bytes())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|||||||
41
accounts/abi/utils.go
Normal file
41
accounts/abi/utils.go
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
// Copyright 2022 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package abi
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
// ResolveNameConflict returns the next available name for a given thing.
|
||||||
|
// This helper can be used for lots of purposes:
|
||||||
|
//
|
||||||
|
// - In solidity function overloading is supported, this function can fix
|
||||||
|
// the name conflicts of overloaded functions.
|
||||||
|
// - In golang binding generation, the parameter(in function, event, error,
|
||||||
|
// and struct definition) name will be converted to camelcase style which
|
||||||
|
// may eventually lead to name conflicts.
|
||||||
|
//
|
||||||
|
// Name conflicts are mostly resolved by adding number suffix.
|
||||||
|
// e.g. if the abi contains Methods send, send1
|
||||||
|
// ResolveNameConflict would return send2 for input send.
|
||||||
|
func ResolveNameConflict(rawName string, used func(string) bool) string {
|
||||||
|
name := rawName
|
||||||
|
ok := used(name)
|
||||||
|
for idx := 0; ok; idx++ {
|
||||||
|
name = fmt.Sprintf("%s%d", rawName, idx)
|
||||||
|
ok = used(name)
|
||||||
|
}
|
||||||
|
return name
|
||||||
|
}
|
||||||
@@ -21,7 +21,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
ethereum "github.com/ethereum/go-ethereum"
|
"github.com/ethereum/go-ethereum"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/event"
|
"github.com/ethereum/go-ethereum/event"
|
||||||
@@ -46,7 +46,7 @@ const (
|
|||||||
// accounts (derived from the same seed).
|
// accounts (derived from the same seed).
|
||||||
type Wallet interface {
|
type Wallet interface {
|
||||||
// URL retrieves the canonical path under which this wallet is reachable. It is
|
// URL retrieves the canonical path under which this wallet is reachable. It is
|
||||||
// user by upper layers to define a sorting order over all wallets from multiple
|
// used by upper layers to define a sorting order over all wallets from multiple
|
||||||
// backends.
|
// backends.
|
||||||
URL() URL
|
URL() URL
|
||||||
|
|
||||||
@@ -88,8 +88,8 @@ type Wallet interface {
|
|||||||
// to discover non zero accounts and automatically add them to list of tracked
|
// to discover non zero accounts and automatically add them to list of tracked
|
||||||
// accounts.
|
// accounts.
|
||||||
//
|
//
|
||||||
// Note, self derivaton will increment the last component of the specified path
|
// Note, self derivation will increment the last component of the specified path
|
||||||
// opposed to decending into a child path to allow discovering accounts starting
|
// opposed to descending into a child path to allow discovering accounts starting
|
||||||
// from non zero components.
|
// from non zero components.
|
||||||
//
|
//
|
||||||
// Some hardware wallets switched derivation paths through their evolution, so
|
// Some hardware wallets switched derivation paths through their evolution, so
|
||||||
@@ -105,7 +105,7 @@ type Wallet interface {
|
|||||||
// or optionally with the aid of any location metadata from the embedded URL field.
|
// or optionally with the aid of any location metadata from the embedded URL field.
|
||||||
//
|
//
|
||||||
// If the wallet requires additional authentication to sign the request (e.g.
|
// If the wallet requires additional authentication to sign the request (e.g.
|
||||||
// a password to decrypt the account, or a PIN code o verify the transaction),
|
// a password to decrypt the account, or a PIN code to verify the transaction),
|
||||||
// an AuthNeededError instance will be returned, containing infos for the user
|
// an AuthNeededError instance will be returned, containing infos for the user
|
||||||
// about which fields or actions are needed. The user may retry by providing
|
// about which fields or actions are needed. The user may retry by providing
|
||||||
// the needed details via SignDataWithPassphrase, or by other means (e.g. unlock
|
// the needed details via SignDataWithPassphrase, or by other means (e.g. unlock
|
||||||
@@ -113,7 +113,7 @@ type Wallet interface {
|
|||||||
SignData(account Account, mimeType string, data []byte) ([]byte, error)
|
SignData(account Account, mimeType string, data []byte) ([]byte, error)
|
||||||
|
|
||||||
// SignDataWithPassphrase is identical to SignData, but also takes a password
|
// SignDataWithPassphrase is identical to SignData, but also takes a password
|
||||||
// NOTE: there's an chance that an erroneous call might mistake the two strings, and
|
// NOTE: there's a chance that an erroneous call might mistake the two strings, and
|
||||||
// supply password in the mimetype field, or vice versa. Thus, an implementation
|
// supply password in the mimetype field, or vice versa. Thus, an implementation
|
||||||
// should never echo the mimetype or return the mimetype in the error-response
|
// should never echo the mimetype or return the mimetype in the error-response
|
||||||
SignDataWithPassphrase(account Account, passphrase, mimeType string, data []byte) ([]byte, error)
|
SignDataWithPassphrase(account Account, passphrase, mimeType string, data []byte) ([]byte, error)
|
||||||
@@ -124,13 +124,13 @@ type Wallet interface {
|
|||||||
// or optionally with the aid of any location metadata from the embedded URL field.
|
// or optionally with the aid of any location metadata from the embedded URL field.
|
||||||
//
|
//
|
||||||
// If the wallet requires additional authentication to sign the request (e.g.
|
// If the wallet requires additional authentication to sign the request (e.g.
|
||||||
// a password to decrypt the account, or a PIN code o verify the transaction),
|
// a password to decrypt the account, or a PIN code to verify the transaction),
|
||||||
// an AuthNeededError instance will be returned, containing infos for the user
|
// an AuthNeededError instance will be returned, containing infos for the user
|
||||||
// about which fields or actions are needed. The user may retry by providing
|
// about which fields or actions are needed. The user may retry by providing
|
||||||
// the needed details via SignHashWithPassphrase, or by other means (e.g. unlock
|
// the needed details via SignTextWithPassphrase, or by other means (e.g. unlock
|
||||||
// the account in a keystore).
|
// the account in a keystore).
|
||||||
//
|
//
|
||||||
// This method should return the signature in 'canonical' format, with v 0 or 1
|
// This method should return the signature in 'canonical' format, with v 0 or 1.
|
||||||
SignText(account Account, text []byte) ([]byte, error)
|
SignText(account Account, text []byte) ([]byte, error)
|
||||||
|
|
||||||
// SignTextWithPassphrase is identical to Signtext, but also takes a password
|
// SignTextWithPassphrase is identical to Signtext, but also takes a password
|
||||||
@@ -176,7 +176,7 @@ type Backend interface {
|
|||||||
// TextHash is a helper function that calculates a hash for the given message that can be
|
// TextHash is a helper function that calculates a hash for the given message that can be
|
||||||
// safely used to calculate a signature from.
|
// safely used to calculate a signature from.
|
||||||
//
|
//
|
||||||
// The hash is calulcated as
|
// The hash is calculated as
|
||||||
// keccak256("\x19Ethereum Signed Message:\n"${message length}${message}).
|
// keccak256("\x19Ethereum Signed Message:\n"${message length}${message}).
|
||||||
//
|
//
|
||||||
// This gives context to the signed message and prevents signing of transactions.
|
// This gives context to the signed message and prevents signing of transactions.
|
||||||
@@ -188,7 +188,7 @@ func TextHash(data []byte) []byte {
|
|||||||
// TextAndHash is a helper function that calculates a hash for the given message that can be
|
// TextAndHash is a helper function that calculates a hash for the given message that can be
|
||||||
// safely used to calculate a signature from.
|
// safely used to calculate a signature from.
|
||||||
//
|
//
|
||||||
// The hash is calulcated as
|
// The hash is calculated as
|
||||||
// keccak256("\x19Ethereum Signed Message:\n"${message length}${message}).
|
// keccak256("\x19Ethereum Signed Message:\n"${message length}${message}).
|
||||||
//
|
//
|
||||||
// This gives context to the signed message and prevents signing of transactions.
|
// This gives context to the signed message and prevents signing of transactions.
|
||||||
|
|||||||
@@ -41,8 +41,7 @@ var ErrInvalidPassphrase = errors.New("invalid password")
|
|||||||
// second time.
|
// second time.
|
||||||
var ErrWalletAlreadyOpen = errors.New("wallet already open")
|
var ErrWalletAlreadyOpen = errors.New("wallet already open")
|
||||||
|
|
||||||
// ErrWalletClosed is returned if a wallet is attempted to be opened the
|
// ErrWalletClosed is returned if a wallet is offline.
|
||||||
// secodn time.
|
|
||||||
var ErrWalletClosed = errors.New("wallet closed")
|
var ErrWalletClosed = errors.New("wallet closed")
|
||||||
|
|
||||||
// AuthNeededError is returned by backends for signing requests where the user
|
// AuthNeededError is returned by backends for signing requests where the user
|
||||||
|
|||||||
48
accounts/external/backend.go
vendored
48
accounts/external/backend.go
vendored
@@ -29,7 +29,7 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/event"
|
"github.com/ethereum/go-ethereum/event"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
"github.com/ethereum/go-ethereum/signer/core"
|
"github.com/ethereum/go-ethereum/signer/core/apitypes"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ExternalBackend struct {
|
type ExternalBackend struct {
|
||||||
@@ -152,10 +152,6 @@ func (api *ExternalSigner) SelfDerive(bases []accounts.DerivationPath, chain eth
|
|||||||
log.Error("operation SelfDerive not supported on external signers")
|
log.Error("operation SelfDerive not supported on external signers")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *ExternalSigner) signHash(account accounts.Account, hash []byte) ([]byte, error) {
|
|
||||||
return []byte{}, fmt.Errorf("operation not supported on external signers")
|
|
||||||
}
|
|
||||||
|
|
||||||
// SignData signs keccak256(data). The mimetype parameter describes the type of data being signed
|
// SignData signs keccak256(data). The mimetype parameter describes the type of data being signed
|
||||||
func (api *ExternalSigner) SignData(account accounts.Account, mimeType string, data []byte) ([]byte, error) {
|
func (api *ExternalSigner) SignData(account accounts.Account, mimeType string, data []byte) ([]byte, error) {
|
||||||
var res hexutil.Bytes
|
var res hexutil.Bytes
|
||||||
@@ -196,6 +192,10 @@ type signTransactionResult struct {
|
|||||||
Tx *types.Transaction `json:"tx"`
|
Tx *types.Transaction `json:"tx"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SignTx sends the transaction to the external signer.
|
||||||
|
// If chainID is nil, or tx.ChainID is zero, the chain ID will be assigned
|
||||||
|
// by the external signer. For non-legacy transactions, the chain ID of the
|
||||||
|
// transaction overrides the chainID parameter.
|
||||||
func (api *ExternalSigner) SignTx(account accounts.Account, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error) {
|
func (api *ExternalSigner) SignTx(account accounts.Account, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error) {
|
||||||
data := hexutil.Bytes(tx.Data())
|
data := hexutil.Bytes(tx.Data())
|
||||||
var to *common.MixedcaseAddress
|
var to *common.MixedcaseAddress
|
||||||
@@ -203,14 +203,36 @@ func (api *ExternalSigner) SignTx(account accounts.Account, tx *types.Transactio
|
|||||||
t := common.NewMixedcaseAddress(*tx.To())
|
t := common.NewMixedcaseAddress(*tx.To())
|
||||||
to = &t
|
to = &t
|
||||||
}
|
}
|
||||||
args := &core.SendTxArgs{
|
args := &apitypes.SendTxArgs{
|
||||||
Data: &data,
|
Data: &data,
|
||||||
Nonce: hexutil.Uint64(tx.Nonce()),
|
Nonce: hexutil.Uint64(tx.Nonce()),
|
||||||
Value: hexutil.Big(*tx.Value()),
|
Value: hexutil.Big(*tx.Value()),
|
||||||
Gas: hexutil.Uint64(tx.Gas()),
|
Gas: hexutil.Uint64(tx.Gas()),
|
||||||
GasPrice: hexutil.Big(*tx.GasPrice()),
|
To: to,
|
||||||
To: to,
|
From: common.NewMixedcaseAddress(account.Address),
|
||||||
From: common.NewMixedcaseAddress(account.Address),
|
}
|
||||||
|
switch tx.Type() {
|
||||||
|
case types.LegacyTxType, types.AccessListTxType:
|
||||||
|
args.GasPrice = (*hexutil.Big)(tx.GasPrice())
|
||||||
|
case types.DynamicFeeTxType:
|
||||||
|
args.MaxFeePerGas = (*hexutil.Big)(tx.GasFeeCap())
|
||||||
|
args.MaxPriorityFeePerGas = (*hexutil.Big)(tx.GasTipCap())
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("unsupported tx type %d", tx.Type())
|
||||||
|
}
|
||||||
|
// We should request the default chain id that we're operating with
|
||||||
|
// (the chain we're executing on)
|
||||||
|
if chainID != nil && chainID.Sign() != 0 {
|
||||||
|
args.ChainID = (*hexutil.Big)(chainID)
|
||||||
|
}
|
||||||
|
if tx.Type() != types.LegacyTxType {
|
||||||
|
// However, if the user asked for a particular chain id, then we should
|
||||||
|
// use that instead.
|
||||||
|
if tx.ChainId().Sign() != 0 {
|
||||||
|
args.ChainID = (*hexutil.Big)(tx.ChainId())
|
||||||
|
}
|
||||||
|
accessList := tx.AccessList()
|
||||||
|
args.AccessList = &accessList
|
||||||
}
|
}
|
||||||
var res signTransactionResult
|
var res signTransactionResult
|
||||||
if err := api.client.Call(&res, "account_signTransaction", args); err != nil {
|
if err := api.client.Call(&res, "account_signTransaction", args); err != nil {
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ var DefaultBaseDerivationPath = DerivationPath{0x80000000 + 44, 0x80000000 + 60,
|
|||||||
var LegacyLedgerBaseDerivationPath = DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 0}
|
var LegacyLedgerBaseDerivationPath = DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 0}
|
||||||
|
|
||||||
// DerivationPath represents the computer friendly version of a hierarchical
|
// DerivationPath represents the computer friendly version of a hierarchical
|
||||||
// deterministic wallet account derivaion path.
|
// deterministic wallet account derivation path.
|
||||||
//
|
//
|
||||||
// The BIP-32 spec https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki
|
// The BIP-32 spec https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki
|
||||||
// defines derivation paths to be of the form:
|
// defines derivation paths to be of the form:
|
||||||
@@ -150,3 +150,31 @@ func (path *DerivationPath) UnmarshalJSON(b []byte) error {
|
|||||||
*path, err = ParseDerivationPath(dp)
|
*path, err = ParseDerivationPath(dp)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DefaultIterator creates a BIP-32 path iterator, which progresses by increasing the last component:
|
||||||
|
// i.e. m/44'/60'/0'/0/0, m/44'/60'/0'/0/1, m/44'/60'/0'/0/2, ... m/44'/60'/0'/0/N.
|
||||||
|
func DefaultIterator(base DerivationPath) func() DerivationPath {
|
||||||
|
path := make(DerivationPath, len(base))
|
||||||
|
copy(path[:], base[:])
|
||||||
|
// Set it back by one, so the first call gives the first result
|
||||||
|
path[len(path)-1]--
|
||||||
|
return func() DerivationPath {
|
||||||
|
path[len(path)-1]++
|
||||||
|
return path
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// LedgerLiveIterator creates a bip44 path iterator for Ledger Live.
|
||||||
|
// Ledger Live increments the third component rather than the fifth component
|
||||||
|
// i.e. m/44'/60'/0'/0/0, m/44'/60'/1'/0/0, m/44'/60'/2'/0/0, ... m/44'/60'/N'/0/0.
|
||||||
|
func LedgerLiveIterator(base DerivationPath) func() DerivationPath {
|
||||||
|
path := make(DerivationPath, len(base))
|
||||||
|
copy(path[:], base[:])
|
||||||
|
// Set it back by one, so the first call gives the first result
|
||||||
|
path[2]--
|
||||||
|
return func() DerivationPath {
|
||||||
|
// ledgerLivePathIterator iterates on the third component
|
||||||
|
path[2]++
|
||||||
|
return path
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package accounts
|
package accounts
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
@@ -77,3 +78,41 @@ func TestHDPathParsing(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testDerive(t *testing.T, next func() DerivationPath, expected []string) {
|
||||||
|
t.Helper()
|
||||||
|
for i, want := range expected {
|
||||||
|
if have := next(); fmt.Sprintf("%v", have) != want {
|
||||||
|
t.Errorf("step %d, have %v, want %v", i, have, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestHdPathIteration(t *testing.T) {
|
||||||
|
testDerive(t, DefaultIterator(DefaultBaseDerivationPath),
|
||||||
|
[]string{
|
||||||
|
"m/44'/60'/0'/0/0", "m/44'/60'/0'/0/1",
|
||||||
|
"m/44'/60'/0'/0/2", "m/44'/60'/0'/0/3",
|
||||||
|
"m/44'/60'/0'/0/4", "m/44'/60'/0'/0/5",
|
||||||
|
"m/44'/60'/0'/0/6", "m/44'/60'/0'/0/7",
|
||||||
|
"m/44'/60'/0'/0/8", "m/44'/60'/0'/0/9",
|
||||||
|
})
|
||||||
|
|
||||||
|
testDerive(t, DefaultIterator(LegacyLedgerBaseDerivationPath),
|
||||||
|
[]string{
|
||||||
|
"m/44'/60'/0'/0", "m/44'/60'/0'/1",
|
||||||
|
"m/44'/60'/0'/2", "m/44'/60'/0'/3",
|
||||||
|
"m/44'/60'/0'/4", "m/44'/60'/0'/5",
|
||||||
|
"m/44'/60'/0'/6", "m/44'/60'/0'/7",
|
||||||
|
"m/44'/60'/0'/8", "m/44'/60'/0'/9",
|
||||||
|
})
|
||||||
|
|
||||||
|
testDerive(t, LedgerLiveIterator(DefaultBaseDerivationPath),
|
||||||
|
[]string{
|
||||||
|
"m/44'/60'/0'/0/0", "m/44'/60'/1'/0/0",
|
||||||
|
"m/44'/60'/2'/0/0", "m/44'/60'/3'/0/0",
|
||||||
|
"m/44'/60'/4'/0/0", "m/44'/60'/5'/0/0",
|
||||||
|
"m/44'/60'/6'/0/0", "m/44'/60'/7'/0/0",
|
||||||
|
"m/44'/60'/8'/0/0", "m/44'/60'/9'/0/0",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ func (ac *accountCache) scanAccounts() error {
|
|||||||
switch {
|
switch {
|
||||||
case err != nil:
|
case err != nil:
|
||||||
log.Debug("Failed to decode keystore key", "path", path, "err", err)
|
log.Debug("Failed to decode keystore key", "path", path, "err", err)
|
||||||
case (addr == common.Address{}):
|
case addr == common.Address{}:
|
||||||
log.Debug("Failed to decode keystore key", "path", path, "err", "missing or zero address")
|
log.Debug("Failed to decode keystore key", "path", path, "err", "missing or zero address")
|
||||||
default:
|
default:
|
||||||
return &accounts.Account{
|
return &accounts.Account{
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ package keystore
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -55,7 +54,6 @@ func TestWatchNewFile(t *testing.T) {
|
|||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
dir, ks := tmpKeyStore(t, false)
|
dir, ks := tmpKeyStore(t, false)
|
||||||
defer os.RemoveAll(dir)
|
|
||||||
|
|
||||||
// Ensure the watcher is started before adding any files.
|
// Ensure the watcher is started before adding any files.
|
||||||
ks.Accounts()
|
ks.Accounts()
|
||||||
@@ -96,7 +94,7 @@ func TestWatchNoDir(t *testing.T) {
|
|||||||
|
|
||||||
// Create ks but not the directory that it watches.
|
// Create ks but not the directory that it watches.
|
||||||
rand.Seed(time.Now().UnixNano())
|
rand.Seed(time.Now().UnixNano())
|
||||||
dir := filepath.Join(os.TempDir(), fmt.Sprintf("eth-keystore-watch-test-%d-%d", os.Getpid(), rand.Int()))
|
dir := filepath.Join(os.TempDir(), fmt.Sprintf("eth-keystore-watchnodir-test-%d-%d", os.Getpid(), rand.Int()))
|
||||||
ks := NewKeyStore(dir, LightScryptN, LightScryptP)
|
ks := NewKeyStore(dir, LightScryptN, LightScryptP)
|
||||||
|
|
||||||
list := ks.Accounts()
|
list := ks.Accounts()
|
||||||
@@ -322,7 +320,7 @@ func TestUpdatedKeyfileContents(t *testing.T) {
|
|||||||
|
|
||||||
// Create a temporary kesytore to test with
|
// Create a temporary kesytore to test with
|
||||||
rand.Seed(time.Now().UnixNano())
|
rand.Seed(time.Now().UnixNano())
|
||||||
dir := filepath.Join(os.TempDir(), fmt.Sprintf("eth-keystore-watch-test-%d-%d", os.Getpid(), rand.Int()))
|
dir := filepath.Join(os.TempDir(), fmt.Sprintf("eth-keystore-updatedkeyfilecontents-test-%d-%d", os.Getpid(), rand.Int()))
|
||||||
ks := NewKeyStore(dir, LightScryptN, LightScryptP)
|
ks := NewKeyStore(dir, LightScryptN, LightScryptP)
|
||||||
|
|
||||||
list := ks.Accounts()
|
list := ks.Accounts()
|
||||||
@@ -381,11 +379,11 @@ func TestUpdatedKeyfileContents(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// needed so that modTime of `file` is different to its current value after ioutil.WriteFile
|
// needed so that modTime of `file` is different to its current value after os.WriteFile
|
||||||
time.Sleep(1000 * time.Millisecond)
|
time.Sleep(1000 * time.Millisecond)
|
||||||
|
|
||||||
// Now replace file contents with crap
|
// Now replace file contents with crap
|
||||||
if err := ioutil.WriteFile(file, []byte("foo"), 0644); err != nil {
|
if err := os.WriteFile(file, []byte("foo"), 0600); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -398,9 +396,9 @@ func TestUpdatedKeyfileContents(t *testing.T) {
|
|||||||
|
|
||||||
// forceCopyFile is like cp.CopyFile, but doesn't complain if the destination exists.
|
// forceCopyFile is like cp.CopyFile, but doesn't complain if the destination exists.
|
||||||
func forceCopyFile(dst, src string) error {
|
func forceCopyFile(dst, src string) error {
|
||||||
data, err := ioutil.ReadFile(src)
|
data, err := os.ReadFile(src)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return ioutil.WriteFile(dst, data, 0644)
|
return os.WriteFile(dst, data, 0644)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
package keystore
|
package keystore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -32,7 +31,7 @@ import (
|
|||||||
type fileCache struct {
|
type fileCache struct {
|
||||||
all mapset.Set // Set of all files from the keystore folder
|
all mapset.Set // Set of all files from the keystore folder
|
||||||
lastMod time.Time // Last time instance when a file was modified
|
lastMod time.Time // Last time instance when a file was modified
|
||||||
mu sync.RWMutex
|
mu sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
// scan performs a new scan on the given directory, compares against the already
|
// scan performs a new scan on the given directory, compares against the already
|
||||||
@@ -41,7 +40,7 @@ func (fc *fileCache) scan(keyDir string) (mapset.Set, mapset.Set, mapset.Set, er
|
|||||||
t0 := time.Now()
|
t0 := time.Now()
|
||||||
|
|
||||||
// List all the failes from the keystore folder
|
// List all the failes from the keystore folder
|
||||||
files, err := ioutil.ReadDir(keyDir)
|
files, err := os.ReadDir(keyDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
}
|
}
|
||||||
@@ -65,7 +64,11 @@ func (fc *fileCache) scan(keyDir string) (mapset.Set, mapset.Set, mapset.Set, er
|
|||||||
// Gather the set of all and fresly modified files
|
// Gather the set of all and fresly modified files
|
||||||
all.Add(path)
|
all.Add(path)
|
||||||
|
|
||||||
modified := fi.ModTime()
|
info, err := fi.Info()
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, nil, err
|
||||||
|
}
|
||||||
|
modified := info.ModTime()
|
||||||
if modified.After(fc.lastMod) {
|
if modified.After(fc.lastMod) {
|
||||||
mods.Add(path)
|
mods.Add(path)
|
||||||
}
|
}
|
||||||
@@ -89,13 +92,13 @@ func (fc *fileCache) scan(keyDir string) (mapset.Set, mapset.Set, mapset.Set, er
|
|||||||
}
|
}
|
||||||
|
|
||||||
// nonKeyFile ignores editor backups, hidden files and folders/symlinks.
|
// nonKeyFile ignores editor backups, hidden files and folders/symlinks.
|
||||||
func nonKeyFile(fi os.FileInfo) bool {
|
func nonKeyFile(fi os.DirEntry) bool {
|
||||||
// Skip editor backups and UNIX-style hidden files.
|
// Skip editor backups and UNIX-style hidden files.
|
||||||
if strings.HasSuffix(fi.Name(), "~") || strings.HasPrefix(fi.Name(), ".") {
|
if strings.HasSuffix(fi.Name(), "~") || strings.HasPrefix(fi.Name(), ".") {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// Skip misc special files, directories (yes, symlinks too).
|
// Skip misc special files, directories (yes, symlinks too).
|
||||||
if fi.IsDir() || fi.Mode()&os.ModeType != 0 {
|
if fi.IsDir() || !fi.Type().IsRegular() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -32,7 +31,7 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/accounts"
|
"github.com/ethereum/go-ethereum/accounts"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/pborman/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -110,7 +109,10 @@ func (k *Key) UnmarshalJSON(j []byte) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
u := new(uuid.UUID)
|
u := new(uuid.UUID)
|
||||||
*u = uuid.Parse(keyJSON.Id)
|
*u, err = uuid.Parse(keyJSON.Id)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
k.Id = *u
|
k.Id = *u
|
||||||
addr, err := hex.DecodeString(keyJSON.Address)
|
addr, err := hex.DecodeString(keyJSON.Address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -128,7 +130,10 @@ func (k *Key) UnmarshalJSON(j []byte) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newKeyFromECDSA(privateKeyECDSA *ecdsa.PrivateKey) *Key {
|
func newKeyFromECDSA(privateKeyECDSA *ecdsa.PrivateKey) *Key {
|
||||||
id := uuid.NewRandom()
|
id, err := uuid.NewRandom()
|
||||||
|
if err != nil {
|
||||||
|
panic(fmt.Sprintf("Could not create random uuid: %v", err))
|
||||||
|
}
|
||||||
key := &Key{
|
key := &Key{
|
||||||
Id: id,
|
Id: id,
|
||||||
Address: crypto.PubkeyToAddress(privateKeyECDSA.PublicKey),
|
Address: crypto.PubkeyToAddress(privateKeyECDSA.PublicKey),
|
||||||
@@ -191,7 +196,7 @@ func writeTemporaryKeyFile(file string, content []byte) (string, error) {
|
|||||||
}
|
}
|
||||||
// Atomic write: create a temporary hidden file first
|
// Atomic write: create a temporary hidden file first
|
||||||
// then move it into place. TempFile assigns mode 0600.
|
// then move it into place. TempFile assigns mode 0600.
|
||||||
f, err := ioutil.TempFile(filepath.Dir(file), "."+filepath.Base(file)+".tmp")
|
f, err := os.CreateTemp(filepath.Dir(file), "."+filepath.Base(file)+".tmp")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -283,11 +283,9 @@ func (ks *KeyStore) SignTx(a accounts.Account, tx *types.Transaction, chainID *b
|
|||||||
if !found {
|
if !found {
|
||||||
return nil, ErrLocked
|
return nil, ErrLocked
|
||||||
}
|
}
|
||||||
// Depending on the presence of the chain ID, sign with EIP155 or homestead
|
// Depending on the presence of the chain ID, sign with 2718 or homestead
|
||||||
if chainID != nil {
|
signer := types.LatestSignerForChainID(chainID)
|
||||||
return types.SignTx(tx, types.NewEIP155Signer(chainID), unlockedKey.PrivateKey)
|
return types.SignTx(tx, signer, unlockedKey.PrivateKey)
|
||||||
}
|
|
||||||
return types.SignTx(tx, types.HomesteadSigner{}, unlockedKey.PrivateKey)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SignHashWithPassphrase signs hash if the private key matching the given address
|
// SignHashWithPassphrase signs hash if the private key matching the given address
|
||||||
@@ -310,12 +308,9 @@ func (ks *KeyStore) SignTxWithPassphrase(a accounts.Account, passphrase string,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer zeroKey(key.PrivateKey)
|
defer zeroKey(key.PrivateKey)
|
||||||
|
// Depending on the presence of the chain ID, sign with or without replay protection.
|
||||||
// Depending on the presence of the chain ID, sign with EIP155 or homestead
|
signer := types.LatestSignerForChainID(chainID)
|
||||||
if chainID != nil {
|
return types.SignTx(tx, signer, key.PrivateKey)
|
||||||
return types.SignTx(tx, types.NewEIP155Signer(chainID), key.PrivateKey)
|
|
||||||
}
|
|
||||||
return types.SignTx(tx, types.HomesteadSigner{}, key.PrivateKey)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unlock unlocks the given account indefinitely.
|
// Unlock unlocks the given account indefinitely.
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
package keystore
|
package keystore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
@@ -38,7 +37,6 @@ var testSigData = make([]byte, 32)
|
|||||||
|
|
||||||
func TestKeyStore(t *testing.T) {
|
func TestKeyStore(t *testing.T) {
|
||||||
dir, ks := tmpKeyStore(t, true)
|
dir, ks := tmpKeyStore(t, true)
|
||||||
defer os.RemoveAll(dir)
|
|
||||||
|
|
||||||
a, err := ks.NewAccount("foo")
|
a, err := ks.NewAccount("foo")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -72,8 +70,7 @@ func TestKeyStore(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSign(t *testing.T) {
|
func TestSign(t *testing.T) {
|
||||||
dir, ks := tmpKeyStore(t, true)
|
_, ks := tmpKeyStore(t, true)
|
||||||
defer os.RemoveAll(dir)
|
|
||||||
|
|
||||||
pass := "" // not used but required by API
|
pass := "" // not used but required by API
|
||||||
a1, err := ks.NewAccount(pass)
|
a1, err := ks.NewAccount(pass)
|
||||||
@@ -89,8 +86,7 @@ func TestSign(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSignWithPassphrase(t *testing.T) {
|
func TestSignWithPassphrase(t *testing.T) {
|
||||||
dir, ks := tmpKeyStore(t, true)
|
_, ks := tmpKeyStore(t, true)
|
||||||
defer os.RemoveAll(dir)
|
|
||||||
|
|
||||||
pass := "passwd"
|
pass := "passwd"
|
||||||
acc, err := ks.NewAccount(pass)
|
acc, err := ks.NewAccount(pass)
|
||||||
@@ -117,8 +113,7 @@ func TestSignWithPassphrase(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestTimedUnlock(t *testing.T) {
|
func TestTimedUnlock(t *testing.T) {
|
||||||
dir, ks := tmpKeyStore(t, true)
|
_, ks := tmpKeyStore(t, true)
|
||||||
defer os.RemoveAll(dir)
|
|
||||||
|
|
||||||
pass := "foo"
|
pass := "foo"
|
||||||
a1, err := ks.NewAccount(pass)
|
a1, err := ks.NewAccount(pass)
|
||||||
@@ -152,8 +147,7 @@ func TestTimedUnlock(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestOverrideUnlock(t *testing.T) {
|
func TestOverrideUnlock(t *testing.T) {
|
||||||
dir, ks := tmpKeyStore(t, false)
|
_, ks := tmpKeyStore(t, false)
|
||||||
defer os.RemoveAll(dir)
|
|
||||||
|
|
||||||
pass := "foo"
|
pass := "foo"
|
||||||
a1, err := ks.NewAccount(pass)
|
a1, err := ks.NewAccount(pass)
|
||||||
@@ -193,8 +187,7 @@ func TestOverrideUnlock(t *testing.T) {
|
|||||||
|
|
||||||
// This test should fail under -race if signing races the expiration goroutine.
|
// This test should fail under -race if signing races the expiration goroutine.
|
||||||
func TestSignRace(t *testing.T) {
|
func TestSignRace(t *testing.T) {
|
||||||
dir, ks := tmpKeyStore(t, false)
|
_, ks := tmpKeyStore(t, false)
|
||||||
defer os.RemoveAll(dir)
|
|
||||||
|
|
||||||
// Create a test account.
|
// Create a test account.
|
||||||
a1, err := ks.NewAccount("")
|
a1, err := ks.NewAccount("")
|
||||||
@@ -222,8 +215,7 @@ func TestSignRace(t *testing.T) {
|
|||||||
// addition and removal of wallet event subscriptions.
|
// addition and removal of wallet event subscriptions.
|
||||||
func TestWalletNotifierLifecycle(t *testing.T) {
|
func TestWalletNotifierLifecycle(t *testing.T) {
|
||||||
// Create a temporary kesytore to test with
|
// Create a temporary kesytore to test with
|
||||||
dir, ks := tmpKeyStore(t, false)
|
_, ks := tmpKeyStore(t, false)
|
||||||
defer os.RemoveAll(dir)
|
|
||||||
|
|
||||||
// Ensure that the notification updater is not running yet
|
// Ensure that the notification updater is not running yet
|
||||||
time.Sleep(250 * time.Millisecond)
|
time.Sleep(250 * time.Millisecond)
|
||||||
@@ -283,8 +275,7 @@ type walletEvent struct {
|
|||||||
// Tests that wallet notifications and correctly fired when accounts are added
|
// Tests that wallet notifications and correctly fired when accounts are added
|
||||||
// or deleted from the keystore.
|
// or deleted from the keystore.
|
||||||
func TestWalletNotifications(t *testing.T) {
|
func TestWalletNotifications(t *testing.T) {
|
||||||
dir, ks := tmpKeyStore(t, false)
|
_, ks := tmpKeyStore(t, false)
|
||||||
defer os.RemoveAll(dir)
|
|
||||||
|
|
||||||
// Subscribe to the wallet feed and collect events.
|
// Subscribe to the wallet feed and collect events.
|
||||||
var (
|
var (
|
||||||
@@ -336,15 +327,16 @@ func TestWalletNotifications(t *testing.T) {
|
|||||||
|
|
||||||
// Shut down the event collector and check events.
|
// Shut down the event collector and check events.
|
||||||
sub.Unsubscribe()
|
sub.Unsubscribe()
|
||||||
<-updates
|
for ev := range updates {
|
||||||
|
events = append(events, walletEvent{ev, ev.Wallet.Accounts()[0]})
|
||||||
|
}
|
||||||
checkAccounts(t, live, ks.Wallets())
|
checkAccounts(t, live, ks.Wallets())
|
||||||
checkEvents(t, wantEvents, events)
|
checkEvents(t, wantEvents, events)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestImportExport tests the import functionality of a keystore.
|
// TestImportExport tests the import functionality of a keystore.
|
||||||
func TestImportECDSA(t *testing.T) {
|
func TestImportECDSA(t *testing.T) {
|
||||||
dir, ks := tmpKeyStore(t, true)
|
_, ks := tmpKeyStore(t, true)
|
||||||
defer os.RemoveAll(dir)
|
|
||||||
key, err := crypto.GenerateKey()
|
key, err := crypto.GenerateKey()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to generate key: %v", key)
|
t.Fatalf("failed to generate key: %v", key)
|
||||||
@@ -362,8 +354,7 @@ func TestImportECDSA(t *testing.T) {
|
|||||||
|
|
||||||
// TestImportECDSA tests the import and export functionality of a keystore.
|
// TestImportECDSA tests the import and export functionality of a keystore.
|
||||||
func TestImportExport(t *testing.T) {
|
func TestImportExport(t *testing.T) {
|
||||||
dir, ks := tmpKeyStore(t, true)
|
_, ks := tmpKeyStore(t, true)
|
||||||
defer os.RemoveAll(dir)
|
|
||||||
acc, err := ks.NewAccount("old")
|
acc, err := ks.NewAccount("old")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to create account: %v", acc)
|
t.Fatalf("failed to create account: %v", acc)
|
||||||
@@ -372,8 +363,7 @@ func TestImportExport(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to export account: %v", acc)
|
t.Fatalf("failed to export account: %v", acc)
|
||||||
}
|
}
|
||||||
dir2, ks2 := tmpKeyStore(t, true)
|
_, ks2 := tmpKeyStore(t, true)
|
||||||
defer os.RemoveAll(dir2)
|
|
||||||
if _, err = ks2.Import(json, "old", "old"); err == nil {
|
if _, err = ks2.Import(json, "old", "old"); err == nil {
|
||||||
t.Errorf("importing with invalid password succeeded")
|
t.Errorf("importing with invalid password succeeded")
|
||||||
}
|
}
|
||||||
@@ -393,8 +383,7 @@ func TestImportExport(t *testing.T) {
|
|||||||
// TestImportRace tests the keystore on races.
|
// TestImportRace tests the keystore on races.
|
||||||
// This test should fail under -race if importing races.
|
// This test should fail under -race if importing races.
|
||||||
func TestImportRace(t *testing.T) {
|
func TestImportRace(t *testing.T) {
|
||||||
dir, ks := tmpKeyStore(t, true)
|
_, ks := tmpKeyStore(t, true)
|
||||||
defer os.RemoveAll(dir)
|
|
||||||
acc, err := ks.NewAccount("old")
|
acc, err := ks.NewAccount("old")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to create account: %v", acc)
|
t.Fatalf("failed to create account: %v", acc)
|
||||||
@@ -403,8 +392,7 @@ func TestImportRace(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to export account: %v", acc)
|
t.Fatalf("failed to export account: %v", acc)
|
||||||
}
|
}
|
||||||
dir2, ks2 := tmpKeyStore(t, true)
|
_, ks2 := tmpKeyStore(t, true)
|
||||||
defer os.RemoveAll(dir2)
|
|
||||||
var atom uint32
|
var atom uint32
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(2)
|
wg.Add(2)
|
||||||
@@ -460,10 +448,7 @@ func checkEvents(t *testing.T, want []walletEvent, have []walletEvent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func tmpKeyStore(t *testing.T, encrypted bool) (string, *KeyStore) {
|
func tmpKeyStore(t *testing.T, encrypted bool) (string, *KeyStore) {
|
||||||
d, err := ioutil.TempDir("", "eth-keystore-test")
|
d := t.TempDir()
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
newKs := NewPlaintextKeyStore
|
newKs := NewPlaintextKeyStore
|
||||||
if encrypted {
|
if encrypted {
|
||||||
newKs = func(kd string) *KeyStore { return NewKeyStore(kd, veryLightScryptN, veryLightScryptP) }
|
newKs = func(kd string) *KeyStore { return NewKeyStore(kd, veryLightScryptN, veryLightScryptP) }
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
@@ -42,7 +41,7 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/common/math"
|
"github.com/ethereum/go-ethereum/common/math"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/pborman/uuid"
|
"github.com/google/uuid"
|
||||||
"golang.org/x/crypto/pbkdf2"
|
"golang.org/x/crypto/pbkdf2"
|
||||||
"golang.org/x/crypto/scrypt"
|
"golang.org/x/crypto/scrypt"
|
||||||
)
|
)
|
||||||
@@ -82,7 +81,7 @@ type keyStorePassphrase struct {
|
|||||||
|
|
||||||
func (ks keyStorePassphrase) GetKey(addr common.Address, filename, auth string) (*Key, error) {
|
func (ks keyStorePassphrase) GetKey(addr common.Address, filename, auth string) (*Key, error) {
|
||||||
// Load the key from the keystore and decrypt its contents
|
// Load the key from the keystore and decrypt its contents
|
||||||
keyjson, err := ioutil.ReadFile(filename)
|
keyjson, err := os.ReadFile(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -228,9 +227,12 @@ func DecryptKey(keyjson []byte, auth string) (*Key, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
key := crypto.ToECDSAUnsafe(keyBytes)
|
key := crypto.ToECDSAUnsafe(keyBytes)
|
||||||
|
id, err := uuid.FromBytes(keyId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
return &Key{
|
return &Key{
|
||||||
Id: uuid.UUID(keyId),
|
Id: id,
|
||||||
Address: crypto.PubkeyToAddress(key.PublicKey),
|
Address: crypto.PubkeyToAddress(key.PublicKey),
|
||||||
PrivateKey: key,
|
PrivateKey: key,
|
||||||
}, nil
|
}, nil
|
||||||
@@ -276,7 +278,11 @@ func decryptKeyV3(keyProtected *encryptedKeyJSONV3, auth string) (keyBytes []byt
|
|||||||
if keyProtected.Version != version {
|
if keyProtected.Version != version {
|
||||||
return nil, nil, fmt.Errorf("version not supported: %v", keyProtected.Version)
|
return nil, nil, fmt.Errorf("version not supported: %v", keyProtected.Version)
|
||||||
}
|
}
|
||||||
keyId = uuid.Parse(keyProtected.Id)
|
keyUUID, err := uuid.Parse(keyProtected.Id)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
keyId = keyUUID[:]
|
||||||
plainText, err := DecryptDataV3(keyProtected.Crypto, auth)
|
plainText, err := DecryptDataV3(keyProtected.Crypto, auth)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
@@ -285,7 +291,11 @@ func decryptKeyV3(keyProtected *encryptedKeyJSONV3, auth string) (keyBytes []byt
|
|||||||
}
|
}
|
||||||
|
|
||||||
func decryptKeyV1(keyProtected *encryptedKeyJSONV1, auth string) (keyBytes []byte, keyId []byte, err error) {
|
func decryptKeyV1(keyProtected *encryptedKeyJSONV1, auth string) (keyBytes []byte, keyId []byte, err error) {
|
||||||
keyId = uuid.Parse(keyProtected.Id)
|
keyUUID, err := uuid.Parse(keyProtected.Id)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
keyId = keyUUID[:]
|
||||||
mac, err := hex.DecodeString(keyProtected.Crypto.MAC)
|
mac, err := hex.DecodeString(keyProtected.Crypto.MAC)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
package keystore
|
package keystore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
@@ -30,7 +30,7 @@ const (
|
|||||||
|
|
||||||
// Tests that a json key file can be decrypted and encrypted in multiple rounds.
|
// Tests that a json key file can be decrypted and encrypted in multiple rounds.
|
||||||
func TestKeyEncryptDecrypt(t *testing.T) {
|
func TestKeyEncryptDecrypt(t *testing.T) {
|
||||||
keyjson, err := ioutil.ReadFile("testdata/very-light-scrypt.json")
|
keyjson, err := os.ReadFile("testdata/very-light-scrypt.json")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,7 @@ func TestKeyEncryptDecrypt(t *testing.T) {
|
|||||||
t.Errorf("test %d: key address mismatch: have %x, want %x", i, key.Address, address)
|
t.Errorf("test %d: key address mismatch: have %x, want %x", i, key.Address, address)
|
||||||
}
|
}
|
||||||
// Recrypt with a new password and start over
|
// Recrypt with a new password and start over
|
||||||
password += "new data appended"
|
password += "new data appended" // nolint: gosec
|
||||||
if keyjson, err = EncryptKey(key, password, veryLightScryptN, veryLightScryptP); err != nil {
|
if keyjson, err = EncryptKey(key, password, veryLightScryptN, veryLightScryptP); err != nil {
|
||||||
t.Errorf("test %d: failed to recrypt key %v", i, err)
|
t.Errorf("test %d: failed to recrypt key %v", i, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ import (
|
|||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -32,10 +30,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func tmpKeyStoreIface(t *testing.T, encrypted bool) (dir string, ks keyStore) {
|
func tmpKeyStoreIface(t *testing.T, encrypted bool) (dir string, ks keyStore) {
|
||||||
d, err := ioutil.TempDir("", "geth-keystore-test")
|
d := t.TempDir()
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if encrypted {
|
if encrypted {
|
||||||
ks = &keyStorePassphrase{d, veryLightScryptN, veryLightScryptP, true}
|
ks = &keyStorePassphrase{d, veryLightScryptN, veryLightScryptP, true}
|
||||||
} else {
|
} else {
|
||||||
@@ -45,8 +40,7 @@ func tmpKeyStoreIface(t *testing.T, encrypted bool) (dir string, ks keyStore) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestKeyStorePlain(t *testing.T) {
|
func TestKeyStorePlain(t *testing.T) {
|
||||||
dir, ks := tmpKeyStoreIface(t, false)
|
_, ks := tmpKeyStoreIface(t, false)
|
||||||
defer os.RemoveAll(dir)
|
|
||||||
|
|
||||||
pass := "" // not used but required by API
|
pass := "" // not used but required by API
|
||||||
k1, account, err := storeNewKey(ks, rand.Reader, pass)
|
k1, account, err := storeNewKey(ks, rand.Reader, pass)
|
||||||
@@ -66,8 +60,7 @@ func TestKeyStorePlain(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestKeyStorePassphrase(t *testing.T) {
|
func TestKeyStorePassphrase(t *testing.T) {
|
||||||
dir, ks := tmpKeyStoreIface(t, true)
|
_, ks := tmpKeyStoreIface(t, true)
|
||||||
defer os.RemoveAll(dir)
|
|
||||||
|
|
||||||
pass := "foo"
|
pass := "foo"
|
||||||
k1, account, err := storeNewKey(ks, rand.Reader, pass)
|
k1, account, err := storeNewKey(ks, rand.Reader, pass)
|
||||||
@@ -87,8 +80,7 @@ func TestKeyStorePassphrase(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestKeyStorePassphraseDecryptionFail(t *testing.T) {
|
func TestKeyStorePassphraseDecryptionFail(t *testing.T) {
|
||||||
dir, ks := tmpKeyStoreIface(t, true)
|
_, ks := tmpKeyStoreIface(t, true)
|
||||||
defer os.RemoveAll(dir)
|
|
||||||
|
|
||||||
pass := "foo"
|
pass := "foo"
|
||||||
k1, account, err := storeNewKey(ks, rand.Reader, pass)
|
k1, account, err := storeNewKey(ks, rand.Reader, pass)
|
||||||
@@ -102,7 +94,6 @@ func TestKeyStorePassphraseDecryptionFail(t *testing.T) {
|
|||||||
|
|
||||||
func TestImportPreSaleKey(t *testing.T) {
|
func TestImportPreSaleKey(t *testing.T) {
|
||||||
dir, ks := tmpKeyStoreIface(t, true)
|
dir, ks := tmpKeyStoreIface(t, true)
|
||||||
defer os.RemoveAll(dir)
|
|
||||||
|
|
||||||
// file content of a presale key file generated with:
|
// file content of a presale key file generated with:
|
||||||
// python pyethsaletool.py genwallet
|
// python pyethsaletool.py genwallet
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import (
|
|||||||
|
|
||||||
"github.com/ethereum/go-ethereum/accounts"
|
"github.com/ethereum/go-ethereum/accounts"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/pborman/uuid"
|
"github.com/google/uuid"
|
||||||
"golang.org/x/crypto/pbkdf2"
|
"golang.org/x/crypto/pbkdf2"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -37,7 +37,10 @@ func importPreSaleKey(keyStore keyStore, keyJSON []byte, password string) (accou
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return accounts.Account{}, nil, err
|
return accounts.Account{}, nil, err
|
||||||
}
|
}
|
||||||
key.Id = uuid.NewRandom()
|
key.Id, err = uuid.NewRandom()
|
||||||
|
if err != nil {
|
||||||
|
return accounts.Account{}, nil, err
|
||||||
|
}
|
||||||
a := accounts.Account{
|
a := accounts.Account{
|
||||||
Address: key.Address,
|
Address: key.Address,
|
||||||
URL: accounts.URL{
|
URL: accounts.URL{
|
||||||
@@ -86,7 +89,7 @@ func decryptPreSaleKey(fileContent []byte, password string) (key *Key, err error
|
|||||||
ecKey := crypto.ToECDSAUnsafe(ethPriv)
|
ecKey := crypto.ToECDSAUnsafe(ethPriv)
|
||||||
|
|
||||||
key = &Key{
|
key = &Key{
|
||||||
Id: nil,
|
Id: uuid.UUID{},
|
||||||
Address: crypto.PubkeyToAddress(ecKey.PublicKey),
|
Address: crypto.PubkeyToAddress(ecKey.PublicKey),
|
||||||
PrivateKey: ecKey,
|
PrivateKey: ecKey,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package keystore
|
|||||||
import (
|
import (
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
ethereum "github.com/ethereum/go-ethereum"
|
"github.com/ethereum/go-ethereum"
|
||||||
"github.com/ethereum/go-ethereum/accounts"
|
"github.com/ethereum/go-ethereum/accounts"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
@@ -58,7 +58,7 @@ func (w *keystoreWallet) Open(passphrase string) error { return nil }
|
|||||||
func (w *keystoreWallet) Close() error { return nil }
|
func (w *keystoreWallet) Close() error { return nil }
|
||||||
|
|
||||||
// Accounts implements accounts.Wallet, returning an account list consisting of
|
// Accounts implements accounts.Wallet, returning an account list consisting of
|
||||||
// a single account that the plain kestore wallet contains.
|
// a single account that the plain keystore wallet contains.
|
||||||
func (w *keystoreWallet) Accounts() []accounts.Account {
|
func (w *keystoreWallet) Accounts() []accounts.Account {
|
||||||
return []accounts.Account{w.account}
|
return []accounts.Account{w.account}
|
||||||
}
|
}
|
||||||
@@ -93,12 +93,12 @@ func (w *keystoreWallet) signHash(account accounts.Account, hash []byte) ([]byte
|
|||||||
return w.keystore.SignHash(account, hash)
|
return w.keystore.SignHash(account, hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SignData signs keccak256(data). The mimetype parameter describes the type of data being signed
|
// SignData signs keccak256(data). The mimetype parameter describes the type of data being signed.
|
||||||
func (w *keystoreWallet) SignData(account accounts.Account, mimeType string, data []byte) ([]byte, error) {
|
func (w *keystoreWallet) SignData(account accounts.Account, mimeType string, data []byte) ([]byte, error) {
|
||||||
return w.signHash(account, crypto.Keccak256(data))
|
return w.signHash(account, crypto.Keccak256(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
// SignDataWithPassphrase signs keccak256(data). The mimetype parameter describes the type of data being signed
|
// SignDataWithPassphrase signs keccak256(data). The mimetype parameter describes the type of data being signed.
|
||||||
func (w *keystoreWallet) SignDataWithPassphrase(account accounts.Account, passphrase, mimeType string, data []byte) ([]byte, error) {
|
func (w *keystoreWallet) SignDataWithPassphrase(account accounts.Account, passphrase, mimeType string, data []byte) ([]byte, error) {
|
||||||
// Make sure the requested account is contained within
|
// Make sure the requested account is contained within
|
||||||
if !w.Contains(account) {
|
if !w.Contains(account) {
|
||||||
@@ -108,12 +108,14 @@ func (w *keystoreWallet) SignDataWithPassphrase(account accounts.Account, passph
|
|||||||
return w.keystore.SignHashWithPassphrase(account, passphrase, crypto.Keccak256(data))
|
return w.keystore.SignHashWithPassphrase(account, passphrase, crypto.Keccak256(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SignText implements accounts.Wallet, attempting to sign the hash of
|
||||||
|
// the given text with the given account.
|
||||||
func (w *keystoreWallet) SignText(account accounts.Account, text []byte) ([]byte, error) {
|
func (w *keystoreWallet) SignText(account accounts.Account, text []byte) ([]byte, error) {
|
||||||
return w.signHash(account, accounts.TextHash(text))
|
return w.signHash(account, accounts.TextHash(text))
|
||||||
}
|
}
|
||||||
|
|
||||||
// SignTextWithPassphrase implements accounts.Wallet, attempting to sign the
|
// SignTextWithPassphrase implements accounts.Wallet, attempting to sign the
|
||||||
// given hash with the given account using passphrase as extra authentication.
|
// hash of the given text with the given account using passphrase as extra authentication.
|
||||||
func (w *keystoreWallet) SignTextWithPassphrase(account accounts.Account, passphrase string, text []byte) ([]byte, error) {
|
func (w *keystoreWallet) SignTextWithPassphrase(account accounts.Account, passphrase string, text []byte) ([]byte, error) {
|
||||||
// Make sure the requested account is contained within
|
// Make sure the requested account is contained within
|
||||||
if !w.Contains(account) {
|
if !w.Contains(account) {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
// You should have received a copy of the GNU Lesser General Public License
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//go:build (darwin && !ios && cgo) || freebsd || (linux && !arm64) || netbsd || solaris
|
||||||
// +build darwin,!ios,cgo freebsd linux,!arm64 netbsd solaris
|
// +build darwin,!ios,cgo freebsd linux,!arm64 netbsd solaris
|
||||||
|
|
||||||
package keystore
|
package keystore
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
// You should have received a copy of the GNU Lesser General Public License
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//go:build (darwin && !cgo) || ios || (linux && arm64) || windows || (!darwin && !freebsd && !linux && !netbsd && !solaris)
|
||||||
// +build darwin,!cgo ios linux,arm64 windows !darwin,!freebsd,!linux,!netbsd,!solaris
|
// +build darwin,!cgo ios linux,arm64 windows !darwin,!freebsd,!linux,!netbsd,!solaris
|
||||||
|
|
||||||
// This is the fallback implementation of directory watching.
|
// This is the fallback implementation of directory watching.
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/event"
|
"github.com/ethereum/go-ethereum/event"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// managerSubBufferSize determines how many incoming wallet events
|
||||||
|
// the manager will buffer in its channel.
|
||||||
|
const managerSubBufferSize = 50
|
||||||
|
|
||||||
// Config contains the settings of the global account manager.
|
// Config contains the settings of the global account manager.
|
||||||
//
|
//
|
||||||
// TODO(rjl493456442, karalabe, holiman): Get rid of this when account management
|
// TODO(rjl493456442, karalabe, holiman): Get rid of this when account management
|
||||||
@@ -33,18 +37,27 @@ type Config struct {
|
|||||||
InsecureUnlockAllowed bool // Whether account unlocking in insecure environment is allowed
|
InsecureUnlockAllowed bool // Whether account unlocking in insecure environment is allowed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// newBackendEvent lets the manager know it should
|
||||||
|
// track the given backend for wallet updates.
|
||||||
|
type newBackendEvent struct {
|
||||||
|
backend Backend
|
||||||
|
processed chan struct{} // Informs event emitter that backend has been integrated
|
||||||
|
}
|
||||||
|
|
||||||
// Manager is an overarching account manager that can communicate with various
|
// Manager is an overarching account manager that can communicate with various
|
||||||
// backends for signing transactions.
|
// backends for signing transactions.
|
||||||
type Manager struct {
|
type Manager struct {
|
||||||
config *Config // Global account manager configurations
|
config *Config // Global account manager configurations
|
||||||
backends map[reflect.Type][]Backend // Index of backends currently registered
|
backends map[reflect.Type][]Backend // Index of backends currently registered
|
||||||
updaters []event.Subscription // Wallet update subscriptions for all backends
|
updaters []event.Subscription // Wallet update subscriptions for all backends
|
||||||
updates chan WalletEvent // Subscription sink for backend wallet changes
|
updates chan WalletEvent // Subscription sink for backend wallet changes
|
||||||
wallets []Wallet // Cache of all wallets from all registered backends
|
newBackends chan newBackendEvent // Incoming backends to be tracked by the manager
|
||||||
|
wallets []Wallet // Cache of all wallets from all registered backends
|
||||||
|
|
||||||
feed event.Feed // Wallet feed notifying of arrivals/departures
|
feed event.Feed // Wallet feed notifying of arrivals/departures
|
||||||
|
|
||||||
quit chan chan error
|
quit chan chan error
|
||||||
|
term chan struct{} // Channel is closed upon termination of the update loop
|
||||||
lock sync.RWMutex
|
lock sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +70,7 @@ func NewManager(config *Config, backends ...Backend) *Manager {
|
|||||||
wallets = merge(wallets, backend.Wallets()...)
|
wallets = merge(wallets, backend.Wallets()...)
|
||||||
}
|
}
|
||||||
// Subscribe to wallet notifications from all backends
|
// Subscribe to wallet notifications from all backends
|
||||||
updates := make(chan WalletEvent, 4*len(backends))
|
updates := make(chan WalletEvent, managerSubBufferSize)
|
||||||
|
|
||||||
subs := make([]event.Subscription, len(backends))
|
subs := make([]event.Subscription, len(backends))
|
||||||
for i, backend := range backends {
|
for i, backend := range backends {
|
||||||
@@ -65,12 +78,14 @@ func NewManager(config *Config, backends ...Backend) *Manager {
|
|||||||
}
|
}
|
||||||
// Assemble the account manager and return
|
// Assemble the account manager and return
|
||||||
am := &Manager{
|
am := &Manager{
|
||||||
config: config,
|
config: config,
|
||||||
backends: make(map[reflect.Type][]Backend),
|
backends: make(map[reflect.Type][]Backend),
|
||||||
updaters: subs,
|
updaters: subs,
|
||||||
updates: updates,
|
updates: updates,
|
||||||
wallets: wallets,
|
newBackends: make(chan newBackendEvent),
|
||||||
quit: make(chan chan error),
|
wallets: wallets,
|
||||||
|
quit: make(chan chan error),
|
||||||
|
term: make(chan struct{}),
|
||||||
}
|
}
|
||||||
for _, backend := range backends {
|
for _, backend := range backends {
|
||||||
kind := reflect.TypeOf(backend)
|
kind := reflect.TypeOf(backend)
|
||||||
@@ -93,6 +108,14 @@ func (am *Manager) Config() *Config {
|
|||||||
return am.config
|
return am.config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddBackend starts the tracking of an additional backend for wallet updates.
|
||||||
|
// cmd/geth assumes once this func returns the backends have been already integrated.
|
||||||
|
func (am *Manager) AddBackend(backend Backend) {
|
||||||
|
done := make(chan struct{})
|
||||||
|
am.newBackends <- newBackendEvent{backend, done}
|
||||||
|
<-done
|
||||||
|
}
|
||||||
|
|
||||||
// update is the wallet event loop listening for notifications from the backends
|
// update is the wallet event loop listening for notifications from the backends
|
||||||
// and updating the cache of wallets.
|
// and updating the cache of wallets.
|
||||||
func (am *Manager) update() {
|
func (am *Manager) update() {
|
||||||
@@ -122,10 +145,22 @@ func (am *Manager) update() {
|
|||||||
|
|
||||||
// Notify any listeners of the event
|
// Notify any listeners of the event
|
||||||
am.feed.Send(event)
|
am.feed.Send(event)
|
||||||
|
case event := <-am.newBackends:
|
||||||
|
am.lock.Lock()
|
||||||
|
// Update caches
|
||||||
|
backend := event.backend
|
||||||
|
am.wallets = merge(am.wallets, backend.Wallets()...)
|
||||||
|
am.updaters = append(am.updaters, backend.Subscribe(am.updates))
|
||||||
|
kind := reflect.TypeOf(backend)
|
||||||
|
am.backends[kind] = append(am.backends[kind], backend)
|
||||||
|
am.lock.Unlock()
|
||||||
|
close(event.processed)
|
||||||
case errc := <-am.quit:
|
case errc := <-am.quit:
|
||||||
// Manager terminating, return
|
// Manager terminating, return
|
||||||
errc <- nil
|
errc <- nil
|
||||||
|
// Signals event emitters the loop is not receiving values
|
||||||
|
// to prevent them from getting stuck.
|
||||||
|
close(am.term)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,6 +168,9 @@ func (am *Manager) update() {
|
|||||||
|
|
||||||
// Backends retrieves the backend(s) with the given type from the account manager.
|
// Backends retrieves the backend(s) with the given type from the account manager.
|
||||||
func (am *Manager) Backends(kind reflect.Type) []Backend {
|
func (am *Manager) Backends(kind reflect.Type) []Backend {
|
||||||
|
am.lock.RLock()
|
||||||
|
defer am.lock.RUnlock()
|
||||||
|
|
||||||
return am.backends[kind]
|
return am.backends[kind]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,12 +31,16 @@
|
|||||||
Write down the URL (`keycard://044def09` in this example). Then ask `geth` to open the wallet:
|
Write down the URL (`keycard://044def09` in this example). Then ask `geth` to open the wallet:
|
||||||
|
|
||||||
```
|
```
|
||||||
> personal.openWallet("keycard://044def09")
|
> personal.openWallet("keycard://044def09", "pairing password")
|
||||||
Please enter the pairing password:
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Enter the pairing password that you have received during card initialization. Same with the PIN that you will subsequently be
|
The pairing password has been generated during the card initialization process.
|
||||||
asked for.
|
|
||||||
|
The process needs to be repeated once more with the PIN:
|
||||||
|
|
||||||
|
```
|
||||||
|
> personal.openWallet("keycard://044def09", "PIN number")
|
||||||
|
```
|
||||||
|
|
||||||
If everything goes well, you should see your new account when typing `personal` on the console:
|
If everything goes well, you should see your new account when typing `personal` on the console:
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ package scwallet
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
@@ -96,7 +96,7 @@ func (hub *Hub) readPairings() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
pairingData, err := ioutil.ReadAll(pairingFile)
|
pairingData, err := io.ReadAll(pairingFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"crypto/aes"
|
"crypto/aes"
|
||||||
"crypto/cipher"
|
"crypto/cipher"
|
||||||
|
"crypto/elliptic"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"crypto/sha512"
|
"crypto/sha512"
|
||||||
@@ -27,7 +28,6 @@ import (
|
|||||||
|
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
pcsc "github.com/gballet/go-libpcsclite"
|
pcsc "github.com/gballet/go-libpcsclite"
|
||||||
"github.com/wsddn/go-ecdh"
|
|
||||||
"golang.org/x/crypto/pbkdf2"
|
"golang.org/x/crypto/pbkdf2"
|
||||||
"golang.org/x/text/unicode/norm"
|
"golang.org/x/text/unicode/norm"
|
||||||
)
|
)
|
||||||
@@ -63,26 +63,19 @@ type SecureChannelSession struct {
|
|||||||
// NewSecureChannelSession creates a new secure channel for the given card and public key.
|
// NewSecureChannelSession creates a new secure channel for the given card and public key.
|
||||||
func NewSecureChannelSession(card *pcsc.Card, keyData []byte) (*SecureChannelSession, error) {
|
func NewSecureChannelSession(card *pcsc.Card, keyData []byte) (*SecureChannelSession, error) {
|
||||||
// Generate an ECDSA keypair for ourselves
|
// Generate an ECDSA keypair for ourselves
|
||||||
gen := ecdh.NewEllipticECDH(crypto.S256())
|
key, err := crypto.GenerateKey()
|
||||||
private, public, err := gen.GenerateKey(rand.Reader)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
cardPublic, err := crypto.UnmarshalPubkey(keyData)
|
||||||
cardPublic, ok := gen.Unmarshal(keyData)
|
|
||||||
if !ok {
|
|
||||||
return nil, fmt.Errorf("could not unmarshal public key from card")
|
|
||||||
}
|
|
||||||
|
|
||||||
secret, err := gen.GenerateSharedSecret(private, cardPublic)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, fmt.Errorf("could not unmarshal public key from card: %v", err)
|
||||||
}
|
}
|
||||||
|
secret, _ := key.Curve.ScalarMult(cardPublic.X, cardPublic.Y, key.D.Bytes())
|
||||||
return &SecureChannelSession{
|
return &SecureChannelSession{
|
||||||
card: card,
|
card: card,
|
||||||
secret: secret,
|
secret: secret.Bytes(),
|
||||||
publicKey: gen.Marshal(public),
|
publicKey: elliptic.Marshal(crypto.S256(), key.PublicKey.X, key.PublicKey.Y),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
ethereum "github.com/ethereum/go-ethereum"
|
"github.com/ethereum/go-ethereum"
|
||||||
"github.com/ethereum/go-ethereum/accounts"
|
"github.com/ethereum/go-ethereum/accounts"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
@@ -637,8 +637,8 @@ func (w *Wallet) Derive(path accounts.DerivationPath, pin bool) (accounts.Accoun
|
|||||||
// to discover non zero accounts and automatically add them to list of tracked
|
// to discover non zero accounts and automatically add them to list of tracked
|
||||||
// accounts.
|
// accounts.
|
||||||
//
|
//
|
||||||
// Note, self derivaton will increment the last component of the specified path
|
// Note, self derivation will increment the last component of the specified path
|
||||||
// opposed to decending into a child path to allow discovering accounts starting
|
// opposed to descending into a child path to allow discovering accounts starting
|
||||||
// from non zero components.
|
// from non zero components.
|
||||||
//
|
//
|
||||||
// Some hardware wallets switched derivation paths through their evolution, so
|
// Some hardware wallets switched derivation paths through their evolution, so
|
||||||
@@ -699,7 +699,7 @@ func (w *Wallet) signHash(account accounts.Account, hash []byte) ([]byte, error)
|
|||||||
// the needed details via SignTxWithPassphrase, or by other means (e.g. unlock
|
// the needed details via SignTxWithPassphrase, or by other means (e.g. unlock
|
||||||
// the account in a keystore).
|
// the account in a keystore).
|
||||||
func (w *Wallet) SignTx(account accounts.Account, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error) {
|
func (w *Wallet) SignTx(account accounts.Account, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error) {
|
||||||
signer := types.NewEIP155Signer(chainID)
|
signer := types.LatestSignerForChainID(chainID)
|
||||||
hash := signer.Hash(tx)
|
hash := signer.Hash(tx)
|
||||||
sig, err := w.signHash(account, hash[:])
|
sig, err := w.signHash(account, hash[:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ func (u URL) String() string {
|
|||||||
func (u URL) TerminalString() string {
|
func (u URL) TerminalString() string {
|
||||||
url := u.String()
|
url := u.String()
|
||||||
if len(url) > 32 {
|
if len(url) > 32 {
|
||||||
return url[:31] + "…"
|
return url[:31] + ".."
|
||||||
}
|
}
|
||||||
return url
|
return url
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,9 +32,10 @@ func TestURLParsing(t *testing.T) {
|
|||||||
t.Errorf("expected: %v, got: %v", "ethereum.org", url.Path)
|
t.Errorf("expected: %v, got: %v", "ethereum.org", url.Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = parseURL("ethereum.org")
|
for _, u := range []string{"ethereum.org", ""} {
|
||||||
if err == nil {
|
if _, err = parseURL(u); err == nil {
|
||||||
t.Error("expected err, got: nil")
|
t.Errorf("input %v, expected err, got: nil", u)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,8 +52,10 @@ const (
|
|||||||
ledgerOpRetrieveAddress ledgerOpcode = 0x02 // Returns the public key and Ethereum address for a given BIP 32 path
|
ledgerOpRetrieveAddress ledgerOpcode = 0x02 // Returns the public key and Ethereum address for a given BIP 32 path
|
||||||
ledgerOpSignTransaction ledgerOpcode = 0x04 // Signs an Ethereum transaction after having the user validate the parameters
|
ledgerOpSignTransaction ledgerOpcode = 0x04 // Signs an Ethereum transaction after having the user validate the parameters
|
||||||
ledgerOpGetConfiguration ledgerOpcode = 0x06 // Returns specific wallet application configuration
|
ledgerOpGetConfiguration ledgerOpcode = 0x06 // Returns specific wallet application configuration
|
||||||
|
ledgerOpSignTypedMessage ledgerOpcode = 0x0c // Signs an Ethereum message following the EIP 712 specification
|
||||||
|
|
||||||
ledgerP1DirectlyFetchAddress ledgerParam1 = 0x00 // Return address directly from the wallet
|
ledgerP1DirectlyFetchAddress ledgerParam1 = 0x00 // Return address directly from the wallet
|
||||||
|
ledgerP1InitTypedMessageData ledgerParam1 = 0x00 // First chunk of Typed Message data
|
||||||
ledgerP1InitTransactionData ledgerParam1 = 0x00 // First transaction data block for signing
|
ledgerP1InitTransactionData ledgerParam1 = 0x00 // First transaction data block for signing
|
||||||
ledgerP1ContTransactionData ledgerParam1 = 0x80 // Subsequent transaction data block for signing
|
ledgerP1ContTransactionData ledgerParam1 = 0x80 // Subsequent transaction data block for signing
|
||||||
ledgerP2DiscardAddressChainCode ledgerParam2 = 0x00 // Do not return the chain code along with the address
|
ledgerP2DiscardAddressChainCode ledgerParam2 = 0x00 // Do not return the chain code along with the address
|
||||||
@@ -162,7 +164,7 @@ func (w *ledgerDriver) SignTx(path accounts.DerivationPath, tx *types.Transactio
|
|||||||
return common.Address{}, nil, accounts.ErrWalletClosed
|
return common.Address{}, nil, accounts.ErrWalletClosed
|
||||||
}
|
}
|
||||||
// Ensure the wallet is capable of signing the given transaction
|
// Ensure the wallet is capable of signing the given transaction
|
||||||
if chainID != nil && w.version[0] <= 1 && w.version[2] <= 2 {
|
if chainID != nil && w.version[0] <= 1 && w.version[1] <= 0 && w.version[2] <= 2 {
|
||||||
//lint:ignore ST1005 brand name displayed on the console
|
//lint:ignore ST1005 brand name displayed on the console
|
||||||
return common.Address{}, nil, fmt.Errorf("Ledger v%d.%d.%d doesn't support signing this transaction, please update to v1.0.3 at least", w.version[0], w.version[1], w.version[2])
|
return common.Address{}, nil, fmt.Errorf("Ledger v%d.%d.%d doesn't support signing this transaction, please update to v1.0.3 at least", w.version[0], w.version[1], w.version[2])
|
||||||
}
|
}
|
||||||
@@ -170,6 +172,24 @@ func (w *ledgerDriver) SignTx(path accounts.DerivationPath, tx *types.Transactio
|
|||||||
return w.ledgerSign(path, tx, chainID)
|
return w.ledgerSign(path, tx, chainID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SignTypedMessage implements usbwallet.driver, sending the message to the Ledger and
|
||||||
|
// waiting for the user to sign or deny the transaction.
|
||||||
|
//
|
||||||
|
// Note: this was introduced in the ledger 1.5.0 firmware
|
||||||
|
func (w *ledgerDriver) SignTypedMessage(path accounts.DerivationPath, domainHash []byte, messageHash []byte) ([]byte, error) {
|
||||||
|
// If the Ethereum app doesn't run, abort
|
||||||
|
if w.offline() {
|
||||||
|
return nil, accounts.ErrWalletClosed
|
||||||
|
}
|
||||||
|
// Ensure the wallet is capable of signing the given transaction
|
||||||
|
if w.version[0] < 1 && w.version[1] < 5 {
|
||||||
|
//lint:ignore ST1005 brand name displayed on the console
|
||||||
|
return nil, fmt.Errorf("Ledger version >= 1.5.0 required for EIP-712 signing (found version v%d.%d.%d)", w.version[0], w.version[1], w.version[2])
|
||||||
|
}
|
||||||
|
// All infos gathered and metadata checks out, request signing
|
||||||
|
return w.ledgerSignTypedMessage(path, domainHash, messageHash)
|
||||||
|
}
|
||||||
|
|
||||||
// ledgerVersion retrieves the current version of the Ethereum wallet app running
|
// ledgerVersion retrieves the current version of the Ethereum wallet app running
|
||||||
// on the Ledger wallet.
|
// on the Ledger wallet.
|
||||||
//
|
//
|
||||||
@@ -367,6 +387,68 @@ func (w *ledgerDriver) ledgerSign(derivationPath []uint32, tx *types.Transaction
|
|||||||
return sender, signed, nil
|
return sender, signed, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ledgerSignTypedMessage sends the transaction to the Ledger wallet, and waits for the user
|
||||||
|
// to confirm or deny the transaction.
|
||||||
|
//
|
||||||
|
// The signing protocol is defined as follows:
|
||||||
|
//
|
||||||
|
// CLA | INS | P1 | P2 | Lc | Le
|
||||||
|
// ----+-----+----+-----------------------------+-----+---
|
||||||
|
// E0 | 0C | 00 | implementation version : 00 | variable | variable
|
||||||
|
//
|
||||||
|
// Where the input is:
|
||||||
|
//
|
||||||
|
// Description | Length
|
||||||
|
// -------------------------------------------------+----------
|
||||||
|
// Number of BIP 32 derivations to perform (max 10) | 1 byte
|
||||||
|
// First derivation index (big endian) | 4 bytes
|
||||||
|
// ... | 4 bytes
|
||||||
|
// Last derivation index (big endian) | 4 bytes
|
||||||
|
// domain hash | 32 bytes
|
||||||
|
// message hash | 32 bytes
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// And the output data is:
|
||||||
|
//
|
||||||
|
// Description | Length
|
||||||
|
// ------------+---------
|
||||||
|
// signature V | 1 byte
|
||||||
|
// signature R | 32 bytes
|
||||||
|
// signature S | 32 bytes
|
||||||
|
func (w *ledgerDriver) ledgerSignTypedMessage(derivationPath []uint32, domainHash []byte, messageHash []byte) ([]byte, error) {
|
||||||
|
// Flatten the derivation path into the Ledger request
|
||||||
|
path := make([]byte, 1+4*len(derivationPath))
|
||||||
|
path[0] = byte(len(derivationPath))
|
||||||
|
for i, component := range derivationPath {
|
||||||
|
binary.BigEndian.PutUint32(path[1+4*i:], component)
|
||||||
|
}
|
||||||
|
// Create the 712 message
|
||||||
|
payload := append(path, domainHash...)
|
||||||
|
payload = append(payload, messageHash...)
|
||||||
|
|
||||||
|
// Send the request and wait for the response
|
||||||
|
var (
|
||||||
|
op = ledgerP1InitTypedMessageData
|
||||||
|
reply []byte
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
|
||||||
|
// Send the message over, ensuring it's processed correctly
|
||||||
|
reply, err = w.ledgerExchange(ledgerOpSignTypedMessage, op, 0, payload)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract the Ethereum signature and do a sanity validation
|
||||||
|
if len(reply) != crypto.SignatureLength {
|
||||||
|
return nil, errors.New("reply lacks signature")
|
||||||
|
}
|
||||||
|
signature := append(reply[1:], reply[0])
|
||||||
|
return signature, nil
|
||||||
|
}
|
||||||
|
|
||||||
// ledgerExchange performs a data exchange with the Ledger wallet, sending it a
|
// ledgerExchange performs a data exchange with the Ledger wallet, sending it a
|
||||||
// message and retrieving the response.
|
// message and retrieving the response.
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -185,6 +185,10 @@ func (w *trezorDriver) SignTx(path accounts.DerivationPath, tx *types.Transactio
|
|||||||
return w.trezorSign(path, tx, chainID)
|
return w.trezorSign(path, tx, chainID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *trezorDriver) SignTypedMessage(path accounts.DerivationPath, domainHash []byte, messageHash []byte) ([]byte, error) {
|
||||||
|
return nil, accounts.ErrNotSupported
|
||||||
|
}
|
||||||
|
|
||||||
// trezorDerive sends a derivation request to the Trezor device and returns the
|
// trezorDerive sends a derivation request to the Trezor device and returns the
|
||||||
// Ethereum address located on that path.
|
// Ethereum address located on that path.
|
||||||
func (w *trezorDriver) trezorDerive(derivationPath []uint32) (common.Address, error) {
|
func (w *trezorDriver) trezorDerive(derivationPath []uint32) (common.Address, error) {
|
||||||
@@ -255,9 +259,11 @@ func (w *trezorDriver) trezorSign(derivationPath []uint32, tx *types.Transaction
|
|||||||
if chainID == nil {
|
if chainID == nil {
|
||||||
signer = new(types.HomesteadSigner)
|
signer = new(types.HomesteadSigner)
|
||||||
} else {
|
} else {
|
||||||
|
// Trezor backend does not support typed transactions yet.
|
||||||
signer = types.NewEIP155Signer(chainID)
|
signer = types.NewEIP155Signer(chainID)
|
||||||
signature[64] -= byte(chainID.Uint64()*2 + 35)
|
signature[64] -= byte(chainID.Uint64()*2 + 35)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inject the final signature into the transaction and sanity check the sender
|
// Inject the final signature into the transaction and sanity check the sender
|
||||||
signed, err := tx.WithSignature(signer, signature)
|
signed, err := tx.WithSignature(signer, signature)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
ethereum "github.com/ethereum/go-ethereum"
|
"github.com/ethereum/go-ethereum"
|
||||||
"github.com/ethereum/go-ethereum/accounts"
|
"github.com/ethereum/go-ethereum/accounts"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
@@ -67,6 +67,8 @@ type driver interface {
|
|||||||
// SignTx sends the transaction to the USB device and waits for the user to confirm
|
// SignTx sends the transaction to the USB device and waits for the user to confirm
|
||||||
// or deny the transaction.
|
// or deny the transaction.
|
||||||
SignTx(path accounts.DerivationPath, tx *types.Transaction, chainID *big.Int) (common.Address, *types.Transaction, error)
|
SignTx(path accounts.DerivationPath, tx *types.Transaction, chainID *big.Int) (common.Address, *types.Transaction, error)
|
||||||
|
|
||||||
|
SignTypedMessage(path accounts.DerivationPath, messageHash []byte, domainHash []byte) ([]byte, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// wallet represents the common functionality shared by all USB hardware
|
// wallet represents the common functionality shared by all USB hardware
|
||||||
@@ -493,8 +495,8 @@ func (w *wallet) Derive(path accounts.DerivationPath, pin bool) (accounts.Accoun
|
|||||||
// to discover non zero accounts and automatically add them to list of tracked
|
// to discover non zero accounts and automatically add them to list of tracked
|
||||||
// accounts.
|
// accounts.
|
||||||
//
|
//
|
||||||
// Note, self derivaton will increment the last component of the specified path
|
// Note, self derivation will increment the last component of the specified path
|
||||||
// opposed to decending into a child path to allow discovering accounts starting
|
// opposed to descending into a child path to allow discovering accounts starting
|
||||||
// from non zero components.
|
// from non zero components.
|
||||||
//
|
//
|
||||||
// Some hardware wallets switched derivation paths through their evolution, so
|
// Some hardware wallets switched derivation paths through their evolution, so
|
||||||
@@ -524,7 +526,46 @@ func (w *wallet) signHash(account accounts.Account, hash []byte) ([]byte, error)
|
|||||||
|
|
||||||
// SignData signs keccak256(data). The mimetype parameter describes the type of data being signed
|
// SignData signs keccak256(data). The mimetype parameter describes the type of data being signed
|
||||||
func (w *wallet) SignData(account accounts.Account, mimeType string, data []byte) ([]byte, error) {
|
func (w *wallet) SignData(account accounts.Account, mimeType string, data []byte) ([]byte, error) {
|
||||||
return w.signHash(account, crypto.Keccak256(data))
|
|
||||||
|
// Unless we are doing 712 signing, simply dispatch to signHash
|
||||||
|
if !(mimeType == accounts.MimetypeTypedData && len(data) == 66 && data[0] == 0x19 && data[1] == 0x01) {
|
||||||
|
return w.signHash(account, crypto.Keccak256(data))
|
||||||
|
}
|
||||||
|
|
||||||
|
// dispatch to 712 signing if the mimetype is TypedData and the format matches
|
||||||
|
w.stateLock.RLock() // Comms have own mutex, this is for the state fields
|
||||||
|
defer w.stateLock.RUnlock()
|
||||||
|
|
||||||
|
// If the wallet is closed, abort
|
||||||
|
if w.device == nil {
|
||||||
|
return nil, accounts.ErrWalletClosed
|
||||||
|
}
|
||||||
|
// Make sure the requested account is contained within
|
||||||
|
path, ok := w.paths[account.Address]
|
||||||
|
if !ok {
|
||||||
|
return nil, accounts.ErrUnknownAccount
|
||||||
|
}
|
||||||
|
// All infos gathered and metadata checks out, request signing
|
||||||
|
<-w.commsLock
|
||||||
|
defer func() { w.commsLock <- struct{}{} }()
|
||||||
|
|
||||||
|
// Ensure the device isn't screwed with while user confirmation is pending
|
||||||
|
// TODO(karalabe): remove if hotplug lands on Windows
|
||||||
|
w.hub.commsLock.Lock()
|
||||||
|
w.hub.commsPend++
|
||||||
|
w.hub.commsLock.Unlock()
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
w.hub.commsLock.Lock()
|
||||||
|
w.hub.commsPend--
|
||||||
|
w.hub.commsLock.Unlock()
|
||||||
|
}()
|
||||||
|
// Sign the transaction
|
||||||
|
signature, err := w.driver.SignTypedMessage(path, data[2:34], data[34:66])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return signature, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SignDataWithPassphrase implements accounts.Wallet, attempting to sign the given
|
// SignDataWithPassphrase implements accounts.Wallet, attempting to sign the given
|
||||||
|
|||||||
74
appveyor.yml
74
appveyor.yml
@@ -1,41 +1,57 @@
|
|||||||
os: Visual Studio 2015
|
|
||||||
|
|
||||||
# Clone directly into GOPATH.
|
|
||||||
clone_folder: C:\gopath\src\github.com\ethereum\go-ethereum
|
|
||||||
clone_depth: 5
|
clone_depth: 5
|
||||||
version: "{branch}.{build}"
|
version: "{branch}.{build}"
|
||||||
|
|
||||||
|
image:
|
||||||
|
- Ubuntu
|
||||||
|
- Visual Studio 2019
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
global:
|
|
||||||
GO111MODULE: on
|
|
||||||
GOPATH: C:\gopath
|
|
||||||
CC: gcc.exe
|
|
||||||
matrix:
|
matrix:
|
||||||
- GETH_ARCH: amd64
|
- GETH_ARCH: amd64
|
||||||
MSYS2_ARCH: x86_64
|
GETH_MINGW: 'C:\msys64\mingw64'
|
||||||
MSYS2_BITS: 64
|
|
||||||
MSYSTEM: MINGW64
|
|
||||||
PATH: C:\msys64\mingw64\bin\;C:\Program Files (x86)\NSIS\;%PATH%
|
|
||||||
- GETH_ARCH: 386
|
- GETH_ARCH: 386
|
||||||
MSYS2_ARCH: i686
|
GETH_MINGW: 'C:\msys64\mingw32'
|
||||||
MSYS2_BITS: 32
|
|
||||||
MSYSTEM: MINGW32
|
|
||||||
PATH: C:\msys64\mingw32\bin\;C:\Program Files (x86)\NSIS\;%PATH%
|
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- git submodule update --init
|
- git submodule update --init --depth 1 --recursive
|
||||||
- rmdir C:\go /s /q
|
|
||||||
- appveyor DownloadFile https://dl.google.com/go/go1.15.windows-%GETH_ARCH%.zip
|
|
||||||
- 7z x go1.15.windows-%GETH_ARCH%.zip -y -oC:\ > NUL
|
|
||||||
- go version
|
- go version
|
||||||
- gcc --version
|
|
||||||
|
|
||||||
build_script:
|
for:
|
||||||
- go run build\ci.go install
|
# Linux has its own script without -arch and -cc.
|
||||||
|
# The linux builder also runs lint.
|
||||||
|
- matrix:
|
||||||
|
only:
|
||||||
|
- image: Ubuntu
|
||||||
|
build_script:
|
||||||
|
- go run build/ci.go lint
|
||||||
|
- go run build/ci.go install -dlgo
|
||||||
|
test_script:
|
||||||
|
- go run build/ci.go test -dlgo -coverage
|
||||||
|
|
||||||
after_build:
|
# linux/386 is disabled.
|
||||||
- go run build\ci.go archive -type zip -signer WINDOWS_SIGNING_KEY -upload gethstore/builds
|
- matrix:
|
||||||
- go run build\ci.go nsis -signer WINDOWS_SIGNING_KEY -upload gethstore/builds
|
exclude:
|
||||||
|
- image: Ubuntu
|
||||||
|
GETH_ARCH: 386
|
||||||
|
|
||||||
test_script:
|
# Windows builds for amd64 + 386.
|
||||||
- set CGO_ENABLED=1
|
- matrix:
|
||||||
- go run build\ci.go test -coverage
|
only:
|
||||||
|
- image: Visual Studio 2019
|
||||||
|
environment:
|
||||||
|
# We use gcc from MSYS2 because it is the most recent compiler version available on
|
||||||
|
# AppVeyor. Note: gcc.exe only works properly if the corresponding bin/ directory is
|
||||||
|
# contained in PATH.
|
||||||
|
GETH_CC: '%GETH_MINGW%\bin\gcc.exe'
|
||||||
|
PATH: '%GETH_MINGW%\bin;C:\Program Files (x86)\NSIS\;%PATH%'
|
||||||
|
build_script:
|
||||||
|
- 'echo %GETH_ARCH%'
|
||||||
|
- 'echo %GETH_CC%'
|
||||||
|
- '%GETH_CC% --version'
|
||||||
|
- go run build/ci.go install -dlgo -arch %GETH_ARCH% -cc %GETH_CC%
|
||||||
|
after_build:
|
||||||
|
# Upload builds. Note that ci.go makes this a no-op PR builds.
|
||||||
|
- go run build/ci.go archive -arch %GETH_ARCH% -type zip -signer WINDOWS_SIGNING_KEY -upload gethstore/builds
|
||||||
|
- go run build/ci.go nsis -arch %GETH_ARCH% -signer WINDOWS_SIGNING_KEY -upload gethstore/builds
|
||||||
|
test_script:
|
||||||
|
- go run build/ci.go test -dlgo -arch %GETH_ARCH% -cc %GETH_CC% -coverage
|
||||||
|
|||||||
22
build/bot/macos-build.sh
Normal file
22
build/bot/macos-build.sh
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e -x
|
||||||
|
|
||||||
|
# -- Check XCode version
|
||||||
|
xcodebuild -version
|
||||||
|
# xcrun simctl list
|
||||||
|
|
||||||
|
# -- Build for macOS and upload to Azure
|
||||||
|
go run build/ci.go install -dlgo
|
||||||
|
go run build/ci.go archive -type tar # -signer OSX_SIGNING_KEY -upload gethstore/builds
|
||||||
|
|
||||||
|
# # -- CocoaPods
|
||||||
|
# gem uninstall cocoapods -a -x
|
||||||
|
# gem install cocoapods
|
||||||
|
# mv ~/.cocoapods/repos/master ~/.cocoapods/repos/master.bak
|
||||||
|
# sed -i '.bak' 's/repo.join/!repo.join/g' $(dirname `gem which cocoapods`)/cocoapods/sources_manager.rb
|
||||||
|
# git clone --depth=1 https://github.com/CocoaPods/Specs.git ~/.cocoapods/repos/master
|
||||||
|
# pod setup --verbose
|
||||||
|
|
||||||
|
# # -- Build for iOS and upload to Azure
|
||||||
|
# go run build/ci.go xcode -signer IOS_SIGNING_KEY -upload gethstore/builds
|
||||||
17
build/bot/ppa-build.sh
Normal file
17
build/bot/ppa-build.sh
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e -x
|
||||||
|
|
||||||
|
# Note: this script is meant to be run in a Debian/Ubuntu docker container,
|
||||||
|
# as user 'root'.
|
||||||
|
|
||||||
|
# Install the required tools for creating source packages.
|
||||||
|
apt-get -yq --no-install-suggests --no-install-recommends install\
|
||||||
|
devscripts debhelper dput fakeroot
|
||||||
|
|
||||||
|
# Add the SSH key of ppa.launchpad.net to known_hosts.
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
echo '|1|7SiYPr9xl3uctzovOTj4gMwAC1M=|t6ReES75Bo/PxlOPJ6/GsGbTrM0= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0aKz5UTUndYgIGG7dQBV+HaeuEZJ2xPHo2DS2iSKvUL4xNMSAY4UguNW+pX56nAQmZKIZZ8MaEvSj6zMEDiq6HFfn5JcTlM80UwlnyKe8B8p7Nk06PPQLrnmQt5fh0HmEcZx+JU9TZsfCHPnX7MNz4ELfZE6cFsclClrKim3BHUIGq//t93DllB+h4O9LHjEUsQ1Sr63irDLSutkLJD6RXchjROXkNirlcNVHH/jwLWR5RcYilNX7S5bIkK8NlWPjsn/8Ua5O7I9/YoE97PpO6i73DTGLh5H9JN/SITwCKBkgSDWUt61uPK3Y11Gty7o2lWsBjhBUm2Y38CBsoGmBw==' >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
|
# Build the source package and upload.
|
||||||
|
go run build/ci.go debsrc -upload ethereum/ethereum -sftp-user geth-ci -signer "Go Ethereum Linux Builder <geth-ci@ethereum.org>"
|
||||||
@@ -1,20 +1,58 @@
|
|||||||
# This file contains sha256 checksums of optional build dependencies.
|
# This file contains sha256 checksums of optional build dependencies.
|
||||||
|
|
||||||
69438f7ed4f532154ffaf878f3dfd83747e7a00b70b3556eddabf7aaee28ac3a go1.15.src.tar.gz
|
efd43e0f1402e083b73a03d444b7b6576bb4c539ac46208b63a916b69aca4088 go1.18.1.src.tar.gz
|
||||||
|
3703e9a0db1000f18c0c7b524f3d378aac71219b4715a6a4c5683eb639f41a4d go1.18.1.darwin-amd64.tar.gz
|
||||||
|
6d5641a06edba8cd6d425fb0adad06bad80e2afe0fa91b4aa0e5aed1bc78f58e go1.18.1.darwin-arm64.tar.gz
|
||||||
|
b9a9063d4265d8ccc046c9b314194d6eadc47e56d0d637db81e98e68aad45035 go1.18.1.freebsd-386.tar.gz
|
||||||
|
2bc1c138d645e37dbbc63517dd1cf1bf33fc4cb95f442a6384df0418b5134e9f go1.18.1.freebsd-amd64.tar.gz
|
||||||
|
9a8df5dde9058f08ac01ecfaae42534610db398e487138788c01da26a0d41ff9 go1.18.1.linux-386.tar.gz
|
||||||
|
b3b815f47ababac13810fc6021eb73d65478e0b2db4b09d348eefad9581a2334 go1.18.1.linux-amd64.tar.gz
|
||||||
|
56a91851c97fb4697077abbca38860f735c32b38993ff79b088dac46e4735633 go1.18.1.linux-arm64.tar.gz
|
||||||
|
9edc01c8e7db64e9ceeffc8258359e027812886ceca3444e83c4eb96ddb068ee go1.18.1.linux-armv6l.tar.gz
|
||||||
|
33db623d1eecf362fe365107c12efc90eff0b9609e0b3345e258388019cb552a go1.18.1.linux-ppc64le.tar.gz
|
||||||
|
5d9301324148ed4dbfaa0800da43a843ffd65c834ee73fcf087255697c925f74 go1.18.1.linux-s390x.tar.gz
|
||||||
|
49ae65551acbfaa57b52fbefa0350b2072512ae3103b8cf1a919a02626dbc743 go1.18.1.windows-386.zip
|
||||||
|
c30bc3f1f7314a953fe208bd9cd5e24bd9403392a6c556ced3677f9f70f71fe1 go1.18.1.windows-amd64.zip
|
||||||
|
2c4a8265030eac37f906634f5c13c22c3d0ea725f2488e1bca005c6b981653d7 go1.18.1.windows-arm64.zip
|
||||||
|
|
||||||
d998a84eea42f2271aca792a7b027ca5c1edfcba229e8e5a844c9ac3f336df35 golangci-lint-1.27.0-linux-armv7.tar.gz
|
03c181fc1bb29ea3e73cbb23399c43b081063833a7cf7554b94e5a98308df53e golangci-lint-1.45.2-linux-riscv64.deb
|
||||||
bf781f05b0d393b4bf0a327d9e62926949a4f14d7774d950c4e009fc766ed1d4 golangci-lint.exe-1.27.0-windows-amd64.zip
|
08a50bbbf451ede6d5354179eb3e14a5634e156dfa92cb9a2606f855a637e35b golangci-lint-1.45.2-linux-ppc64le.rpm
|
||||||
bf781f05b0d393b4bf0a327d9e62926949a4f14d7774d950c4e009fc766ed1d4 golangci-lint-1.27.0-windows-amd64.zip
|
0d12f6ec1296b5a70e392aa88cd2295cceef266165eb7028e675f455515dd1c9 golangci-lint-1.45.2-linux-armv7.deb
|
||||||
0e2a57d6ba709440d3ed018ef1037465fa010ed02595829092860e5cf863042e golangci-lint-1.27.0-freebsd-386.tar.gz
|
10f2846e2e50e4ea8ae426ee62dcd2227b23adddd8e991aa3c065927ac948735 golangci-lint-1.45.2-linux-ppc64le.deb
|
||||||
90205fc42ab5ed0096413e790d88ac9b4ed60f4c47e576d13dc0660f7ed4b013 golangci-lint-1.27.0-linux-arm64.tar.gz
|
1463049b744871168095e3e8f687247d6040eeb895955b869889ea151e0603ab golangci-lint-1.45.2-linux-arm64.tar.gz
|
||||||
8d345e4e88520e21c113d81978e89ad77fc5b13bfdf20e5bca86b83fc4261272 golangci-lint-1.27.0-linux-amd64.tar.gz
|
15720f9c4c6f9324af695f081dc189adc7751b255759e78d7b2df1d7e9192533 golangci-lint-1.45.2-linux-amd64.deb
|
||||||
cc619634a77f18dc73df2a0725be13116d64328dc35131ca1737a850d6f76a59 golangci-lint-1.27.0-freebsd-armv7.tar.gz
|
166d922e4d3cfe3d47786c590154a9c8ea689dff0aa92b73d2f5fc74fc570c29 golangci-lint-1.45.2-linux-arm64.rpm
|
||||||
fe683583cfc9eeec83e498c0d6159d87b5e1919dbe4b6c3b3913089642906069 golangci-lint-1.27.0-linux-s390x.tar.gz
|
1a3754c69f7cc19ab89cbdcc2550da4cf9abb3120383c6b3bd440c1ec22da2e6 golangci-lint-1.45.2-freebsd-386.tar.gz
|
||||||
058f5579bee75bdaacbaf75b75e1369f7ad877fd8b3b145aed17a17545de913e golangci-lint-1.27.0-freebsd-armv6.tar.gz
|
1dec0aa46d4f0d241863b573f70129bdf1de9c595cf51172a840a588a4cd9fc5 golangci-lint-1.45.2-windows-amd64.zip
|
||||||
38e1e3dadbe3f56ab62b4de82ee0b88e8fad966d8dfd740a26ef94c2edef9818 golangci-lint-1.27.0-linux-armv6.tar.gz
|
3198453806517c1ad988229f5e758ef850e671203f46d6905509df5bdf4dc24b golangci-lint-1.45.2-freebsd-armv7.tar.gz
|
||||||
071b34af5516f4e1ddcaea6011e18208f4f043e1af8ba21eeccad4585cb3d095 golangci-lint.exe-1.27.0-windows-386.zip
|
46a3cd1749d7b98adc2dc01510ddbe21abe42689c8a53fb0e81662713629f215 golangci-lint-1.45.2-linux-386.deb
|
||||||
071b34af5516f4e1ddcaea6011e18208f4f043e1af8ba21eeccad4585cb3d095 golangci-lint-1.27.0-windows-386.zip
|
4e28bfb593d464b9e160f2acd5b71993836a183270bf8299b78ad31f7a168c0d golangci-lint-1.45.2-linux-arm64.deb
|
||||||
5f37e2b33914ecddb7cad38186ef4ec61d88172fc04f930fa0267c91151ff306 golangci-lint-1.27.0-linux-386.tar.gz
|
5157a58c8f9ab85c33af2e46f0d7c57a3b1e8953b81d61130e292e09f545cfab golangci-lint-1.45.2-linux-mips64le.tar.gz
|
||||||
4d94cfb51fdebeb205f1d5a349ac2b683c30591c5150708073c1c329e15965f0 golangci-lint-1.27.0-freebsd-amd64.tar.gz
|
518cd027644129fbf8ec4f02bd6f9ad7278aae826f92b63c80d4d0819ddde49a golangci-lint-1.45.2-linux-armv6.rpm
|
||||||
52572ba8ff07d5169c2365d3de3fec26dc55a97522094d13d1596199580fa281 golangci-lint-1.27.0-linux-ppc64le.tar.gz
|
595ad6c6dade4c064351bc309f411703e457f8ffbb7a1806b3d8ee713333427f golangci-lint-1.45.2-linux-amd64.tar.gz
|
||||||
3fb1a1683a29c6c0a8cd76135f62b606fbdd538d5a7aeab94af1af70ffdc2fd4 golangci-lint-1.27.0-darwin-amd64.tar.gz
|
6994d6c80f0730751090986184a3481b4be2e6b6e84416238a2b857910045a4f golangci-lint-1.45.2-windows-arm64.zip
|
||||||
|
6c81652fc340118811b487f713c441fc6f527800bf5fd11b8929d08124efa015 golangci-lint-1.45.2-linux-armv7.tar.gz
|
||||||
|
726cb045559b7518bafdd3459de70a0647c087eb1b4634627a4b2e95b1258580 golangci-lint-1.45.2-freebsd-amd64.tar.gz
|
||||||
|
77df3774cdfda49b956d4a0e676da9a9b883f496ee37293c530770fef6b1d24e golangci-lint-1.45.2-linux-mips64.deb
|
||||||
|
7a9840f279a7d5d405bb434e101c2290964b3729630ac2add29280b962b7b9a5 golangci-lint-1.45.2-windows-armv6.zip
|
||||||
|
7d4bf9a5d80ec467aaaf66e78dbdcab567bbc6ba8151334c714eee58766aae32 golangci-lint-1.45.2-windows-armv7.zip
|
||||||
|
7e5f8821d39bb11d273b0841b34355f56bd5a45a2d5179f0d09e614e0efc0482 golangci-lint-1.45.2-linux-s390x.rpm
|
||||||
|
828de1bde796b23d8656b17a8885fbd879ef612795d62d1e4618126b419728b5 golangci-lint-1.45.2-linux-mips64.rpm
|
||||||
|
879a52107a797678a03c175cc7cf441411a14a01f66dc87f70bdfa304a4129a6 golangci-lint-1.45.2-windows-386.zip
|
||||||
|
87b6c7e3a3769f7d9abeb3bb82119b3c91e3c975300f6834fdeef8b2e37c98ff golangci-lint-1.45.2-linux-amd64.rpm
|
||||||
|
8b605c6d686c8af53ecc4ef39544541eeb1644d34cc10f9ffc5087808210c4ff golangci-lint-1.45.2-linux-s390x.deb
|
||||||
|
9427dbf51d0ac6f73a0f992838bd40c817470cc5bf6c8e2e2bea6fac46d7af6e golangci-lint-1.45.2-linux-ppc64le.tar.gz
|
||||||
|
995e509e895ca6a64ffc7395ac884d5961bdec98423cb896b17f345a9b4a19cf golangci-lint-1.45.2-darwin-amd64.tar.gz
|
||||||
|
a3f36278f2ea5516341e9071a2df6e65df272be80230b5406a12b72c6d425bee golangci-lint-1.45.2-linux-armv7.rpm
|
||||||
|
a5e12c50c23e87ac1deffc872f92ae85427b1198604969399805ae47cfe43f08 golangci-lint-1.45.2-linux-riscv64.tar.gz
|
||||||
|
aa8fa1be0729dbc2fbc4e01e82027097613eee74bd686ebef20f860b01fff8b3 golangci-lint-1.45.2-freebsd-armv6.tar.gz
|
||||||
|
c2b9669decc1b638cf2ee9060571af4e255f6dfcbb225c293e3a7ee4bb2c7217 golangci-lint-1.45.2-darwin-arm64.tar.gz
|
||||||
|
dfa8bdaf0387aec1cd5c1aa8857f67b2bbdfc2e42efce540c8fb9bbe3e8af302 golangci-lint-1.45.2-linux-armv6.tar.gz
|
||||||
|
eb8b8539dd017eee5c131ea9b875893ab2cebeeca41e8c6624907fb02224d643 golangci-lint-1.45.2-linux-386.rpm
|
||||||
|
ed6c7e17a857f30d715c5302fa250d95936936b277024bffea201187a257d7a7 golangci-lint-1.45.2-linux-armv6.deb
|
||||||
|
ef4d0154ace4001f01b288baeb118176242efb4fd163e178763e3213b77ef30b golangci-lint-1.45.2-linux-mips64le.deb
|
||||||
|
ef7002a2229f5ff5ba201a715fcf877664ea88decbe58e69d163293913024955 golangci-lint-1.45.2-linux-s390x.tar.gz
|
||||||
|
f13ecbd09228632e6bbe91a8324bd675c406eed22eb6d2c1e8192eed9ec4f914 golangci-lint-1.45.2-linux-386.tar.gz
|
||||||
|
f4cd9cfb09252f51699407277512263cae8409b665dd764f55a34738d0e89edc golangci-lint-1.45.2-linux-riscv64.rpm
|
||||||
|
fb1945dc59d37c9d14bf0a4aea11ea8651fa0e1d582ea80c4c44d0a536c08893 golangci-lint-1.45.2-linux-mips64.tar.gz
|
||||||
|
fe542c22738010f453c735a3c410decfd3784d1bd394b395c298ee298fc4c606 golangci-lint-1.45.2-linux-mips64le.rpm
|
||||||
|
|||||||
573
build/ci.go
573
build/ci.go
@@ -14,6 +14,7 @@
|
|||||||
// You should have received a copy of the GNU Lesser General Public License
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//go:build none
|
||||||
// +build none
|
// +build none
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -26,13 +27,12 @@ Available commands are:
|
|||||||
install [ -arch architecture ] [ -cc compiler ] [ packages... ] -- builds packages and executables
|
install [ -arch architecture ] [ -cc compiler ] [ packages... ] -- builds packages and executables
|
||||||
test [ -coverage ] [ packages... ] -- runs the tests
|
test [ -coverage ] [ packages... ] -- runs the tests
|
||||||
lint -- runs certain pre-selected linters
|
lint -- runs certain pre-selected linters
|
||||||
archive [ -arch architecture ] [ -type zip|tar ] [ -signer key-envvar ] [ -upload dest ] -- archives build artifacts
|
archive [ -arch architecture ] [ -type zip|tar ] [ -signer key-envvar ] [ -signify key-envvar ] [ -upload dest ] -- archives build artifacts
|
||||||
importkeys -- imports signing keys from env
|
importkeys -- imports signing keys from env
|
||||||
debsrc [ -signer key-id ] [ -upload dest ] -- creates a debian source package
|
debsrc [ -signer key-id ] [ -upload dest ] -- creates a debian source package
|
||||||
nsis -- creates a Windows NSIS installer
|
nsis -- creates a Windows NSIS installer
|
||||||
aar [ -local ] [ -sign key-id ] [-deploy repo] [ -upload dest ] -- creates an Android archive
|
aar [ -local ] [ -sign key-id ] [-deploy repo] [ -upload dest ] -- creates an Android archive
|
||||||
xcode [ -local ] [ -sign key-id ] [-deploy repo] [ -upload dest ] -- creates an iOS XCode framework
|
xcode [ -local ] [ -sign key-id ] [-deploy repo] [ -upload dest ] -- creates an iOS XCode framework
|
||||||
xgo [ -alltools ] [ options ] -- cross builds according to options
|
|
||||||
purge [ -store blobstore ] [ -days threshold ] -- purges old archives from the blobstore
|
purge [ -store blobstore ] [ -days threshold ] -- purges old archives from the blobstore
|
||||||
|
|
||||||
For all commands, -n prevents execution of external programs (dry run mode).
|
For all commands, -n prevents execution of external programs (dry run mode).
|
||||||
@@ -46,19 +46,20 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/parser"
|
|
||||||
"go/token"
|
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/cespare/cp"
|
"github.com/cespare/cp"
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/crypto/signify"
|
||||||
"github.com/ethereum/go-ethereum/internal/build"
|
"github.com/ethereum/go-ethereum/internal/build"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
)
|
)
|
||||||
@@ -115,7 +116,6 @@ var (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// A debian package is created for all executables listed here.
|
// A debian package is created for all executables listed here.
|
||||||
|
|
||||||
debEthereum = debPackage{
|
debEthereum = debPackage{
|
||||||
Name: "ethereum",
|
Name: "ethereum",
|
||||||
Version: params.Version,
|
Version: params.Version,
|
||||||
@@ -129,25 +129,27 @@ var (
|
|||||||
|
|
||||||
// Distros for which packages are created.
|
// Distros for which packages are created.
|
||||||
// Note: vivid is unsupported because there is no golang-1.6 package for it.
|
// Note: vivid is unsupported because there is no golang-1.6 package for it.
|
||||||
// Note: wily is unsupported because it was officially deprecated on Launchpad.
|
// Note: the following Ubuntu releases have been officially deprecated on Launchpad:
|
||||||
// Note: yakkety is unsupported because it was officially deprecated on Launchpad.
|
// wily, yakkety, zesty, artful, cosmic, disco, eoan, groovy, hirsuite
|
||||||
// Note: zesty is unsupported because it was officially deprecated on Launchpad.
|
|
||||||
// Note: artful is unsupported because it was officially deprecated on Launchpad.
|
|
||||||
// Note: cosmic is unsupported because it was officially deprecated on Launchpad.
|
|
||||||
// Note: disco is unsupported because it was officially deprecated on Launchpad.
|
|
||||||
debDistroGoBoots = map[string]string{
|
debDistroGoBoots = map[string]string{
|
||||||
"trusty": "golang-1.11",
|
"trusty": "golang-1.11", // EOL: 04/2024
|
||||||
"xenial": "golang-go",
|
"xenial": "golang-go", // EOL: 04/2026
|
||||||
"bionic": "golang-go",
|
"bionic": "golang-go", // EOL: 04/2028
|
||||||
"eoan": "golang-go",
|
"focal": "golang-go", // EOL: 04/2030
|
||||||
"focal": "golang-go",
|
"impish": "golang-go", // EOL: 07/2022
|
||||||
"groovy": "golang-go",
|
"jammy": "golang-go", // EOL: 04/2032
|
||||||
|
//"kinetic": "golang-go", // EOL: 07/2023
|
||||||
}
|
}
|
||||||
|
|
||||||
debGoBootPaths = map[string]string{
|
debGoBootPaths = map[string]string{
|
||||||
"golang-1.11": "/usr/lib/go-1.11",
|
"golang-1.11": "/usr/lib/go-1.11",
|
||||||
"golang-go": "/usr/lib/go",
|
"golang-go": "/usr/lib/go",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is the version of go that will be downloaded by
|
||||||
|
//
|
||||||
|
// go run ci.go install -dlgo
|
||||||
|
dlgoVersion = "1.18.1"
|
||||||
)
|
)
|
||||||
|
|
||||||
var GOBIN, _ = filepath.Abs(filepath.Join("build", "bin"))
|
var GOBIN, _ = filepath.Abs(filepath.Join("build", "bin"))
|
||||||
@@ -162,7 +164,7 @@ func executablePath(name string) string {
|
|||||||
func main() {
|
func main() {
|
||||||
log.SetFlags(log.Lshortfile)
|
log.SetFlags(log.Lshortfile)
|
||||||
|
|
||||||
if _, err := os.Stat(filepath.Join("build", "ci.go")); os.IsNotExist(err) {
|
if !common.FileExist(filepath.Join("build", "ci.go")) {
|
||||||
log.Fatal("this script must be run from the root of the repository")
|
log.Fatal("this script must be run from the root of the repository")
|
||||||
}
|
}
|
||||||
if len(os.Args) < 2 {
|
if len(os.Args) < 2 {
|
||||||
@@ -177,6 +179,8 @@ func main() {
|
|||||||
doLint(os.Args[2:])
|
doLint(os.Args[2:])
|
||||||
case "archive":
|
case "archive":
|
||||||
doArchive(os.Args[2:])
|
doArchive(os.Args[2:])
|
||||||
|
case "docker":
|
||||||
|
doDocker(os.Args[2:])
|
||||||
case "debsrc":
|
case "debsrc":
|
||||||
doDebianSource(os.Args[2:])
|
doDebianSource(os.Args[2:])
|
||||||
case "nsis":
|
case "nsis":
|
||||||
@@ -185,8 +189,6 @@ func main() {
|
|||||||
doAndroidArchive(os.Args[2:])
|
doAndroidArchive(os.Args[2:])
|
||||||
case "xcode":
|
case "xcode":
|
||||||
doXCodeFramework(os.Args[2:])
|
doXCodeFramework(os.Args[2:])
|
||||||
case "xgo":
|
|
||||||
doXgo(os.Args[2:])
|
|
||||||
case "purge":
|
case "purge":
|
||||||
doPurge(os.Args[2:])
|
doPurge(os.Args[2:])
|
||||||
default:
|
default:
|
||||||
@@ -198,131 +200,101 @@ func main() {
|
|||||||
|
|
||||||
func doInstall(cmdline []string) {
|
func doInstall(cmdline []string) {
|
||||||
var (
|
var (
|
||||||
|
dlgo = flag.Bool("dlgo", false, "Download Go and build with it")
|
||||||
arch = flag.String("arch", "", "Architecture to cross build for")
|
arch = flag.String("arch", "", "Architecture to cross build for")
|
||||||
cc = flag.String("cc", "", "C compiler to cross build with")
|
cc = flag.String("cc", "", "C compiler to cross build with")
|
||||||
)
|
)
|
||||||
flag.CommandLine.Parse(cmdline)
|
flag.CommandLine.Parse(cmdline)
|
||||||
|
|
||||||
|
// Configure the toolchain.
|
||||||
|
tc := build.GoToolchain{GOARCH: *arch, CC: *cc}
|
||||||
|
if *dlgo {
|
||||||
|
csdb := build.MustLoadChecksums("build/checksums.txt")
|
||||||
|
tc.Root = build.DownloadGo(csdb, dlgoVersion)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Configure the build.
|
||||||
env := build.Env()
|
env := build.Env()
|
||||||
|
gobuild := tc.Go("build", buildFlags(env)...)
|
||||||
|
|
||||||
// Check Go version. People regularly open issues about compilation
|
// arm64 CI builders are memory-constrained and can't handle concurrent builds,
|
||||||
// failure with outdated Go. This should save them the trouble.
|
// better disable it. This check isn't the best, it should probably
|
||||||
if !strings.Contains(runtime.Version(), "devel") {
|
// check for something in env instead.
|
||||||
// Figure out the minor version number since we can't textually compare (1.10 < 1.9)
|
if env.CI && runtime.GOARCH == "arm64" {
|
||||||
var minor int
|
gobuild.Args = append(gobuild.Args, "-p", "1")
|
||||||
fmt.Sscanf(strings.TrimPrefix(runtime.Version(), "go1."), "%d", &minor)
|
|
||||||
|
|
||||||
if minor < 13 {
|
|
||||||
log.Println("You have Go version", runtime.Version())
|
|
||||||
log.Println("go-ethereum requires at least Go version 1.13 and cannot")
|
|
||||||
log.Println("be compiled with an earlier version. Please upgrade your Go installation.")
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Compile packages given as arguments, or everything if there are no arguments.
|
|
||||||
packages := []string{"./..."}
|
|
||||||
if flag.NArg() > 0 {
|
|
||||||
packages = flag.Args()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if *arch == "" || *arch == runtime.GOARCH {
|
// We use -trimpath to avoid leaking local paths into the built executables.
|
||||||
goinstall := goTool("install", buildFlags(env)...)
|
gobuild.Args = append(gobuild.Args, "-trimpath")
|
||||||
if runtime.GOARCH == "arm64" {
|
|
||||||
goinstall.Args = append(goinstall.Args, "-p", "1")
|
// Show packages during build.
|
||||||
}
|
gobuild.Args = append(gobuild.Args, "-v")
|
||||||
goinstall.Args = append(goinstall.Args, "-trimpath")
|
|
||||||
goinstall.Args = append(goinstall.Args, "-v")
|
// Now we choose what we're even building.
|
||||||
goinstall.Args = append(goinstall.Args, packages...)
|
// Default: collect all 'main' packages in cmd/ and build those.
|
||||||
build.MustRun(goinstall)
|
packages := flag.Args()
|
||||||
return
|
if len(packages) == 0 {
|
||||||
|
packages = build.FindMainPackages("./cmd")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Seems we are cross compiling, work around forbidden GOBIN
|
// Do the build!
|
||||||
goinstall := goToolArch(*arch, *cc, "install", buildFlags(env)...)
|
for _, pkg := range packages {
|
||||||
goinstall.Args = append(goinstall.Args, "-trimpath")
|
args := make([]string, len(gobuild.Args))
|
||||||
goinstall.Args = append(goinstall.Args, "-v")
|
copy(args, gobuild.Args)
|
||||||
goinstall.Args = append(goinstall.Args, []string{"-buildmode", "archive"}...)
|
args = append(args, "-o", executablePath(path.Base(pkg)))
|
||||||
goinstall.Args = append(goinstall.Args, packages...)
|
args = append(args, pkg)
|
||||||
build.MustRun(goinstall)
|
build.MustRun(&exec.Cmd{Path: gobuild.Path, Args: args, Env: gobuild.Env})
|
||||||
|
|
||||||
if cmds, err := ioutil.ReadDir("cmd"); err == nil {
|
|
||||||
for _, cmd := range cmds {
|
|
||||||
pkgs, err := parser.ParseDir(token.NewFileSet(), filepath.Join(".", "cmd", cmd.Name()), nil, parser.PackageClauseOnly)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
for name := range pkgs {
|
|
||||||
if name == "main" {
|
|
||||||
gobuild := goToolArch(*arch, *cc, "build", buildFlags(env)...)
|
|
||||||
gobuild.Args = append(gobuild.Args, "-v")
|
|
||||||
gobuild.Args = append(gobuild.Args, []string{"-o", executablePath(cmd.Name())}...)
|
|
||||||
gobuild.Args = append(gobuild.Args, "."+string(filepath.Separator)+filepath.Join("cmd", cmd.Name()))
|
|
||||||
build.MustRun(gobuild)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// buildFlags returns the go tool flags for building.
|
||||||
func buildFlags(env build.Environment) (flags []string) {
|
func buildFlags(env build.Environment) (flags []string) {
|
||||||
var ld []string
|
var ld []string
|
||||||
if env.Commit != "" {
|
if env.Commit != "" {
|
||||||
ld = append(ld, "-X", "main.gitCommit="+env.Commit)
|
ld = append(ld, "-X", "main.gitCommit="+env.Commit)
|
||||||
ld = append(ld, "-X", "main.gitDate="+env.Date)
|
ld = append(ld, "-X", "main.gitDate="+env.Date)
|
||||||
}
|
}
|
||||||
|
// Strip DWARF on darwin. This used to be required for certain things,
|
||||||
|
// and there is no downside to this, so we just keep doing it.
|
||||||
if runtime.GOOS == "darwin" {
|
if runtime.GOOS == "darwin" {
|
||||||
ld = append(ld, "-s")
|
ld = append(ld, "-s")
|
||||||
}
|
}
|
||||||
|
// Enforce the stacksize to 8M, which is the case on most platforms apart from
|
||||||
|
// alpine Linux.
|
||||||
|
if runtime.GOOS == "linux" {
|
||||||
|
ld = append(ld, "-extldflags", "-Wl,-z,stack-size=0x800000")
|
||||||
|
}
|
||||||
if len(ld) > 0 {
|
if len(ld) > 0 {
|
||||||
flags = append(flags, "-ldflags", strings.Join(ld, " "))
|
flags = append(flags, "-ldflags", strings.Join(ld, " "))
|
||||||
}
|
}
|
||||||
return flags
|
return flags
|
||||||
}
|
}
|
||||||
|
|
||||||
func goTool(subcmd string, args ...string) *exec.Cmd {
|
|
||||||
return goToolArch(runtime.GOARCH, os.Getenv("CC"), subcmd, args...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func goToolArch(arch string, cc string, subcmd string, args ...string) *exec.Cmd {
|
|
||||||
cmd := build.GoTool(subcmd, args...)
|
|
||||||
if arch == "" || arch == runtime.GOARCH {
|
|
||||||
cmd.Env = append(cmd.Env, "GOBIN="+GOBIN)
|
|
||||||
} else {
|
|
||||||
cmd.Env = append(cmd.Env, "CGO_ENABLED=1")
|
|
||||||
cmd.Env = append(cmd.Env, "GOARCH="+arch)
|
|
||||||
}
|
|
||||||
if cc != "" {
|
|
||||||
cmd.Env = append(cmd.Env, "CC="+cc)
|
|
||||||
}
|
|
||||||
for _, e := range os.Environ() {
|
|
||||||
if strings.HasPrefix(e, "GOBIN=") {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
cmd.Env = append(cmd.Env, e)
|
|
||||||
}
|
|
||||||
return cmd
|
|
||||||
}
|
|
||||||
|
|
||||||
// Running The Tests
|
// Running The Tests
|
||||||
//
|
//
|
||||||
// "tests" also includes static analysis tools such as vet.
|
// "tests" also includes static analysis tools such as vet.
|
||||||
|
|
||||||
func doTest(cmdline []string) {
|
func doTest(cmdline []string) {
|
||||||
coverage := flag.Bool("coverage", false, "Whether to record code coverage")
|
var (
|
||||||
verbose := flag.Bool("v", false, "Whether to log verbosely")
|
dlgo = flag.Bool("dlgo", false, "Download Go and build with it")
|
||||||
|
arch = flag.String("arch", "", "Run tests for given architecture")
|
||||||
|
cc = flag.String("cc", "", "Sets C compiler binary")
|
||||||
|
coverage = flag.Bool("coverage", false, "Whether to record code coverage")
|
||||||
|
verbose = flag.Bool("v", false, "Whether to log verbosely")
|
||||||
|
race = flag.Bool("race", false, "Execute the race detector")
|
||||||
|
)
|
||||||
flag.CommandLine.Parse(cmdline)
|
flag.CommandLine.Parse(cmdline)
|
||||||
env := build.Env()
|
|
||||||
|
|
||||||
packages := []string{"./..."}
|
// Configure the toolchain.
|
||||||
if len(flag.CommandLine.Args()) > 0 {
|
tc := build.GoToolchain{GOARCH: *arch, CC: *cc}
|
||||||
packages = flag.CommandLine.Args()
|
if *dlgo {
|
||||||
|
csdb := build.MustLoadChecksums("build/checksums.txt")
|
||||||
|
tc.Root = build.DownloadGo(csdb, dlgoVersion)
|
||||||
}
|
}
|
||||||
|
gotest := tc.Go("test")
|
||||||
|
|
||||||
// Run the actual tests.
|
|
||||||
// Test a single package at a time. CI builders are slow
|
// Test a single package at a time. CI builders are slow
|
||||||
// and some tests run into timeouts under load.
|
// and some tests run into timeouts under load.
|
||||||
gotest := goTool("test", buildFlags(env)...)
|
|
||||||
gotest.Args = append(gotest.Args, "-p", "1")
|
gotest.Args = append(gotest.Args, "-p", "1")
|
||||||
if *coverage {
|
if *coverage {
|
||||||
gotest.Args = append(gotest.Args, "-covermode=atomic", "-cover")
|
gotest.Args = append(gotest.Args, "-covermode=atomic", "-cover")
|
||||||
@@ -330,7 +302,14 @@ func doTest(cmdline []string) {
|
|||||||
if *verbose {
|
if *verbose {
|
||||||
gotest.Args = append(gotest.Args, "-v")
|
gotest.Args = append(gotest.Args, "-v")
|
||||||
}
|
}
|
||||||
|
if *race {
|
||||||
|
gotest.Args = append(gotest.Args, "-race")
|
||||||
|
}
|
||||||
|
|
||||||
|
packages := []string{"./..."}
|
||||||
|
if len(flag.CommandLine.Args()) > 0 {
|
||||||
|
packages = flag.CommandLine.Args()
|
||||||
|
}
|
||||||
gotest.Args = append(gotest.Args, packages...)
|
gotest.Args = append(gotest.Args, packages...)
|
||||||
build.MustRun(gotest)
|
build.MustRun(gotest)
|
||||||
}
|
}
|
||||||
@@ -354,16 +333,25 @@ func doLint(cmdline []string) {
|
|||||||
|
|
||||||
// downloadLinter downloads and unpacks golangci-lint.
|
// downloadLinter downloads and unpacks golangci-lint.
|
||||||
func downloadLinter(cachedir string) string {
|
func downloadLinter(cachedir string) string {
|
||||||
const version = "1.27.0"
|
const version = "1.45.2"
|
||||||
|
|
||||||
csdb := build.MustLoadChecksums("build/checksums.txt")
|
csdb := build.MustLoadChecksums("build/checksums.txt")
|
||||||
base := fmt.Sprintf("golangci-lint-%s-%s-%s", version, runtime.GOOS, runtime.GOARCH)
|
arch := runtime.GOARCH
|
||||||
url := fmt.Sprintf("https://github.com/golangci/golangci-lint/releases/download/v%s/%s.tar.gz", version, base)
|
ext := ".tar.gz"
|
||||||
archivePath := filepath.Join(cachedir, base+".tar.gz")
|
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
ext = ".zip"
|
||||||
|
}
|
||||||
|
if arch == "arm" {
|
||||||
|
arch += "v" + os.Getenv("GOARM")
|
||||||
|
}
|
||||||
|
base := fmt.Sprintf("golangci-lint-%s-%s-%s", version, runtime.GOOS, arch)
|
||||||
|
url := fmt.Sprintf("https://github.com/golangci/golangci-lint/releases/download/v%s/%s%s", version, base, ext)
|
||||||
|
archivePath := filepath.Join(cachedir, base+ext)
|
||||||
if err := csdb.DownloadFile(url, archivePath); err != nil {
|
if err := csdb.DownloadFile(url, archivePath); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
if err := build.ExtractTarballArchive(archivePath, cachedir); err != nil {
|
if err := build.ExtractArchive(archivePath, cachedir); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
return filepath.Join(cachedir, base, "golangci-lint")
|
return filepath.Join(cachedir, base, "golangci-lint")
|
||||||
@@ -372,11 +360,12 @@ func downloadLinter(cachedir string) string {
|
|||||||
// Release Packaging
|
// Release Packaging
|
||||||
func doArchive(cmdline []string) {
|
func doArchive(cmdline []string) {
|
||||||
var (
|
var (
|
||||||
arch = flag.String("arch", runtime.GOARCH, "Architecture cross packaging")
|
arch = flag.String("arch", runtime.GOARCH, "Architecture cross packaging")
|
||||||
atype = flag.String("type", "zip", "Type of archive to write (zip|tar)")
|
atype = flag.String("type", "zip", "Type of archive to write (zip|tar)")
|
||||||
signer = flag.String("signer", "", `Environment variable holding the signing key (e.g. LINUX_SIGNING_KEY)`)
|
signer = flag.String("signer", "", `Environment variable holding the signing key (e.g. LINUX_SIGNING_KEY)`)
|
||||||
upload = flag.String("upload", "", `Destination to upload the archives (usually "gethstore/builds")`)
|
signify = flag.String("signify", "", `Environment variable holding the signify key (e.g. LINUX_SIGNIFY_KEY)`)
|
||||||
ext string
|
upload = flag.String("upload", "", `Destination to upload the archives (usually "gethstore/builds")`)
|
||||||
|
ext string
|
||||||
)
|
)
|
||||||
flag.CommandLine.Parse(cmdline)
|
flag.CommandLine.Parse(cmdline)
|
||||||
switch *atype {
|
switch *atype {
|
||||||
@@ -389,8 +378,7 @@ func doArchive(cmdline []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
env = build.Env()
|
env = build.Env()
|
||||||
|
|
||||||
basegeth = archiveBasename(*arch, params.ArchiveVersion(env.Commit))
|
basegeth = archiveBasename(*arch, params.ArchiveVersion(env.Commit))
|
||||||
geth = "geth-" + basegeth + ext
|
geth = "geth-" + basegeth + ext
|
||||||
alltools = "geth-alltools-" + basegeth + ext
|
alltools = "geth-alltools-" + basegeth + ext
|
||||||
@@ -403,7 +391,7 @@ func doArchive(cmdline []string) {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
for _, archive := range []string{geth, alltools} {
|
for _, archive := range []string{geth, alltools} {
|
||||||
if err := archiveUpload(archive, *upload, *signer); err != nil {
|
if err := archiveUpload(archive, *upload, *signer, *signify); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -423,7 +411,7 @@ func archiveBasename(arch string, archiveVersion string) string {
|
|||||||
return platform + "-" + archiveVersion
|
return platform + "-" + archiveVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
func archiveUpload(archive string, blobstore string, signer string) error {
|
func archiveUpload(archive string, blobstore string, signer string, signifyVar string) error {
|
||||||
// If signing was requested, generate the signature files
|
// If signing was requested, generate the signature files
|
||||||
if signer != "" {
|
if signer != "" {
|
||||||
key := getenvBase64(signer)
|
key := getenvBase64(signer)
|
||||||
@@ -431,6 +419,14 @@ func archiveUpload(archive string, blobstore string, signer string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if signifyVar != "" {
|
||||||
|
key := os.Getenv(signifyVar)
|
||||||
|
untrustedComment := "verify with geth-release.pub"
|
||||||
|
trustedComment := fmt.Sprintf("%s (%s)", archive, time.Now().UTC().Format(time.RFC1123))
|
||||||
|
if err := signify.SignFile(archive, archive+".sig", key, untrustedComment, trustedComment); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
// If uploading to Azure was requested, push the archive possibly with its signature
|
// If uploading to Azure was requested, push the archive possibly with its signature
|
||||||
if blobstore != "" {
|
if blobstore != "" {
|
||||||
auth := build.AzureBlobstoreConfig{
|
auth := build.AzureBlobstoreConfig{
|
||||||
@@ -446,6 +442,11 @@ func archiveUpload(archive string, blobstore string, signer string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if signifyVar != "" {
|
||||||
|
if err := build.AzureBlobstoreUpload(archive+".sig", filepath.Base(archive+".sig"), auth); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -453,33 +454,199 @@ func archiveUpload(archive string, blobstore string, signer string) error {
|
|||||||
// skips archiving for some build configurations.
|
// skips archiving for some build configurations.
|
||||||
func maybeSkipArchive(env build.Environment) {
|
func maybeSkipArchive(env build.Environment) {
|
||||||
if env.IsPullRequest {
|
if env.IsPullRequest {
|
||||||
log.Printf("skipping because this is a PR build")
|
log.Printf("skipping archive creation because this is a PR build")
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
if env.IsCronJob {
|
if env.IsCronJob {
|
||||||
log.Printf("skipping because this is a cron job")
|
log.Printf("skipping archive creation because this is a cron job")
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
if env.Branch != "master" && !strings.HasPrefix(env.Tag, "v1.") {
|
if env.Branch != "master" && !strings.HasPrefix(env.Tag, "v1.") {
|
||||||
log.Printf("skipping because branch %q, tag %q is not on the whitelist", env.Branch, env.Tag)
|
log.Printf("skipping archive creation because branch %q, tag %q is not on the inclusion list", env.Branch, env.Tag)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Builds the docker images and optionally uploads them to Docker Hub.
|
||||||
|
func doDocker(cmdline []string) {
|
||||||
|
var (
|
||||||
|
image = flag.Bool("image", false, `Whether to build and push an arch specific docker image`)
|
||||||
|
manifest = flag.String("manifest", "", `Push a multi-arch docker image for the specified architectures (usually "amd64,arm64")`)
|
||||||
|
upload = flag.String("upload", "", `Where to upload the docker image (usually "ethereum/client-go")`)
|
||||||
|
)
|
||||||
|
flag.CommandLine.Parse(cmdline)
|
||||||
|
|
||||||
|
// Skip building and pushing docker images for PR builds
|
||||||
|
env := build.Env()
|
||||||
|
maybeSkipArchive(env)
|
||||||
|
|
||||||
|
// Retrieve the upload credentials and authenticate
|
||||||
|
user := getenvBase64("DOCKER_HUB_USERNAME")
|
||||||
|
pass := getenvBase64("DOCKER_HUB_PASSWORD")
|
||||||
|
|
||||||
|
if len(user) > 0 && len(pass) > 0 {
|
||||||
|
auther := exec.Command("docker", "login", "-u", string(user), "--password-stdin")
|
||||||
|
auther.Stdin = bytes.NewReader(pass)
|
||||||
|
build.MustRun(auther)
|
||||||
|
}
|
||||||
|
// Retrieve the version infos to build and push to the following paths:
|
||||||
|
// - ethereum/client-go:latest - Pushes to the master branch, Geth only
|
||||||
|
// - ethereum/client-go:stable - Version tag publish on GitHub, Geth only
|
||||||
|
// - ethereum/client-go:alltools-latest - Pushes to the master branch, Geth & tools
|
||||||
|
// - ethereum/client-go:alltools-stable - Version tag publish on GitHub, Geth & tools
|
||||||
|
// - ethereum/client-go:release-<major>.<minor> - Version tag publish on GitHub, Geth only
|
||||||
|
// - ethereum/client-go:alltools-release-<major>.<minor> - Version tag publish on GitHub, Geth & tools
|
||||||
|
// - ethereum/client-go:v<major>.<minor>.<patch> - Version tag publish on GitHub, Geth only
|
||||||
|
// - ethereum/client-go:alltools-v<major>.<minor>.<patch> - Version tag publish on GitHub, Geth & tools
|
||||||
|
var tags []string
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case env.Branch == "master":
|
||||||
|
tags = []string{"latest"}
|
||||||
|
case strings.HasPrefix(env.Tag, "v1."):
|
||||||
|
tags = []string{"stable", fmt.Sprintf("release-1.%d", params.VersionMinor), "v" + params.Version}
|
||||||
|
}
|
||||||
|
// If architecture specific image builds are requested, build and push them
|
||||||
|
if *image {
|
||||||
|
build.MustRunCommand("docker", "build", "--build-arg", "COMMIT="+env.Commit, "--build-arg", "VERSION="+params.VersionWithMeta, "--build-arg", "BUILDNUM="+env.Buildnum, "--tag", fmt.Sprintf("%s:TAG", *upload), ".")
|
||||||
|
build.MustRunCommand("docker", "build", "--build-arg", "COMMIT="+env.Commit, "--build-arg", "VERSION="+params.VersionWithMeta, "--build-arg", "BUILDNUM="+env.Buildnum, "--tag", fmt.Sprintf("%s:alltools-TAG", *upload), "-f", "Dockerfile.alltools", ".")
|
||||||
|
|
||||||
|
// Tag and upload the images to Docker Hub
|
||||||
|
for _, tag := range tags {
|
||||||
|
gethImage := fmt.Sprintf("%s:%s-%s", *upload, tag, runtime.GOARCH)
|
||||||
|
toolImage := fmt.Sprintf("%s:alltools-%s-%s", *upload, tag, runtime.GOARCH)
|
||||||
|
|
||||||
|
// If the image already exists (non version tag), check the build
|
||||||
|
// number to prevent overwriting a newer commit if concurrent builds
|
||||||
|
// are running. This is still a tiny bit racey if two published are
|
||||||
|
// done at the same time, but that's extremely unlikely even on the
|
||||||
|
// master branch.
|
||||||
|
for _, img := range []string{gethImage, toolImage} {
|
||||||
|
if exec.Command("docker", "pull", img).Run() != nil {
|
||||||
|
continue // Generally the only failure is a missing image, which is good
|
||||||
|
}
|
||||||
|
buildnum, err := exec.Command("docker", "inspect", "--format", "{{index .Config.Labels \"buildnum\"}}", img).CombinedOutput()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Failed to inspect container: %v\nOutput: %s", err, string(buildnum))
|
||||||
|
}
|
||||||
|
buildnum = bytes.TrimSpace(buildnum)
|
||||||
|
|
||||||
|
if len(buildnum) > 0 && len(env.Buildnum) > 0 {
|
||||||
|
oldnum, err := strconv.Atoi(string(buildnum))
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Failed to parse old image build number: %v", err)
|
||||||
|
}
|
||||||
|
newnum, err := strconv.Atoi(env.Buildnum)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Failed to parse current build number: %v", err)
|
||||||
|
}
|
||||||
|
if oldnum > newnum {
|
||||||
|
log.Fatalf("Current build number %d not newer than existing %d", newnum, oldnum)
|
||||||
|
} else {
|
||||||
|
log.Printf("Updating %s from build %d to %d", img, oldnum, newnum)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
build.MustRunCommand("docker", "image", "tag", fmt.Sprintf("%s:TAG", *upload), gethImage)
|
||||||
|
build.MustRunCommand("docker", "image", "tag", fmt.Sprintf("%s:alltools-TAG", *upload), toolImage)
|
||||||
|
build.MustRunCommand("docker", "push", gethImage)
|
||||||
|
build.MustRunCommand("docker", "push", toolImage)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If multi-arch image manifest push is requested, assemble it
|
||||||
|
if len(*manifest) != 0 {
|
||||||
|
// Since different architectures are pushed by different builders, wait
|
||||||
|
// until all required images are updated.
|
||||||
|
var mismatch bool
|
||||||
|
for i := 0; i < 2; i++ { // 2 attempts, second is race check
|
||||||
|
mismatch = false // hope there's no mismatch now
|
||||||
|
|
||||||
|
for _, tag := range tags {
|
||||||
|
for _, arch := range strings.Split(*manifest, ",") {
|
||||||
|
gethImage := fmt.Sprintf("%s:%s-%s", *upload, tag, arch)
|
||||||
|
toolImage := fmt.Sprintf("%s:alltools-%s-%s", *upload, tag, arch)
|
||||||
|
|
||||||
|
for _, img := range []string{gethImage, toolImage} {
|
||||||
|
if out, err := exec.Command("docker", "pull", img).CombinedOutput(); err != nil {
|
||||||
|
log.Printf("Required image %s unavailable: %v\nOutput: %s", img, err, out)
|
||||||
|
mismatch = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
buildnum, err := exec.Command("docker", "inspect", "--format", "{{index .Config.Labels \"buildnum\"}}", img).CombinedOutput()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Failed to inspect container: %v\nOutput: %s", err, string(buildnum))
|
||||||
|
}
|
||||||
|
buildnum = bytes.TrimSpace(buildnum)
|
||||||
|
|
||||||
|
if string(buildnum) != env.Buildnum {
|
||||||
|
log.Printf("Build number mismatch on %s: want %s, have %s", img, env.Buildnum, buildnum)
|
||||||
|
mismatch = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if mismatch {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if mismatch {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if mismatch {
|
||||||
|
// Build numbers mismatching, retry in a short time to
|
||||||
|
// avoid concurrent failes in both publisher images. If
|
||||||
|
// however the retry failed too, it means the concurrent
|
||||||
|
// builder is still crunching, let that do the publish.
|
||||||
|
if i == 0 {
|
||||||
|
time.Sleep(30 * time.Second)
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if mismatch {
|
||||||
|
log.Println("Relinquishing publish to other builder")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// Assemble and push the Geth manifest image
|
||||||
|
for _, tag := range tags {
|
||||||
|
gethImage := fmt.Sprintf("%s:%s", *upload, tag)
|
||||||
|
|
||||||
|
var gethSubImages []string
|
||||||
|
for _, arch := range strings.Split(*manifest, ",") {
|
||||||
|
gethSubImages = append(gethSubImages, gethImage+"-"+arch)
|
||||||
|
}
|
||||||
|
build.MustRunCommand("docker", append([]string{"manifest", "create", gethImage}, gethSubImages...)...)
|
||||||
|
build.MustRunCommand("docker", "manifest", "push", gethImage)
|
||||||
|
}
|
||||||
|
// Assemble and push the alltools manifest image
|
||||||
|
for _, tag := range tags {
|
||||||
|
toolImage := fmt.Sprintf("%s:alltools-%s", *upload, tag)
|
||||||
|
|
||||||
|
var toolSubImages []string
|
||||||
|
for _, arch := range strings.Split(*manifest, ",") {
|
||||||
|
toolSubImages = append(toolSubImages, toolImage+"-"+arch)
|
||||||
|
}
|
||||||
|
build.MustRunCommand("docker", append([]string{"manifest", "create", toolImage}, toolSubImages...)...)
|
||||||
|
build.MustRunCommand("docker", "manifest", "push", toolImage)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Debian Packaging
|
// Debian Packaging
|
||||||
func doDebianSource(cmdline []string) {
|
func doDebianSource(cmdline []string) {
|
||||||
var (
|
var (
|
||||||
goversion = flag.String("goversion", "", `Go version to build with (will be included in the source package)`)
|
cachedir = flag.String("cachedir", "./build/cache", `Filesystem path to cache the downloaded Go bundles at`)
|
||||||
cachedir = flag.String("cachedir", "./build/cache", `Filesystem path to cache the downloaded Go bundles at`)
|
signer = flag.String("signer", "", `Signing key name, also used as package author`)
|
||||||
signer = flag.String("signer", "", `Signing key name, also used as package author`)
|
upload = flag.String("upload", "", `Where to upload the source package (usually "ethereum/ethereum")`)
|
||||||
upload = flag.String("upload", "", `Where to upload the source package (usually "ethereum/ethereum")`)
|
sshUser = flag.String("sftp-user", "", `Username for SFTP upload (usually "geth-ci")`)
|
||||||
sshUser = flag.String("sftp-user", "", `Username for SFTP upload (usually "geth-ci")`)
|
workdir = flag.String("workdir", "", `Output directory for packages (uses temp dir if unset)`)
|
||||||
workdir = flag.String("workdir", "", `Output directory for packages (uses temp dir if unset)`)
|
now = time.Now()
|
||||||
now = time.Now()
|
|
||||||
)
|
)
|
||||||
flag.CommandLine.Parse(cmdline)
|
flag.CommandLine.Parse(cmdline)
|
||||||
*workdir = makeWorkdir(*workdir)
|
*workdir = makeWorkdir(*workdir)
|
||||||
env := build.Env()
|
env := build.Env()
|
||||||
|
tc := new(build.GoToolchain)
|
||||||
maybeSkipArchive(env)
|
maybeSkipArchive(env)
|
||||||
|
|
||||||
// Import the signing key.
|
// Import the signing key.
|
||||||
@@ -490,15 +657,15 @@ func doDebianSource(cmdline []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Download and verify the Go source package.
|
// Download and verify the Go source package.
|
||||||
gobundle := downloadGoSources(*goversion, *cachedir)
|
gobundle := downloadGoSources(*cachedir)
|
||||||
|
|
||||||
// Download all the dependencies needed to build the sources and run the ci script
|
// Download all the dependencies needed to build the sources and run the ci script
|
||||||
srcdepfetch := goTool("install", "-n", "./...")
|
srcdepfetch := tc.Go("mod", "download")
|
||||||
srcdepfetch.Env = append(os.Environ(), "GOPATH="+filepath.Join(*workdir, "modgopath"))
|
srcdepfetch.Env = append(srcdepfetch.Env, "GOPATH="+filepath.Join(*workdir, "modgopath"))
|
||||||
build.MustRun(srcdepfetch)
|
build.MustRun(srcdepfetch)
|
||||||
|
|
||||||
cidepfetch := goTool("run", "./build/ci.go")
|
cidepfetch := tc.Go("run", "./build/ci.go")
|
||||||
cidepfetch.Env = append(os.Environ(), "GOPATH="+filepath.Join(*workdir, "modgopath"))
|
cidepfetch.Env = append(cidepfetch.Env, "GOPATH="+filepath.Join(*workdir, "modgopath"))
|
||||||
cidepfetch.Run() // Command fails, don't care, we only need the deps to start it
|
cidepfetch.Run() // Command fails, don't care, we only need the deps to start it
|
||||||
|
|
||||||
// Create Debian packages and upload them.
|
// Create Debian packages and upload them.
|
||||||
@@ -509,7 +676,7 @@ func doDebianSource(cmdline []string) {
|
|||||||
pkgdir := stageDebianSource(*workdir, meta)
|
pkgdir := stageDebianSource(*workdir, meta)
|
||||||
|
|
||||||
// Add Go source code
|
// Add Go source code
|
||||||
if err := build.ExtractTarballArchive(gobundle, pkgdir); err != nil {
|
if err := build.ExtractArchive(gobundle, pkgdir); err != nil {
|
||||||
log.Fatalf("Failed to extract Go sources: %v", err)
|
log.Fatalf("Failed to extract Go sources: %v", err)
|
||||||
}
|
}
|
||||||
if err := os.Rename(filepath.Join(pkgdir, "go"), filepath.Join(pkgdir, ".go")); err != nil {
|
if err := os.Rename(filepath.Join(pkgdir, "go"), filepath.Join(pkgdir, ".go")); err != nil {
|
||||||
@@ -526,24 +693,26 @@ func doDebianSource(cmdline []string) {
|
|||||||
build.MustRun(debuild)
|
build.MustRun(debuild)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
basename = fmt.Sprintf("%s_%s", meta.Name(), meta.VersionString())
|
basename = fmt.Sprintf("%s_%s", meta.Name(), meta.VersionString())
|
||||||
source = filepath.Join(*workdir, basename+".tar.xz")
|
source = filepath.Join(*workdir, basename+".tar.xz")
|
||||||
dsc = filepath.Join(*workdir, basename+".dsc")
|
dsc = filepath.Join(*workdir, basename+".dsc")
|
||||||
changes = filepath.Join(*workdir, basename+"_source.changes")
|
changes = filepath.Join(*workdir, basename+"_source.changes")
|
||||||
|
buildinfo = filepath.Join(*workdir, basename+"_source.buildinfo")
|
||||||
)
|
)
|
||||||
if *signer != "" {
|
if *signer != "" {
|
||||||
build.MustRunCommand("debsign", changes)
|
build.MustRunCommand("debsign", changes)
|
||||||
}
|
}
|
||||||
if *upload != "" {
|
if *upload != "" {
|
||||||
ppaUpload(*workdir, *upload, *sshUser, []string{source, dsc, changes})
|
ppaUpload(*workdir, *upload, *sshUser, []string{source, dsc, changes, buildinfo})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func downloadGoSources(version string, cachedir string) string {
|
// downloadGoSources downloads the Go source tarball.
|
||||||
|
func downloadGoSources(cachedir string) string {
|
||||||
csdb := build.MustLoadChecksums("build/checksums.txt")
|
csdb := build.MustLoadChecksums("build/checksums.txt")
|
||||||
file := fmt.Sprintf("go%s.src.tar.gz", version)
|
file := fmt.Sprintf("go%s.src.tar.gz", dlgoVersion)
|
||||||
url := "https://dl.google.com/go/" + file
|
url := "https://dl.google.com/go/" + file
|
||||||
dst := filepath.Join(cachedir, file)
|
dst := filepath.Join(cachedir, file)
|
||||||
if err := csdb.DownloadFile(url, dst); err != nil {
|
if err := csdb.DownloadFile(url, dst); err != nil {
|
||||||
@@ -565,8 +734,8 @@ func ppaUpload(workdir, ppa, sshUser string, files []string) {
|
|||||||
var idfile string
|
var idfile string
|
||||||
if sshkey := getenvBase64("PPA_SSH_KEY"); len(sshkey) > 0 {
|
if sshkey := getenvBase64("PPA_SSH_KEY"); len(sshkey) > 0 {
|
||||||
idfile = filepath.Join(workdir, "sshkey")
|
idfile = filepath.Join(workdir, "sshkey")
|
||||||
if _, err := os.Stat(idfile); os.IsNotExist(err) {
|
if !common.FileExist(idfile) {
|
||||||
ioutil.WriteFile(idfile, sshkey, 0600)
|
os.WriteFile(idfile, sshkey, 0600)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Upload
|
// Upload
|
||||||
@@ -589,7 +758,7 @@ func makeWorkdir(wdflag string) string {
|
|||||||
if wdflag != "" {
|
if wdflag != "" {
|
||||||
err = os.MkdirAll(wdflag, 0744)
|
err = os.MkdirAll(wdflag, 0744)
|
||||||
} else {
|
} else {
|
||||||
wdflag, err = ioutil.TempDir("", "geth-build-")
|
wdflag, err = os.MkdirTemp("", "geth-build-")
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
@@ -747,6 +916,7 @@ func doWindowsInstaller(cmdline []string) {
|
|||||||
var (
|
var (
|
||||||
arch = flag.String("arch", runtime.GOARCH, "Architecture for cross build packaging")
|
arch = flag.String("arch", runtime.GOARCH, "Architecture for cross build packaging")
|
||||||
signer = flag.String("signer", "", `Environment variable holding the signing key (e.g. WINDOWS_SIGNING_KEY)`)
|
signer = flag.String("signer", "", `Environment variable holding the signing key (e.g. WINDOWS_SIGNING_KEY)`)
|
||||||
|
signify = flag.String("signify key", "", `Environment variable holding the signify signing key (e.g. WINDOWS_SIGNIFY_KEY)`)
|
||||||
upload = flag.String("upload", "", `Destination to upload the archives (usually "gethstore/builds")`)
|
upload = flag.String("upload", "", `Destination to upload the archives (usually "gethstore/builds")`)
|
||||||
workdir = flag.String("workdir", "", `Output directory for packages (uses temp dir if unset)`)
|
workdir = flag.String("workdir", "", `Output directory for packages (uses temp dir if unset)`)
|
||||||
)
|
)
|
||||||
@@ -786,10 +956,10 @@ func doWindowsInstaller(cmdline []string) {
|
|||||||
build.Render("build/nsis.pathupdate.nsh", filepath.Join(*workdir, "PathUpdate.nsh"), 0644, nil)
|
build.Render("build/nsis.pathupdate.nsh", filepath.Join(*workdir, "PathUpdate.nsh"), 0644, nil)
|
||||||
build.Render("build/nsis.envvarupdate.nsh", filepath.Join(*workdir, "EnvVarUpdate.nsh"), 0644, nil)
|
build.Render("build/nsis.envvarupdate.nsh", filepath.Join(*workdir, "EnvVarUpdate.nsh"), 0644, nil)
|
||||||
if err := cp.CopyFile(filepath.Join(*workdir, "SimpleFC.dll"), "build/nsis.simplefc.dll"); err != nil {
|
if err := cp.CopyFile(filepath.Join(*workdir, "SimpleFC.dll"), "build/nsis.simplefc.dll"); err != nil {
|
||||||
log.Fatal("Failed to copy SimpleFC.dll: %v", err)
|
log.Fatalf("Failed to copy SimpleFC.dll: %v", err)
|
||||||
}
|
}
|
||||||
if err := cp.CopyFile(filepath.Join(*workdir, "COPYING"), "COPYING"); err != nil {
|
if err := cp.CopyFile(filepath.Join(*workdir, "COPYING"), "COPYING"); err != nil {
|
||||||
log.Fatal("Failed to copy copyright note: %v", err)
|
log.Fatalf("Failed to copy copyright note: %v", err)
|
||||||
}
|
}
|
||||||
// Build the installer. This assumes that all the needed files have been previously
|
// Build the installer. This assumes that all the needed files have been previously
|
||||||
// built (don't mix building and packaging to keep cross compilation complexity to a
|
// built (don't mix building and packaging to keep cross compilation complexity to a
|
||||||
@@ -808,7 +978,7 @@ func doWindowsInstaller(cmdline []string) {
|
|||||||
filepath.Join(*workdir, "geth.nsi"),
|
filepath.Join(*workdir, "geth.nsi"),
|
||||||
)
|
)
|
||||||
// Sign and publish installer.
|
// Sign and publish installer.
|
||||||
if err := archiveUpload(installer, *upload, *signer); err != nil {
|
if err := archiveUpload(installer, *upload, *signer, *signify); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -817,25 +987,37 @@ func doWindowsInstaller(cmdline []string) {
|
|||||||
|
|
||||||
func doAndroidArchive(cmdline []string) {
|
func doAndroidArchive(cmdline []string) {
|
||||||
var (
|
var (
|
||||||
local = flag.Bool("local", false, `Flag whether we're only doing a local build (skip Maven artifacts)`)
|
local = flag.Bool("local", false, `Flag whether we're only doing a local build (skip Maven artifacts)`)
|
||||||
signer = flag.String("signer", "", `Environment variable holding the signing key (e.g. ANDROID_SIGNING_KEY)`)
|
signer = flag.String("signer", "", `Environment variable holding the signing key (e.g. ANDROID_SIGNING_KEY)`)
|
||||||
deploy = flag.String("deploy", "", `Destination to deploy the archive (usually "https://oss.sonatype.org")`)
|
signify = flag.String("signify", "", `Environment variable holding the signify signing key (e.g. ANDROID_SIGNIFY_KEY)`)
|
||||||
upload = flag.String("upload", "", `Destination to upload the archive (usually "gethstore/builds")`)
|
deploy = flag.String("deploy", "", `Destination to deploy the archive (usually "https://oss.sonatype.org")`)
|
||||||
|
upload = flag.String("upload", "", `Destination to upload the archive (usually "gethstore/builds")`)
|
||||||
)
|
)
|
||||||
flag.CommandLine.Parse(cmdline)
|
flag.CommandLine.Parse(cmdline)
|
||||||
env := build.Env()
|
env := build.Env()
|
||||||
|
tc := new(build.GoToolchain)
|
||||||
|
|
||||||
// Sanity check that the SDK and NDK are installed and set
|
// Sanity check that the SDK and NDK are installed and set
|
||||||
if os.Getenv("ANDROID_HOME") == "" {
|
if os.Getenv("ANDROID_HOME") == "" {
|
||||||
log.Fatal("Please ensure ANDROID_HOME points to your Android SDK")
|
log.Fatal("Please ensure ANDROID_HOME points to your Android SDK")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Build gomobile.
|
||||||
|
install := tc.Install(GOBIN, "golang.org/x/mobile/cmd/gomobile@latest", "golang.org/x/mobile/cmd/gobind@latest")
|
||||||
|
install.Env = append(install.Env)
|
||||||
|
build.MustRun(install)
|
||||||
|
|
||||||
|
// Ensure all dependencies are available. This is required to make
|
||||||
|
// gomobile bind work because it expects go.sum to contain all checksums.
|
||||||
|
build.MustRun(tc.Go("mod", "download"))
|
||||||
|
|
||||||
// Build the Android archive and Maven resources
|
// Build the Android archive and Maven resources
|
||||||
build.MustRun(goTool("get", "golang.org/x/mobile/cmd/gomobile", "golang.org/x/mobile/cmd/gobind"))
|
|
||||||
build.MustRun(gomobileTool("bind", "-ldflags", "-s -w", "--target", "android", "--javapkg", "org.ethereum", "-v", "github.com/ethereum/go-ethereum/mobile"))
|
build.MustRun(gomobileTool("bind", "-ldflags", "-s -w", "--target", "android", "--javapkg", "org.ethereum", "-v", "github.com/ethereum/go-ethereum/mobile"))
|
||||||
|
|
||||||
if *local {
|
if *local {
|
||||||
// If we're building locally, copy bundle to build dir and skip Maven
|
// If we're building locally, copy bundle to build dir and skip Maven
|
||||||
os.Rename("geth.aar", filepath.Join(GOBIN, "geth.aar"))
|
os.Rename("geth.aar", filepath.Join(GOBIN, "geth.aar"))
|
||||||
|
os.Rename("geth-sources.jar", filepath.Join(GOBIN, "geth-sources.jar"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
meta := newMavenMetadata(env)
|
meta := newMavenMetadata(env)
|
||||||
@@ -848,7 +1030,7 @@ func doAndroidArchive(cmdline []string) {
|
|||||||
archive := "geth-" + archiveBasename("android", params.ArchiveVersion(env.Commit)) + ".aar"
|
archive := "geth-" + archiveBasename("android", params.ArchiveVersion(env.Commit)) + ".aar"
|
||||||
os.Rename("geth.aar", archive)
|
os.Rename("geth.aar", archive)
|
||||||
|
|
||||||
if err := archiveUpload(archive, *upload, *signer); err != nil {
|
if err := archiveUpload(archive, *upload, *signer, *signify); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
// Sign and upload all the artifacts to Maven Central
|
// Sign and upload all the artifacts to Maven Central
|
||||||
@@ -941,17 +1123,20 @@ func newMavenMetadata(env build.Environment) mavenMetadata {
|
|||||||
|
|
||||||
func doXCodeFramework(cmdline []string) {
|
func doXCodeFramework(cmdline []string) {
|
||||||
var (
|
var (
|
||||||
local = flag.Bool("local", false, `Flag whether we're only doing a local build (skip Maven artifacts)`)
|
local = flag.Bool("local", false, `Flag whether we're only doing a local build (skip Maven artifacts)`)
|
||||||
signer = flag.String("signer", "", `Environment variable holding the signing key (e.g. IOS_SIGNING_KEY)`)
|
signer = flag.String("signer", "", `Environment variable holding the signing key (e.g. IOS_SIGNING_KEY)`)
|
||||||
deploy = flag.String("deploy", "", `Destination to deploy the archive (usually "trunk")`)
|
signify = flag.String("signify", "", `Environment variable holding the signify signing key (e.g. IOS_SIGNIFY_KEY)`)
|
||||||
upload = flag.String("upload", "", `Destination to upload the archives (usually "gethstore/builds")`)
|
deploy = flag.String("deploy", "", `Destination to deploy the archive (usually "trunk")`)
|
||||||
|
upload = flag.String("upload", "", `Destination to upload the archives (usually "gethstore/builds")`)
|
||||||
)
|
)
|
||||||
flag.CommandLine.Parse(cmdline)
|
flag.CommandLine.Parse(cmdline)
|
||||||
env := build.Env()
|
env := build.Env()
|
||||||
|
tc := new(build.GoToolchain)
|
||||||
|
|
||||||
|
// Build gomobile.
|
||||||
|
build.MustRun(tc.Install(GOBIN, "golang.org/x/mobile/cmd/gomobile", "golang.org/x/mobile/cmd/gobind"))
|
||||||
|
|
||||||
// Build the iOS XCode framework
|
// Build the iOS XCode framework
|
||||||
build.MustRun(goTool("get", "golang.org/x/mobile/cmd/gomobile", "golang.org/x/mobile/cmd/gobind"))
|
|
||||||
build.MustRun(gomobileTool("init"))
|
|
||||||
bind := gomobileTool("bind", "-ldflags", "-s -w", "--target", "ios", "-v", "github.com/ethereum/go-ethereum/mobile")
|
bind := gomobileTool("bind", "-ldflags", "-s -w", "--target", "ios", "-v", "github.com/ethereum/go-ethereum/mobile")
|
||||||
|
|
||||||
if *local {
|
if *local {
|
||||||
@@ -960,26 +1145,26 @@ func doXCodeFramework(cmdline []string) {
|
|||||||
build.MustRun(bind)
|
build.MustRun(bind)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create the archive.
|
||||||
|
maybeSkipArchive(env)
|
||||||
archive := "geth-" + archiveBasename("ios", params.ArchiveVersion(env.Commit))
|
archive := "geth-" + archiveBasename("ios", params.ArchiveVersion(env.Commit))
|
||||||
if err := os.Mkdir(archive, os.ModePerm); err != nil {
|
if err := os.MkdirAll(archive, 0755); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
bind.Dir, _ = filepath.Abs(archive)
|
bind.Dir, _ = filepath.Abs(archive)
|
||||||
build.MustRun(bind)
|
build.MustRun(bind)
|
||||||
build.MustRunCommand("tar", "-zcvf", archive+".tar.gz", archive)
|
build.MustRunCommand("tar", "-zcvf", archive+".tar.gz", archive)
|
||||||
|
|
||||||
// Skip CocoaPods deploy and Azure upload for PR builds
|
|
||||||
maybeSkipArchive(env)
|
|
||||||
|
|
||||||
// Sign and upload the framework to Azure
|
// Sign and upload the framework to Azure
|
||||||
if err := archiveUpload(archive+".tar.gz", *upload, *signer); err != nil {
|
if err := archiveUpload(archive+".tar.gz", *upload, *signer, *signify); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
// Prepare and upload a PodSpec to CocoaPods
|
// Prepare and upload a PodSpec to CocoaPods
|
||||||
if *deploy != "" {
|
if *deploy != "" {
|
||||||
meta := newPodMetadata(env, archive)
|
meta := newPodMetadata(env, archive)
|
||||||
build.Render("build/pod.podspec", "Geth.podspec", 0755, meta)
|
build.Render("build/pod.podspec", "Geth.podspec", 0755, meta)
|
||||||
build.MustRunCommand("pod", *deploy, "push", "Geth.podspec", "--allow-warnings", "--verbose")
|
build.MustRunCommand("pod", *deploy, "push", "Geth.podspec", "--allow-warnings")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1028,52 +1213,6 @@ func newPodMetadata(env build.Environment, archive string) podMetadata {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cross compilation
|
|
||||||
|
|
||||||
func doXgo(cmdline []string) {
|
|
||||||
var (
|
|
||||||
alltools = flag.Bool("alltools", false, `Flag whether we're building all known tools, or only on in particular`)
|
|
||||||
)
|
|
||||||
flag.CommandLine.Parse(cmdline)
|
|
||||||
env := build.Env()
|
|
||||||
|
|
||||||
// Make sure xgo is available for cross compilation
|
|
||||||
gogetxgo := goTool("get", "github.com/karalabe/xgo")
|
|
||||||
build.MustRun(gogetxgo)
|
|
||||||
|
|
||||||
// If all tools building is requested, build everything the builder wants
|
|
||||||
args := append(buildFlags(env), flag.Args()...)
|
|
||||||
|
|
||||||
if *alltools {
|
|
||||||
args = append(args, []string{"--dest", GOBIN}...)
|
|
||||||
for _, res := range allToolsArchiveFiles {
|
|
||||||
if strings.HasPrefix(res, GOBIN) {
|
|
||||||
// Binary tool found, cross build it explicitly
|
|
||||||
args = append(args, "./"+filepath.Join("cmd", filepath.Base(res)))
|
|
||||||
xgo := xgoTool(args)
|
|
||||||
build.MustRun(xgo)
|
|
||||||
args = args[:len(args)-1]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// Otherwise xxecute the explicit cross compilation
|
|
||||||
path := args[len(args)-1]
|
|
||||||
args = append(args[:len(args)-1], []string{"--dest", GOBIN, path}...)
|
|
||||||
|
|
||||||
xgo := xgoTool(args)
|
|
||||||
build.MustRun(xgo)
|
|
||||||
}
|
|
||||||
|
|
||||||
func xgoTool(args []string) *exec.Cmd {
|
|
||||||
cmd := exec.Command(filepath.Join(GOBIN, "xgo"), args...)
|
|
||||||
cmd.Env = os.Environ()
|
|
||||||
cmd.Env = append(cmd.Env, []string{
|
|
||||||
"GOBIN=" + GOBIN,
|
|
||||||
}...)
|
|
||||||
return cmd
|
|
||||||
}
|
|
||||||
|
|
||||||
// Binary distribution cleanups
|
// Binary distribution cleanups
|
||||||
|
|
||||||
func doPurge(cmdline []string) {
|
func doPurge(cmdline []string) {
|
||||||
@@ -1101,21 +1240,21 @@ func doPurge(cmdline []string) {
|
|||||||
|
|
||||||
// Iterate over the blobs, collect and sort all unstable builds
|
// Iterate over the blobs, collect and sort all unstable builds
|
||||||
for i := 0; i < len(blobs); i++ {
|
for i := 0; i < len(blobs); i++ {
|
||||||
if !strings.Contains(blobs[i].Name, "unstable") {
|
if !strings.Contains(*blobs[i].Name, "unstable") {
|
||||||
blobs = append(blobs[:i], blobs[i+1:]...)
|
blobs = append(blobs[:i], blobs[i+1:]...)
|
||||||
i--
|
i--
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for i := 0; i < len(blobs); i++ {
|
for i := 0; i < len(blobs); i++ {
|
||||||
for j := i + 1; j < len(blobs); j++ {
|
for j := i + 1; j < len(blobs); j++ {
|
||||||
if blobs[i].Properties.LastModified.After(blobs[j].Properties.LastModified) {
|
if blobs[i].Properties.LastModified.After(*blobs[j].Properties.LastModified) {
|
||||||
blobs[i], blobs[j] = blobs[j], blobs[i]
|
blobs[i], blobs[j] = blobs[j], blobs[i]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Filter out all archives more recent that the given threshold
|
// Filter out all archives more recent that the given threshold
|
||||||
for i, blob := range blobs {
|
for i, blob := range blobs {
|
||||||
if time.Since(blob.Properties.LastModified) < time.Duration(*limit)*24*time.Hour {
|
if time.Since(*blob.Properties.LastModified) < time.Duration(*limit)*24*time.Hour {
|
||||||
blobs = blobs[:i]
|
blobs = blobs[:i]
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ Maintainer: {{.Author}}
|
|||||||
Build-Depends: debhelper (>= 8.0.0), {{.GoBootPackage}}
|
Build-Depends: debhelper (>= 8.0.0), {{.GoBootPackage}}
|
||||||
Standards-Version: 3.9.5
|
Standards-Version: 3.9.5
|
||||||
Homepage: https://ethereum.org
|
Homepage: https://ethereum.org
|
||||||
Vcs-Git: git://github.com/ethereum/go-ethereum.git
|
Vcs-Git: https://github.com/ethereum/go-ethereum.git
|
||||||
Vcs-Browser: https://github.com/ethereum/go-ethereum
|
Vcs-Browser: https://github.com/ethereum/go-ethereum
|
||||||
|
|
||||||
Package: {{.Name}}
|
Package: {{.Name}}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
!ifndef Un${StrFuncName}_INCLUDED
|
!ifndef Un${StrFuncName}_INCLUDED
|
||||||
${Un${StrFuncName}}
|
${Un${StrFuncName}}
|
||||||
!endif
|
!endif
|
||||||
!define un.${StrFuncName} "${Un${StrFuncName}}"
|
!define un.${StrFuncName} '${Un${StrFuncName}}'
|
||||||
!macroend
|
!macroend
|
||||||
|
|
||||||
!insertmacro _IncludeStrFunction StrTok
|
!insertmacro _IncludeStrFunction StrTok
|
||||||
|
|||||||
31
build/tools/tools.go
Normal file
31
build/tools/tools.go
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
// Copyright 2019 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//go:build tools
|
||||||
|
// +build tools
|
||||||
|
|
||||||
|
package tools
|
||||||
|
|
||||||
|
import (
|
||||||
|
// Tool imports for go:generate.
|
||||||
|
_ "github.com/fjl/gencodec"
|
||||||
|
_ "github.com/golang/protobuf/protoc-gen-go"
|
||||||
|
_ "golang.org/x/tools/cmd/stringer"
|
||||||
|
|
||||||
|
// Tool imports for mobile build.
|
||||||
|
_ "golang.org/x/mobile/cmd/gobind"
|
||||||
|
_ "golang.org/x/mobile/cmd/gomobile"
|
||||||
|
)
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
// You should have received a copy of the GNU Lesser General Public License
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//go:build none
|
||||||
// +build none
|
// +build none
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -39,7 +40,6 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
@@ -68,7 +68,9 @@ var (
|
|||||||
"common/bitutil/bitutil",
|
"common/bitutil/bitutil",
|
||||||
"common/prque/",
|
"common/prque/",
|
||||||
"consensus/ethash/xor.go",
|
"consensus/ethash/xor.go",
|
||||||
|
"crypto/blake2b/",
|
||||||
"crypto/bn256/",
|
"crypto/bn256/",
|
||||||
|
"crypto/bls12381/",
|
||||||
"crypto/ecies/",
|
"crypto/ecies/",
|
||||||
"graphql/graphiql.go",
|
"graphql/graphiql.go",
|
||||||
"internal/jsre/deps",
|
"internal/jsre/deps",
|
||||||
@@ -241,7 +243,7 @@ func gitAuthors(files []string) []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func readAuthors() []string {
|
func readAuthors() []string {
|
||||||
content, err := ioutil.ReadFile("AUTHORS")
|
content, err := os.ReadFile("AUTHORS")
|
||||||
if err != nil && !os.IsNotExist(err) {
|
if err != nil && !os.IsNotExist(err) {
|
||||||
log.Fatalln("error reading AUTHORS:", err)
|
log.Fatalln("error reading AUTHORS:", err)
|
||||||
}
|
}
|
||||||
@@ -305,7 +307,7 @@ func writeAuthors(files []string) {
|
|||||||
content.WriteString("\n")
|
content.WriteString("\n")
|
||||||
}
|
}
|
||||||
fmt.Println("writing AUTHORS")
|
fmt.Println("writing AUTHORS")
|
||||||
if err := ioutil.WriteFile("AUTHORS", content.Bytes(), 0644); err != nil {
|
if err := os.WriteFile("AUTHORS", content.Bytes(), 0644); err != nil {
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -381,7 +383,7 @@ func writeLicense(info *info) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("error stat'ing %s: %v\n", info.file, err)
|
log.Fatalf("error stat'ing %s: %v\n", info.file, err)
|
||||||
}
|
}
|
||||||
content, err := ioutil.ReadFile(info.file)
|
content, err := os.ReadFile(info.file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("error reading %s: %v\n", info.file, err)
|
log.Fatalf("error reading %s: %v\n", info.file, err)
|
||||||
}
|
}
|
||||||
@@ -400,7 +402,7 @@ func writeLicense(info *info) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Println("writing", info.ShortLicense(), info.file)
|
fmt.Println("writing", info.ShortLicense(), info.file)
|
||||||
if err := ioutil.WriteFile(info.file, buf.Bytes(), fi.Mode()); err != nil {
|
if err := os.WriteFile(info.file, buf.Bytes(), fi.Mode()); err != nil {
|
||||||
log.Fatalf("error writing %s: %v", info.file, err)
|
log.Fatalf("error writing %s: %v", info.file, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
// Copyright 2019 The go-ethereum Authors
|
// Copyright 2020 The go-ethereum Authors
|
||||||
// This file is part of the go-ethereum library.
|
// This file is part of go-ethereum.
|
||||||
//
|
//
|
||||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
// go-ethereum is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU Lesser General Public License as published by
|
// it under the terms of the GNU General Public License as published by
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
// (at your option) any later version.
|
// (at your option) any later version.
|
||||||
//
|
//
|
||||||
// The go-ethereum library is distributed in the hope that it will be useful,
|
// go-ethereum is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU Lesser General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Lesser General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/signer/core"
|
"github.com/ethereum/go-ethereum/signer/core/apitypes"
|
||||||
"github.com/ethereum/go-ethereum/signer/fourbyte"
|
"github.com/ethereum/go-ethereum/signer/fourbyte"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ func parse(data []byte) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
die(err)
|
die(err)
|
||||||
}
|
}
|
||||||
messages := core.ValidationMessages{}
|
messages := apitypes.ValidationMessages{}
|
||||||
db.ValidateCallData(nil, data, &messages)
|
db.ValidateCallData(nil, data, &messages)
|
||||||
for _, m := range messages.Messages {
|
for _, m := range messages.Messages {
|
||||||
fmt.Printf("%v: %v\n", m.Typ, m.Message)
|
fmt.Printf("%v: %v\n", m.Typ, m.Message)
|
||||||
|
|||||||
@@ -19,13 +19,11 @@ package main
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
|
||||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||||
"github.com/ethereum/go-ethereum/cmd/utils"
|
"github.com/ethereum/go-ethereum/cmd/utils"
|
||||||
"github.com/ethereum/go-ethereum/common/compiler"
|
"github.com/ethereum/go-ethereum/common/compiler"
|
||||||
@@ -57,25 +55,7 @@ var (
|
|||||||
}
|
}
|
||||||
jsonFlag = cli.StringFlag{
|
jsonFlag = cli.StringFlag{
|
||||||
Name: "combined-json",
|
Name: "combined-json",
|
||||||
Usage: "Path to the combined-json file generated by compiler",
|
Usage: "Path to the combined-json file generated by compiler, - for STDIN",
|
||||||
}
|
|
||||||
solFlag = cli.StringFlag{
|
|
||||||
Name: "sol",
|
|
||||||
Usage: "Path to the Ethereum contract Solidity source to build and bind",
|
|
||||||
}
|
|
||||||
solcFlag = cli.StringFlag{
|
|
||||||
Name: "solc",
|
|
||||||
Usage: "Solidity compiler to use if source builds are requested",
|
|
||||||
Value: "solc",
|
|
||||||
}
|
|
||||||
vyFlag = cli.StringFlag{
|
|
||||||
Name: "vy",
|
|
||||||
Usage: "Path to the Ethereum contract Vyper source to build and bind",
|
|
||||||
}
|
|
||||||
vyperFlag = cli.StringFlag{
|
|
||||||
Name: "vyper",
|
|
||||||
Usage: "Vyper compiler to use if source builds are requested",
|
|
||||||
Value: "vyper",
|
|
||||||
}
|
}
|
||||||
excFlag = cli.StringFlag{
|
excFlag = cli.StringFlag{
|
||||||
Name: "exc",
|
Name: "exc",
|
||||||
@@ -96,7 +76,7 @@ var (
|
|||||||
}
|
}
|
||||||
aliasFlag = cli.StringFlag{
|
aliasFlag = cli.StringFlag{
|
||||||
Name: "alias",
|
Name: "alias",
|
||||||
Usage: "Comma separated aliases for function and event renaming, e.g. foo=bar",
|
Usage: "Comma separated aliases for function and event renaming, e.g. original1=alias1, original2=alias2",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -107,10 +87,6 @@ func init() {
|
|||||||
binFlag,
|
binFlag,
|
||||||
typeFlag,
|
typeFlag,
|
||||||
jsonFlag,
|
jsonFlag,
|
||||||
solFlag,
|
|
||||||
solcFlag,
|
|
||||||
vyFlag,
|
|
||||||
vyperFlag,
|
|
||||||
excFlag,
|
excFlag,
|
||||||
pkgFlag,
|
pkgFlag,
|
||||||
outFlag,
|
outFlag,
|
||||||
@@ -122,7 +98,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func abigen(c *cli.Context) error {
|
func abigen(c *cli.Context) error {
|
||||||
utils.CheckExclusive(c, abiFlag, jsonFlag, solFlag, vyFlag) // Only one source can be selected.
|
utils.CheckExclusive(c, abiFlag, jsonFlag) // Only one source can be selected.
|
||||||
if c.GlobalString(pkgFlag.Name) == "" {
|
if c.GlobalString(pkgFlag.Name) == "" {
|
||||||
utils.Fatalf("No destination package specified (--pkg)")
|
utils.Fatalf("No destination package specified (--pkg)")
|
||||||
}
|
}
|
||||||
@@ -155,9 +131,9 @@ func abigen(c *cli.Context) error {
|
|||||||
)
|
)
|
||||||
input := c.GlobalString(abiFlag.Name)
|
input := c.GlobalString(abiFlag.Name)
|
||||||
if input == "-" {
|
if input == "-" {
|
||||||
abi, err = ioutil.ReadAll(os.Stdin)
|
abi, err = io.ReadAll(os.Stdin)
|
||||||
} else {
|
} else {
|
||||||
abi, err = ioutil.ReadFile(input)
|
abi, err = os.ReadFile(input)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf("Failed to read input ABI: %v", err)
|
utils.Fatalf("Failed to read input ABI: %v", err)
|
||||||
@@ -166,7 +142,7 @@ func abigen(c *cli.Context) error {
|
|||||||
|
|
||||||
var bin []byte
|
var bin []byte
|
||||||
if binFile := c.GlobalString(binFlag.Name); binFile != "" {
|
if binFile := c.GlobalString(binFlag.Name); binFile != "" {
|
||||||
if bin, err = ioutil.ReadFile(binFile); err != nil {
|
if bin, err = os.ReadFile(binFile); err != nil {
|
||||||
utils.Fatalf("Failed to read input bytecode: %v", err)
|
utils.Fatalf("Failed to read input bytecode: %v", err)
|
||||||
}
|
}
|
||||||
if strings.Contains(string(bin), "//") {
|
if strings.Contains(string(bin), "//") {
|
||||||
@@ -186,36 +162,21 @@ func abigen(c *cli.Context) error {
|
|||||||
for _, kind := range strings.Split(c.GlobalString(excFlag.Name), ",") {
|
for _, kind := range strings.Split(c.GlobalString(excFlag.Name), ",") {
|
||||||
exclude[strings.ToLower(kind)] = true
|
exclude[strings.ToLower(kind)] = true
|
||||||
}
|
}
|
||||||
var err error
|
|
||||||
var contracts map[string]*compiler.Contract
|
var contracts map[string]*compiler.Contract
|
||||||
|
|
||||||
switch {
|
if c.GlobalIsSet(jsonFlag.Name) {
|
||||||
case c.GlobalIsSet(solFlag.Name):
|
var (
|
||||||
contracts, err = compiler.CompileSolidity(c.GlobalString(solcFlag.Name), c.GlobalString(solFlag.Name))
|
input = c.GlobalString(jsonFlag.Name)
|
||||||
if err != nil {
|
jsonOutput []byte
|
||||||
utils.Fatalf("Failed to build Solidity contract: %v", err)
|
err error
|
||||||
|
)
|
||||||
|
if input == "-" {
|
||||||
|
jsonOutput, err = io.ReadAll(os.Stdin)
|
||||||
|
} else {
|
||||||
|
jsonOutput, err = os.ReadFile(input)
|
||||||
}
|
}
|
||||||
case c.GlobalIsSet(vyFlag.Name):
|
|
||||||
output, err := compiler.CompileVyper(c.GlobalString(vyperFlag.Name), c.GlobalString(vyFlag.Name))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf("Failed to build Vyper contract: %v", err)
|
utils.Fatalf("Failed to read combined-json: %v", err)
|
||||||
}
|
|
||||||
contracts = make(map[string]*compiler.Contract)
|
|
||||||
for n, contract := range output {
|
|
||||||
name := n
|
|
||||||
// Sanitize the combined json names to match the
|
|
||||||
// format expected by solidity.
|
|
||||||
if !strings.Contains(n, ":") {
|
|
||||||
// Remove extra path components
|
|
||||||
name = abi.ToCamelCase(strings.TrimSuffix(filepath.Base(name), ".vy"))
|
|
||||||
}
|
|
||||||
contracts[name] = contract
|
|
||||||
}
|
|
||||||
|
|
||||||
case c.GlobalIsSet(jsonFlag.Name):
|
|
||||||
jsonOutput, err := ioutil.ReadFile(c.GlobalString(jsonFlag.Name))
|
|
||||||
if err != nil {
|
|
||||||
utils.Fatalf("Failed to read combined-json from compiler: %v", err)
|
|
||||||
}
|
}
|
||||||
contracts, err = compiler.ParseCombinedJSON(jsonOutput, "", "", "", "")
|
contracts, err = compiler.ParseCombinedJSON(jsonOutput, "", "", "", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -237,7 +198,11 @@ func abigen(c *cli.Context) error {
|
|||||||
nameParts := strings.Split(name, ":")
|
nameParts := strings.Split(name, ":")
|
||||||
types = append(types, nameParts[len(nameParts)-1])
|
types = append(types, nameParts[len(nameParts)-1])
|
||||||
|
|
||||||
libPattern := crypto.Keccak256Hash([]byte(name)).String()[2:36]
|
// Derive the library placeholder which is a 34 character prefix of the
|
||||||
|
// hex encoding of the keccak256 hash of the fully qualified library name.
|
||||||
|
// Note that the fully qualified library name is the path of its source
|
||||||
|
// file and the library name separated by ":".
|
||||||
|
libPattern := crypto.Keccak256Hash([]byte(name)).String()[2:36] // the first 2 chars are 0x
|
||||||
libs[libPattern] = nameParts[len(nameParts)-1]
|
libs[libPattern] = nameParts[len(nameParts)-1]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -263,7 +228,7 @@ func abigen(c *cli.Context) error {
|
|||||||
fmt.Printf("%s\n", code)
|
fmt.Printf("%s\n", code)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if err := ioutil.WriteFile(c.GlobalString(outFlag.Name), []byte(code), 0600); err != nil {
|
if err := os.WriteFile(c.GlobalString(outFlag.Name), []byte(code), 0600); err != nil {
|
||||||
utils.Fatalf("Failed to write ABI binding: %v", err)
|
utils.Fatalf("Failed to write ABI binding: %v", err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/p2p/discover"
|
"github.com/ethereum/go-ethereum/p2p/discover"
|
||||||
"github.com/ethereum/go-ethereum/p2p/discv5"
|
|
||||||
"github.com/ethereum/go-ethereum/p2p/enode"
|
"github.com/ethereum/go-ethereum/p2p/enode"
|
||||||
"github.com/ethereum/go-ethereum/p2p/nat"
|
"github.com/ethereum/go-ethereum/p2p/nat"
|
||||||
"github.com/ethereum/go-ethereum/p2p/netutil"
|
"github.com/ethereum/go-ethereum/p2p/netutil"
|
||||||
@@ -44,7 +43,7 @@ func main() {
|
|||||||
natdesc = flag.String("nat", "none", "port mapping mechanism (any|none|upnp|pmp|extip:<IP>)")
|
natdesc = flag.String("nat", "none", "port mapping mechanism (any|none|upnp|pmp|extip:<IP>)")
|
||||||
netrestrict = flag.String("netrestrict", "", "restrict network communication to the given IP networks (CIDR masks)")
|
netrestrict = flag.String("netrestrict", "", "restrict network communication to the given IP networks (CIDR masks)")
|
||||||
runv5 = flag.Bool("v5", false, "run a v5 topic discovery bootnode")
|
runv5 = flag.Bool("v5", false, "run a v5 topic discovery bootnode")
|
||||||
verbosity = flag.Int("verbosity", int(log.LvlInfo), "log verbosity (0-9)")
|
verbosity = flag.Int("verbosity", int(log.LvlInfo), "log verbosity (0-5)")
|
||||||
vmodule = flag.String("vmodule", "", "log verbosity pattern")
|
vmodule = flag.String("vmodule", "", "log verbosity pattern")
|
||||||
|
|
||||||
nodeKey *ecdsa.PrivateKey
|
nodeKey *ecdsa.PrivateKey
|
||||||
@@ -121,17 +120,17 @@ func main() {
|
|||||||
|
|
||||||
printNotice(&nodeKey.PublicKey, *realaddr)
|
printNotice(&nodeKey.PublicKey, *realaddr)
|
||||||
|
|
||||||
|
db, _ := enode.OpenDB("")
|
||||||
|
ln := enode.NewLocalNode(db, nodeKey)
|
||||||
|
cfg := discover.Config{
|
||||||
|
PrivateKey: nodeKey,
|
||||||
|
NetRestrict: restrictList,
|
||||||
|
}
|
||||||
if *runv5 {
|
if *runv5 {
|
||||||
if _, err := discv5.ListenUDP(nodeKey, conn, "", restrictList); err != nil {
|
if _, err := discover.ListenV5(conn, ln, cfg); err != nil {
|
||||||
utils.Fatalf("%v", err)
|
utils.Fatalf("%v", err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
db, _ := enode.OpenDB("")
|
|
||||||
ln := enode.NewLocalNode(db, nodeKey)
|
|
||||||
cfg := discover.Config{
|
|
||||||
PrivateKey: nodeKey,
|
|
||||||
NetRestrict: restrictList,
|
|
||||||
}
|
|
||||||
if _, err := discover.ListenUDP(conn, ln, cfg); err != nil {
|
if _, err := discover.ListenUDP(conn, ln, cfg); err != nil {
|
||||||
utils.Fatalf("%v", err)
|
utils.Fatalf("%v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -919,4 +919,4 @@ There are a couple of implementation for a UI. We'll try to keep this list up to
|
|||||||
| QtSigner| https://github.com/holiman/qtsigner/| Python3/QT-based| :+1:| :+1:| :+1:| :+1:| :+1:| :x: | :+1: (partially)|
|
| QtSigner| https://github.com/holiman/qtsigner/| Python3/QT-based| :+1:| :+1:| :+1:| :+1:| :+1:| :x: | :+1: (partially)|
|
||||||
| GtkSigner| https://github.com/holiman/gtksigner| Python3/GTK-based| :+1:| :x:| :x:| :+1:| :+1:| :x: | :x: |
|
| GtkSigner| https://github.com/holiman/gtksigner| Python3/GTK-based| :+1:| :x:| :x:| :+1:| :+1:| :x: | :x: |
|
||||||
| Frame | https://github.com/floating/frame/commits/go-signer| Electron-based| :x:| :x:| :x:| :x:| ?| :x: | :x: |
|
| Frame | https://github.com/floating/frame/commits/go-signer| Electron-based| :x:| :x:| :x:| :x:| ?| :x: | :x: |
|
||||||
| Clef UI| https://github.com/kyokan/clef-ui| Golang/QT-based| :+1:| :+1:| :x:| :+1:| :+1:| :x: | :+1: (approve tx only)|
|
| Clef UI| https://github.com/ethereum/clef-ui| Golang/QT-based| :+1:| :+1:| :x:| :+1:| :+1:| :x: | :+1: (approve tx only)|
|
||||||
|
|||||||
@@ -10,6 +10,64 @@ TL;DR: Given a version number MAJOR.MINOR.PATCH, increment the:
|
|||||||
|
|
||||||
Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.
|
Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.
|
||||||
|
|
||||||
|
### 6.1.0
|
||||||
|
|
||||||
|
The API-method `account_signGnosisSafeTx` was added. This method takes two parameters,
|
||||||
|
`[address, safeTx]`. The latter, `safeTx`, can be copy-pasted from the gnosis relay. For example:
|
||||||
|
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"method": "account_signGnosisSafeTx",
|
||||||
|
"params": ["0xfd1c4226bfD1c436672092F4eCbfC270145b7256",
|
||||||
|
{
|
||||||
|
"safe": "0x25a6c4BBd32B2424A9c99aEB0584Ad12045382B3",
|
||||||
|
"to": "0xB372a646f7F05Cc1785018dBDA7EBc734a2A20E2",
|
||||||
|
"value": "20000000000000000",
|
||||||
|
"data": null,
|
||||||
|
"operation": 0,
|
||||||
|
"gasToken": "0x0000000000000000000000000000000000000000",
|
||||||
|
"safeTxGas": 27845,
|
||||||
|
"baseGas": 0,
|
||||||
|
"gasPrice": "0",
|
||||||
|
"refundReceiver": "0x0000000000000000000000000000000000000000",
|
||||||
|
"nonce": 2,
|
||||||
|
"executionDate": null,
|
||||||
|
"submissionDate": "2020-09-15T21:54:49.617634Z",
|
||||||
|
"modified": "2020-09-15T21:54:49.617634Z",
|
||||||
|
"blockNumber": null,
|
||||||
|
"transactionHash": null,
|
||||||
|
"safeTxHash": "0x2edfbd5bc113ff18c0631595db32eb17182872d88d9bf8ee4d8c2dd5db6d95e2",
|
||||||
|
"executor": null,
|
||||||
|
"isExecuted": false,
|
||||||
|
"isSuccessful": null,
|
||||||
|
"ethGasPrice": null,
|
||||||
|
"gasUsed": null,
|
||||||
|
"fee": null,
|
||||||
|
"origin": null,
|
||||||
|
"dataDecoded": null,
|
||||||
|
"confirmationsRequired": null,
|
||||||
|
"confirmations": [
|
||||||
|
{
|
||||||
|
"owner": "0xAd2e180019FCa9e55CADe76E4487F126Fd08DA34",
|
||||||
|
"submissionDate": "2020-09-15T21:54:49.663299Z",
|
||||||
|
"transactionHash": null,
|
||||||
|
"confirmationType": "CONFIRMATION",
|
||||||
|
"signature": "0x95a7250bb645f831c86defc847350e7faff815b2fb586282568e96cc859e39315876db20a2eed5f7a0412906ec5ab57652a6f645ad4833f345bda059b9da2b821c",
|
||||||
|
"signatureType": "EOA"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"signatures": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"id": 67
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Not all fields are required, though. This method is really just a UX helper, which massages the
|
||||||
|
input to conform to the `EIP-712` [specification](https://docs.gnosis.io/safe/docs/contracts_tx_execution/#transaction-hash)
|
||||||
|
for the Gnosis Safe, and making the output be directly importable to by a relay service.
|
||||||
|
|
||||||
|
|
||||||
### 6.0.0
|
### 6.0.0
|
||||||
|
|
||||||
|
|||||||
@@ -25,11 +25,9 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"math/big"
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"os/user"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sort"
|
"sort"
|
||||||
@@ -51,11 +49,11 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
"github.com/ethereum/go-ethereum/signer/core"
|
"github.com/ethereum/go-ethereum/signer/core"
|
||||||
|
"github.com/ethereum/go-ethereum/signer/core/apitypes"
|
||||||
"github.com/ethereum/go-ethereum/signer/fourbyte"
|
"github.com/ethereum/go-ethereum/signer/fourbyte"
|
||||||
"github.com/ethereum/go-ethereum/signer/rules"
|
"github.com/ethereum/go-ethereum/signer/rules"
|
||||||
"github.com/ethereum/go-ethereum/signer/storage"
|
"github.com/ethereum/go-ethereum/signer/storage"
|
||||||
|
"github.com/mattn/go-colorable"
|
||||||
colorable "github.com/mattn/go-colorable"
|
|
||||||
"github.com/mattn/go-isatty"
|
"github.com/mattn/go-isatty"
|
||||||
"gopkg.in/urfave/cli.v1"
|
"gopkg.in/urfave/cli.v1"
|
||||||
)
|
)
|
||||||
@@ -108,11 +106,6 @@ var (
|
|||||||
Usage: "HTTP-RPC server listening port",
|
Usage: "HTTP-RPC server listening port",
|
||||||
Value: node.DefaultHTTPPort + 5,
|
Value: node.DefaultHTTPPort + 5,
|
||||||
}
|
}
|
||||||
legacyRPCPortFlag = cli.IntFlag{
|
|
||||||
Name: "rpcport",
|
|
||||||
Usage: "HTTP-RPC server listening port (Deprecated, please use --http.port).",
|
|
||||||
Value: node.DefaultHTTPPort + 5,
|
|
||||||
}
|
|
||||||
signerSecretFlag = cli.StringFlag{
|
signerSecretFlag = cli.StringFlag{
|
||||||
Name: "signersecret",
|
Name: "signersecret",
|
||||||
Usage: "A file containing the (encrypted) master seed to encrypt Clef data, e.g. keystore credentials and ruleset hash",
|
Usage: "A file containing the (encrypted) master seed to encrypt Clef data, e.g. keystore credentials and ruleset hash",
|
||||||
@@ -251,12 +244,6 @@ var AppHelpFlagGroups = []flags.FlagGroup{
|
|||||||
acceptFlag,
|
acceptFlag,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
Name: "ALIASED (deprecated)",
|
|
||||||
Flags: []cli.Flag{
|
|
||||||
legacyRPCPortFlag,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -284,7 +271,6 @@ func init() {
|
|||||||
testFlag,
|
testFlag,
|
||||||
advancedMode,
|
advancedMode,
|
||||||
acceptFlag,
|
acceptFlag,
|
||||||
legacyRPCPortFlag,
|
|
||||||
}
|
}
|
||||||
app.Action = signer
|
app.Action = signer
|
||||||
app.Commands = []cli.Command{initCommand,
|
app.Commands = []cli.Command{initCommand,
|
||||||
@@ -387,7 +373,7 @@ func initializeSecrets(c *cli.Context) error {
|
|||||||
return fmt.Errorf("master key %v already exists, will not overwrite", location)
|
return fmt.Errorf("master key %v already exists, will not overwrite", location)
|
||||||
}
|
}
|
||||||
// Write the file and print the usual warning message
|
// Write the file and print the usual warning message
|
||||||
if err = ioutil.WriteFile(location, cipherSeed, 0400); err != nil {
|
if err = os.WriteFile(location, cipherSeed, 0400); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fmt.Printf("A master seed has been generated into %s\n", location)
|
fmt.Printf("A master seed has been generated into %s\n", location)
|
||||||
@@ -606,7 +592,7 @@ func signer(c *cli.Context) error {
|
|||||||
|
|
||||||
// Do we have a rule-file?
|
// Do we have a rule-file?
|
||||||
if ruleFile := c.GlobalString(ruleFlag.Name); ruleFile != "" {
|
if ruleFile := c.GlobalString(ruleFlag.Name); ruleFile != "" {
|
||||||
ruleJS, err := ioutil.ReadFile(ruleFile)
|
ruleJS, err := os.ReadFile(ruleFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn("Could not load rules, disabling", "file", ruleFile, "err", err)
|
log.Warn("Could not load rules, disabling", "file", ruleFile, "err", err)
|
||||||
} else {
|
} else {
|
||||||
@@ -666,24 +652,18 @@ func signer(c *cli.Context) error {
|
|||||||
Version: "1.0"},
|
Version: "1.0"},
|
||||||
}
|
}
|
||||||
if c.GlobalBool(utils.HTTPEnabledFlag.Name) {
|
if c.GlobalBool(utils.HTTPEnabledFlag.Name) {
|
||||||
vhosts := splitAndTrim(c.GlobalString(utils.HTTPVirtualHostsFlag.Name))
|
vhosts := utils.SplitAndTrim(c.GlobalString(utils.HTTPVirtualHostsFlag.Name))
|
||||||
cors := splitAndTrim(c.GlobalString(utils.HTTPCORSDomainFlag.Name))
|
cors := utils.SplitAndTrim(c.GlobalString(utils.HTTPCORSDomainFlag.Name))
|
||||||
|
|
||||||
srv := rpc.NewServer()
|
srv := rpc.NewServer()
|
||||||
err := node.RegisterApisFromWhitelist(rpcAPI, []string{"account"}, srv, false)
|
err := node.RegisterApis(rpcAPI, []string{"account"}, srv, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf("Could not register API: %w", err)
|
utils.Fatalf("Could not register API: %w", err)
|
||||||
}
|
}
|
||||||
handler := node.NewHTTPHandlerStack(srv, cors, vhosts)
|
handler := node.NewHTTPHandlerStack(srv, cors, vhosts, nil)
|
||||||
|
|
||||||
// set port
|
// set port
|
||||||
port := c.Int(rpcPortFlag.Name)
|
port := c.Int(rpcPortFlag.Name)
|
||||||
if c.GlobalIsSet(legacyRPCPortFlag.Name) {
|
|
||||||
if !c.GlobalIsSet(rpcPortFlag.Name) {
|
|
||||||
port = c.Int(legacyRPCPortFlag.Name)
|
|
||||||
}
|
|
||||||
log.Warn("The flag --rpcport is deprecated and will be removed in the future, please use --http.port")
|
|
||||||
}
|
|
||||||
|
|
||||||
// start http server
|
// start http server
|
||||||
httpEndpoint := fmt.Sprintf("%s:%d", c.GlobalString(utils.HTTPListenAddrFlag.Name), port)
|
httpEndpoint := fmt.Sprintf("%s:%d", c.GlobalString(utils.HTTPListenAddrFlag.Name), port)
|
||||||
@@ -736,21 +716,11 @@ func signer(c *cli.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// splitAndTrim splits input separated by a comma
|
|
||||||
// and trims excessive white space from the substrings.
|
|
||||||
func splitAndTrim(input string) []string {
|
|
||||||
result := strings.Split(input, ",")
|
|
||||||
for i, r := range result {
|
|
||||||
result[i] = strings.TrimSpace(r)
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
// DefaultConfigDir is the default config directory to use for the vaults and other
|
// DefaultConfigDir is the default config directory to use for the vaults and other
|
||||||
// persistence requirements.
|
// persistence requirements.
|
||||||
func DefaultConfigDir() string {
|
func DefaultConfigDir() string {
|
||||||
// Try to place the data folder in the user's home dir
|
// Try to place the data folder in the user's home dir
|
||||||
home := homeDir()
|
home := utils.HomeDir()
|
||||||
if home != "" {
|
if home != "" {
|
||||||
if runtime.GOOS == "darwin" {
|
if runtime.GOOS == "darwin" {
|
||||||
return filepath.Join(home, "Library", "Signer")
|
return filepath.Join(home, "Library", "Signer")
|
||||||
@@ -758,26 +728,15 @@ func DefaultConfigDir() string {
|
|||||||
appdata := os.Getenv("APPDATA")
|
appdata := os.Getenv("APPDATA")
|
||||||
if appdata != "" {
|
if appdata != "" {
|
||||||
return filepath.Join(appdata, "Signer")
|
return filepath.Join(appdata, "Signer")
|
||||||
} else {
|
|
||||||
return filepath.Join(home, "AppData", "Roaming", "Signer")
|
|
||||||
}
|
}
|
||||||
} else {
|
return filepath.Join(home, "AppData", "Roaming", "Signer")
|
||||||
return filepath.Join(home, ".clef")
|
|
||||||
}
|
}
|
||||||
|
return filepath.Join(home, ".clef")
|
||||||
}
|
}
|
||||||
// As we cannot guess a stable location, return empty and handle later
|
// As we cannot guess a stable location, return empty and handle later
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func homeDir() string {
|
|
||||||
if home := os.Getenv("HOME"); home != "" {
|
|
||||||
return home
|
|
||||||
}
|
|
||||||
if usr, err := user.Current(); err == nil {
|
|
||||||
return usr.HomeDir
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
func readMasterKey(ctx *cli.Context, ui core.UIClientAPI) ([]byte, error) {
|
func readMasterKey(ctx *cli.Context, ui core.UIClientAPI) ([]byte, error) {
|
||||||
var (
|
var (
|
||||||
file string
|
file string
|
||||||
@@ -791,7 +750,7 @@ func readMasterKey(ctx *cli.Context, ui core.UIClientAPI) ([]byte, error) {
|
|||||||
if err := checkFile(file); err != nil {
|
if err := checkFile(file); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
cipherKey, err := ioutil.ReadFile(file)
|
cipherKey, err := os.ReadFile(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -827,14 +786,16 @@ func readMasterKey(ctx *cli.Context, ui core.UIClientAPI) ([]byte, error) {
|
|||||||
|
|
||||||
// checkFile is a convenience function to check if a file
|
// checkFile is a convenience function to check if a file
|
||||||
// * exists
|
// * exists
|
||||||
// * is mode 0400
|
// * is mode 0400 (unix only)
|
||||||
func checkFile(filename string) error {
|
func checkFile(filename string) error {
|
||||||
info, err := os.Stat(filename)
|
info, err := os.Stat(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed stat on %s: %v", filename, err)
|
return fmt.Errorf("failed stat on %s: %v", filename, err)
|
||||||
}
|
}
|
||||||
// Check the unix permission bits
|
// Check the unix permission bits
|
||||||
if info.Mode().Perm()&0377 != 0 {
|
// However, on windows, we cannot use the unix perm-bits, see
|
||||||
|
// https://github.com/ethereum/go-ethereum/issues/20123
|
||||||
|
if runtime.GOOS != "windows" && info.Mode().Perm()&0377 != 0 {
|
||||||
return fmt.Errorf("file (%v) has insecure file permissions (%v)", filename, info.Mode().String())
|
return fmt.Errorf("file (%v) has insecure file permissions (%v)", filename, info.Mode().String())
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@@ -936,7 +897,7 @@ func testExternalUI(api *core.SignerAPI) {
|
|||||||
addr, _ := common.NewMixedcaseAddressFromString("0x0011223344556677889900112233445566778899")
|
addr, _ := common.NewMixedcaseAddressFromString("0x0011223344556677889900112233445566778899")
|
||||||
data := `{"types":{"EIP712Domain":[{"name":"name","type":"string"},{"name":"version","type":"string"},{"name":"chainId","type":"uint256"},{"name":"verifyingContract","type":"address"}],"Person":[{"name":"name","type":"string"},{"name":"test","type":"uint8"},{"name":"wallet","type":"address"}],"Mail":[{"name":"from","type":"Person"},{"name":"to","type":"Person"},{"name":"contents","type":"string"}]},"primaryType":"Mail","domain":{"name":"Ether Mail","version":"1","chainId":"1","verifyingContract":"0xCCCcccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"},"message":{"from":{"name":"Cow","test":"3","wallet":"0xcD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826"},"to":{"name":"Bob","wallet":"0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB","test":"2"},"contents":"Hello, Bob!"}}`
|
data := `{"types":{"EIP712Domain":[{"name":"name","type":"string"},{"name":"version","type":"string"},{"name":"chainId","type":"uint256"},{"name":"verifyingContract","type":"address"}],"Person":[{"name":"name","type":"string"},{"name":"test","type":"uint8"},{"name":"wallet","type":"address"}],"Mail":[{"name":"from","type":"Person"},{"name":"to","type":"Person"},{"name":"contents","type":"string"}]},"primaryType":"Mail","domain":{"name":"Ether Mail","version":"1","chainId":"1","verifyingContract":"0xCCCcccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"},"message":{"from":{"name":"Cow","test":"3","wallet":"0xcD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826"},"to":{"name":"Bob","wallet":"0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB","test":"2"},"contents":"Hello, Bob!"}}`
|
||||||
//_, err := api.SignData(ctx, accounts.MimetypeTypedData, *addr, hexutil.Encode([]byte(data)))
|
//_, err := api.SignData(ctx, accounts.MimetypeTypedData, *addr, hexutil.Encode([]byte(data)))
|
||||||
var typedData core.TypedData
|
var typedData apitypes.TypedData
|
||||||
json.Unmarshal([]byte(data), &typedData)
|
json.Unmarshal([]byte(data), &typedData)
|
||||||
_, err := api.SignTypedData(ctx, *addr, typedData)
|
_, err := api.SignTypedData(ctx, *addr, typedData)
|
||||||
expectApprove("sign 712 typed data", err)
|
expectApprove("sign 712 typed data", err)
|
||||||
@@ -961,13 +922,13 @@ func testExternalUI(api *core.SignerAPI) {
|
|||||||
time.Sleep(delay)
|
time.Sleep(delay)
|
||||||
data := hexutil.Bytes([]byte{})
|
data := hexutil.Bytes([]byte{})
|
||||||
to := common.NewMixedcaseAddress(a)
|
to := common.NewMixedcaseAddress(a)
|
||||||
tx := core.SendTxArgs{
|
tx := apitypes.SendTxArgs{
|
||||||
Data: &data,
|
Data: &data,
|
||||||
Nonce: 0x1,
|
Nonce: 0x1,
|
||||||
Value: hexutil.Big(*big.NewInt(6)),
|
Value: hexutil.Big(*big.NewInt(6)),
|
||||||
From: common.NewMixedcaseAddress(a),
|
From: common.NewMixedcaseAddress(a),
|
||||||
To: &to,
|
To: &to,
|
||||||
GasPrice: hexutil.Big(*big.NewInt(5)),
|
GasPrice: (*hexutil.Big)(big.NewInt(5)),
|
||||||
Gas: 1000,
|
Gas: 1000,
|
||||||
Input: nil,
|
Input: nil,
|
||||||
}
|
}
|
||||||
@@ -1063,7 +1024,7 @@ func GenDoc(ctx *cli.Context) {
|
|||||||
"of the work in canonicalizing and making sense of the data, and it's up to the UI to present" +
|
"of the work in canonicalizing and making sense of the data, and it's up to the UI to present" +
|
||||||
"the user with the contents of the `message`"
|
"the user with the contents of the `message`"
|
||||||
sighash, msg := accounts.TextAndHash([]byte("hello world"))
|
sighash, msg := accounts.TextAndHash([]byte("hello world"))
|
||||||
messages := []*core.NameValueType{{Name: "message", Value: msg, Typ: accounts.MimetypeTextPlain}}
|
messages := []*apitypes.NameValueType{{Name: "message", Value: msg, Typ: accounts.MimetypeTextPlain}}
|
||||||
|
|
||||||
add("SignDataRequest", desc, &core.SignDataRequest{
|
add("SignDataRequest", desc, &core.SignDataRequest{
|
||||||
Address: common.NewMixedcaseAddress(a),
|
Address: common.NewMixedcaseAddress(a),
|
||||||
@@ -1093,17 +1054,17 @@ func GenDoc(ctx *cli.Context) {
|
|||||||
data := hexutil.Bytes([]byte{0x01, 0x02, 0x03, 0x04})
|
data := hexutil.Bytes([]byte{0x01, 0x02, 0x03, 0x04})
|
||||||
add("SignTxRequest", desc, &core.SignTxRequest{
|
add("SignTxRequest", desc, &core.SignTxRequest{
|
||||||
Meta: meta,
|
Meta: meta,
|
||||||
Callinfo: []core.ValidationInfo{
|
Callinfo: []apitypes.ValidationInfo{
|
||||||
{Typ: "Warning", Message: "Something looks odd, show this message as a warning"},
|
{Typ: "Warning", Message: "Something looks odd, show this message as a warning"},
|
||||||
{Typ: "Info", Message: "User should see this as well"},
|
{Typ: "Info", Message: "User should see this as well"},
|
||||||
},
|
},
|
||||||
Transaction: core.SendTxArgs{
|
Transaction: apitypes.SendTxArgs{
|
||||||
Data: &data,
|
Data: &data,
|
||||||
Nonce: 0x1,
|
Nonce: 0x1,
|
||||||
Value: hexutil.Big(*big.NewInt(6)),
|
Value: hexutil.Big(*big.NewInt(6)),
|
||||||
From: common.NewMixedcaseAddress(a),
|
From: common.NewMixedcaseAddress(a),
|
||||||
To: nil,
|
To: nil,
|
||||||
GasPrice: hexutil.Big(*big.NewInt(5)),
|
GasPrice: (*hexutil.Big)(big.NewInt(5)),
|
||||||
Gas: 1000,
|
Gas: 1000,
|
||||||
Input: nil,
|
Input: nil,
|
||||||
}})
|
}})
|
||||||
@@ -1113,13 +1074,13 @@ func GenDoc(ctx *cli.Context) {
|
|||||||
add("SignTxResponse - approve", "Response to request to sign a transaction. This response needs to contain the `transaction`"+
|
add("SignTxResponse - approve", "Response to request to sign a transaction. This response needs to contain the `transaction`"+
|
||||||
", because the UI is free to make modifications to the transaction.",
|
", because the UI is free to make modifications to the transaction.",
|
||||||
&core.SignTxResponse{Approved: true,
|
&core.SignTxResponse{Approved: true,
|
||||||
Transaction: core.SendTxArgs{
|
Transaction: apitypes.SendTxArgs{
|
||||||
Data: &data,
|
Data: &data,
|
||||||
Nonce: 0x4,
|
Nonce: 0x4,
|
||||||
Value: hexutil.Big(*big.NewInt(6)),
|
Value: hexutil.Big(*big.NewInt(6)),
|
||||||
From: common.NewMixedcaseAddress(a),
|
From: common.NewMixedcaseAddress(a),
|
||||||
To: nil,
|
To: nil,
|
||||||
GasPrice: hexutil.Big(*big.NewInt(5)),
|
GasPrice: (*hexutil.Big)(big.NewInt(5)),
|
||||||
Gas: 1000,
|
Gas: 1000,
|
||||||
Input: nil,
|
Input: nil,
|
||||||
}})
|
}})
|
||||||
@@ -1144,7 +1105,7 @@ func GenDoc(ctx *cli.Context) {
|
|||||||
|
|
||||||
rlpdata := common.FromHex("0xf85d640101948a8eafb1cf62bfbeb1741769dae1a9dd47996192018026a0716bd90515acb1e68e5ac5867aa11a1e65399c3349d479f5fb698554ebc6f293a04e8a4ebfff434e971e0ef12c5bf3a881b06fd04fc3f8b8a7291fb67a26a1d4ed")
|
rlpdata := common.FromHex("0xf85d640101948a8eafb1cf62bfbeb1741769dae1a9dd47996192018026a0716bd90515acb1e68e5ac5867aa11a1e65399c3349d479f5fb698554ebc6f293a04e8a4ebfff434e971e0ef12c5bf3a881b06fd04fc3f8b8a7291fb67a26a1d4ed")
|
||||||
var tx types.Transaction
|
var tx types.Transaction
|
||||||
rlp.DecodeBytes(rlpdata, &tx)
|
tx.UnmarshalBinary(rlpdata)
|
||||||
add("OnApproved - SignTransactionResult", desc, ðapi.SignTransactionResult{Raw: rlpdata, Tx: &tx})
|
add("OnApproved - SignTransactionResult", desc, ðapi.SignTransactionResult{Raw: rlpdata, Tx: &tx})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,177 +1,315 @@
|
|||||||
import os,sys, subprocess
|
import sys
|
||||||
|
import subprocess
|
||||||
|
|
||||||
from tinyrpc.transports import ServerTransport
|
from tinyrpc.transports import ServerTransport
|
||||||
from tinyrpc.protocols.jsonrpc import JSONRPCProtocol
|
from tinyrpc.protocols.jsonrpc import JSONRPCProtocol
|
||||||
from tinyrpc.dispatch import public,RPCDispatcher
|
from tinyrpc.dispatch import public, RPCDispatcher
|
||||||
from tinyrpc.server import RPCServer
|
from tinyrpc.server import RPCServer
|
||||||
|
|
||||||
""" This is a POC example of how to write a custom UI for Clef. The UI starts the
|
"""
|
||||||
clef process with the '--stdio-ui' option, and communicates with clef using standard input / output.
|
This is a POC example of how to write a custom UI for Clef.
|
||||||
|
The UI starts the clef process with the '--stdio-ui' option
|
||||||
|
and communicates with clef using standard input / output.
|
||||||
|
|
||||||
The standard input/output is a relatively secure way to communicate, as it does not require opening any ports
|
The standard input/output is a relatively secure way to communicate,
|
||||||
or IPC files. Needless to say, it does not protect against memory inspection mechanisms where an attacker
|
as it does not require opening any ports or IPC files. Needless to say,
|
||||||
can access process memory."""
|
it does not protect against memory inspection mechanisms
|
||||||
|
where an attacker can access process memory.
|
||||||
|
|
||||||
|
To make this work install all the requirements:
|
||||||
|
|
||||||
|
pip install -r requirements.txt
|
||||||
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import urllib.parse as urlparse
|
import urllib.parse as urlparse
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import urllib as urlparse
|
import urllib as urlparse
|
||||||
|
|
||||||
|
|
||||||
class StdIOTransport(ServerTransport):
|
class StdIOTransport(ServerTransport):
|
||||||
""" Uses std input/output for RPC """
|
"""Uses std input/output for RPC"""
|
||||||
|
|
||||||
def receive_message(self):
|
def receive_message(self):
|
||||||
return None, urlparse.unquote(sys.stdin.readline())
|
return None, urlparse.unquote(sys.stdin.readline())
|
||||||
|
|
||||||
def send_reply(self, context, reply):
|
def send_reply(self, context, reply):
|
||||||
print(reply)
|
print(reply)
|
||||||
|
|
||||||
class PipeTransport(ServerTransport):
|
|
||||||
""" Uses std a pipe for RPC """
|
|
||||||
|
|
||||||
def __init__(self,input, output):
|
class PipeTransport(ServerTransport):
|
||||||
|
"""Uses std a pipe for RPC"""
|
||||||
|
|
||||||
|
def __init__(self, input, output):
|
||||||
self.input = input
|
self.input = input
|
||||||
self.output = output
|
self.output = output
|
||||||
|
|
||||||
def receive_message(self):
|
def receive_message(self):
|
||||||
data = self.input.readline()
|
data = self.input.readline()
|
||||||
print(">> {}".format( data))
|
print(">> {}".format(data))
|
||||||
return None, urlparse.unquote(data)
|
return None, urlparse.unquote(data)
|
||||||
|
|
||||||
def send_reply(self, context, reply):
|
def send_reply(self, context, reply):
|
||||||
print("<< {}".format( reply))
|
reply = str(reply, "utf-8")
|
||||||
self.output.write(reply)
|
print("<< {}".format(reply))
|
||||||
self.output.write("\n")
|
self.output.write("{}\n".format(reply))
|
||||||
|
|
||||||
class StdIOHandler():
|
|
||||||
|
def sanitize(txt, limit=100):
|
||||||
|
return txt[:limit].encode("unicode_escape").decode("utf-8")
|
||||||
|
|
||||||
|
|
||||||
|
def metaString(meta):
|
||||||
|
"""
|
||||||
|
"meta":{"remote":"clef binary","local":"main","scheme":"in-proc","User-Agent":"","Origin":""}
|
||||||
|
""" # noqa: E501
|
||||||
|
message = (
|
||||||
|
"\tRequest context:\n"
|
||||||
|
"\t\t{remote} -> {scheme} -> {local}\n"
|
||||||
|
"\tAdditional HTTP header data, provided by the external caller:\n"
|
||||||
|
"\t\tUser-Agent: {user_agent}\n"
|
||||||
|
"\t\tOrigin: {origin}\n"
|
||||||
|
)
|
||||||
|
return message.format(
|
||||||
|
remote=meta.get("remote", "<missing>"),
|
||||||
|
scheme=meta.get("scheme", "<missing>"),
|
||||||
|
local=meta.get("local", "<missing>"),
|
||||||
|
user_agent=sanitize(meta.get("User-Agent"), 200),
|
||||||
|
origin=sanitize(meta.get("Origin"), 100),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class StdIOHandler:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@public
|
@public
|
||||||
def ApproveTx(self,req):
|
def approveTx(self, req):
|
||||||
"""
|
"""
|
||||||
Example request:
|
Example request:
|
||||||
{
|
|
||||||
"jsonrpc": "2.0",
|
{"jsonrpc":"2.0","id":20,"method":"ui_approveTx","params":[{"transaction":{"from":"0xDEADbEeF000000000000000000000000DeaDbeEf","to":"0xDEADbEeF000000000000000000000000DeaDbeEf","gas":"0x3e8","gasPrice":"0x5","maxFeePerGas":null,"maxPriorityFeePerGas":null,"value":"0x6","nonce":"0x1","data":"0x"},"call_info":null,"meta":{"remote":"clef binary","local":"main","scheme":"in-proc","User-Agent":"","Origin":""}}]}
|
||||||
"method": "ApproveTx",
|
|
||||||
"params": [{
|
|
||||||
"transaction": {
|
|
||||||
"to": "0xae967917c465db8578ca9024c205720b1a3651A9",
|
|
||||||
"gas": "0x333",
|
|
||||||
"gasPrice": "0x123",
|
|
||||||
"value": "0x10",
|
|
||||||
"data": "0xd7a5865800000000000000000000000000000000000000000000000000000000000000ff",
|
|
||||||
"nonce": "0x0"
|
|
||||||
},
|
|
||||||
"from": "0xAe967917c465db8578ca9024c205720b1a3651A9",
|
|
||||||
"call_info": "Warning! Could not validate ABI-data against calldata\nSupplied ABI spec does not contain method signature in data: 0xd7a58658",
|
|
||||||
"meta": {
|
|
||||||
"remote": "127.0.0.1:34572",
|
|
||||||
"local": "localhost:8550",
|
|
||||||
"scheme": "HTTP/1.1"
|
|
||||||
}
|
|
||||||
}],
|
|
||||||
"id": 1
|
|
||||||
}
|
|
||||||
|
|
||||||
:param transaction: transaction info
|
:param transaction: transaction info
|
||||||
:param call_info: info abou the call, e.g. if ABI info could not be
|
:param call_info: info abou the call, e.g. if ABI info could not be
|
||||||
:param meta: metadata about the request, e.g. where the call comes from
|
:param meta: metadata about the request, e.g. where the call comes from
|
||||||
:return:
|
:return:
|
||||||
"""
|
""" # noqa: E501
|
||||||
transaction = req.get('transaction')
|
message = (
|
||||||
_from = req.get('from')
|
"Sign transaction request:\n"
|
||||||
call_info = req.get('call_info')
|
"\t{meta_string}\n"
|
||||||
meta = req.get('meta')
|
"\n"
|
||||||
|
"\tFrom: {from_}\n"
|
||||||
|
"\tTo: {to}\n"
|
||||||
|
"\n"
|
||||||
|
"\tAuto-rejecting request"
|
||||||
|
)
|
||||||
|
meta = req.get("meta", {})
|
||||||
|
transaction = req.get("transaction")
|
||||||
|
sys.stdout.write(
|
||||||
|
message.format(
|
||||||
|
meta_string=metaString(meta),
|
||||||
|
from_=transaction.get("from", "<missing>"),
|
||||||
|
to=transaction.get("to", "<missing>"),
|
||||||
|
)
|
||||||
|
)
|
||||||
return {
|
return {
|
||||||
"approved" : False,
|
"approved": False,
|
||||||
#"transaction" : transaction,
|
|
||||||
# "from" : _from,
|
|
||||||
# "password" : None,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@public
|
@public
|
||||||
def ApproveSignData(self, req):
|
def approveSignData(self, req):
|
||||||
""" Example request
|
|
||||||
|
|
||||||
"""
|
|
||||||
return {"approved": False, "password" : None}
|
|
||||||
|
|
||||||
@public
|
|
||||||
def ApproveExport(self, req):
|
|
||||||
""" Example request
|
|
||||||
|
|
||||||
"""
|
|
||||||
return {"approved" : False}
|
|
||||||
|
|
||||||
@public
|
|
||||||
def ApproveImport(self, req):
|
|
||||||
""" Example request
|
|
||||||
|
|
||||||
"""
|
|
||||||
return { "approved" : False, "old_password": "", "new_password": ""}
|
|
||||||
|
|
||||||
@public
|
|
||||||
def ApproveListing(self, req):
|
|
||||||
""" Example request
|
|
||||||
|
|
||||||
"""
|
|
||||||
return {'accounts': []}
|
|
||||||
|
|
||||||
@public
|
|
||||||
def ApproveNewAccount(self, req):
|
|
||||||
"""
|
|
||||||
Example request
|
|
||||||
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
return {"approved": False,
|
|
||||||
#"password": ""
|
|
||||||
}
|
|
||||||
|
|
||||||
@public
|
|
||||||
def ShowError(self,message = {}):
|
|
||||||
"""
|
"""
|
||||||
Example request:
|
Example request:
|
||||||
|
|
||||||
{"jsonrpc":"2.0","method":"ShowInfo","params":{"message":"Testing 'ShowError'"},"id":1}
|
{"jsonrpc":"2.0","id":8,"method":"ui_approveSignData","params":[{"content_type":"application/x-clique-header","address":"0x0011223344556677889900112233445566778899","raw_data":"+QIRoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlAAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAuQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIIFOYIFOYIFOoIFOoIFOppFeHRyYSBkYXRhIEV4dHJhIGRhdGEgRXh0cqAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIgAAAAAAAAAAA==","messages":[{"name":"Clique header","value":"clique header 1337 [0x44381ab449d77774874aca34634cb53bc21bd22aef2d3d4cf40e51176cb585ec]","type":"clique"}],"call_info":null,"hash":"0xa47ab61438a12a06c81420e308c2b7aae44e9cd837a5df70dd021421c0f58643","meta":{"remote":"clef binary","local":"main","scheme":"in-proc","User-Agent":"","Origin":""}}]}
|
||||||
|
""" # noqa: E501
|
||||||
|
message = (
|
||||||
|
"Sign data request:\n"
|
||||||
|
"\t{meta_string}\n"
|
||||||
|
"\n"
|
||||||
|
"\tContent-type: {content_type}\n"
|
||||||
|
"\tAddress: {address}\n"
|
||||||
|
"\tHash: {hash_}\n"
|
||||||
|
"\n"
|
||||||
|
"\tAuto-rejecting request\n"
|
||||||
|
)
|
||||||
|
meta = req.get("meta", {})
|
||||||
|
sys.stdout.write(
|
||||||
|
message.format(
|
||||||
|
meta_string=metaString(meta),
|
||||||
|
content_type=req.get("content_type"),
|
||||||
|
address=req.get("address"),
|
||||||
|
hash_=req.get("hash"),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
:param message: to show
|
return {
|
||||||
:return: nothing
|
"approved": False,
|
||||||
"""
|
"password": None,
|
||||||
if 'text' in message.keys():
|
}
|
||||||
sys.stderr.write("Error: {}\n".format( message['text']))
|
|
||||||
return
|
|
||||||
|
|
||||||
@public
|
@public
|
||||||
def ShowInfo(self,message = {}):
|
def approveNewAccount(self, req):
|
||||||
"""
|
"""
|
||||||
Example request
|
Example request:
|
||||||
{"jsonrpc":"2.0","method":"ShowInfo","params":{"message":"Testing 'ShowInfo'"},"id":0}
|
|
||||||
|
{"jsonrpc":"2.0","id":25,"method":"ui_approveNewAccount","params":[{"meta":{"remote":"clef binary","local":"main","scheme":"in-proc","User-Agent":"","Origin":""}}]}
|
||||||
|
""" # noqa: E501
|
||||||
|
message = (
|
||||||
|
"Create new account request:\n"
|
||||||
|
"\t{meta_string}\n"
|
||||||
|
"\n"
|
||||||
|
"\tAuto-rejecting request\n"
|
||||||
|
)
|
||||||
|
meta = req.get("meta", {})
|
||||||
|
sys.stdout.write(message.format(meta_string=metaString(meta)))
|
||||||
|
return {
|
||||||
|
"approved": False,
|
||||||
|
}
|
||||||
|
|
||||||
|
@public
|
||||||
|
def showError(self, req):
|
||||||
|
"""
|
||||||
|
Example request:
|
||||||
|
|
||||||
|
{"jsonrpc":"2.0","method":"ui_showError","params":[{"text":"If you see this message, enter 'yes' to the next question"}]}
|
||||||
|
|
||||||
:param message: to display
|
:param message: to display
|
||||||
:return:nothing
|
:return:nothing
|
||||||
"""
|
""" # noqa: E501
|
||||||
|
message = (
|
||||||
if 'text' in message.keys():
|
"## Error\n{text}\n"
|
||||||
sys.stdout.write("Error: {}\n".format( message['text']))
|
"Press enter to continue\n"
|
||||||
|
)
|
||||||
|
text = req.get("text")
|
||||||
|
sys.stdout.write(message.format(text=text))
|
||||||
|
input()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@public
|
||||||
|
def showInfo(self, req):
|
||||||
|
"""
|
||||||
|
Example request:
|
||||||
|
|
||||||
|
{"jsonrpc":"2.0","method":"ui_showInfo","params":[{"text":"If you see this message, enter 'yes' to next question"}]}
|
||||||
|
|
||||||
|
:param message: to display
|
||||||
|
:return:nothing
|
||||||
|
""" # noqa: E501
|
||||||
|
message = (
|
||||||
|
"## Info\n{text}\n"
|
||||||
|
"Press enter to continue\n"
|
||||||
|
)
|
||||||
|
text = req.get("text")
|
||||||
|
sys.stdout.write(message.format(text=text))
|
||||||
|
input()
|
||||||
|
return
|
||||||
|
|
||||||
|
@public
|
||||||
|
def onSignerStartup(self, req):
|
||||||
|
"""
|
||||||
|
Example request:
|
||||||
|
|
||||||
|
{"jsonrpc":"2.0", "method":"ui_onSignerStartup", "params":[{"info":{"extapi_http":"n/a","extapi_ipc":"/home/user/.clef/clef.ipc","extapi_version":"6.1.0","intapi_version":"7.0.1"}}]}
|
||||||
|
""" # noqa: E501
|
||||||
|
message = (
|
||||||
|
"\n"
|
||||||
|
"\t\tExt api url: {extapi_http}\n"
|
||||||
|
"\t\tInt api ipc: {extapi_ipc}\n"
|
||||||
|
"\t\tExt api ver: {extapi_version}\n"
|
||||||
|
"\t\tInt api ver: {intapi_version}\n"
|
||||||
|
)
|
||||||
|
info = req.get("info")
|
||||||
|
sys.stdout.write(
|
||||||
|
message.format(
|
||||||
|
extapi_http=info.get("extapi_http"),
|
||||||
|
extapi_ipc=info.get("extapi_ipc"),
|
||||||
|
extapi_version=info.get("extapi_version"),
|
||||||
|
intapi_version=info.get("intapi_version"),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
@public
|
||||||
|
def approveListing(self, req):
|
||||||
|
"""
|
||||||
|
Example request:
|
||||||
|
|
||||||
|
{"jsonrpc":"2.0","id":23,"method":"ui_approveListing","params":[{"accounts":[{"address":...
|
||||||
|
""" # noqa: E501
|
||||||
|
message = (
|
||||||
|
"\n"
|
||||||
|
"## Account listing request\n"
|
||||||
|
"\t{meta_string}\n"
|
||||||
|
"\tDo you want to allow listing the following accounts?\n"
|
||||||
|
"\t-{addrs}\n"
|
||||||
|
"\n"
|
||||||
|
"->Auto-answering No\n"
|
||||||
|
)
|
||||||
|
meta = req.get("meta", {})
|
||||||
|
accounts = req.get("accounts", [])
|
||||||
|
addrs = [x.get("address") for x in accounts]
|
||||||
|
sys.stdout.write(
|
||||||
|
message.format(
|
||||||
|
addrs="\n\t-".join(addrs),
|
||||||
|
meta_string=metaString(meta)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return {}
|
||||||
|
|
||||||
|
@public
|
||||||
|
def onInputRequired(self, req):
|
||||||
|
"""
|
||||||
|
Example request:
|
||||||
|
|
||||||
|
{"jsonrpc":"2.0","id":1,"method":"ui_onInputRequired","params":[{"title":"Master Password","prompt":"Please enter the password to decrypt the master seed","isPassword":true}]}
|
||||||
|
|
||||||
|
:param message: to display
|
||||||
|
:return:nothing
|
||||||
|
""" # noqa: E501
|
||||||
|
message = (
|
||||||
|
"\n"
|
||||||
|
"## {title}\n"
|
||||||
|
"\t{prompt}\n"
|
||||||
|
"\n"
|
||||||
|
"> "
|
||||||
|
)
|
||||||
|
sys.stdout.write(
|
||||||
|
message.format(
|
||||||
|
title=req.get("title"),
|
||||||
|
prompt=req.get("prompt")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
isPassword = req.get("isPassword")
|
||||||
|
if not isPassword:
|
||||||
|
return {"text": input()}
|
||||||
|
|
||||||
|
return ""
|
||||||
|
|
||||||
|
|
||||||
def main(args):
|
def main(args):
|
||||||
cmd = ["clef", "--stdio-ui"]
|
cmd = ["clef", "--stdio-ui"]
|
||||||
if len(args) > 0 and args[0] == "test":
|
if len(args) > 0 and args[0] == "test":
|
||||||
cmd.extend(["--stdio-ui-test"])
|
cmd.extend(["--stdio-ui-test"])
|
||||||
print("cmd: {}".format(" ".join(cmd)))
|
print("cmd: {}".format(" ".join(cmd)))
|
||||||
|
|
||||||
dispatcher = RPCDispatcher()
|
dispatcher = RPCDispatcher()
|
||||||
dispatcher.register_instance(StdIOHandler(), '')
|
dispatcher.register_instance(StdIOHandler(), "ui_")
|
||||||
|
|
||||||
# line buffered
|
# line buffered
|
||||||
p = subprocess.Popen(cmd, bufsize=1, universal_newlines=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
p = subprocess.Popen(
|
||||||
|
cmd,
|
||||||
|
bufsize=1,
|
||||||
|
universal_newlines=True,
|
||||||
|
stdin=subprocess.PIPE,
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
)
|
||||||
|
|
||||||
rpc_server = RPCServer(
|
rpc_server = RPCServer(
|
||||||
PipeTransport(p.stdout, p.stdin),
|
PipeTransport(p.stdout, p.stdin), JSONRPCProtocol(), dispatcher
|
||||||
JSONRPCProtocol(),
|
|
||||||
dispatcher
|
|
||||||
)
|
)
|
||||||
rpc_server.serve_forever()
|
rpc_server.serve_forever()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
|
if __name__ == "__main__":
|
||||||
main(sys.argv[1:])
|
main(sys.argv[1:])
|
||||||
|
|||||||
1
cmd/clef/requirements.txt
Normal file
1
cmd/clef/requirements.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
tinyrpc==1.1.4
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
16
cmd/clef/testdata/sign_1559_missing_field_exp_fail.json
vendored
Normal file
16
cmd/clef/testdata/sign_1559_missing_field_exp_fail.json
vendored
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"method": "account_signTransaction",
|
||||||
|
"params": [
|
||||||
|
{
|
||||||
|
"from": "0x8A8eAFb1cf62BfBeb1741769DAE1a9dd47996192",
|
||||||
|
"to": "0x8A8eAFb1cf62BfBeb1741769DAE1a9dd47996192",
|
||||||
|
"gas": "0x333",
|
||||||
|
"maxFeePerGas": "0x123",
|
||||||
|
"nonce": "0x0",
|
||||||
|
"value": "0x10",
|
||||||
|
"data": "0x4401a6e40000000000000000000000000000000000000000000000000000000000000012"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"id": 67
|
||||||
|
}
|
||||||
16
cmd/clef/testdata/sign_1559_missing_maxfeepergas_exp_fail.json
vendored
Normal file
16
cmd/clef/testdata/sign_1559_missing_maxfeepergas_exp_fail.json
vendored
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"method": "account_signTransaction",
|
||||||
|
"params": [
|
||||||
|
{
|
||||||
|
"from": "0x8A8eAFb1cf62BfBeb1741769DAE1a9dd47996192",
|
||||||
|
"to": "0x8A8eAFb1cf62BfBeb1741769DAE1a9dd47996192",
|
||||||
|
"gas": "0x333",
|
||||||
|
"maxPriorityFeePerGas": "0x123",
|
||||||
|
"nonce": "0x0",
|
||||||
|
"value": "0x10",
|
||||||
|
"data": "0x4401a6e40000000000000000000000000000000000000000000000000000000000000012"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"id": 67
|
||||||
|
}
|
||||||
17
cmd/clef/testdata/sign_1559_tx.json
vendored
Normal file
17
cmd/clef/testdata/sign_1559_tx.json
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"method": "account_signTransaction",
|
||||||
|
"params": [
|
||||||
|
{
|
||||||
|
"from": "0x8A8eAFb1cf62BfBeb1741769DAE1a9dd47996192",
|
||||||
|
"to": "0x8A8eAFb1cf62BfBeb1741769DAE1a9dd47996192",
|
||||||
|
"gas": "0x333",
|
||||||
|
"maxPriorityFeePerGas": "0x123",
|
||||||
|
"maxFeePerGas": "0x123",
|
||||||
|
"nonce": "0x0",
|
||||||
|
"value": "0x10",
|
||||||
|
"data": "0x4401a6e40000000000000000000000000000000000000000000000000000000000000012"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"id": 67
|
||||||
|
}
|
||||||
17
cmd/clef/testdata/sign_bad_checksum_exp_fail.json
vendored
Normal file
17
cmd/clef/testdata/sign_bad_checksum_exp_fail.json
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"method": "account_signTransaction",
|
||||||
|
"params": [
|
||||||
|
{
|
||||||
|
"from":"0x8a8eafb1cf62bfbeb1741769dae1a9dd47996192",
|
||||||
|
"to":"0x8a8eafb1cf62bfbeb1741769dae1a9dd47996192",
|
||||||
|
"gas": "0x333",
|
||||||
|
"gasPrice": "0x123",
|
||||||
|
"nonce": "0x0",
|
||||||
|
"value": "0x10",
|
||||||
|
"data":
|
||||||
|
"0x4401a6e40000000000000000000000000000000000000000000000000000000000000012"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"id": 67
|
||||||
|
}
|
||||||
17
cmd/clef/testdata/sign_normal_exp_ok.json
vendored
Normal file
17
cmd/clef/testdata/sign_normal_exp_ok.json
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"method": "account_signTransaction",
|
||||||
|
"params": [
|
||||||
|
{
|
||||||
|
"from":"0x8A8eAFb1cf62BfBeb1741769DAE1a9dd47996192",
|
||||||
|
"to":"0x8A8eAFb1cf62BfBeb1741769DAE1a9dd47996192",
|
||||||
|
"gas": "0x333",
|
||||||
|
"gasPrice": "0x123",
|
||||||
|
"nonce": "0x0",
|
||||||
|
"value": "0x10",
|
||||||
|
"data":
|
||||||
|
"0x4401a6e40000000000000000000000000000000000000000000000000000000000000012"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"id": 67
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user