Compare commits
672 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
24d727b6d6 | ||
|
|
83a9a73b89 | ||
|
|
5584574217 | ||
|
|
38c3d88cea | ||
|
|
69a8d9841a | ||
|
|
bb724080ca | ||
|
|
b2aac658b0 | ||
|
|
9fe5d20011 | ||
|
|
dd98d1da94 | ||
|
|
362e2ba792 | ||
|
|
31b3334922 | ||
|
|
48b70ecff1 | ||
|
|
c1e3fe6b14 | ||
|
|
2fdff33803 | ||
|
|
da6e6e7971 | ||
|
|
af8daf91a6 | ||
|
|
fd66af5ee5 | ||
|
|
0983d02aa9 | ||
|
|
42a914a84f | ||
|
|
09d588e0da | ||
|
|
6a1a4375c6 | ||
|
|
dfa16a3e4e | ||
|
|
c1d462ee5d | ||
|
|
f32790fb05 | ||
|
|
d2328b604a | ||
|
|
661809714e | ||
|
|
de39513ced | ||
|
|
3ac633ba84 | ||
|
|
b98d2e9a1c | ||
|
|
92639b676a | ||
|
|
f74077b4c2 | ||
|
|
d4415f5e40 | ||
|
|
7a5c1b28dd | ||
|
|
8698fbabf6 | ||
|
|
a3fd415c0f | ||
|
|
4825d9c3dd | ||
|
|
f850123ec7 | ||
|
|
efe5886877 | ||
|
|
085f89172f | ||
|
|
54abb97e3b | ||
|
|
ef8ced4151 | ||
|
|
7e7781ffaa | ||
|
|
cf62bd2e88 | ||
|
|
01371469e6 | ||
|
|
32d35c9c08 | ||
|
|
a4428c505e | ||
|
|
55a4ff806f | ||
|
|
8380a1303c | ||
|
|
7c657fc789 | ||
|
|
3d21d455dc | ||
|
|
3dba6a6d27 | ||
|
|
a7501d0c41 | ||
|
|
dae82f0985 | ||
|
|
8fdbbef72d | ||
|
|
8696986547 | ||
|
|
d606a7a46a | ||
|
|
174083c3ae | ||
|
|
bfed28a421 | ||
|
|
edc39aaedf | ||
|
|
89fe24bbcc | ||
|
|
8b9f469419 | ||
|
|
695a5cce1e | ||
|
|
c207edf2a3 | ||
|
|
4f0d978eaa | ||
|
|
1cd007ecae | ||
|
|
bba5fd8192 | ||
|
|
2714e8f091 | ||
|
|
0699287440 | ||
|
|
197d609b9a | ||
|
|
ca228569e4 | ||
|
|
f5e6634fd2 | ||
|
|
93854bbad4 | ||
|
|
f0515800e6 | ||
|
|
bb29d20828 | ||
|
|
38592a13a3 | ||
|
|
a5898ba621 | ||
|
|
2a113f6d72 | ||
|
|
b24ef5e05d | ||
|
|
76f5f662cc | ||
|
|
6b2cc8950e | ||
|
|
2843001ac2 | ||
|
|
9d5e3e0637 | ||
|
|
3ba0418a9a | ||
|
|
e0d091e090 | ||
|
|
070caec4bd | ||
|
|
4c181e4fb9 | ||
|
|
333b5fb123 | ||
|
|
3fd87f2193 | ||
|
|
c7e522fd17 | ||
|
|
5d80a1b665 | ||
|
|
21dd59bd04 | ||
|
|
493903eede | ||
|
|
3d997b6dec | ||
|
|
d876f214e5 | ||
|
|
7bf7bd2f50 | ||
|
|
d31f1f4fdb | ||
|
|
6b6c4d1c27 | ||
|
|
3333fe660f | ||
|
|
51e2e78d26 | ||
|
|
d136e985e8 | ||
|
|
91c66d47ef | ||
|
|
accc0fab4f | ||
|
|
51b2f1620c | ||
|
|
68be45e5f8 | ||
|
|
ffe2fc3bc4 | ||
|
|
324027640b | ||
|
|
b91766fe6d | ||
|
|
a6942b9f25 | ||
|
|
17d67c5834 | ||
|
|
434dd5bc00 | ||
|
|
14346e4ef9 | ||
|
|
b8a2ac3fcf | ||
|
|
9a000601c6 | ||
|
|
23de6197f9 | ||
|
|
698843b45f | ||
|
|
48b4e8069c | ||
|
|
58632d4402 | ||
|
|
eb8fa3cc89 | ||
|
|
cff97119a7 | ||
|
|
cef7ed53bd | ||
|
|
c41e1bd1eb | ||
|
|
4fecc7a3b1 | ||
|
|
588aa88121 | ||
|
|
8080265f3f | ||
|
|
1212c7b844 | ||
|
|
201a0bf181 | ||
|
|
a0876f7433 | ||
|
|
1ff152f3a4 | ||
|
|
f574c4e74b | ||
|
|
870efeef01 | ||
|
|
144c1c6c52 | ||
|
|
b16cc501a8 | ||
|
|
9313fa63f9 | ||
|
|
d0675e9d9c | ||
|
|
bd519ab8ae | ||
|
|
1064e3283d | ||
|
|
a5dc087845 | ||
|
|
212bf266c5 | ||
|
|
c71e4fc4d5 | ||
|
|
968f6019d0 | ||
|
|
503993c819 | ||
|
|
cf3b187bde | ||
|
|
81533deae5 | ||
|
|
0bcff8f525 | ||
|
|
36ca85fa1c | ||
|
|
b35165555d | ||
|
|
5b74bb6445 | ||
|
|
eea3ae42a3 | ||
|
|
dc6648bb58 | ||
|
|
0fe0b8f7b9 | ||
|
|
80e2f3aca4 | ||
|
|
e2640a96d4 | ||
|
|
79c7a69ac8 | ||
|
|
53eb4e0b0f | ||
|
|
baee850471 | ||
|
|
126dfde6c9 | ||
|
|
f08f596a37 | ||
|
|
3e1cfbae93 | ||
|
|
54f650a3be | ||
|
|
1b6fd032e3 | ||
|
|
8ed4739176 | ||
|
|
80d3907767 | ||
|
|
6810933640 | ||
|
|
7f22b59f87 | ||
|
|
4c0883e20d | ||
|
|
3088c122d8 | ||
|
|
88b41a9e68 | ||
|
|
66debd91d9 | ||
|
|
75060ef96e | ||
|
|
6ff97bf2e5 | ||
|
|
d98c45f70f | ||
|
|
aeb733623e | ||
|
|
97fb08342d | ||
|
|
cdf5982cfc | ||
|
|
4e693ad5a6 | ||
|
|
4466c7b971 | ||
|
|
2868acd80b | ||
|
|
6c313fff7b | ||
|
|
a352de6a08 | ||
|
|
6a7695e367 | ||
|
|
16e4d0e005 | ||
|
|
331fa6d307 | ||
|
|
3e92c853fb | ||
|
|
60827dc50f | ||
|
|
2e98631c5e | ||
|
|
6566a0a3b8 | ||
|
|
dc3c3fb1e1 | ||
|
|
862d6f2fbf | ||
|
|
4868964bb9 | ||
|
|
6f607de5d5 | ||
|
|
dcae0d348b | ||
|
|
f951e23fb5 | ||
|
|
aff421e78c | ||
|
|
4e474c74dc | ||
|
|
da290e9707 | ||
|
|
0fe9a372b3 | ||
|
|
d5c7a6056a | ||
|
|
ff5538ad4c | ||
|
|
8bbe72075e | ||
|
|
97b2806686 | ||
|
|
11d0ff6578 | ||
|
|
72a076840b | ||
|
|
459278cd57 | ||
|
|
cfcc47529d | ||
|
|
c5d34fc94e | ||
|
|
53634f1e04 | ||
|
|
31c4e3a118 | ||
|
|
1d3d4a4d57 | ||
|
|
c5cb214f68 | ||
|
|
f95811e65b | ||
|
|
5ed3960b9b | ||
|
|
5b0c9c8ae5 | ||
|
|
58e868b759 | ||
|
|
5d3b7bb023 | ||
|
|
6ee3b26f44 | ||
|
|
092df3ab59 | ||
|
|
81375a3801 | ||
|
|
d79602d2d4 | ||
|
|
ff7fad18fb | ||
|
|
89a32451ae | ||
|
|
8c63d0d2e4 | ||
|
|
1895059119 | ||
|
|
127553253e | ||
|
|
ff6e0351ab | ||
|
|
b8a0daf0cc | ||
|
|
bfa0f96822 | ||
|
|
82a1c771ef | ||
|
|
9d06b2c5f3 | ||
|
|
e5677114dc | ||
|
|
303b99663e | ||
|
|
14bef9a2db | ||
|
|
d3a773c284 | ||
|
|
de01178c18 | ||
|
|
696bc9b01c | ||
|
|
58c0879c2f | ||
|
|
68b8088cb9 | ||
|
|
b6ccc06cda | ||
|
|
83705ef6aa | ||
|
|
b35622cf3c | ||
|
|
f1e86ad9cf | ||
|
|
bd1f7ebda2 | ||
|
|
26a37c5351 | ||
|
|
0bf3065fb4 | ||
|
|
83116a3479 | ||
|
|
2c8d5dec50 | ||
|
|
668c37fde1 | ||
|
|
b7bbe66b19 | ||
|
|
96fd50be10 | ||
|
|
634e963f02 | ||
|
|
dc5d643bb5 | ||
|
|
9a749dcde5 | ||
|
|
b69942befe | ||
|
|
86ec213076 | ||
|
|
3d782bc727 | ||
|
|
01d9f29805 | ||
|
|
024b22c30e | ||
|
|
ffca6dfe01 | ||
|
|
107f556b2d | ||
|
|
44eb69561a | ||
|
|
d9e324a331 | ||
|
|
a5aaab2f22 | ||
|
|
f1b9a3e2f4 | ||
|
|
79ca6c7a65 | ||
|
|
4d8c7248bd | ||
|
|
7e1c374dc6 | ||
|
|
7910dd5179 | ||
|
|
0ee44e796a | ||
|
|
bf37241eb5 | ||
|
|
d5837e84ff | ||
|
|
dcaabfe7f6 | ||
|
|
2c110c81ee | ||
|
|
c63985d194 | ||
|
|
0da3b17a11 | ||
|
|
d8d8669271 | ||
|
|
bd1f74f654 | ||
|
|
86f68cf04f | ||
|
|
a5e6bf7eef | ||
|
|
e39a9b3480 | ||
|
|
c3cfdfacd0 | ||
|
|
4b6824e07b | ||
|
|
3f7acbbeb9 | ||
|
|
0d5e1e7bc9 | ||
|
|
26cf866349 | ||
|
|
60577d48d5 | ||
|
|
bf411a04ba | ||
|
|
24349144b6 | ||
|
|
7d56602391 | ||
|
|
d3441ebb56 | ||
|
|
09dde380f9 | ||
|
|
a95a601f35 | ||
|
|
d5db4f810e | ||
|
|
b66f793443 | ||
|
|
6663e5da10 | ||
|
|
30cd5c1854 | ||
|
|
9e99a0c2b9 | ||
|
|
0ae462fb80 | ||
|
|
477eb0933b | ||
|
|
1d9d3815e5 | ||
|
|
06d40d37b8 | ||
|
|
ee92bc537f | ||
|
|
d3f056bd68 | ||
|
|
81080bf8cb | ||
|
|
c528e3e3cf | ||
|
|
1a16cc71c6 | ||
|
|
b0d60721f1 | ||
|
|
ab13cd9924 | ||
|
|
32c05e82a3 | ||
|
|
5e32152c02 | ||
|
|
457e930f27 | ||
|
|
ba0a8b7887 | ||
|
|
f55c26ae6d | ||
|
|
d6254f827b | ||
|
|
af89093116 | ||
|
|
f89dce0126 | ||
|
|
0f2ba07c41 | ||
|
|
c37238cae9 | ||
|
|
da29332c5f | ||
|
|
3fec73500b | ||
|
|
6975c72981 | ||
|
|
c35659c6a0 | ||
|
|
6f004c46d5 | ||
|
|
16e95f33b7 | ||
|
|
f5c7d1c8eb | ||
|
|
736b45a876 | ||
|
|
bd9d79adba | ||
|
|
16bc8741bf | ||
|
|
0b477712a1 | ||
|
|
faa69bea1c | ||
|
|
67c332e9b5 | ||
|
|
360a72d54e | ||
|
|
5d921fa3a0 | ||
|
|
1f45ba9bb1 | ||
|
|
caa2c23a38 | ||
|
|
58374e28d9 | ||
|
|
b8aa5980cf | ||
|
|
bd58098f2d | ||
|
|
5d1d1a808d | ||
|
|
41ac8dd803 | ||
|
|
c1345b0742 | ||
|
|
7efb12d29b | ||
|
|
cc21928e12 | ||
|
|
3df7df0386 | ||
|
|
7c71e936a7 | ||
|
|
d4a28a13ca | ||
|
|
86a03f97d3 | ||
|
|
44a1764f9c | ||
|
|
7bb95a9a64 | ||
|
|
72c820c49e | ||
|
|
3ff2f75636 | ||
|
|
ff3a5d24d2 | ||
|
|
0732617b65 | ||
|
|
bfce00385f | ||
|
|
b06ff563a1 | ||
|
|
b040b75075 | ||
|
|
933ebaa47e | ||
|
|
2d98099c25 | ||
|
|
4bb25042eb | ||
|
|
6dd87483d4 | ||
|
|
10bac36647 | ||
|
|
0e32989a08 | ||
|
|
bcfb7f58b9 | ||
|
|
ae992a5d73 | ||
|
|
8b9b149d54 | ||
|
|
70d31fb278 | ||
|
|
580145e96d | ||
|
|
4c15ffffdd | ||
|
|
5918b88a8f | ||
|
|
8711e2b636 | ||
|
|
cf33d8b83c | ||
|
|
42bd67bd6f | ||
|
|
beee7a52e0 | ||
|
|
661aa4dc20 | ||
|
|
3e81840061 | ||
|
|
84084df26c | ||
|
|
003e031994 | ||
|
|
32f28a9360 | ||
|
|
6a33954731 | ||
|
|
6fc8494620 | ||
|
|
cc2b39bbd1 | ||
|
|
c9a0b36a5f | ||
|
|
e1c64a7d89 | ||
|
|
992b77992f | ||
|
|
5c0954afff | ||
|
|
62e94895da | ||
|
|
89451f7c38 | ||
|
|
f0242ee76d | ||
|
|
a4bc2c31e1 | ||
|
|
75ae5af62a | ||
|
|
9574968116 | ||
|
|
e29c2e4364 | ||
|
|
f751c6ed47 | ||
|
|
e8f229b82e | ||
|
|
c1c003e4ff | ||
|
|
63352bf424 | ||
|
|
b69476b372 | ||
|
|
c64d72bea2 | ||
|
|
0bec85f2e2 | ||
|
|
f236ac710e | ||
|
|
1acefafe22 | ||
|
|
f0488e80f7 | ||
|
|
d1aa605f1e | ||
|
|
70398d300d | ||
|
|
c134e00e48 | ||
|
|
40a71f28cf | ||
|
|
c3f7e3be3b | ||
|
|
1136269a79 | ||
|
|
67d6d0bb7d | ||
|
|
1e63a015a5 | ||
|
|
92381ee009 | ||
|
|
1df1187d83 | ||
|
|
f34f361ca6 | ||
|
|
2993fb519d | ||
|
|
316fc7ecfc | ||
|
|
af85d8e2b3 | ||
|
|
6a8b47c880 | ||
|
|
e0d0e64ce2 | ||
|
|
b2c644ffb5 | ||
|
|
522cfc68ff | ||
|
|
a063fe9b2d | ||
|
|
1dcad8b2de | ||
|
|
86acdf1a5b | ||
|
|
9f036647e4 | ||
|
|
355fc47d39 | ||
|
|
76301ca051 | ||
|
|
c582667c9b | ||
|
|
dcd97c41fa | ||
|
|
85c6a1c526 | ||
|
|
ecca49e078 | ||
|
|
106d196ec4 | ||
|
|
a6d45a5d00 | ||
|
|
7d38d53ae4 | ||
|
|
1de9ada401 | ||
|
|
c929030e28 | ||
|
|
87f294aa0b | ||
|
|
68f0a414ea | ||
|
|
55d050ccd8 | ||
|
|
a8aa89accb | ||
|
|
c4078fc805 | ||
|
|
d3488c1aff | ||
|
|
0fd02fe9cf | ||
|
|
251c868008 | ||
|
|
99e1a5e0fb | ||
|
|
22cd3f70a6 | ||
|
|
2695fa2213 | ||
|
|
f44046a1c6 | ||
|
|
2a06791461 | ||
|
|
60390878a5 | ||
|
|
9bf6bb8f63 | ||
|
|
1d439b5e10 | ||
|
|
62f5137a72 | ||
|
|
54216811a0 | ||
|
|
5952d962dc | ||
|
|
3e21adc648 | ||
|
|
b24fb76a3a | ||
|
|
2cdf6ee7e0 | ||
|
|
e8752f4e9f | ||
|
|
d8541a9f99 | ||
|
|
040aa2bb10 | ||
|
|
e598ae5c01 | ||
|
|
2a17fe2561 | ||
|
|
212bba47ff | ||
|
|
b52bb31b76 | ||
|
|
b2ddb1fcbf | ||
|
|
a1783d1697 | ||
|
|
e0e0e53401 | ||
|
|
97887d98da | ||
|
|
8a040de60b | ||
|
|
e07e507d1a | ||
|
|
d8328a96b4 | ||
|
|
fb368723ac | ||
|
|
6d1e292eef | ||
|
|
3ec5dda4d2 | ||
|
|
f0998415ba | ||
|
|
45eaef2431 | ||
|
|
3bcb501c8f | ||
|
|
d3e4c2dcb0 | ||
|
|
7b5c375825 | ||
|
|
beade042d1 | ||
|
|
11bbc66082 | ||
|
|
834057592f | ||
|
|
abbb219933 | ||
|
|
8051a0768a | ||
|
|
a1eb9c7d13 | ||
|
|
00e6da9704 | ||
|
|
9df16f3468 | ||
|
|
8461fea44b | ||
|
|
4bb2dc3d09 | ||
|
|
cf05ef9106 | ||
|
|
de9b0660ac | ||
|
|
042191338d | ||
|
|
93fe16b0a5 | ||
|
|
64a4e89504 | ||
|
|
eef65b20fc | ||
|
|
c4df67461f | ||
|
|
941018b570 | ||
|
|
a72ba5a55b | ||
|
|
6711f098d5 | ||
|
|
c376a5263f | ||
|
|
2901b8b2d2 | ||
|
|
35fcd2f423 | ||
|
|
faf0e06ed8 | ||
|
|
51db5975cc | ||
|
|
70176cda0e | ||
|
|
d56fa8a659 | ||
|
|
e4cb158d01 | ||
|
|
0ab54de1a5 | ||
|
|
adc2944b4c | ||
|
|
16eaf2b158 | ||
|
|
83e2761c3a | ||
|
|
353a82385b | ||
|
|
46d4721519 | ||
|
|
454382e81a | ||
|
|
225171a4bf | ||
|
|
702b8a7aec | ||
|
|
5d7e18539e | ||
|
|
c4a1d4fecf | ||
|
|
fb9f7261ec | ||
|
|
d927cbb638 | ||
|
|
2fbc454355 | ||
|
|
d6efa69187 | ||
|
|
3ea8ac6a9a | ||
|
|
8a9c31a307 | ||
|
|
6380c06c65 | ||
|
|
54d1111965 | ||
|
|
f00d0daf33 | ||
|
|
2cffd4ff3c | ||
|
|
7b1aa64220 | ||
|
|
8f4c4fea20 | ||
|
|
d42ce0f2c1 | ||
|
|
273c7a9dc4 | ||
|
|
a5d5609e38 | ||
|
|
93c0f1715d | ||
|
|
d9575e92fc | ||
|
|
11a402f747 | ||
|
|
021d6fbbbb | ||
|
|
feed8069a6 | ||
|
|
514022bde6 | ||
|
|
ff22ec31b6 | ||
|
|
0598707129 | ||
|
|
a511f6b515 | ||
|
|
8b1e14b7f8 | ||
|
|
6c412e313c | ||
|
|
6b232ce325 | ||
|
|
7abedf9bbb | ||
|
|
27a278e6e3 | ||
|
|
a0bcb16875 | ||
|
|
bc0a43191e | ||
|
|
1064b9e691 | ||
|
|
10780e8a00 | ||
|
|
2433349c80 | ||
|
|
58243b4d3e | ||
|
|
cab1cff11c | ||
|
|
2909f6d7a2 | ||
|
|
d96ba77113 | ||
|
|
62467e4405 | ||
|
|
d0082bb7ec | ||
|
|
21c059b67e | ||
|
|
9e24491c65 | ||
|
|
49f63deb24 | ||
|
|
b536460f8e | ||
|
|
afd8b84706 | ||
|
|
f6206efe5b | ||
|
|
ae674a3660 | ||
|
|
894022a3d5 | ||
|
|
68da9aa716 | ||
|
|
14bdcdeab4 | ||
|
|
fe6a9473dc | ||
|
|
427316a707 | ||
|
|
0647c4de7b | ||
|
|
7ddc2c9e95 | ||
|
|
dcaaa3c804 | ||
|
|
f5b128a5b3 | ||
|
|
fd982d3f3b | ||
|
|
526abe2736 | ||
|
|
8997efe31f | ||
|
|
4ea2d707f9 | ||
|
|
ee8877509a | ||
|
|
763e64cad8 | ||
|
|
040dd5bd5d | ||
|
|
dcdd57df62 | ||
|
|
323428865f | ||
|
|
65c91ad5e7 | ||
|
|
5d30be412b | ||
|
|
eb7f901289 | ||
|
|
db5e403afe | ||
|
|
96116758d2 | ||
|
|
65cebb7730 | ||
|
|
2e0391ea84 | ||
|
|
d483da766f | ||
|
|
7c9314f231 | ||
|
|
e1f1d3085c | ||
|
|
96339daf40 | ||
|
|
f7d3678c28 | ||
|
|
facf1bc9d6 | ||
|
|
e8824f6e74 | ||
|
|
a9835c1816 | ||
|
|
2eedbe799f | ||
|
|
b3711af051 | ||
|
|
30bdf817a0 | ||
|
|
fbeb4f20f9 | ||
|
|
0b20b1a050 | ||
|
|
4dbefc1f25 | ||
|
|
dbae1dc7b3 | ||
|
|
3b07451564 | ||
|
|
37685930d9 | ||
|
|
51df1c1f20 | ||
|
|
f524ec4326 | ||
|
|
eb794af833 | ||
|
|
67a7857124 | ||
|
|
c73b654fd1 | ||
|
|
9da128db70 | ||
|
|
4e5d1f1c39 | ||
|
|
d57e85ecc9 | ||
|
|
1990c9e621 | ||
|
|
319098cc1c | ||
|
|
223d943481 | ||
|
|
8974e2e5e0 | ||
|
|
a4a2343cdc | ||
|
|
fdfd6d3c39 | ||
|
|
b5537c5601 | ||
|
|
e916f9786d | ||
|
|
909e968ebb | ||
|
|
598f786aab | ||
|
|
461291882e | ||
|
|
1f0f6f0272 | ||
|
|
0a22ae5572 | ||
|
|
b0cfd9c786 | ||
|
|
6d8a1bfb08 | ||
|
|
4895665670 | ||
|
|
eaff89291c | ||
|
|
e187711c65 | ||
|
|
6209545083 | ||
|
|
193a402cc0 | ||
|
|
dcca66bce8 | ||
|
|
399aa710d5 | ||
|
|
699794d88d | ||
|
|
773857a524 | ||
|
|
2a75fe3308 | ||
|
|
d926bf2c7e | ||
|
|
8db8d074e2 | ||
|
|
1a70338734 | ||
|
|
61a5976368 | ||
|
|
88c42ab4e7 | ||
|
|
4210dd1500 | ||
|
|
c971ab617d | ||
|
|
f1986f86f2 | ||
|
|
28aca90716 | ||
|
|
9b1536b26a | ||
|
|
3e57c33147 | ||
|
|
baa7eb901e | ||
|
|
574378edb5 | ||
|
|
c95e4a80d1 | ||
|
|
897ea01d5f | ||
|
|
ec192f18b4 | ||
|
|
aa34173f13 | ||
|
|
c343f75c26 | ||
|
|
52b1d09457 | ||
|
|
9402f96597 | ||
|
|
d0fd8d6fc2 | ||
|
|
cfde0b5f52 | ||
|
|
de06185fc3 | ||
|
|
3fb5f3ae11 | ||
|
|
e75d0a6e4c | ||
|
|
947e0afeb3 | ||
|
|
1836366ac1 | ||
|
|
591cef17d4 | ||
|
|
e33a5de454 | ||
|
|
f04c0e341e | ||
|
|
ea89f40f0d | ||
|
|
1fc54d92ec | ||
|
|
8c4a7fa8d3 | ||
|
|
423d4254f5 |
41
.github/CODEOWNERS
vendored
@@ -1,12 +1,35 @@
|
|||||||
# Lines starting with '#' are comments.
|
# Lines starting with '#' are comments.
|
||||||
# Each line is a file pattern followed by one or more owners.
|
# Each line is a file pattern followed by one or more owners.
|
||||||
|
|
||||||
accounts/usbwallet @karalabe
|
accounts/usbwallet @karalabe
|
||||||
consensus @karalabe
|
consensus @karalabe
|
||||||
core/ @karalabe @holiman
|
core/ @karalabe @holiman
|
||||||
eth/ @karalabe
|
eth/ @karalabe
|
||||||
les/ @zsfelfoldi
|
les/ @zsfelfoldi
|
||||||
light/ @zsfelfoldi
|
light/ @zsfelfoldi
|
||||||
mobile/ @karalabe
|
mobile/ @karalabe
|
||||||
p2p/ @fjl @zsfelfoldi
|
p2p/ @fjl @zsfelfoldi
|
||||||
whisper/ @gballet @gluk256
|
p2p/simulations @lmars
|
||||||
|
p2p/protocols @zelig
|
||||||
|
swarm/api/http @justelad
|
||||||
|
swarm/bmt @zelig
|
||||||
|
swarm/dev @lmars
|
||||||
|
swarm/fuse @jmozah @holisticode
|
||||||
|
swarm/grafana_dashboards @nonsense
|
||||||
|
swarm/metrics @nonsense @holisticode
|
||||||
|
swarm/multihash @nolash
|
||||||
|
swarm/network/bitvector @zelig @janos
|
||||||
|
swarm/network/priorityqueue @zelig @janos
|
||||||
|
swarm/network/simulations @zelig @janos
|
||||||
|
swarm/network/stream @janos @zelig @holisticode @justelad
|
||||||
|
swarm/network/stream/intervals @janos
|
||||||
|
swarm/network/stream/testing @zelig
|
||||||
|
swarm/pot @zelig
|
||||||
|
swarm/pss @nolash @zelig @nonsense
|
||||||
|
swarm/services @zelig
|
||||||
|
swarm/state @justelad
|
||||||
|
swarm/storage/encryption @zelig @nagydani
|
||||||
|
swarm/storage/mock @janos
|
||||||
|
swarm/storage/feed @nolash @jpeletier
|
||||||
|
swarm/testutil @lmars
|
||||||
|
whisper/ @gballet @gluk256
|
||||||
|
|||||||
46
.github/CONTRIBUTING.md
vendored
@@ -1,16 +1,40 @@
|
|||||||
|
# Contributing
|
||||||
|
|
||||||
|
Thank you for considering to help out with the source code! We welcome
|
||||||
|
contributions 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 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) 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 and merge procedures quick and simple.
|
||||||
|
|
||||||
|
## Coding guidelines
|
||||||
|
|
||||||
|
Please make sure your contributions adhere to our coding guidelines:
|
||||||
|
|
||||||
|
* Code must adhere to the official Go
|
||||||
|
[formatting](https://golang.org/doc/effective_go.html#formatting) guidelines
|
||||||
|
(i.e. uses [gofmt](https://golang.org/cmd/gofmt/)).
|
||||||
|
* Code must be documented adhering to the official Go
|
||||||
|
[commentary](https://golang.org/doc/effective_go.html#commentary) guidelines.
|
||||||
|
* Pull requests need to be based on and opened against the `master` branch.
|
||||||
|
* Commit messages should be prefixed with the package(s) they modify.
|
||||||
|
* E.g. "eth, rpc: make trace configs optional"
|
||||||
|
|
||||||
## Can I have feature X
|
## Can I have feature X
|
||||||
|
|
||||||
Before you do a feature request please check and make sure that it isn't possible
|
Before you submit a feature request, please check and make sure that it isn't
|
||||||
through some other means. The JavaScript enabled console is a powerful feature
|
possible through some other means. The JavaScript-enabled console is a powerful
|
||||||
in the right hands. Please check our [Wiki page](https://github.com/ethereum/go-ethereum/wiki) for more info
|
feature in the right hands. Please check our
|
||||||
|
[Wiki page](https://github.com/ethereum/go-ethereum/wiki) for more info
|
||||||
and help.
|
and help.
|
||||||
|
|
||||||
## Contributing
|
## Configuration, dependencies, and tests
|
||||||
|
|
||||||
If you'd like to contribute to go-ethereum please fork, fix, commit and
|
Please see the [Developers' Guide](https://github.com/ethereum/go-ethereum/wiki/Developers'-Guide)
|
||||||
send a pull request. Commits which do not comply with the coding standards
|
for more details on configuring your environment, managing project dependencies
|
||||||
are ignored (use gofmt!).
|
and testing procedures.
|
||||||
|
|
||||||
See [Developers' Guide](https://github.com/ethereum/go-ethereum/wiki/Developers'-Guide)
|
|
||||||
for more details on configuring your environment, testing, and
|
|
||||||
dependency management.
|
|
||||||
|
|||||||
4
.github/no-response.yml
vendored
@@ -7,5 +7,5 @@ closeComment: >
|
|||||||
This issue has been automatically closed because there has been no response
|
This issue has been automatically closed because there has been no response
|
||||||
to our request for more information from the original author. With only the
|
to our request for more information from the original author. With only the
|
||||||
information that is currently in the issue, we don't have enough information
|
information that is currently in the issue, we don't have enough information
|
||||||
to take action. Please reach out if you have or find the answers we need so
|
to take action. Please reach out if you have more relevant information or
|
||||||
that we can investigate further.
|
answers to our questions so that we can investigate further.
|
||||||
|
|||||||
73
.travis.yml
@@ -6,19 +6,19 @@ matrix:
|
|||||||
- os: linux
|
- os: linux
|
||||||
dist: trusty
|
dist: trusty
|
||||||
sudo: required
|
sudo: required
|
||||||
go: 1.9.x
|
go: 1.10.x
|
||||||
script:
|
script:
|
||||||
- sudo modprobe fuse
|
- sudo modprobe fuse
|
||||||
- sudo chmod 666 /dev/fuse
|
- sudo chmod 666 /dev/fuse
|
||||||
- sudo chown root:$USER /etc/fuse.conf
|
- sudo chown root:$USER /etc/fuse.conf
|
||||||
- go run build/ci.go install
|
- go run build/ci.go install
|
||||||
- go run build/ci.go test -coverage $TEST_PACKAGES
|
- go run build/ci.go test -coverage $TEST_PACKAGES
|
||||||
|
|
||||||
# These are the latest Go versions.
|
# These are the latest Go versions.
|
||||||
- os: linux
|
- os: linux
|
||||||
dist: trusty
|
dist: trusty
|
||||||
sudo: required
|
sudo: required
|
||||||
go: 1.10.x
|
go: 1.11.x
|
||||||
script:
|
script:
|
||||||
- sudo modprobe fuse
|
- sudo modprobe fuse
|
||||||
- sudo chmod 666 /dev/fuse
|
- sudo chmod 666 /dev/fuse
|
||||||
@@ -27,18 +27,24 @@ matrix:
|
|||||||
- go run build/ci.go test -coverage $TEST_PACKAGES
|
- go run build/ci.go test -coverage $TEST_PACKAGES
|
||||||
|
|
||||||
- os: osx
|
- os: osx
|
||||||
go: 1.10.x
|
go: 1.11.x
|
||||||
script:
|
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
|
- unset -f cd # workaround for https://github.com/travis-ci/travis-ci/issues/8703
|
||||||
- brew update
|
|
||||||
- brew cask install osxfuse
|
|
||||||
- go run build/ci.go install
|
- go run build/ci.go install
|
||||||
- go run build/ci.go test -coverage $TEST_PACKAGES
|
- go run build/ci.go test -coverage $TEST_PACKAGES
|
||||||
|
|
||||||
# This builder only tests code linters on latest version of Go
|
# This builder only tests code linters on latest version of Go
|
||||||
- os: linux
|
- os: linux
|
||||||
dist: trusty
|
dist: trusty
|
||||||
go: 1.10.x
|
go: 1.11.x
|
||||||
env:
|
env:
|
||||||
- lint
|
- lint
|
||||||
git:
|
git:
|
||||||
@@ -47,9 +53,10 @@ matrix:
|
|||||||
- go run build/ci.go lint
|
- go run build/ci.go lint
|
||||||
|
|
||||||
# This builder does the Ubuntu PPA upload
|
# This builder does the Ubuntu PPA upload
|
||||||
- os: linux
|
- if: type = push
|
||||||
|
os: linux
|
||||||
dist: trusty
|
dist: trusty
|
||||||
go: 1.10.x
|
go: 1.11.x
|
||||||
env:
|
env:
|
||||||
- ubuntu-ppa
|
- ubuntu-ppa
|
||||||
git:
|
git:
|
||||||
@@ -65,10 +72,11 @@ matrix:
|
|||||||
- go run build/ci.go debsrc -signer "Go Ethereum Linux Builder <geth-ci@ethereum.org>" -upload ppa:ethereum/ethereum
|
- go run build/ci.go debsrc -signer "Go Ethereum Linux Builder <geth-ci@ethereum.org>" -upload ppa:ethereum/ethereum
|
||||||
|
|
||||||
# This builder does the Linux Azure uploads
|
# This builder does the Linux Azure uploads
|
||||||
- os: linux
|
- if: type = push
|
||||||
|
os: linux
|
||||||
dist: trusty
|
dist: trusty
|
||||||
sudo: required
|
sudo: required
|
||||||
go: 1.10.x
|
go: 1.11.x
|
||||||
env:
|
env:
|
||||||
- azure-linux
|
- azure-linux
|
||||||
git:
|
git:
|
||||||
@@ -98,11 +106,12 @@ matrix:
|
|||||||
- 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 -upload gethstore/builds
|
||||||
|
|
||||||
# This builder does the Linux Azure MIPS xgo uploads
|
# This builder does the Linux Azure MIPS xgo uploads
|
||||||
- os: linux
|
- if: type = push
|
||||||
|
os: linux
|
||||||
dist: trusty
|
dist: trusty
|
||||||
services:
|
services:
|
||||||
- docker
|
- docker
|
||||||
go: 1.10.x
|
go: 1.11.x
|
||||||
env:
|
env:
|
||||||
- azure-linux-mips
|
- azure-linux-mips
|
||||||
git:
|
git:
|
||||||
@@ -125,7 +134,8 @@ matrix:
|
|||||||
- go run build/ci.go archive -arch mips64le -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
|
- 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
|
||||||
- os: linux
|
- if: type = push
|
||||||
|
os: linux
|
||||||
dist: trusty
|
dist: trusty
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
@@ -146,24 +156,25 @@ matrix:
|
|||||||
git:
|
git:
|
||||||
submodules: false # avoid cloning ethereum/tests
|
submodules: false # avoid cloning ethereum/tests
|
||||||
before_install:
|
before_install:
|
||||||
- curl https://storage.googleapis.com/golang/go1.10.2.linux-amd64.tar.gz | tar -xz
|
- curl https://storage.googleapis.com/golang/go1.11.2.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-r16b-linux-x86_64.zip -o android-ndk-r16b.zip
|
- curl https://dl.google.com/android/repository/android-ndk-r17b-linux-x86_64.zip -o android-ndk-r17b.zip
|
||||||
- unzip -q android-ndk-r16b.zip && rm android-ndk-r16b.zip
|
- unzip -q android-ndk-r17b.zip && rm android-ndk-r17b.zip
|
||||||
- mv android-ndk-r16b $HOME
|
- mv android-ndk-r17b $HOME
|
||||||
- export ANDROID_NDK=$HOME/android-ndk-r16b
|
- export ANDROID_NDK=$HOME/android-ndk-r17b
|
||||||
|
|
||||||
- mkdir -p $GOPATH/src/github.com/ethereum
|
- mkdir -p $GOPATH/src/github.com/ethereum
|
||||||
- ln -s `pwd` $GOPATH/src/github.com/ethereum
|
- ln -s `pwd` $GOPATH/src/github.com/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 -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
|
||||||
- os: osx
|
- if: type = push
|
||||||
go: 1.10.x
|
os: osx
|
||||||
|
go: 1.11.x
|
||||||
env:
|
env:
|
||||||
- azure-osx
|
- azure-osx
|
||||||
- azure-ios
|
- azure-ios
|
||||||
@@ -190,19 +201,13 @@ matrix:
|
|||||||
- 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 -deploy trunk -upload gethstore/builds
|
||||||
|
|
||||||
# This builder does the Azure archive purges to avoid accumulating junk
|
# This builder does the Azure archive purges to avoid accumulating junk
|
||||||
- os: linux
|
- if: type = cron
|
||||||
|
os: linux
|
||||||
dist: trusty
|
dist: trusty
|
||||||
go: 1.10.x
|
go: 1.11.x
|
||||||
env:
|
env:
|
||||||
- azure-purge
|
- azure-purge
|
||||||
git:
|
git:
|
||||||
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
|
||||||
|
|
||||||
notifications:
|
|
||||||
webhooks:
|
|
||||||
urls:
|
|
||||||
- https://webhooks.gitter.im/e/e09ccdce1048c5e03445
|
|
||||||
on_success: change
|
|
||||||
on_failure: always
|
|
||||||
|
|||||||
1
AUTHORS
@@ -171,3 +171,4 @@ xiekeyang <xiekeyang@users.noreply.github.com>
|
|||||||
yoza <yoza.is12s@gmail.com>
|
yoza <yoza.is12s@gmail.com>
|
||||||
ΞTHΞЯSPHΞЯΞ <{viktor.tron,nagydani,zsfelfoldi}@gmail.com>
|
ΞTHΞЯSPHΞЯΞ <{viktor.tron,nagydani,zsfelfoldi}@gmail.com>
|
||||||
Максим Чусовлянов <mchusovlianov@gmail.com>
|
Максим Чусовлянов <mchusovlianov@gmail.com>
|
||||||
|
Ralph Caraveo <deckarep@gmail.com>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Build Geth in a stock Go builder container
|
# Build Geth in a stock Go builder container
|
||||||
FROM golang:1.10-alpine as builder
|
FROM golang:1.11-alpine as builder
|
||||||
|
|
||||||
RUN apk add --no-cache make gcc musl-dev linux-headers
|
RUN apk add --no-cache make gcc musl-dev linux-headers
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Build Geth in a stock Go builder container
|
# Build Geth in a stock Go builder container
|
||||||
FROM golang:1.10-alpine as builder
|
FROM golang:1.11-alpine as builder
|
||||||
|
|
||||||
RUN apk add --no-cache make gcc musl-dev linux-headers
|
RUN apk add --no-cache make gcc musl-dev linux-headers
|
||||||
|
|
||||||
|
|||||||
4
Makefile
@@ -41,6 +41,7 @@ lint: ## Run linters.
|
|||||||
build/env.sh go run build/ci.go lint
|
build/env.sh go run build/ci.go lint
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
./build/clean_go_build_cache.sh
|
||||||
rm -fr build/_workspace/pkg/ $(GOBIN)/*
|
rm -fr build/_workspace/pkg/ $(GOBIN)/*
|
||||||
|
|
||||||
# The devtools target installs tools required for 'go generate'.
|
# The devtools target installs tools required for 'go generate'.
|
||||||
@@ -56,6 +57,9 @@ devtools:
|
|||||||
@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'
|
||||||
|
|
||||||
|
swarm-devtools:
|
||||||
|
env GOBIN= go install ./cmd/swarm/mimegen
|
||||||
|
|
||||||
# Cross Compilation Targets (xgo)
|
# Cross Compilation Targets (xgo)
|
||||||
|
|
||||||
geth-cross: geth-linux geth-darwin geth-windows geth-android geth-ios
|
geth-cross: geth-linux geth-darwin geth-windows geth-android geth-ios
|
||||||
|
|||||||
12
README.md
@@ -7,7 +7,7 @@ https://camo.githubusercontent.com/915b7be44ada53c290eb157634330494ebe3e30a/6874
|
|||||||
)](https://godoc.org/github.com/ethereum/go-ethereum)
|
)](https://godoc.org/github.com/ethereum/go-ethereum)
|
||||||
[](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.org/ethereum/go-ethereum)
|
||||||
[](https://gitter.im/ethereum/go-ethereum?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
[](https://discord.gg/nthXNEv)
|
||||||
|
|
||||||
Automated builds are available for stable releases and the unstable master branch.
|
Automated builds are available for stable releases and the unstable master branch.
|
||||||
Binary archives are published at https://geth.ethereum.org/downloads/.
|
Binary archives are published at https://geth.ethereum.org/downloads/.
|
||||||
@@ -18,7 +18,7 @@ For prerequisites and detailed build instructions please read the
|
|||||||
[Installation Instructions](https://github.com/ethereum/go-ethereum/wiki/Building-Ethereum)
|
[Installation Instructions](https://github.com/ethereum/go-ethereum/wiki/Building-Ethereum)
|
||||||
on the wiki.
|
on the wiki.
|
||||||
|
|
||||||
Building geth requires both a Go (version 1.7 or later) and a C compiler.
|
Building geth requires both a Go (version 1.9 or later) and a C compiler.
|
||||||
You can install them using your favourite package manager.
|
You can install them using your favourite package manager.
|
||||||
Once the dependencies are installed, run
|
Once the dependencies are installed, run
|
||||||
|
|
||||||
@@ -34,13 +34,13 @@ The go-ethereum project comes with several wrappers/executables found in the `cm
|
|||||||
|
|
||||||
| 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 Wiki page](https://github.com/ethereum/go-ethereum/wiki/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. |
|
| `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. |
|
||||||
| `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`). |
|
| `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`). |
|
||||||
| `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. |
|
| `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://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`). |
|
| `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`). |
|
||||||
| `swarm` | swarm daemon and tools. This is the entrypoint for the swarm network. `swarm --help` for command line options and subcommands. See https://swarm-guide.readthedocs.io for swarm documentation. |
|
| `swarm` | Swarm daemon and tools. This is the entrypoint for the Swarm network. `swarm --help` for command line options and subcommands. See [Swarm README](https://github.com/ethereum/go-ethereum/tree/master/swarm) for more information. |
|
||||||
| `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
|
||||||
@@ -69,7 +69,7 @@ This command will:
|
|||||||
* 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://github.com/ethereum/go-ethereum/wiki/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 invoke all official [`web3` methods](https://github.com/ethereum/wiki/wiki/JavaScript-API)
|
||||||
as well as Geth's own [management APIs](https://github.com/ethereum/go-ethereum/wiki/Management-APIs).
|
as well as Geth's own [management APIs](https://github.com/ethereum/go-ethereum/wiki/Management-APIs).
|
||||||
This too is optional and if you leave it out you can always attach to an already running Geth instance
|
This tool is optional and if you leave it out you can always attach to an already running Geth instance
|
||||||
with `geth attach`.
|
with `geth attach`.
|
||||||
|
|
||||||
### Full node on the Ethereum test network
|
### Full node on the Ethereum test network
|
||||||
@@ -168,7 +168,7 @@ HTTP based JSON-RPC API options:
|
|||||||
* `--ipcpath` Filename for IPC socket/pipe within the datadir (explicit paths escape it)
|
* `--ipcpath` Filename for IPC socket/pipe within the datadir (explicit paths escape it)
|
||||||
|
|
||||||
You'll need to use your own programming environments' capabilities (libraries, tools, etc) to connect
|
You'll need to use your own programming environments' capabilities (libraries, tools, etc) to connect
|
||||||
via HTTP, WS or IPC to a Geth node configured with the above flags and you'll need to speak [JSON-RPC](http://www.jsonrpc.org/specification)
|
via HTTP, WS or IPC to a Geth node configured with the above flags and you'll need to speak [JSON-RPC](https://www.jsonrpc.org/specification)
|
||||||
on all transports. You can reuse the same connection for multiple requests!
|
on all transports. You can reuse the same connection for multiple requests!
|
||||||
|
|
||||||
**Note: Please understand the security implications of opening up an HTTP/WS based transport before
|
**Note: Please understand the security implications of opening up an HTTP/WS based transport before
|
||||||
|
|||||||
@@ -137,6 +137,9 @@ func (abi *ABI) UnmarshalJSON(data []byte) error {
|
|||||||
// MethodById looks up a method by the 4-byte id
|
// MethodById looks up a method by the 4-byte id
|
||||||
// returns nil if none found
|
// 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 {
|
||||||
|
return nil, fmt.Errorf("data too short (% bytes) for abi method lookup", len(sigdata))
|
||||||
|
}
|
||||||
for _, method := range abi.Methods {
|
for _, method := range abi.Methods {
|
||||||
if bytes.Equal(method.Id(), sigdata[:4]) {
|
if bytes.Equal(method.Id(), sigdata[:4]) {
|
||||||
return &method, nil
|
return &method, nil
|
||||||
|
|||||||
@@ -711,5 +711,14 @@ func TestABI_MethodById(t *testing.T) {
|
|||||||
t.Errorf("Method %v (id %v) not 'findable' by id in ABI", name, common.ToHex(m.Id()))
|
t.Errorf("Method %v (id %v) not 'findable' by id in ABI", name, common.ToHex(m.Id()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Also test empty
|
||||||
|
if _, err := abi.MethodById([]byte{0x00}); err == nil {
|
||||||
|
t.Errorf("Expected error, too short to decode data")
|
||||||
|
}
|
||||||
|
if _, err := abi.MethodById([]byte{}); err == nil {
|
||||||
|
t.Errorf("Expected error, too short to decode data")
|
||||||
|
}
|
||||||
|
if _, err := abi.MethodById(nil); err == nil {
|
||||||
|
t.Errorf("Expected error, nil is short to decode data")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -243,11 +243,7 @@ func (arguments Arguments) Pack(args ...interface{}) ([]byte, error) {
|
|||||||
// input offset is the bytes offset for packed output
|
// input offset is the bytes offset for packed output
|
||||||
inputOffset := 0
|
inputOffset := 0
|
||||||
for _, abiArg := range abiArgs {
|
for _, abiArg := range abiArgs {
|
||||||
if abiArg.Type.T == ArrayTy {
|
inputOffset += getDynamicTypeOffset(abiArg.Type)
|
||||||
inputOffset += 32 * abiArg.Type.Size
|
|
||||||
} else {
|
|
||||||
inputOffset += 32
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
var ret []byte
|
var ret []byte
|
||||||
for i, a := range args {
|
for i, a := range args {
|
||||||
@@ -257,14 +253,13 @@ func (arguments Arguments) Pack(args ...interface{}) ([]byte, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// check for a slice type (string, bytes, slice)
|
// check for dynamic types
|
||||||
if input.Type.requiresLengthPrefix() {
|
if isDynamicType(input.Type) {
|
||||||
// calculate the offset
|
|
||||||
offset := inputOffset + len(variableInput)
|
|
||||||
// set the offset
|
// set the offset
|
||||||
ret = append(ret, packNum(reflect.ValueOf(offset))...)
|
ret = append(ret, packNum(reflect.ValueOf(inputOffset))...)
|
||||||
// Append the packed output to the variable input. The variable input
|
// calculate next offset
|
||||||
// will be appended at the end of the input.
|
inputOffset += len(packed)
|
||||||
|
// append to variable input
|
||||||
variableInput = append(variableInput, packed...)
|
variableInput = append(variableInput, packed...)
|
||||||
} else {
|
} else {
|
||||||
// append the packed value to the input
|
// append the packed value to the input
|
||||||
|
|||||||
@@ -65,11 +65,11 @@ type SimulatedBackend struct {
|
|||||||
|
|
||||||
// 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.
|
||||||
func NewSimulatedBackend(alloc core.GenesisAlloc) *SimulatedBackend {
|
func NewSimulatedBackend(alloc core.GenesisAlloc, gasLimit uint64) *SimulatedBackend {
|
||||||
database := ethdb.NewMemDatabase()
|
database := ethdb.NewMemDatabase()
|
||||||
genesis := core.Genesis{Config: params.AllEthashProtocolChanges, Alloc: alloc}
|
genesis := core.Genesis{Config: params.AllEthashProtocolChanges, GasLimit: gasLimit, Alloc: alloc}
|
||||||
genesis.MustCommit(database)
|
genesis.MustCommit(database)
|
||||||
blockchain, _ := core.NewBlockChain(database, nil, genesis.Config, ethash.NewFaker(), vm.Config{})
|
blockchain, _ := core.NewBlockChain(database, nil, genesis.Config, ethash.NewFaker(), vm.Config{}, nil)
|
||||||
|
|
||||||
backend := &SimulatedBackend{
|
backend := &SimulatedBackend{
|
||||||
database: database,
|
database: database,
|
||||||
@@ -208,7 +208,7 @@ func (b *SimulatedBackend) PendingNonceAt(ctx context.Context, account common.Ad
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SuggestGasPrice implements ContractTransactor.SuggestGasPrice. Since the simulated
|
// SuggestGasPrice implements ContractTransactor.SuggestGasPrice. Since the simulated
|
||||||
// chain doens'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(ctx context.Context) (*big.Int, error) {
|
func (b *SimulatedBackend) SuggestGasPrice(ctx context.Context) (*big.Int, error) {
|
||||||
return big.NewInt(1), nil
|
return big.NewInt(1), nil
|
||||||
}
|
}
|
||||||
@@ -324,18 +324,24 @@ func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transa
|
|||||||
//
|
//
|
||||||
// TODO(karalabe): Deprecate when the subscription one can return past data too.
|
// TODO(karalabe): Deprecate when the subscription one can return past data too.
|
||||||
func (b *SimulatedBackend) FilterLogs(ctx context.Context, query ethereum.FilterQuery) ([]types.Log, error) {
|
func (b *SimulatedBackend) FilterLogs(ctx context.Context, query ethereum.FilterQuery) ([]types.Log, error) {
|
||||||
// Initialize unset filter boundaried to run from genesis to chain head
|
var filter *filters.Filter
|
||||||
from := int64(0)
|
if query.BlockHash != nil {
|
||||||
if query.FromBlock != nil {
|
// Block filter requested, construct a single-shot filter
|
||||||
from = query.FromBlock.Int64()
|
filter = filters.NewBlockFilter(&filterBackend{b.database, b.blockchain}, *query.BlockHash, query.Addresses, query.Topics)
|
||||||
|
} else {
|
||||||
|
// Initialize unset filter boundaried to run from genesis to chain head
|
||||||
|
from := int64(0)
|
||||||
|
if query.FromBlock != nil {
|
||||||
|
from = query.FromBlock.Int64()
|
||||||
|
}
|
||||||
|
to := int64(-1)
|
||||||
|
if query.ToBlock != nil {
|
||||||
|
to = query.ToBlock.Int64()
|
||||||
|
}
|
||||||
|
// Construct the range filter
|
||||||
|
filter = filters.NewRangeFilter(&filterBackend{b.database, b.blockchain}, from, to, query.Addresses, query.Topics)
|
||||||
}
|
}
|
||||||
to := int64(-1)
|
// Run the filter and return all the logs
|
||||||
if query.ToBlock != nil {
|
|
||||||
to = query.ToBlock.Int64()
|
|
||||||
}
|
|
||||||
// Construct and execute the filter
|
|
||||||
filter := filters.New(&filterBackend{b.database, b.blockchain}, from, to, query.Addresses, query.Topics)
|
|
||||||
|
|
||||||
logs, err := filter.Logs(ctx)
|
logs, err := filter.Logs(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -430,6 +436,10 @@ func (fb *filterBackend) HeaderByNumber(ctx context.Context, block rpc.BlockNumb
|
|||||||
return fb.bc.GetHeaderByNumber(uint64(block.Int64())), nil
|
return fb.bc.GetHeaderByNumber(uint64(block.Int64())), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (fb *filterBackend) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error) {
|
||||||
|
return fb.bc.GetHeaderByHash(hash), nil
|
||||||
|
}
|
||||||
|
|
||||||
func (fb *filterBackend) GetReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error) {
|
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 {
|
||||||
|
|||||||
@@ -23,13 +23,13 @@ package bind
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"go/format"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||||
"golang.org/x/tools/imports"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Lang is a target programming language selector to generate bindings for.
|
// Lang is a target programming language selector to generate bindings for.
|
||||||
@@ -145,9 +145,9 @@ func Bind(types []string, abis []string, bytecodes []string, pkg string, lang La
|
|||||||
if err := tmpl.Execute(buffer, data); err != nil {
|
if err := tmpl.Execute(buffer, data); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
// For Go bindings pass the code through goimports to clean it up and double check
|
// For Go bindings pass the code through gofmt to clean it up
|
||||||
if lang == LangGo {
|
if lang == LangGo {
|
||||||
code, err := imports.Process(".", buffer.Bytes(), nil)
|
code, err := format.Source(buffer.Bytes())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("%v\n%s", err, buffer)
|
return "", fmt.Errorf("%v\n%s", err, buffer)
|
||||||
}
|
}
|
||||||
@@ -207,7 +207,7 @@ func bindTypeGo(kind abi.Type) string {
|
|||||||
|
|
||||||
// The inner function of bindTypeGo, this finds the inner type of stringKind.
|
// The inner function of bindTypeGo, this finds the inner type of stringKind.
|
||||||
// (Or just the type itself if it is not an array or slice)
|
// (Or just the type itself if it is not an array or slice)
|
||||||
// The length of the matched part is returned, with the the translated type.
|
// The length of the matched part is returned, with the translated type.
|
||||||
func bindUnnestedTypeGo(stringKind string) (int, string) {
|
func bindUnnestedTypeGo(stringKind string) (int, string) {
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
@@ -255,7 +255,7 @@ func bindTypeJava(kind abi.Type) string {
|
|||||||
|
|
||||||
// The inner function of bindTypeJava, this finds the inner type of stringKind.
|
// The inner function of bindTypeJava, this finds the inner type of stringKind.
|
||||||
// (Or just the type itself if it is not an array or slice)
|
// (Or just the type itself if it is not an array or slice)
|
||||||
// The length of the matched part is returned, with the the translated type.
|
// The length of the matched part is returned, with the translated type.
|
||||||
func bindUnnestedTypeJava(stringKind string) (int, string) {
|
func bindUnnestedTypeJava(stringKind string) (int, string) {
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
|
|||||||
@@ -64,6 +64,30 @@ const tmplSourceGo = `
|
|||||||
|
|
||||||
package {{.Package}}
|
package {{.Package}}
|
||||||
|
|
||||||
|
import (
|
||||||
|
"math/big"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
ethereum "github.com/ethereum/go-ethereum"
|
||||||
|
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||||
|
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
"github.com/ethereum/go-ethereum/event"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
|
var (
|
||||||
|
_ = big.NewInt
|
||||||
|
_ = strings.NewReader
|
||||||
|
_ = ethereum.NotFound
|
||||||
|
_ = abi.U256
|
||||||
|
_ = bind.Bind
|
||||||
|
_ = common.Big1
|
||||||
|
_ = types.BloomLookup
|
||||||
|
_ = event.NewSubscription
|
||||||
|
)
|
||||||
|
|
||||||
{{range $contract := .Contracts}}
|
{{range $contract := .Contracts}}
|
||||||
// {{.Type}}ABI is the input ABI used to generate the binding from.
|
// {{.Type}}ABI is the input ABI used to generate the binding from.
|
||||||
const {{.Type}}ABI = "{{.InputABI}}"
|
const {{.Type}}ABI = "{{.InputABI}}"
|
||||||
|
|||||||
@@ -53,9 +53,11 @@ var waitDeployedTests = map[string]struct {
|
|||||||
|
|
||||||
func TestWaitDeployed(t *testing.T) {
|
func TestWaitDeployed(t *testing.T) {
|
||||||
for name, test := range waitDeployedTests {
|
for name, test := range waitDeployedTests {
|
||||||
backend := backends.NewSimulatedBackend(core.GenesisAlloc{
|
backend := backends.NewSimulatedBackend(
|
||||||
crypto.PubkeyToAddress(testKey.PublicKey): {Balance: big.NewInt(10000000000)},
|
core.GenesisAlloc{
|
||||||
})
|
crypto.PubkeyToAddress(testKey.PublicKey): {Balance: big.NewInt(10000000000)},
|
||||||
|
}, 10000000,
|
||||||
|
)
|
||||||
|
|
||||||
// Create the transaction.
|
// Create the transaction.
|
||||||
tx := types.NewContractCreation(0, big.NewInt(0), test.gas, big.NewInt(1), common.FromHex(test.code))
|
tx := types.NewContractCreation(0, big.NewInt(0), test.gas, big.NewInt(1), common.FromHex(test.code))
|
||||||
|
|||||||
@@ -47,10 +47,8 @@ type Method struct {
|
|||||||
// Please note that "int" is substitute for its canonical representation "int256"
|
// Please note that "int" is substitute for its canonical representation "int256"
|
||||||
func (method Method) Sig() string {
|
func (method Method) Sig() string {
|
||||||
types := make([]string, len(method.Inputs))
|
types := make([]string, len(method.Inputs))
|
||||||
i := 0
|
for i, input := range method.Inputs {
|
||||||
for _, input := range method.Inputs {
|
|
||||||
types[i] = input.Type.String()
|
types[i] = input.Type.String()
|
||||||
i++
|
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%v(%v)", method.Name, strings.Join(types, ","))
|
return fmt.Sprintf("%v(%v)", method.Name, strings.Join(types, ","))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,29 +31,14 @@ var (
|
|||||||
uint16T = reflect.TypeOf(uint16(0))
|
uint16T = reflect.TypeOf(uint16(0))
|
||||||
uint32T = reflect.TypeOf(uint32(0))
|
uint32T = reflect.TypeOf(uint32(0))
|
||||||
uint64T = reflect.TypeOf(uint64(0))
|
uint64T = reflect.TypeOf(uint64(0))
|
||||||
intT = reflect.TypeOf(int(0))
|
|
||||||
int8T = reflect.TypeOf(int8(0))
|
int8T = reflect.TypeOf(int8(0))
|
||||||
int16T = reflect.TypeOf(int16(0))
|
int16T = reflect.TypeOf(int16(0))
|
||||||
int32T = reflect.TypeOf(int32(0))
|
int32T = reflect.TypeOf(int32(0))
|
||||||
int64T = reflect.TypeOf(int64(0))
|
int64T = reflect.TypeOf(int64(0))
|
||||||
addressT = reflect.TypeOf(common.Address{})
|
addressT = reflect.TypeOf(common.Address{})
|
||||||
intTS = reflect.TypeOf([]int(nil))
|
|
||||||
int8TS = reflect.TypeOf([]int8(nil))
|
|
||||||
int16TS = reflect.TypeOf([]int16(nil))
|
|
||||||
int32TS = reflect.TypeOf([]int32(nil))
|
|
||||||
int64TS = reflect.TypeOf([]int64(nil))
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// U256 converts a big Int into a 256bit EVM number.
|
// U256 converts a big Int into a 256bit EVM number.
|
||||||
func U256(n *big.Int) []byte {
|
func U256(n *big.Int) []byte {
|
||||||
return math.PaddedBigBytes(math.U256(n), 32)
|
return math.PaddedBigBytes(math.U256(n), 32)
|
||||||
}
|
}
|
||||||
|
|
||||||
// checks whether the given reflect value is signed. This also works for slices with a number type
|
|
||||||
func isSigned(v reflect.Value) bool {
|
|
||||||
switch v.Type() {
|
|
||||||
case intTS, int8TS, int16TS, int32TS, int64TS, intT, int8T, int16T, int32T, int64T:
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package abi
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"math/big"
|
"math/big"
|
||||||
"reflect"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -32,13 +31,3 @@ func TestNumberTypes(t *testing.T) {
|
|||||||
t.Errorf("expected %x got %x", ubytes, unsigned)
|
t.Errorf("expected %x got %x", ubytes, unsigned)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSigned(t *testing.T) {
|
|
||||||
if isSigned(reflect.ValueOf(uint(10))) {
|
|
||||||
t.Error("signed")
|
|
||||||
}
|
|
||||||
|
|
||||||
if !isSigned(reflect.ValueOf(int(10))) {
|
|
||||||
t.Error("not signed")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -324,6 +324,66 @@ func TestPack(t *testing.T) {
|
|||||||
"foobar",
|
"foobar",
|
||||||
common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000006666f6f6261720000000000000000000000000000000000000000000000000000"),
|
common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000006666f6f6261720000000000000000000000000000000000000000000000000000"),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"string[]",
|
||||||
|
[]string{"hello", "foobar"},
|
||||||
|
common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000002" + // len(array) = 2
|
||||||
|
"0000000000000000000000000000000000000000000000000000000000000040" + // offset 64 to i = 0
|
||||||
|
"0000000000000000000000000000000000000000000000000000000000000080" + // offset 128 to i = 1
|
||||||
|
"0000000000000000000000000000000000000000000000000000000000000005" + // len(str[0]) = 5
|
||||||
|
"68656c6c6f000000000000000000000000000000000000000000000000000000" + // str[0]
|
||||||
|
"0000000000000000000000000000000000000000000000000000000000000006" + // len(str[1]) = 6
|
||||||
|
"666f6f6261720000000000000000000000000000000000000000000000000000"), // str[1]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"string[2]",
|
||||||
|
[]string{"hello", "foobar"},
|
||||||
|
common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000040" + // offset to i = 0
|
||||||
|
"0000000000000000000000000000000000000000000000000000000000000080" + // offset to i = 1
|
||||||
|
"0000000000000000000000000000000000000000000000000000000000000005" + // len(str[0]) = 5
|
||||||
|
"68656c6c6f000000000000000000000000000000000000000000000000000000" + // str[0]
|
||||||
|
"0000000000000000000000000000000000000000000000000000000000000006" + // len(str[1]) = 6
|
||||||
|
"666f6f6261720000000000000000000000000000000000000000000000000000"), // str[1]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"bytes32[][]",
|
||||||
|
[][]common.Hash{{{1}, {2}}, {{3}, {4}, {5}}},
|
||||||
|
common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000002" + // len(array) = 2
|
||||||
|
"0000000000000000000000000000000000000000000000000000000000000040" + // offset 64 to i = 0
|
||||||
|
"00000000000000000000000000000000000000000000000000000000000000a0" + // offset 160 to i = 1
|
||||||
|
"0000000000000000000000000000000000000000000000000000000000000002" + // len(array[0]) = 2
|
||||||
|
"0100000000000000000000000000000000000000000000000000000000000000" + // array[0][0]
|
||||||
|
"0200000000000000000000000000000000000000000000000000000000000000" + // array[0][1]
|
||||||
|
"0000000000000000000000000000000000000000000000000000000000000003" + // len(array[1]) = 3
|
||||||
|
"0300000000000000000000000000000000000000000000000000000000000000" + // array[1][0]
|
||||||
|
"0400000000000000000000000000000000000000000000000000000000000000" + // array[1][1]
|
||||||
|
"0500000000000000000000000000000000000000000000000000000000000000"), // array[1][2]
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"bytes32[][2]",
|
||||||
|
[][]common.Hash{{{1}, {2}}, {{3}, {4}, {5}}},
|
||||||
|
common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000040" + // offset 64 to i = 0
|
||||||
|
"00000000000000000000000000000000000000000000000000000000000000a0" + // offset 160 to i = 1
|
||||||
|
"0000000000000000000000000000000000000000000000000000000000000002" + // len(array[0]) = 2
|
||||||
|
"0100000000000000000000000000000000000000000000000000000000000000" + // array[0][0]
|
||||||
|
"0200000000000000000000000000000000000000000000000000000000000000" + // array[0][1]
|
||||||
|
"0000000000000000000000000000000000000000000000000000000000000003" + // len(array[1]) = 3
|
||||||
|
"0300000000000000000000000000000000000000000000000000000000000000" + // array[1][0]
|
||||||
|
"0400000000000000000000000000000000000000000000000000000000000000" + // array[1][1]
|
||||||
|
"0500000000000000000000000000000000000000000000000000000000000000"), // array[1][2]
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"bytes32[3][2]",
|
||||||
|
[][]common.Hash{{{1}, {2}, {3}}, {{3}, {4}, {5}}},
|
||||||
|
common.Hex2Bytes("0100000000000000000000000000000000000000000000000000000000000000" + // array[0][0]
|
||||||
|
"0200000000000000000000000000000000000000000000000000000000000000" + // array[0][1]
|
||||||
|
"0300000000000000000000000000000000000000000000000000000000000000" + // array[0][2]
|
||||||
|
"0300000000000000000000000000000000000000000000000000000000000000" + // array[1][0]
|
||||||
|
"0400000000000000000000000000000000000000000000000000000000000000" + // array[1][1]
|
||||||
|
"0500000000000000000000000000000000000000000000000000000000000000"), // array[1][2]
|
||||||
|
},
|
||||||
} {
|
} {
|
||||||
typ, err := NewType(test.typ)
|
typ, err := NewType(test.typ)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -336,7 +396,7 @@ func TestPack(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !bytes.Equal(output, test.output) {
|
if !bytes.Equal(output, test.output) {
|
||||||
t.Errorf("%d failed. Expected bytes: '%x' Got: '%x'", i, test.output, output)
|
t.Errorf("input %d for typ: %v failed. Expected bytes: '%x' Got: '%x'", i, typ.String(), test.output, output)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,7 +103,12 @@ func NewType(t string) (typ Type, err error) {
|
|||||||
return typ, err
|
return typ, err
|
||||||
}
|
}
|
||||||
// parse the type and size of the abi-type.
|
// parse the type and size of the abi-type.
|
||||||
parsedType := typeRegex.FindAllStringSubmatch(t, -1)[0]
|
matches := typeRegex.FindAllStringSubmatch(t, -1)
|
||||||
|
if len(matches) == 0 {
|
||||||
|
return Type{}, fmt.Errorf("invalid type '%v'", t)
|
||||||
|
}
|
||||||
|
parsedType := matches[0]
|
||||||
|
|
||||||
// varSize is the size of the variable
|
// varSize is the size of the variable
|
||||||
var varSize int
|
var varSize int
|
||||||
if len(parsedType[3]) > 0 {
|
if len(parsedType[3]) > 0 {
|
||||||
@@ -178,23 +183,39 @@ func (t Type) pack(v reflect.Value) ([]byte, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if t.T == SliceTy || t.T == ArrayTy {
|
switch t.T {
|
||||||
var packed []byte
|
case SliceTy, ArrayTy:
|
||||||
|
var ret []byte
|
||||||
|
|
||||||
|
if t.requiresLengthPrefix() {
|
||||||
|
// append length
|
||||||
|
ret = append(ret, packNum(reflect.ValueOf(v.Len()))...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// calculate offset if any
|
||||||
|
offset := 0
|
||||||
|
offsetReq := isDynamicType(*t.Elem)
|
||||||
|
if offsetReq {
|
||||||
|
offset = getDynamicTypeOffset(*t.Elem) * v.Len()
|
||||||
|
}
|
||||||
|
var tail []byte
|
||||||
for i := 0; i < v.Len(); i++ {
|
for i := 0; i < v.Len(); i++ {
|
||||||
val, err := t.Elem.pack(v.Index(i))
|
val, err := t.Elem.pack(v.Index(i))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
packed = append(packed, val...)
|
if !offsetReq {
|
||||||
}
|
ret = append(ret, val...)
|
||||||
if t.T == SliceTy {
|
continue
|
||||||
return packBytesSlice(packed, v.Len()), nil
|
}
|
||||||
} else if t.T == ArrayTy {
|
ret = append(ret, packNum(reflect.ValueOf(offset))...)
|
||||||
return packed, nil
|
offset += len(val)
|
||||||
|
tail = append(tail, val...)
|
||||||
}
|
}
|
||||||
|
return append(ret, tail...), nil
|
||||||
|
default:
|
||||||
|
return packElement(t, v), nil
|
||||||
}
|
}
|
||||||
return packElement(t, v), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// requireLengthPrefix returns whether the type requires any sort of length
|
// requireLengthPrefix returns whether the type requires any sort of length
|
||||||
@@ -202,3 +223,27 @@ func (t Type) pack(v reflect.Value) ([]byte, error) {
|
|||||||
func (t Type) requiresLengthPrefix() bool {
|
func (t Type) requiresLengthPrefix() bool {
|
||||||
return t.T == StringTy || t.T == BytesTy || t.T == SliceTy
|
return t.T == StringTy || t.T == BytesTy || t.T == SliceTy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// isDynamicType returns true if the type is dynamic.
|
||||||
|
// StringTy, BytesTy, and SliceTy(irrespective of slice element type) are dynamic types
|
||||||
|
// ArrayTy is considered dynamic if and only if the Array element is a dynamic type.
|
||||||
|
// This function recursively checks the type for slice and array elements.
|
||||||
|
func isDynamicType(t Type) bool {
|
||||||
|
// dynamic types
|
||||||
|
// array is also a dynamic type if the array type is dynamic
|
||||||
|
return t.T == StringTy || t.T == BytesTy || t.T == SliceTy || (t.T == ArrayTy && isDynamicType(*t.Elem))
|
||||||
|
}
|
||||||
|
|
||||||
|
// getDynamicTypeOffset returns the offset for the type.
|
||||||
|
// See `isDynamicType` to know which types are considered dynamic.
|
||||||
|
// If the type t is an array and element type is not a dynamic type, then we consider it a static type and
|
||||||
|
// return 32 * size of array since length prefix is not required.
|
||||||
|
// If t is a dynamic type or element type(for slices and arrays) is dynamic, then we simply return 32 as offset.
|
||||||
|
func getDynamicTypeOffset(t Type) int {
|
||||||
|
// if it is an array and there are no dynamic types
|
||||||
|
// then the array is static type
|
||||||
|
if t.T == ArrayTy && !isDynamicType(*t.Elem) {
|
||||||
|
return 32 * t.Size
|
||||||
|
}
|
||||||
|
return 32
|
||||||
|
}
|
||||||
|
|||||||
@@ -25,8 +25,17 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
maxUint256 = big.NewInt(0).Add(
|
||||||
|
big.NewInt(0).Exp(big.NewInt(2), big.NewInt(256), nil),
|
||||||
|
big.NewInt(-1))
|
||||||
|
maxInt256 = big.NewInt(0).Add(
|
||||||
|
big.NewInt(0).Exp(big.NewInt(2), big.NewInt(255), nil),
|
||||||
|
big.NewInt(-1))
|
||||||
|
)
|
||||||
|
|
||||||
// reads the integer based on its kind
|
// reads the integer based on its kind
|
||||||
func readInteger(kind reflect.Kind, b []byte) interface{} {
|
func readInteger(typ byte, kind reflect.Kind, b []byte) interface{} {
|
||||||
switch kind {
|
switch kind {
|
||||||
case reflect.Uint8:
|
case reflect.Uint8:
|
||||||
return b[len(b)-1]
|
return b[len(b)-1]
|
||||||
@@ -45,7 +54,20 @@ func readInteger(kind reflect.Kind, b []byte) interface{} {
|
|||||||
case reflect.Int64:
|
case reflect.Int64:
|
||||||
return int64(binary.BigEndian.Uint64(b[len(b)-8:]))
|
return int64(binary.BigEndian.Uint64(b[len(b)-8:]))
|
||||||
default:
|
default:
|
||||||
return new(big.Int).SetBytes(b)
|
// the only case lefts for integer is int256/uint256.
|
||||||
|
// big.SetBytes can't tell if a number is negative, positive on itself.
|
||||||
|
// On EVM, if the returned number > max int256, it is negative.
|
||||||
|
ret := new(big.Int).SetBytes(b)
|
||||||
|
if typ == UintTy {
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
if ret.Cmp(maxInt256) > 0 {
|
||||||
|
ret.Add(maxUint256, big.NewInt(0).Neg(ret))
|
||||||
|
ret.Add(ret, big.NewInt(1))
|
||||||
|
ret.Neg(ret)
|
||||||
|
}
|
||||||
|
return ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +201,7 @@ func toGoType(index int, t Type, output []byte) (interface{}, error) {
|
|||||||
case StringTy: // variable arrays are written at the end of the return bytes
|
case StringTy: // variable arrays are written at the end of the return bytes
|
||||||
return string(output[begin : begin+end]), nil
|
return string(output[begin : begin+end]), nil
|
||||||
case IntTy, UintTy:
|
case IntTy, UintTy:
|
||||||
return readInteger(t.Kind, returnOutput), nil
|
return readInteger(t.T, t.Kind, returnOutput), nil
|
||||||
case BoolTy:
|
case BoolTy:
|
||||||
return readBool(returnOutput)
|
return readBool(returnOutput)
|
||||||
case AddressTy:
|
case AddressTy:
|
||||||
|
|||||||
@@ -117,6 +117,11 @@ var unpackTests = []unpackTest{
|
|||||||
enc: "0000000000000000000000000000000000000000000000000000000000000001",
|
enc: "0000000000000000000000000000000000000000000000000000000000000001",
|
||||||
want: big.NewInt(1),
|
want: big.NewInt(1),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
def: `[{"type": "int256"}]`,
|
||||||
|
enc: "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
||||||
|
want: big.NewInt(-1),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
def: `[{"type": "address"}]`,
|
def: `[{"type": "address"}]`,
|
||||||
enc: "0000000000000000000000000100000000000000000000000000000000000000",
|
enc: "0000000000000000000000000100000000000000000000000000000000000000",
|
||||||
|
|||||||
@@ -106,7 +106,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 SignTxWithPassphrase, or by other means (e.g. unlock
|
// the needed details via SignTxWithPassphrase, or by other means (e.g. unlock
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ import (
|
|||||||
var DefaultRootDerivationPath = DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 0}
|
var DefaultRootDerivationPath = DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 0}
|
||||||
|
|
||||||
// DefaultBaseDerivationPath is the base path from which custom derivation endpoints
|
// DefaultBaseDerivationPath is the base path from which custom derivation endpoints
|
||||||
// are incremented. As such, the first account will be at m/44'/60'/0'/0, the second
|
// are incremented. As such, the first account will be at m/44'/60'/0'/0/0, the second
|
||||||
// at m/44'/60'/0'/1, etc.
|
// at m/44'/60'/0'/0/1, etc.
|
||||||
var DefaultBaseDerivationPath = DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 0, 0}
|
var DefaultBaseDerivationPath = DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 0, 0}
|
||||||
|
|
||||||
// DefaultLedgerBaseDerivationPath is the base path from which custom derivation endpoints
|
// DefaultLedgerBaseDerivationPath is the base path from which custom derivation endpoints
|
||||||
|
|||||||
@@ -27,10 +27,10 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
mapset "github.com/deckarep/golang-set"
|
||||||
"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/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"gopkg.in/fatih/set.v0"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Minimum amount of time between cache reloads. This limit applies if the platform does
|
// Minimum amount of time between cache reloads. This limit applies if the platform does
|
||||||
@@ -79,7 +79,7 @@ func newAccountCache(keydir string) (*accountCache, chan struct{}) {
|
|||||||
keydir: keydir,
|
keydir: keydir,
|
||||||
byAddr: make(map[common.Address][]accounts.Account),
|
byAddr: make(map[common.Address][]accounts.Account),
|
||||||
notify: make(chan struct{}, 1),
|
notify: make(chan struct{}, 1),
|
||||||
fileC: fileCache{all: set.NewNonTS()},
|
fileC: fileCache{all: mapset.NewThreadUnsafeSet()},
|
||||||
}
|
}
|
||||||
ac.watcher = newWatcher(ac)
|
ac.watcher = newWatcher(ac)
|
||||||
return ac, ac.notify
|
return ac, ac.notify
|
||||||
@@ -237,7 +237,7 @@ func (ac *accountCache) scanAccounts() error {
|
|||||||
log.Debug("Failed to reload keystore contents", "err", err)
|
log.Debug("Failed to reload keystore contents", "err", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if creates.Size() == 0 && deletes.Size() == 0 && updates.Size() == 0 {
|
if creates.Cardinality() == 0 && deletes.Cardinality() == 0 && updates.Cardinality() == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
// Create a helper method to scan the contents of the key files
|
// Create a helper method to scan the contents of the key files
|
||||||
@@ -265,22 +265,25 @@ func (ac *accountCache) scanAccounts() error {
|
|||||||
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{Address: addr, URL: accounts.URL{Scheme: KeyStoreScheme, Path: path}}
|
return &accounts.Account{
|
||||||
|
Address: addr,
|
||||||
|
URL: accounts.URL{Scheme: KeyStoreScheme, Path: path},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
// Process all the file diffs
|
// Process all the file diffs
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
for _, p := range creates.List() {
|
for _, p := range creates.ToSlice() {
|
||||||
if a := readAccount(p.(string)); a != nil {
|
if a := readAccount(p.(string)); a != nil {
|
||||||
ac.add(*a)
|
ac.add(*a)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, p := range deletes.List() {
|
for _, p := range deletes.ToSlice() {
|
||||||
ac.deleteByFile(p.(string))
|
ac.deleteByFile(p.(string))
|
||||||
}
|
}
|
||||||
for _, p := range updates.List() {
|
for _, p := range updates.ToSlice() {
|
||||||
path := p.(string)
|
path := p.(string)
|
||||||
ac.deleteByFile(path)
|
ac.deleteByFile(path)
|
||||||
if a := readAccount(path); a != nil {
|
if a := readAccount(path); a != nil {
|
||||||
|
|||||||
@@ -24,20 +24,20 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
mapset "github.com/deckarep/golang-set"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
set "gopkg.in/fatih/set.v0"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// fileCache is a cache of files seen during scan of keystore.
|
// fileCache is a cache of files seen during scan of keystore.
|
||||||
type fileCache struct {
|
type fileCache struct {
|
||||||
all *set.SetNonTS // 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.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
||||||
// cached filenames, and returns file sets: creates, deletes, updates.
|
// cached filenames, and returns file sets: creates, deletes, updates.
|
||||||
func (fc *fileCache) scan(keyDir string) (set.Interface, set.Interface, set.Interface, error) {
|
func (fc *fileCache) scan(keyDir string) (mapset.Set, mapset.Set, mapset.Set, error) {
|
||||||
t0 := time.Now()
|
t0 := time.Now()
|
||||||
|
|
||||||
// List all the failes from the keystore folder
|
// List all the failes from the keystore folder
|
||||||
@@ -51,14 +51,14 @@ func (fc *fileCache) scan(keyDir string) (set.Interface, set.Interface, set.Inte
|
|||||||
defer fc.mu.Unlock()
|
defer fc.mu.Unlock()
|
||||||
|
|
||||||
// Iterate all the files and gather their metadata
|
// Iterate all the files and gather their metadata
|
||||||
all := set.NewNonTS()
|
all := mapset.NewThreadUnsafeSet()
|
||||||
mods := set.NewNonTS()
|
mods := mapset.NewThreadUnsafeSet()
|
||||||
|
|
||||||
var newLastMod time.Time
|
var newLastMod time.Time
|
||||||
for _, fi := range files {
|
for _, fi := range files {
|
||||||
// Skip any non-key files from the folder
|
|
||||||
path := filepath.Join(keyDir, fi.Name())
|
path := filepath.Join(keyDir, fi.Name())
|
||||||
if skipKeyFile(fi) {
|
// Skip any non-key files from the folder
|
||||||
|
if nonKeyFile(fi) {
|
||||||
log.Trace("Ignoring file on account scan", "path", path)
|
log.Trace("Ignoring file on account scan", "path", path)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -76,9 +76,9 @@ func (fc *fileCache) scan(keyDir string) (set.Interface, set.Interface, set.Inte
|
|||||||
t2 := time.Now()
|
t2 := time.Now()
|
||||||
|
|
||||||
// Update the tracked files and return the three sets
|
// Update the tracked files and return the three sets
|
||||||
deletes := set.Difference(fc.all, all) // Deletes = previous - current
|
deletes := fc.all.Difference(all) // Deletes = previous - current
|
||||||
creates := set.Difference(all, fc.all) // Creates = current - previous
|
creates := all.Difference(fc.all) // Creates = current - previous
|
||||||
updates := set.Difference(mods, creates) // Updates = modified - creates
|
updates := mods.Difference(creates) // Updates = modified - creates
|
||||||
|
|
||||||
fc.all, fc.lastMod = all, newLastMod
|
fc.all, fc.lastMod = all, newLastMod
|
||||||
t3 := time.Now()
|
t3 := time.Now()
|
||||||
@@ -88,8 +88,8 @@ func (fc *fileCache) scan(keyDir string) (set.Interface, set.Interface, set.Inte
|
|||||||
return creates, deletes, updates, nil
|
return creates, deletes, updates, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// skipKeyFile ignores editor backups, hidden files and folders/symlinks.
|
// nonKeyFile ignores editor backups, hidden files and folders/symlinks.
|
||||||
func skipKeyFile(fi os.FileInfo) bool {
|
func nonKeyFile(fi os.FileInfo) 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
|
||||||
|
|||||||
@@ -66,19 +66,19 @@ type plainKeyJSON struct {
|
|||||||
|
|
||||||
type encryptedKeyJSONV3 struct {
|
type encryptedKeyJSONV3 struct {
|
||||||
Address string `json:"address"`
|
Address string `json:"address"`
|
||||||
Crypto cryptoJSON `json:"crypto"`
|
Crypto CryptoJSON `json:"crypto"`
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
Version int `json:"version"`
|
Version int `json:"version"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type encryptedKeyJSONV1 struct {
|
type encryptedKeyJSONV1 struct {
|
||||||
Address string `json:"address"`
|
Address string `json:"address"`
|
||||||
Crypto cryptoJSON `json:"crypto"`
|
Crypto CryptoJSON `json:"crypto"`
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type cryptoJSON struct {
|
type CryptoJSON struct {
|
||||||
Cipher string `json:"cipher"`
|
Cipher string `json:"cipher"`
|
||||||
CipherText string `json:"ciphertext"`
|
CipherText string `json:"ciphertext"`
|
||||||
CipherParams cipherparamsJSON `json:"cipherparams"`
|
CipherParams cipherparamsJSON `json:"cipherparams"`
|
||||||
@@ -171,7 +171,10 @@ func storeNewKey(ks keyStore, rand io.Reader, auth string) (*Key, accounts.Accou
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, accounts.Account{}, err
|
return nil, accounts.Account{}, err
|
||||||
}
|
}
|
||||||
a := accounts.Account{Address: key.Address, URL: accounts.URL{Scheme: KeyStoreScheme, Path: ks.JoinPath(keyFileName(key.Address))}}
|
a := accounts.Account{
|
||||||
|
Address: key.Address,
|
||||||
|
URL: accounts.URL{Scheme: KeyStoreScheme, Path: ks.JoinPath(keyFileName(key.Address))},
|
||||||
|
}
|
||||||
if err := ks.StoreKey(a.URL.Path, key, auth); err != nil {
|
if err := ks.StoreKey(a.URL.Path, key, auth); err != nil {
|
||||||
zeroKey(key.PrivateKey)
|
zeroKey(key.PrivateKey)
|
||||||
return nil, a, err
|
return nil, a, err
|
||||||
@@ -179,26 +182,34 @@ func storeNewKey(ks keyStore, rand io.Reader, auth string) (*Key, accounts.Accou
|
|||||||
return key, a, err
|
return key, a, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeKeyFile(file string, content []byte) error {
|
func writeTemporaryKeyFile(file string, content []byte) (string, error) {
|
||||||
// Create the keystore directory with appropriate permissions
|
// Create the keystore directory with appropriate permissions
|
||||||
// in case it is not present yet.
|
// in case it is not present yet.
|
||||||
const dirPerm = 0700
|
const dirPerm = 0700
|
||||||
if err := os.MkdirAll(filepath.Dir(file), dirPerm); err != nil {
|
if err := os.MkdirAll(filepath.Dir(file), dirPerm); err != nil {
|
||||||
return err
|
return "", err
|
||||||
}
|
}
|
||||||
// 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 := ioutil.TempFile(filepath.Dir(file), "."+filepath.Base(file)+".tmp")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return "", err
|
||||||
}
|
}
|
||||||
if _, err := f.Write(content); err != nil {
|
if _, err := f.Write(content); err != nil {
|
||||||
f.Close()
|
f.Close()
|
||||||
os.Remove(f.Name())
|
os.Remove(f.Name())
|
||||||
return err
|
return "", err
|
||||||
}
|
}
|
||||||
f.Close()
|
f.Close()
|
||||||
return os.Rename(f.Name(), file)
|
return f.Name(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func writeKeyFile(file string, content []byte) error {
|
||||||
|
name, err := writeTemporaryKeyFile(file, content)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return os.Rename(name, file)
|
||||||
}
|
}
|
||||||
|
|
||||||
// keyFileName implements the naming convention for keyfiles:
|
// keyFileName implements the naming convention for keyfiles:
|
||||||
@@ -216,5 +227,6 @@ func toISO8601(t time.Time) string {
|
|||||||
} else {
|
} else {
|
||||||
tz = fmt.Sprintf("%03d00", offset/3600)
|
tz = fmt.Sprintf("%03d00", offset/3600)
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%04d-%02d-%02dT%02d-%02d-%02d.%09d%s", t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second(), t.Nanosecond(), tz)
|
return fmt.Sprintf("%04d-%02d-%02dT%02d-%02d-%02d.%09d%s",
|
||||||
|
t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second(), t.Nanosecond(), tz)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ var (
|
|||||||
var KeyStoreType = reflect.TypeOf(&KeyStore{})
|
var KeyStoreType = reflect.TypeOf(&KeyStore{})
|
||||||
|
|
||||||
// KeyStoreScheme is the protocol scheme prefixing account and wallet URLs.
|
// KeyStoreScheme is the protocol scheme prefixing account and wallet URLs.
|
||||||
var KeyStoreScheme = "keystore"
|
const KeyStoreScheme = "keystore"
|
||||||
|
|
||||||
// Maximum time between wallet refreshes (if filesystem notifications don't work).
|
// Maximum time between wallet refreshes (if filesystem notifications don't work).
|
||||||
const walletRefreshCycle = 3 * time.Second
|
const walletRefreshCycle = 3 * time.Second
|
||||||
@@ -78,7 +78,7 @@ type unlocked struct {
|
|||||||
// NewKeyStore creates a keystore for the given directory.
|
// NewKeyStore creates a keystore for the given directory.
|
||||||
func NewKeyStore(keydir string, scryptN, scryptP int) *KeyStore {
|
func NewKeyStore(keydir string, scryptN, scryptP int) *KeyStore {
|
||||||
keydir, _ = filepath.Abs(keydir)
|
keydir, _ = filepath.Abs(keydir)
|
||||||
ks := &KeyStore{storage: &keyStorePassphrase{keydir, scryptN, scryptP}}
|
ks := &KeyStore{storage: &keyStorePassphrase{keydir, scryptN, scryptP, false}}
|
||||||
ks.init(keydir)
|
ks.init(keydir)
|
||||||
return ks
|
return ks
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,18 +28,19 @@ package keystore
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/aes"
|
"crypto/aes"
|
||||||
crand "crypto/rand"
|
"crypto/rand"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"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/ethereum/go-ethereum/crypto/randentropy"
|
|
||||||
"github.com/pborman/uuid"
|
"github.com/pborman/uuid"
|
||||||
"golang.org/x/crypto/pbkdf2"
|
"golang.org/x/crypto/pbkdf2"
|
||||||
"golang.org/x/crypto/scrypt"
|
"golang.org/x/crypto/scrypt"
|
||||||
@@ -72,6 +73,10 @@ type keyStorePassphrase struct {
|
|||||||
keysDirPath string
|
keysDirPath string
|
||||||
scryptN int
|
scryptN int
|
||||||
scryptP int
|
scryptP int
|
||||||
|
// skipKeyFileVerification disables the security-feature which does
|
||||||
|
// reads and decrypts any newly created keyfiles. This should be 'false' in all
|
||||||
|
// cases except tests -- setting this to 'true' is not recommended.
|
||||||
|
skipKeyFileVerification bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ks keyStorePassphrase) GetKey(addr common.Address, filename, auth string) (*Key, error) {
|
func (ks keyStorePassphrase) GetKey(addr common.Address, filename, auth string) (*Key, error) {
|
||||||
@@ -93,7 +98,7 @@ func (ks keyStorePassphrase) GetKey(addr common.Address, filename, auth string)
|
|||||||
|
|
||||||
// StoreKey generates a key, encrypts with 'auth' and stores in the given directory
|
// StoreKey generates a key, encrypts with 'auth' and stores in the given directory
|
||||||
func StoreKey(dir, auth string, scryptN, scryptP int) (common.Address, error) {
|
func StoreKey(dir, auth string, scryptN, scryptP int) (common.Address, error) {
|
||||||
_, a, err := storeNewKey(&keyStorePassphrase{dir, scryptN, scryptP}, crand.Reader, auth)
|
_, a, err := storeNewKey(&keyStorePassphrase{dir, scryptN, scryptP, false}, rand.Reader, auth)
|
||||||
return a.Address, err
|
return a.Address, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +107,25 @@ func (ks keyStorePassphrase) StoreKey(filename string, key *Key, auth string) er
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return writeKeyFile(filename, keyjson)
|
// Write into temporary file
|
||||||
|
tmpName, err := writeTemporaryKeyFile(filename, keyjson)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if !ks.skipKeyFileVerification {
|
||||||
|
// Verify that we can decrypt the file with the given password.
|
||||||
|
_, err = ks.GetKey(key.Address, tmpName, auth)
|
||||||
|
if err != nil {
|
||||||
|
msg := "An error was encountered when saving and verifying the keystore file. \n" +
|
||||||
|
"This indicates that the keystore is corrupted. \n" +
|
||||||
|
"The corrupted file is stored at \n%v\n" +
|
||||||
|
"Please file a ticket at:\n\n" +
|
||||||
|
"https://github.com/ethereum/go-ethereum/issues." +
|
||||||
|
"The error was : %s"
|
||||||
|
return fmt.Errorf(msg, tmpName, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return os.Rename(tmpName, filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ks keyStorePassphrase) JoinPath(filename string) string {
|
func (ks keyStorePassphrase) JoinPath(filename string) string {
|
||||||
@@ -112,22 +135,26 @@ func (ks keyStorePassphrase) JoinPath(filename string) string {
|
|||||||
return filepath.Join(ks.keysDirPath, filename)
|
return filepath.Join(ks.keysDirPath, filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
// EncryptKey encrypts a key using the specified scrypt parameters into a json
|
// Encryptdata encrypts the data given as 'data' with the password 'auth'.
|
||||||
// blob that can be decrypted later on.
|
func EncryptDataV3(data, auth []byte, scryptN, scryptP int) (CryptoJSON, error) {
|
||||||
func EncryptKey(key *Key, auth string, scryptN, scryptP int) ([]byte, error) {
|
|
||||||
authArray := []byte(auth)
|
salt := make([]byte, 32)
|
||||||
salt := randentropy.GetEntropyCSPRNG(32)
|
if _, err := io.ReadFull(rand.Reader, salt); err != nil {
|
||||||
derivedKey, err := scrypt.Key(authArray, salt, scryptN, scryptR, scryptP, scryptDKLen)
|
panic("reading from crypto/rand failed: " + err.Error())
|
||||||
|
}
|
||||||
|
derivedKey, err := scrypt.Key(auth, salt, scryptN, scryptR, scryptP, scryptDKLen)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return CryptoJSON{}, err
|
||||||
}
|
}
|
||||||
encryptKey := derivedKey[:16]
|
encryptKey := derivedKey[:16]
|
||||||
keyBytes := math.PaddedBigBytes(key.PrivateKey.D, 32)
|
|
||||||
|
|
||||||
iv := randentropy.GetEntropyCSPRNG(aes.BlockSize) // 16
|
iv := make([]byte, aes.BlockSize) // 16
|
||||||
cipherText, err := aesCTRXOR(encryptKey, keyBytes, iv)
|
if _, err := io.ReadFull(rand.Reader, iv); err != nil {
|
||||||
|
panic("reading from crypto/rand failed: " + err.Error())
|
||||||
|
}
|
||||||
|
cipherText, err := aesCTRXOR(encryptKey, data, iv)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return CryptoJSON{}, err
|
||||||
}
|
}
|
||||||
mac := crypto.Keccak256(derivedKey[16:32], cipherText)
|
mac := crypto.Keccak256(derivedKey[16:32], cipherText)
|
||||||
|
|
||||||
@@ -137,12 +164,11 @@ func EncryptKey(key *Key, auth string, scryptN, scryptP int) ([]byte, error) {
|
|||||||
scryptParamsJSON["p"] = scryptP
|
scryptParamsJSON["p"] = scryptP
|
||||||
scryptParamsJSON["dklen"] = scryptDKLen
|
scryptParamsJSON["dklen"] = scryptDKLen
|
||||||
scryptParamsJSON["salt"] = hex.EncodeToString(salt)
|
scryptParamsJSON["salt"] = hex.EncodeToString(salt)
|
||||||
|
|
||||||
cipherParamsJSON := cipherparamsJSON{
|
cipherParamsJSON := cipherparamsJSON{
|
||||||
IV: hex.EncodeToString(iv),
|
IV: hex.EncodeToString(iv),
|
||||||
}
|
}
|
||||||
|
|
||||||
cryptoStruct := cryptoJSON{
|
cryptoStruct := CryptoJSON{
|
||||||
Cipher: "aes-128-ctr",
|
Cipher: "aes-128-ctr",
|
||||||
CipherText: hex.EncodeToString(cipherText),
|
CipherText: hex.EncodeToString(cipherText),
|
||||||
CipherParams: cipherParamsJSON,
|
CipherParams: cipherParamsJSON,
|
||||||
@@ -150,6 +176,17 @@ func EncryptKey(key *Key, auth string, scryptN, scryptP int) ([]byte, error) {
|
|||||||
KDFParams: scryptParamsJSON,
|
KDFParams: scryptParamsJSON,
|
||||||
MAC: hex.EncodeToString(mac),
|
MAC: hex.EncodeToString(mac),
|
||||||
}
|
}
|
||||||
|
return cryptoStruct, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// EncryptKey encrypts a key using the specified scrypt parameters into a json
|
||||||
|
// blob that can be decrypted later on.
|
||||||
|
func EncryptKey(key *Key, auth string, scryptN, scryptP int) ([]byte, error) {
|
||||||
|
keyBytes := math.PaddedBigBytes(key.PrivateKey.D, 32)
|
||||||
|
cryptoStruct, err := EncryptDataV3(keyBytes, []byte(auth), scryptN, scryptP)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
encryptedKeyJSONV3 := encryptedKeyJSONV3{
|
encryptedKeyJSONV3 := encryptedKeyJSONV3{
|
||||||
hex.EncodeToString(key.Address[:]),
|
hex.EncodeToString(key.Address[:]),
|
||||||
cryptoStruct,
|
cryptoStruct,
|
||||||
@@ -197,42 +234,48 @@ func DecryptKey(keyjson []byte, auth string) (*Key, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func decryptKeyV3(keyProtected *encryptedKeyJSONV3, auth string) (keyBytes []byte, keyId []byte, err error) {
|
func DecryptDataV3(cryptoJson CryptoJSON, auth string) ([]byte, error) {
|
||||||
if keyProtected.Version != version {
|
if cryptoJson.Cipher != "aes-128-ctr" {
|
||||||
return nil, nil, fmt.Errorf("Version not supported: %v", keyProtected.Version)
|
return nil, fmt.Errorf("Cipher not supported: %v", cryptoJson.Cipher)
|
||||||
}
|
}
|
||||||
|
mac, err := hex.DecodeString(cryptoJson.MAC)
|
||||||
if keyProtected.Crypto.Cipher != "aes-128-ctr" {
|
|
||||||
return nil, nil, fmt.Errorf("Cipher not supported: %v", keyProtected.Crypto.Cipher)
|
|
||||||
}
|
|
||||||
|
|
||||||
keyId = uuid.Parse(keyProtected.Id)
|
|
||||||
mac, err := hex.DecodeString(keyProtected.Crypto.MAC)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
iv, err := hex.DecodeString(keyProtected.Crypto.CipherParams.IV)
|
iv, err := hex.DecodeString(cryptoJson.CipherParams.IV)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
cipherText, err := hex.DecodeString(keyProtected.Crypto.CipherText)
|
cipherText, err := hex.DecodeString(cryptoJson.CipherText)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
derivedKey, err := getKDFKey(keyProtected.Crypto, auth)
|
derivedKey, err := getKDFKey(cryptoJson, auth)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
calculatedMAC := crypto.Keccak256(derivedKey[16:32], cipherText)
|
calculatedMAC := crypto.Keccak256(derivedKey[16:32], cipherText)
|
||||||
if !bytes.Equal(calculatedMAC, mac) {
|
if !bytes.Equal(calculatedMAC, mac) {
|
||||||
return nil, nil, ErrDecrypt
|
return nil, ErrDecrypt
|
||||||
}
|
}
|
||||||
|
|
||||||
plainText, err := aesCTRXOR(derivedKey[:16], cipherText, iv)
|
plainText, err := aesCTRXOR(derivedKey[:16], cipherText, iv)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return plainText, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func decryptKeyV3(keyProtected *encryptedKeyJSONV3, auth string) (keyBytes []byte, keyId []byte, err error) {
|
||||||
|
if keyProtected.Version != version {
|
||||||
|
return nil, nil, fmt.Errorf("Version not supported: %v", keyProtected.Version)
|
||||||
|
}
|
||||||
|
keyId = uuid.Parse(keyProtected.Id)
|
||||||
|
plainText, err := DecryptDataV3(keyProtected.Crypto, auth)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
@@ -273,7 +316,7 @@ func decryptKeyV1(keyProtected *encryptedKeyJSONV1, auth string) (keyBytes []byt
|
|||||||
return plainText, keyId, err
|
return plainText, keyId, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func getKDFKey(cryptoJSON cryptoJSON, auth string) ([]byte, error) {
|
func getKDFKey(cryptoJSON CryptoJSON, auth string) ([]byte, error) {
|
||||||
authArray := []byte(auth)
|
authArray := []byte(auth)
|
||||||
salt, err := hex.DecodeString(cryptoJSON.KDFParams["salt"].(string))
|
salt, err := hex.DecodeString(cryptoJSON.KDFParams["salt"].(string))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -37,7 +37,7 @@ func tmpKeyStoreIface(t *testing.T, encrypted bool) (dir string, ks keyStore) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if encrypted {
|
if encrypted {
|
||||||
ks = &keyStorePassphrase{d, veryLightScryptN, veryLightScryptP}
|
ks = &keyStorePassphrase{d, veryLightScryptN, veryLightScryptP, true}
|
||||||
} else {
|
} else {
|
||||||
ks = &keyStorePlain{d}
|
ks = &keyStorePlain{d}
|
||||||
}
|
}
|
||||||
@@ -191,7 +191,7 @@ func TestV1_1(t *testing.T) {
|
|||||||
|
|
||||||
func TestV1_2(t *testing.T) {
|
func TestV1_2(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
ks := &keyStorePassphrase{"testdata/v1", LightScryptN, LightScryptP}
|
ks := &keyStorePassphrase{"testdata/v1", LightScryptN, LightScryptP, true}
|
||||||
addr := common.HexToAddress("cb61d5a9c4896fb9658090b597ef0e7be6f7b67e")
|
addr := common.HexToAddress("cb61d5a9c4896fb9658090b597ef0e7be6f7b67e")
|
||||||
file := "testdata/v1/cb61d5a9c4896fb9658090b597ef0e7be6f7b67e/cb61d5a9c4896fb9658090b597ef0e7be6f7b67e"
|
file := "testdata/v1/cb61d5a9c4896fb9658090b597ef0e7be6f7b67e/cb61d5a9c4896fb9658090b597ef0e7be6f7b67e"
|
||||||
k, err := ks.GetKey(addr, file, "g")
|
k, err := ks.GetKey(addr, file, "g")
|
||||||
@@ -38,7 +38,13 @@ func importPreSaleKey(keyStore keyStore, keyJSON []byte, password string) (accou
|
|||||||
return accounts.Account{}, nil, err
|
return accounts.Account{}, nil, err
|
||||||
}
|
}
|
||||||
key.Id = uuid.NewRandom()
|
key.Id = uuid.NewRandom()
|
||||||
a := accounts.Account{Address: key.Address, URL: accounts.URL{Scheme: KeyStoreScheme, Path: keyStore.JoinPath(keyFileName(key.Address))}}
|
a := accounts.Account{
|
||||||
|
Address: key.Address,
|
||||||
|
URL: accounts.URL{
|
||||||
|
Scheme: KeyStoreScheme,
|
||||||
|
Path: keyStore.JoinPath(keyFileName(key.Address)),
|
||||||
|
},
|
||||||
|
}
|
||||||
err = keyStore.StoreKey(a.URL.Path, key, password)
|
err = keyStore.StoreKey(a.URL.Path, key, password)
|
||||||
return a, key, err
|
return a, key, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,12 +76,12 @@ func (u URL) MarshalJSON() ([]byte, error) {
|
|||||||
|
|
||||||
// UnmarshalJSON parses url.
|
// UnmarshalJSON parses url.
|
||||||
func (u *URL) UnmarshalJSON(input []byte) error {
|
func (u *URL) UnmarshalJSON(input []byte) error {
|
||||||
var textUrl string
|
var textURL string
|
||||||
err := json.Unmarshal(input, &textUrl)
|
err := json.Unmarshal(input, &textURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
url, err := parseURL(textUrl)
|
url, err := parseURL(textURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
96
accounts/url_test.go
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
// Copyright 2017 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 accounts
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestURLParsing(t *testing.T) {
|
||||||
|
url, err := parseURL("https://ethereum.org")
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("unexpected error: %v", err)
|
||||||
|
}
|
||||||
|
if url.Scheme != "https" {
|
||||||
|
t.Errorf("expected: %v, got: %v", "https", url.Scheme)
|
||||||
|
}
|
||||||
|
if url.Path != "ethereum.org" {
|
||||||
|
t.Errorf("expected: %v, got: %v", "ethereum.org", url.Path)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = parseURL("ethereum.org")
|
||||||
|
if err == nil {
|
||||||
|
t.Error("expected err, got: nil")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestURLString(t *testing.T) {
|
||||||
|
url := URL{Scheme: "https", Path: "ethereum.org"}
|
||||||
|
if url.String() != "https://ethereum.org" {
|
||||||
|
t.Errorf("expected: %v, got: %v", "https://ethereum.org", url.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
url = URL{Scheme: "", Path: "ethereum.org"}
|
||||||
|
if url.String() != "ethereum.org" {
|
||||||
|
t.Errorf("expected: %v, got: %v", "ethereum.org", url.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestURLMarshalJSON(t *testing.T) {
|
||||||
|
url := URL{Scheme: "https", Path: "ethereum.org"}
|
||||||
|
json, err := url.MarshalJSON()
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("unexpcted error: %v", err)
|
||||||
|
}
|
||||||
|
if string(json) != "\"https://ethereum.org\"" {
|
||||||
|
t.Errorf("expected: %v, got: %v", "\"https://ethereum.org\"", string(json))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestURLUnmarshalJSON(t *testing.T) {
|
||||||
|
url := &URL{}
|
||||||
|
err := url.UnmarshalJSON([]byte("\"https://ethereum.org\""))
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("unexpcted error: %v", err)
|
||||||
|
}
|
||||||
|
if url.Scheme != "https" {
|
||||||
|
t.Errorf("expected: %v, got: %v", "https", url.Scheme)
|
||||||
|
}
|
||||||
|
if url.Path != "ethereum.org" {
|
||||||
|
t.Errorf("expected: %v, got: %v", "https", url.Path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestURLComparison(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
urlA URL
|
||||||
|
urlB URL
|
||||||
|
expect int
|
||||||
|
}{
|
||||||
|
{URL{"https", "ethereum.org"}, URL{"https", "ethereum.org"}, 0},
|
||||||
|
{URL{"http", "ethereum.org"}, URL{"https", "ethereum.org"}, -1},
|
||||||
|
{URL{"https", "ethereum.org/a"}, URL{"https", "ethereum.org"}, 1},
|
||||||
|
{URL{"https", "abc.org"}, URL{"https", "ethereum.org"}, -1},
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, tt := range tests {
|
||||||
|
result := tt.urlA.Cmp(tt.urlB)
|
||||||
|
if result != tt.expect {
|
||||||
|
t.Errorf("test %d: cmp mismatch: expected: %d, got: %d", i, tt.expect, result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -36,7 +36,7 @@ func Type(msg proto.Message) uint16 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Name returns the friendly message type name of a specific protocol buffer
|
// Name returns the friendly message type name of a specific protocol buffer
|
||||||
// type numbers.
|
// type number.
|
||||||
func Name(kind uint16) string {
|
func Name(kind uint16) string {
|
||||||
name := MessageType_name[int32(kind)]
|
name := MessageType_name[int32(kind)]
|
||||||
if len(name) < 12 {
|
if len(name) < 12 {
|
||||||
|
|||||||
@@ -302,7 +302,7 @@ func (w *ledgerDriver) ledgerSign(derivationPath []uint32, tx *types.Transaction
|
|||||||
for i, component := range derivationPath {
|
for i, component := range derivationPath {
|
||||||
binary.BigEndian.PutUint32(path[1+4*i:], component)
|
binary.BigEndian.PutUint32(path[1+4*i:], component)
|
||||||
}
|
}
|
||||||
// Create the transaction RLP based on whether legacy or EIP155 signing was requeste
|
// Create the transaction RLP based on whether legacy or EIP155 signing was requested
|
||||||
var (
|
var (
|
||||||
txrlp []byte
|
txrlp []byte
|
||||||
err error
|
err error
|
||||||
@@ -350,7 +350,7 @@ func (w *ledgerDriver) ledgerSign(derivationPath []uint32, tx *types.Transaction
|
|||||||
signer = new(types.HomesteadSigner)
|
signer = new(types.HomesteadSigner)
|
||||||
} else {
|
} else {
|
||||||
signer = types.NewEIP155Signer(chainID)
|
signer = types.NewEIP155Signer(chainID)
|
||||||
signature[64] = signature[64] - byte(chainID.Uint64()*2+35)
|
signature[64] -= byte(chainID.Uint64()*2 + 35)
|
||||||
}
|
}
|
||||||
signed, err := tx.WithSignature(signer, signature)
|
signed, err := tx.WithSignature(signer, signature)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ func (w *trezorDriver) trezorSign(derivationPath []uint32, tx *types.Transaction
|
|||||||
signer = new(types.HomesteadSigner)
|
signer = new(types.HomesteadSigner)
|
||||||
} else {
|
} else {
|
||||||
signer = types.NewEIP155Signer(chainID)
|
signer = types.NewEIP155Signer(chainID)
|
||||||
signature[64] = 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)
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ environment:
|
|||||||
install:
|
install:
|
||||||
- git submodule update --init
|
- git submodule update --init
|
||||||
- rmdir C:\go /s /q
|
- rmdir C:\go /s /q
|
||||||
- appveyor DownloadFile https://storage.googleapis.com/golang/go1.10.2.windows-%GETH_ARCH%.zip
|
- appveyor DownloadFile https://storage.googleapis.com/golang/go1.11.2.windows-%GETH_ARCH%.zip
|
||||||
- 7z x go1.10.2.windows-%GETH_ARCH%.zip -y -oC:\ > NUL
|
- 7z x go1.11.2.windows-%GETH_ARCH%.zip -y -oC:\ > NUL
|
||||||
- go version
|
- go version
|
||||||
- gcc --version
|
- gcc --version
|
||||||
|
|
||||||
|
|||||||
560
bmt/bmt.go
@@ -1,560 +0,0 @@
|
|||||||
// Copyright 2017 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 bmt provides a binary merkle tree implementation
|
|
||||||
package bmt
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"hash"
|
|
||||||
"io"
|
|
||||||
"strings"
|
|
||||||
"sync"
|
|
||||||
"sync/atomic"
|
|
||||||
)
|
|
||||||
|
|
||||||
/*
|
|
||||||
Binary Merkle Tree Hash is a hash function over arbitrary datachunks of limited size
|
|
||||||
It is defined as the root hash of the binary merkle tree built over fixed size segments
|
|
||||||
of the underlying chunk using any base hash function (e.g keccak 256 SHA3)
|
|
||||||
|
|
||||||
It is used as the chunk hash function in swarm which in turn is the basis for the
|
|
||||||
128 branching swarm hash http://swarm-guide.readthedocs.io/en/latest/architecture.html#swarm-hash
|
|
||||||
|
|
||||||
The BMT is optimal for providing compact inclusion proofs, i.e. prove that a
|
|
||||||
segment is a substring of a chunk starting at a particular offset
|
|
||||||
The size of the underlying segments is fixed at 32 bytes (called the resolution
|
|
||||||
of the BMT hash), the EVM word size to optimize for on-chain BMT verification
|
|
||||||
as well as the hash size optimal for inclusion proofs in the merkle tree of the swarm hash.
|
|
||||||
|
|
||||||
Two implementations are provided:
|
|
||||||
|
|
||||||
* RefHasher is optimized for code simplicity and meant as a reference implementation
|
|
||||||
* Hasher is optimized for speed taking advantage of concurrency with minimalistic
|
|
||||||
control structure to coordinate the concurrent routines
|
|
||||||
It implements the ChunkHash interface as well as the go standard hash.Hash interface
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
const (
|
|
||||||
// DefaultSegmentCount is the maximum number of segments of the underlying chunk
|
|
||||||
DefaultSegmentCount = 128 // Should be equal to storage.DefaultBranches
|
|
||||||
// DefaultPoolSize is the maximum number of bmt trees used by the hashers, i.e,
|
|
||||||
// the maximum number of concurrent BMT hashing operations performed by the same hasher
|
|
||||||
DefaultPoolSize = 8
|
|
||||||
)
|
|
||||||
|
|
||||||
// BaseHasher is a hash.Hash constructor function used for the base hash of the BMT.
|
|
||||||
type BaseHasher func() hash.Hash
|
|
||||||
|
|
||||||
// Hasher a reusable hasher for fixed maximum size chunks representing a BMT
|
|
||||||
// implements the hash.Hash interface
|
|
||||||
// reuse pool of Tree-s for amortised memory allocation and resource control
|
|
||||||
// supports order-agnostic concurrent segment writes
|
|
||||||
// as well as sequential read and write
|
|
||||||
// can not be called concurrently on more than one chunk
|
|
||||||
// can be further appended after Sum
|
|
||||||
// Reset gives back the Tree to the pool and guaranteed to leave
|
|
||||||
// the tree and itself in a state reusable for hashing a new chunk
|
|
||||||
type Hasher struct {
|
|
||||||
pool *TreePool // BMT resource pool
|
|
||||||
bmt *Tree // prebuilt BMT resource for flowcontrol and proofs
|
|
||||||
blocksize int // segment size (size of hash) also for hash.Hash
|
|
||||||
count int // segment count
|
|
||||||
size int // for hash.Hash same as hashsize
|
|
||||||
cur int // cursor position for rightmost currently open chunk
|
|
||||||
segment []byte // the rightmost open segment (not complete)
|
|
||||||
depth int // index of last level
|
|
||||||
result chan []byte // result channel
|
|
||||||
hash []byte // to record the result
|
|
||||||
max int32 // max segments for SegmentWriter interface
|
|
||||||
blockLength []byte // The block length that needes to be added in Sum
|
|
||||||
}
|
|
||||||
|
|
||||||
// New creates a reusable Hasher
|
|
||||||
// implements the hash.Hash interface
|
|
||||||
// pulls a new Tree from a resource pool for hashing each chunk
|
|
||||||
func New(p *TreePool) *Hasher {
|
|
||||||
return &Hasher{
|
|
||||||
pool: p,
|
|
||||||
depth: depth(p.SegmentCount),
|
|
||||||
size: p.SegmentSize,
|
|
||||||
blocksize: p.SegmentSize,
|
|
||||||
count: p.SegmentCount,
|
|
||||||
result: make(chan []byte),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Node is a reuseable segment hasher representing a node in a BMT
|
|
||||||
// it allows for continued writes after a Sum
|
|
||||||
// and is left in completely reusable state after Reset
|
|
||||||
type Node struct {
|
|
||||||
level, index int // position of node for information/logging only
|
|
||||||
initial bool // first and last node
|
|
||||||
root bool // whether the node is root to a smaller BMT
|
|
||||||
isLeft bool // whether it is left side of the parent double segment
|
|
||||||
unbalanced bool // indicates if a node has only the left segment
|
|
||||||
parent *Node // BMT connections
|
|
||||||
state int32 // atomic increment impl concurrent boolean toggle
|
|
||||||
left, right []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewNode constructor for segment hasher nodes in the BMT
|
|
||||||
func NewNode(level, index int, parent *Node) *Node {
|
|
||||||
return &Node{
|
|
||||||
parent: parent,
|
|
||||||
level: level,
|
|
||||||
index: index,
|
|
||||||
initial: index == 0,
|
|
||||||
isLeft: index%2 == 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TreePool provides a pool of Trees used as resources by Hasher
|
|
||||||
// a Tree popped from the pool is guaranteed to have clean state
|
|
||||||
// for hashing a new chunk
|
|
||||||
// Hasher Reset releases the Tree to the pool
|
|
||||||
type TreePool struct {
|
|
||||||
lock sync.Mutex
|
|
||||||
c chan *Tree
|
|
||||||
hasher BaseHasher
|
|
||||||
SegmentSize int
|
|
||||||
SegmentCount int
|
|
||||||
Capacity int
|
|
||||||
count int
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewTreePool creates a Tree pool with hasher, segment size, segment count and capacity
|
|
||||||
// on GetTree it reuses free Trees or creates a new one if size is not reached
|
|
||||||
func NewTreePool(hasher BaseHasher, segmentCount, capacity int) *TreePool {
|
|
||||||
return &TreePool{
|
|
||||||
c: make(chan *Tree, capacity),
|
|
||||||
hasher: hasher,
|
|
||||||
SegmentSize: hasher().Size(),
|
|
||||||
SegmentCount: segmentCount,
|
|
||||||
Capacity: capacity,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Drain drains the pool until it has no more than n resources
|
|
||||||
func (p *TreePool) Drain(n int) {
|
|
||||||
p.lock.Lock()
|
|
||||||
defer p.lock.Unlock()
|
|
||||||
for len(p.c) > n {
|
|
||||||
<-p.c
|
|
||||||
p.count--
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reserve is blocking until it returns an available Tree
|
|
||||||
// it reuses free Trees or creates a new one if size is not reached
|
|
||||||
func (p *TreePool) Reserve() *Tree {
|
|
||||||
p.lock.Lock()
|
|
||||||
defer p.lock.Unlock()
|
|
||||||
var t *Tree
|
|
||||||
if p.count == p.Capacity {
|
|
||||||
return <-p.c
|
|
||||||
}
|
|
||||||
select {
|
|
||||||
case t = <-p.c:
|
|
||||||
default:
|
|
||||||
t = NewTree(p.hasher, p.SegmentSize, p.SegmentCount)
|
|
||||||
p.count++
|
|
||||||
}
|
|
||||||
return t
|
|
||||||
}
|
|
||||||
|
|
||||||
// Release gives back a Tree to the pool.
|
|
||||||
// This Tree is guaranteed to be in reusable state
|
|
||||||
// does not need locking
|
|
||||||
func (p *TreePool) Release(t *Tree) {
|
|
||||||
p.c <- t // can never fail but...
|
|
||||||
}
|
|
||||||
|
|
||||||
// Tree is a reusable control structure representing a BMT
|
|
||||||
// organised in a binary tree
|
|
||||||
// Hasher uses a TreePool to pick one for each chunk hash
|
|
||||||
// the Tree is 'locked' while not in the pool
|
|
||||||
type Tree struct {
|
|
||||||
leaves []*Node
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw draws the BMT (badly)
|
|
||||||
func (t *Tree) Draw(hash []byte, d int) string {
|
|
||||||
var left, right []string
|
|
||||||
var anc []*Node
|
|
||||||
for i, n := range t.leaves {
|
|
||||||
left = append(left, fmt.Sprintf("%v", hashstr(n.left)))
|
|
||||||
if i%2 == 0 {
|
|
||||||
anc = append(anc, n.parent)
|
|
||||||
}
|
|
||||||
right = append(right, fmt.Sprintf("%v", hashstr(n.right)))
|
|
||||||
}
|
|
||||||
anc = t.leaves
|
|
||||||
var hashes [][]string
|
|
||||||
for l := 0; len(anc) > 0; l++ {
|
|
||||||
var nodes []*Node
|
|
||||||
hash := []string{""}
|
|
||||||
for i, n := range anc {
|
|
||||||
hash = append(hash, fmt.Sprintf("%v|%v", hashstr(n.left), hashstr(n.right)))
|
|
||||||
if i%2 == 0 && n.parent != nil {
|
|
||||||
nodes = append(nodes, n.parent)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
hash = append(hash, "")
|
|
||||||
hashes = append(hashes, hash)
|
|
||||||
anc = nodes
|
|
||||||
}
|
|
||||||
hashes = append(hashes, []string{"", fmt.Sprintf("%v", hashstr(hash)), ""})
|
|
||||||
total := 60
|
|
||||||
del := " "
|
|
||||||
var rows []string
|
|
||||||
for i := len(hashes) - 1; i >= 0; i-- {
|
|
||||||
var textlen int
|
|
||||||
hash := hashes[i]
|
|
||||||
for _, s := range hash {
|
|
||||||
textlen += len(s)
|
|
||||||
}
|
|
||||||
if total < textlen {
|
|
||||||
total = textlen + len(hash)
|
|
||||||
}
|
|
||||||
delsize := (total - textlen) / (len(hash) - 1)
|
|
||||||
if delsize > len(del) {
|
|
||||||
delsize = len(del)
|
|
||||||
}
|
|
||||||
row := fmt.Sprintf("%v: %v", len(hashes)-i-1, strings.Join(hash, del[:delsize]))
|
|
||||||
rows = append(rows, row)
|
|
||||||
|
|
||||||
}
|
|
||||||
rows = append(rows, strings.Join(left, " "))
|
|
||||||
rows = append(rows, strings.Join(right, " "))
|
|
||||||
return strings.Join(rows, "\n") + "\n"
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewTree initialises the Tree by building up the nodes of a BMT
|
|
||||||
// segment size is stipulated to be the size of the hash
|
|
||||||
// segmentCount needs to be positive integer and does not need to be
|
|
||||||
// a power of two and can even be an odd number
|
|
||||||
// segmentSize * segmentCount determines the maximum chunk size
|
|
||||||
// hashed using the tree
|
|
||||||
func NewTree(hasher BaseHasher, segmentSize, segmentCount int) *Tree {
|
|
||||||
n := NewNode(0, 0, nil)
|
|
||||||
n.root = true
|
|
||||||
prevlevel := []*Node{n}
|
|
||||||
// iterate over levels and creates 2^level nodes
|
|
||||||
level := 1
|
|
||||||
count := 2
|
|
||||||
for d := 1; d <= depth(segmentCount); d++ {
|
|
||||||
nodes := make([]*Node, count)
|
|
||||||
for i := 0; i < len(nodes); i++ {
|
|
||||||
parent := prevlevel[i/2]
|
|
||||||
t := NewNode(level, i, parent)
|
|
||||||
nodes[i] = t
|
|
||||||
}
|
|
||||||
prevlevel = nodes
|
|
||||||
level++
|
|
||||||
count *= 2
|
|
||||||
}
|
|
||||||
// the datanode level is the nodes on the last level where
|
|
||||||
return &Tree{
|
|
||||||
leaves: prevlevel,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// methods needed by hash.Hash
|
|
||||||
|
|
||||||
// Size returns the size
|
|
||||||
func (h *Hasher) Size() int {
|
|
||||||
return h.size
|
|
||||||
}
|
|
||||||
|
|
||||||
// BlockSize returns the block size
|
|
||||||
func (h *Hasher) BlockSize() int {
|
|
||||||
return h.blocksize
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sum returns the hash of the buffer
|
|
||||||
// hash.Hash interface Sum method appends the byte slice to the underlying
|
|
||||||
// data before it calculates and returns the hash of the chunk
|
|
||||||
func (h *Hasher) Sum(b []byte) (r []byte) {
|
|
||||||
t := h.bmt
|
|
||||||
i := h.cur
|
|
||||||
n := t.leaves[i]
|
|
||||||
j := i
|
|
||||||
// must run strictly before all nodes calculate
|
|
||||||
// datanodes are guaranteed to have a parent
|
|
||||||
if len(h.segment) > h.size && i > 0 && n.parent != nil {
|
|
||||||
n = n.parent
|
|
||||||
} else {
|
|
||||||
i *= 2
|
|
||||||
}
|
|
||||||
d := h.finalise(n, i)
|
|
||||||
h.writeSegment(j, h.segment, d)
|
|
||||||
c := <-h.result
|
|
||||||
h.releaseTree()
|
|
||||||
|
|
||||||
// sha3(length + BMT(pure_chunk))
|
|
||||||
if h.blockLength == nil {
|
|
||||||
return c
|
|
||||||
}
|
|
||||||
res := h.pool.hasher()
|
|
||||||
res.Reset()
|
|
||||||
res.Write(h.blockLength)
|
|
||||||
res.Write(c)
|
|
||||||
return res.Sum(nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hasher implements the SwarmHash interface
|
|
||||||
|
|
||||||
// Hash waits for the hasher result and returns it
|
|
||||||
// caller must call this on a BMT Hasher being written to
|
|
||||||
func (h *Hasher) Hash() []byte {
|
|
||||||
return <-h.result
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hasher implements the io.Writer interface
|
|
||||||
|
|
||||||
// Write fills the buffer to hash
|
|
||||||
// with every full segment complete launches a hasher go routine
|
|
||||||
// that shoots up the BMT
|
|
||||||
func (h *Hasher) Write(b []byte) (int, error) {
|
|
||||||
l := len(b)
|
|
||||||
if l <= 0 {
|
|
||||||
return 0, nil
|
|
||||||
}
|
|
||||||
s := h.segment
|
|
||||||
i := h.cur
|
|
||||||
count := (h.count + 1) / 2
|
|
||||||
need := h.count*h.size - h.cur*2*h.size
|
|
||||||
size := h.size
|
|
||||||
if need > size {
|
|
||||||
size *= 2
|
|
||||||
}
|
|
||||||
if l < need {
|
|
||||||
need = l
|
|
||||||
}
|
|
||||||
// calculate missing bit to complete current open segment
|
|
||||||
rest := size - len(s)
|
|
||||||
if need < rest {
|
|
||||||
rest = need
|
|
||||||
}
|
|
||||||
s = append(s, b[:rest]...)
|
|
||||||
need -= rest
|
|
||||||
// read full segments and the last possibly partial segment
|
|
||||||
for need > 0 && i < count-1 {
|
|
||||||
// push all finished chunks we read
|
|
||||||
h.writeSegment(i, s, h.depth)
|
|
||||||
need -= size
|
|
||||||
if need < 0 {
|
|
||||||
size += need
|
|
||||||
}
|
|
||||||
s = b[rest : rest+size]
|
|
||||||
rest += size
|
|
||||||
i++
|
|
||||||
}
|
|
||||||
h.segment = s
|
|
||||||
h.cur = i
|
|
||||||
// otherwise, we can assume len(s) == 0, so all buffer is read and chunk is not yet full
|
|
||||||
return l, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hasher implements the io.ReaderFrom interface
|
|
||||||
|
|
||||||
// ReadFrom reads from io.Reader and appends to the data to hash using Write
|
|
||||||
// it reads so that chunk to hash is maximum length or reader reaches EOF
|
|
||||||
// caller must Reset the hasher prior to call
|
|
||||||
func (h *Hasher) ReadFrom(r io.Reader) (m int64, err error) {
|
|
||||||
bufsize := h.size*h.count - h.size*h.cur - len(h.segment)
|
|
||||||
buf := make([]byte, bufsize)
|
|
||||||
var read int
|
|
||||||
for {
|
|
||||||
var n int
|
|
||||||
n, err = r.Read(buf)
|
|
||||||
read += n
|
|
||||||
if err == io.EOF || read == len(buf) {
|
|
||||||
hash := h.Sum(buf[:n])
|
|
||||||
if read == len(buf) {
|
|
||||||
err = NewEOC(hash)
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
n, err = h.Write(buf[:n])
|
|
||||||
if err != nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return int64(read), err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset needs to be called before writing to the hasher
|
|
||||||
func (h *Hasher) Reset() {
|
|
||||||
h.getTree()
|
|
||||||
h.blockLength = nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hasher implements the SwarmHash interface
|
|
||||||
|
|
||||||
// ResetWithLength needs to be called before writing to the hasher
|
|
||||||
// the argument is supposed to be the byte slice binary representation of
|
|
||||||
// the length of the data subsumed under the hash
|
|
||||||
func (h *Hasher) ResetWithLength(l []byte) {
|
|
||||||
h.Reset()
|
|
||||||
h.blockLength = l
|
|
||||||
}
|
|
||||||
|
|
||||||
// Release gives back the Tree to the pool whereby it unlocks
|
|
||||||
// it resets tree, segment and index
|
|
||||||
func (h *Hasher) releaseTree() {
|
|
||||||
if h.bmt != nil {
|
|
||||||
n := h.bmt.leaves[h.cur]
|
|
||||||
for ; n != nil; n = n.parent {
|
|
||||||
n.unbalanced = false
|
|
||||||
if n.parent != nil {
|
|
||||||
n.root = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
h.pool.Release(h.bmt)
|
|
||||||
h.bmt = nil
|
|
||||||
|
|
||||||
}
|
|
||||||
h.cur = 0
|
|
||||||
h.segment = nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *Hasher) writeSegment(i int, s []byte, d int) {
|
|
||||||
hash := h.pool.hasher()
|
|
||||||
n := h.bmt.leaves[i]
|
|
||||||
|
|
||||||
if len(s) > h.size && n.parent != nil {
|
|
||||||
go func() {
|
|
||||||
hash.Reset()
|
|
||||||
hash.Write(s)
|
|
||||||
s = hash.Sum(nil)
|
|
||||||
|
|
||||||
if n.root {
|
|
||||||
h.result <- s
|
|
||||||
return
|
|
||||||
}
|
|
||||||
h.run(n.parent, hash, d, n.index, s)
|
|
||||||
}()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
go h.run(n, hash, d, i*2, s)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *Hasher) run(n *Node, hash hash.Hash, d int, i int, s []byte) {
|
|
||||||
isLeft := i%2 == 0
|
|
||||||
for {
|
|
||||||
if isLeft {
|
|
||||||
n.left = s
|
|
||||||
} else {
|
|
||||||
n.right = s
|
|
||||||
}
|
|
||||||
if !n.unbalanced && n.toggle() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !n.unbalanced || !isLeft || i == 0 && d == 0 {
|
|
||||||
hash.Reset()
|
|
||||||
hash.Write(n.left)
|
|
||||||
hash.Write(n.right)
|
|
||||||
s = hash.Sum(nil)
|
|
||||||
|
|
||||||
} else {
|
|
||||||
s = append(n.left, n.right...)
|
|
||||||
}
|
|
||||||
|
|
||||||
h.hash = s
|
|
||||||
if n.root {
|
|
||||||
h.result <- s
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
isLeft = n.isLeft
|
|
||||||
n = n.parent
|
|
||||||
i++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// getTree obtains a BMT resource by reserving one from the pool
|
|
||||||
func (h *Hasher) getTree() *Tree {
|
|
||||||
if h.bmt != nil {
|
|
||||||
return h.bmt
|
|
||||||
}
|
|
||||||
t := h.pool.Reserve()
|
|
||||||
h.bmt = t
|
|
||||||
return t
|
|
||||||
}
|
|
||||||
|
|
||||||
// atomic bool toggle implementing a concurrent reusable 2-state object
|
|
||||||
// atomic addint with %2 implements atomic bool toggle
|
|
||||||
// it returns true if the toggler just put it in the active/waiting state
|
|
||||||
func (n *Node) toggle() bool {
|
|
||||||
return atomic.AddInt32(&n.state, 1)%2 == 1
|
|
||||||
}
|
|
||||||
|
|
||||||
func hashstr(b []byte) string {
|
|
||||||
end := len(b)
|
|
||||||
if end > 4 {
|
|
||||||
end = 4
|
|
||||||
}
|
|
||||||
return fmt.Sprintf("%x", b[:end])
|
|
||||||
}
|
|
||||||
|
|
||||||
func depth(n int) (d int) {
|
|
||||||
for l := (n - 1) / 2; l > 0; l /= 2 {
|
|
||||||
d++
|
|
||||||
}
|
|
||||||
return d
|
|
||||||
}
|
|
||||||
|
|
||||||
// finalise is following the zigzags on the tree belonging
|
|
||||||
// to the final datasegment
|
|
||||||
func (h *Hasher) finalise(n *Node, i int) (d int) {
|
|
||||||
isLeft := i%2 == 0
|
|
||||||
for {
|
|
||||||
// when the final segment's path is going via left segments
|
|
||||||
// the incoming data is pushed to the parent upon pulling the left
|
|
||||||
// we do not need toggle the state since this condition is
|
|
||||||
// detectable
|
|
||||||
n.unbalanced = isLeft
|
|
||||||
n.right = nil
|
|
||||||
if n.initial {
|
|
||||||
n.root = true
|
|
||||||
return d
|
|
||||||
}
|
|
||||||
isLeft = n.isLeft
|
|
||||||
n = n.parent
|
|
||||||
d++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// EOC (end of chunk) implements the error interface
|
|
||||||
type EOC struct {
|
|
||||||
Hash []byte // read the hash of the chunk off the error
|
|
||||||
}
|
|
||||||
|
|
||||||
// Error returns the error string
|
|
||||||
func (e *EOC) Error() string {
|
|
||||||
return fmt.Sprintf("hasher limit reached, chunk hash: %x", e.Hash)
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewEOC creates new end of chunk error with the hash
|
|
||||||
func NewEOC(hash []byte) *EOC {
|
|
||||||
return &EOC{hash}
|
|
||||||
}
|
|
||||||
85
bmt/bmt_r.go
@@ -1,85 +0,0 @@
|
|||||||
// Copyright 2017 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/>.
|
|
||||||
|
|
||||||
// simple nonconcurrent reference implementation for hashsize segment based
|
|
||||||
// Binary Merkle tree hash on arbitrary but fixed maximum chunksize
|
|
||||||
//
|
|
||||||
// This implementation does not take advantage of any paralellisms and uses
|
|
||||||
// far more memory than necessary, but it is easy to see that it is correct.
|
|
||||||
// It can be used for generating test cases for optimized implementations.
|
|
||||||
// see testBMTHasherCorrectness function in bmt_test.go
|
|
||||||
package bmt
|
|
||||||
|
|
||||||
import (
|
|
||||||
"hash"
|
|
||||||
)
|
|
||||||
|
|
||||||
// RefHasher is the non-optimized easy to read reference implementation of BMT
|
|
||||||
type RefHasher struct {
|
|
||||||
span int
|
|
||||||
section int
|
|
||||||
cap int
|
|
||||||
h hash.Hash
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewRefHasher returns a new RefHasher
|
|
||||||
func NewRefHasher(hasher BaseHasher, count int) *RefHasher {
|
|
||||||
h := hasher()
|
|
||||||
hashsize := h.Size()
|
|
||||||
maxsize := hashsize * count
|
|
||||||
c := 2
|
|
||||||
for ; c < count; c *= 2 {
|
|
||||||
}
|
|
||||||
if c > 2 {
|
|
||||||
c /= 2
|
|
||||||
}
|
|
||||||
return &RefHasher{
|
|
||||||
section: 2 * hashsize,
|
|
||||||
span: c * hashsize,
|
|
||||||
cap: maxsize,
|
|
||||||
h: h,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hash returns the BMT hash of the byte slice
|
|
||||||
// implements the SwarmHash interface
|
|
||||||
func (rh *RefHasher) Hash(d []byte) []byte {
|
|
||||||
if len(d) > rh.cap {
|
|
||||||
d = d[:rh.cap]
|
|
||||||
}
|
|
||||||
|
|
||||||
return rh.hash(d, rh.span)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (rh *RefHasher) hash(d []byte, s int) []byte {
|
|
||||||
l := len(d)
|
|
||||||
left := d
|
|
||||||
var right []byte
|
|
||||||
if l > rh.section {
|
|
||||||
for ; s >= l; s /= 2 {
|
|
||||||
}
|
|
||||||
left = rh.hash(d[:s], s)
|
|
||||||
right = d[s:]
|
|
||||||
if l-s > rh.section/2 {
|
|
||||||
right = rh.hash(right, s)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
defer rh.h.Reset()
|
|
||||||
rh.h.Write(left)
|
|
||||||
rh.h.Write(right)
|
|
||||||
h := rh.h.Sum(nil)
|
|
||||||
return h
|
|
||||||
}
|
|
||||||
481
bmt/bmt_test.go
@@ -1,481 +0,0 @@
|
|||||||
// Copyright 2017 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 bmt
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
crand "crypto/rand"
|
|
||||||
"fmt"
|
|
||||||
"hash"
|
|
||||||
"io"
|
|
||||||
"math/rand"
|
|
||||||
"sync"
|
|
||||||
"sync/atomic"
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/crypto/sha3"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
maxproccnt = 8
|
|
||||||
)
|
|
||||||
|
|
||||||
// TestRefHasher tests that the RefHasher computes the expected BMT hash for
|
|
||||||
// all data lengths between 0 and 256 bytes
|
|
||||||
func TestRefHasher(t *testing.T) {
|
|
||||||
hashFunc := sha3.NewKeccak256
|
|
||||||
|
|
||||||
sha3 := func(data ...[]byte) []byte {
|
|
||||||
h := hashFunc()
|
|
||||||
for _, v := range data {
|
|
||||||
h.Write(v)
|
|
||||||
}
|
|
||||||
return h.Sum(nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// the test struct is used to specify the expected BMT hash for data
|
|
||||||
// lengths between "from" and "to"
|
|
||||||
type test struct {
|
|
||||||
from int64
|
|
||||||
to int64
|
|
||||||
expected func([]byte) []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
var tests []*test
|
|
||||||
|
|
||||||
// all lengths in [0,64] should be:
|
|
||||||
//
|
|
||||||
// sha3(data)
|
|
||||||
//
|
|
||||||
tests = append(tests, &test{
|
|
||||||
from: 0,
|
|
||||||
to: 64,
|
|
||||||
expected: func(data []byte) []byte {
|
|
||||||
return sha3(data)
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
// all lengths in [65,96] should be:
|
|
||||||
//
|
|
||||||
// sha3(
|
|
||||||
// sha3(data[:64])
|
|
||||||
// data[64:]
|
|
||||||
// )
|
|
||||||
//
|
|
||||||
tests = append(tests, &test{
|
|
||||||
from: 65,
|
|
||||||
to: 96,
|
|
||||||
expected: func(data []byte) []byte {
|
|
||||||
return sha3(sha3(data[:64]), data[64:])
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
// all lengths in [97,128] should be:
|
|
||||||
//
|
|
||||||
// sha3(
|
|
||||||
// sha3(data[:64])
|
|
||||||
// sha3(data[64:])
|
|
||||||
// )
|
|
||||||
//
|
|
||||||
tests = append(tests, &test{
|
|
||||||
from: 97,
|
|
||||||
to: 128,
|
|
||||||
expected: func(data []byte) []byte {
|
|
||||||
return sha3(sha3(data[:64]), sha3(data[64:]))
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
// all lengths in [129,160] should be:
|
|
||||||
//
|
|
||||||
// sha3(
|
|
||||||
// sha3(
|
|
||||||
// sha3(data[:64])
|
|
||||||
// sha3(data[64:128])
|
|
||||||
// )
|
|
||||||
// data[128:]
|
|
||||||
// )
|
|
||||||
//
|
|
||||||
tests = append(tests, &test{
|
|
||||||
from: 129,
|
|
||||||
to: 160,
|
|
||||||
expected: func(data []byte) []byte {
|
|
||||||
return sha3(sha3(sha3(data[:64]), sha3(data[64:128])), data[128:])
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
// all lengths in [161,192] should be:
|
|
||||||
//
|
|
||||||
// sha3(
|
|
||||||
// sha3(
|
|
||||||
// sha3(data[:64])
|
|
||||||
// sha3(data[64:128])
|
|
||||||
// )
|
|
||||||
// sha3(data[128:])
|
|
||||||
// )
|
|
||||||
//
|
|
||||||
tests = append(tests, &test{
|
|
||||||
from: 161,
|
|
||||||
to: 192,
|
|
||||||
expected: func(data []byte) []byte {
|
|
||||||
return sha3(sha3(sha3(data[:64]), sha3(data[64:128])), sha3(data[128:]))
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
// all lengths in [193,224] should be:
|
|
||||||
//
|
|
||||||
// sha3(
|
|
||||||
// sha3(
|
|
||||||
// sha3(data[:64])
|
|
||||||
// sha3(data[64:128])
|
|
||||||
// )
|
|
||||||
// sha3(
|
|
||||||
// sha3(data[128:192])
|
|
||||||
// data[192:]
|
|
||||||
// )
|
|
||||||
// )
|
|
||||||
//
|
|
||||||
tests = append(tests, &test{
|
|
||||||
from: 193,
|
|
||||||
to: 224,
|
|
||||||
expected: func(data []byte) []byte {
|
|
||||||
return sha3(sha3(sha3(data[:64]), sha3(data[64:128])), sha3(sha3(data[128:192]), data[192:]))
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
// all lengths in [225,256] should be:
|
|
||||||
//
|
|
||||||
// sha3(
|
|
||||||
// sha3(
|
|
||||||
// sha3(data[:64])
|
|
||||||
// sha3(data[64:128])
|
|
||||||
// )
|
|
||||||
// sha3(
|
|
||||||
// sha3(data[128:192])
|
|
||||||
// sha3(data[192:])
|
|
||||||
// )
|
|
||||||
// )
|
|
||||||
//
|
|
||||||
tests = append(tests, &test{
|
|
||||||
from: 225,
|
|
||||||
to: 256,
|
|
||||||
expected: func(data []byte) []byte {
|
|
||||||
return sha3(sha3(sha3(data[:64]), sha3(data[64:128])), sha3(sha3(data[128:192]), sha3(data[192:])))
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
// run the tests
|
|
||||||
for _, x := range tests {
|
|
||||||
for length := x.from; length <= x.to; length++ {
|
|
||||||
t.Run(fmt.Sprintf("%d_bytes", length), func(t *testing.T) {
|
|
||||||
data := make([]byte, length)
|
|
||||||
if _, err := io.ReadFull(crand.Reader, data); err != nil && err != io.EOF {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
expected := x.expected(data)
|
|
||||||
actual := NewRefHasher(hashFunc, 128).Hash(data)
|
|
||||||
if !bytes.Equal(actual, expected) {
|
|
||||||
t.Fatalf("expected %x, got %x", expected, actual)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func testDataReader(l int) (r io.Reader) {
|
|
||||||
return io.LimitReader(crand.Reader, int64(l))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestHasherCorrectness(t *testing.T) {
|
|
||||||
err := testHasher(testBaseHasher)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func testHasher(f func(BaseHasher, []byte, int, int) error) error {
|
|
||||||
tdata := testDataReader(4128)
|
|
||||||
data := make([]byte, 4128)
|
|
||||||
tdata.Read(data)
|
|
||||||
hasher := sha3.NewKeccak256
|
|
||||||
size := hasher().Size()
|
|
||||||
counts := []int{1, 2, 3, 4, 5, 8, 16, 32, 64, 128}
|
|
||||||
|
|
||||||
var err error
|
|
||||||
for _, count := range counts {
|
|
||||||
max := count * size
|
|
||||||
incr := 1
|
|
||||||
for n := 0; n <= max+incr; n += incr {
|
|
||||||
err = f(hasher, data, n, count)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestHasherReuseWithoutRelease(t *testing.T) {
|
|
||||||
testHasherReuse(1, t)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestHasherReuseWithRelease(t *testing.T) {
|
|
||||||
testHasherReuse(maxproccnt, t)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testHasherReuse(i int, t *testing.T) {
|
|
||||||
hasher := sha3.NewKeccak256
|
|
||||||
pool := NewTreePool(hasher, 128, i)
|
|
||||||
defer pool.Drain(0)
|
|
||||||
bmt := New(pool)
|
|
||||||
|
|
||||||
for i := 0; i < 500; i++ {
|
|
||||||
n := rand.Intn(4096)
|
|
||||||
tdata := testDataReader(n)
|
|
||||||
data := make([]byte, n)
|
|
||||||
tdata.Read(data)
|
|
||||||
|
|
||||||
err := testHasherCorrectness(bmt, hasher, data, n, 128)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestHasherConcurrency(t *testing.T) {
|
|
||||||
hasher := sha3.NewKeccak256
|
|
||||||
pool := NewTreePool(hasher, 128, maxproccnt)
|
|
||||||
defer pool.Drain(0)
|
|
||||||
wg := sync.WaitGroup{}
|
|
||||||
cycles := 100
|
|
||||||
wg.Add(maxproccnt * cycles)
|
|
||||||
errc := make(chan error)
|
|
||||||
|
|
||||||
for p := 0; p < maxproccnt; p++ {
|
|
||||||
for i := 0; i < cycles; i++ {
|
|
||||||
go func() {
|
|
||||||
bmt := New(pool)
|
|
||||||
n := rand.Intn(4096)
|
|
||||||
tdata := testDataReader(n)
|
|
||||||
data := make([]byte, n)
|
|
||||||
tdata.Read(data)
|
|
||||||
err := testHasherCorrectness(bmt, hasher, data, n, 128)
|
|
||||||
wg.Done()
|
|
||||||
if err != nil {
|
|
||||||
errc <- err
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
go func() {
|
|
||||||
wg.Wait()
|
|
||||||
close(errc)
|
|
||||||
}()
|
|
||||||
var err error
|
|
||||||
select {
|
|
||||||
case <-time.NewTimer(5 * time.Second).C:
|
|
||||||
err = fmt.Errorf("timed out")
|
|
||||||
case err = <-errc:
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func testBaseHasher(hasher BaseHasher, d []byte, n, count int) error {
|
|
||||||
pool := NewTreePool(hasher, count, 1)
|
|
||||||
defer pool.Drain(0)
|
|
||||||
bmt := New(pool)
|
|
||||||
return testHasherCorrectness(bmt, hasher, d, n, count)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testHasherCorrectness(bmt hash.Hash, hasher BaseHasher, d []byte, n, count int) (err error) {
|
|
||||||
data := d[:n]
|
|
||||||
rbmt := NewRefHasher(hasher, count)
|
|
||||||
exp := rbmt.Hash(data)
|
|
||||||
timeout := time.NewTimer(time.Second)
|
|
||||||
c := make(chan error)
|
|
||||||
|
|
||||||
go func() {
|
|
||||||
bmt.Reset()
|
|
||||||
bmt.Write(data)
|
|
||||||
got := bmt.Sum(nil)
|
|
||||||
if !bytes.Equal(got, exp) {
|
|
||||||
c <- fmt.Errorf("wrong hash: expected %x, got %x", exp, got)
|
|
||||||
}
|
|
||||||
close(c)
|
|
||||||
}()
|
|
||||||
select {
|
|
||||||
case <-timeout.C:
|
|
||||||
err = fmt.Errorf("BMT hash calculation timed out")
|
|
||||||
case err = <-c:
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkSHA3_4k(t *testing.B) { benchmarkSHA3(4096, t) }
|
|
||||||
func BenchmarkSHA3_2k(t *testing.B) { benchmarkSHA3(4096/2, t) }
|
|
||||||
func BenchmarkSHA3_1k(t *testing.B) { benchmarkSHA3(4096/4, t) }
|
|
||||||
func BenchmarkSHA3_512b(t *testing.B) { benchmarkSHA3(4096/8, t) }
|
|
||||||
func BenchmarkSHA3_256b(t *testing.B) { benchmarkSHA3(4096/16, t) }
|
|
||||||
func BenchmarkSHA3_128b(t *testing.B) { benchmarkSHA3(4096/32, t) }
|
|
||||||
|
|
||||||
func BenchmarkBMTBaseline_4k(t *testing.B) { benchmarkBMTBaseline(4096, t) }
|
|
||||||
func BenchmarkBMTBaseline_2k(t *testing.B) { benchmarkBMTBaseline(4096/2, t) }
|
|
||||||
func BenchmarkBMTBaseline_1k(t *testing.B) { benchmarkBMTBaseline(4096/4, t) }
|
|
||||||
func BenchmarkBMTBaseline_512b(t *testing.B) { benchmarkBMTBaseline(4096/8, t) }
|
|
||||||
func BenchmarkBMTBaseline_256b(t *testing.B) { benchmarkBMTBaseline(4096/16, t) }
|
|
||||||
func BenchmarkBMTBaseline_128b(t *testing.B) { benchmarkBMTBaseline(4096/32, t) }
|
|
||||||
|
|
||||||
func BenchmarkRefHasher_4k(t *testing.B) { benchmarkRefHasher(4096, t) }
|
|
||||||
func BenchmarkRefHasher_2k(t *testing.B) { benchmarkRefHasher(4096/2, t) }
|
|
||||||
func BenchmarkRefHasher_1k(t *testing.B) { benchmarkRefHasher(4096/4, t) }
|
|
||||||
func BenchmarkRefHasher_512b(t *testing.B) { benchmarkRefHasher(4096/8, t) }
|
|
||||||
func BenchmarkRefHasher_256b(t *testing.B) { benchmarkRefHasher(4096/16, t) }
|
|
||||||
func BenchmarkRefHasher_128b(t *testing.B) { benchmarkRefHasher(4096/32, t) }
|
|
||||||
|
|
||||||
func BenchmarkHasher_4k(t *testing.B) { benchmarkHasher(4096, t) }
|
|
||||||
func BenchmarkHasher_2k(t *testing.B) { benchmarkHasher(4096/2, t) }
|
|
||||||
func BenchmarkHasher_1k(t *testing.B) { benchmarkHasher(4096/4, t) }
|
|
||||||
func BenchmarkHasher_512b(t *testing.B) { benchmarkHasher(4096/8, t) }
|
|
||||||
func BenchmarkHasher_256b(t *testing.B) { benchmarkHasher(4096/16, t) }
|
|
||||||
func BenchmarkHasher_128b(t *testing.B) { benchmarkHasher(4096/32, t) }
|
|
||||||
|
|
||||||
func BenchmarkHasherNoReuse_4k(t *testing.B) { benchmarkHasherReuse(1, 4096, t) }
|
|
||||||
func BenchmarkHasherNoReuse_2k(t *testing.B) { benchmarkHasherReuse(1, 4096/2, t) }
|
|
||||||
func BenchmarkHasherNoReuse_1k(t *testing.B) { benchmarkHasherReuse(1, 4096/4, t) }
|
|
||||||
func BenchmarkHasherNoReuse_512b(t *testing.B) { benchmarkHasherReuse(1, 4096/8, t) }
|
|
||||||
func BenchmarkHasherNoReuse_256b(t *testing.B) { benchmarkHasherReuse(1, 4096/16, t) }
|
|
||||||
func BenchmarkHasherNoReuse_128b(t *testing.B) { benchmarkHasherReuse(1, 4096/32, t) }
|
|
||||||
|
|
||||||
func BenchmarkHasherReuse_4k(t *testing.B) { benchmarkHasherReuse(16, 4096, t) }
|
|
||||||
func BenchmarkHasherReuse_2k(t *testing.B) { benchmarkHasherReuse(16, 4096/2, t) }
|
|
||||||
func BenchmarkHasherReuse_1k(t *testing.B) { benchmarkHasherReuse(16, 4096/4, t) }
|
|
||||||
func BenchmarkHasherReuse_512b(t *testing.B) { benchmarkHasherReuse(16, 4096/8, t) }
|
|
||||||
func BenchmarkHasherReuse_256b(t *testing.B) { benchmarkHasherReuse(16, 4096/16, t) }
|
|
||||||
func BenchmarkHasherReuse_128b(t *testing.B) { benchmarkHasherReuse(16, 4096/32, t) }
|
|
||||||
|
|
||||||
// benchmarks the minimum hashing time for a balanced (for simplicity) BMT
|
|
||||||
// by doing count/segmentsize parallel hashings of 2*segmentsize bytes
|
|
||||||
// doing it on n maxproccnt each reusing the base hasher
|
|
||||||
// the premise is that this is the minimum computation needed for a BMT
|
|
||||||
// therefore this serves as a theoretical optimum for concurrent implementations
|
|
||||||
func benchmarkBMTBaseline(n int, t *testing.B) {
|
|
||||||
tdata := testDataReader(64)
|
|
||||||
data := make([]byte, 64)
|
|
||||||
tdata.Read(data)
|
|
||||||
hasher := sha3.NewKeccak256
|
|
||||||
|
|
||||||
t.ReportAllocs()
|
|
||||||
t.ResetTimer()
|
|
||||||
for i := 0; i < t.N; i++ {
|
|
||||||
count := int32((n-1)/hasher().Size() + 1)
|
|
||||||
wg := sync.WaitGroup{}
|
|
||||||
wg.Add(maxproccnt)
|
|
||||||
var i int32
|
|
||||||
for j := 0; j < maxproccnt; j++ {
|
|
||||||
go func() {
|
|
||||||
defer wg.Done()
|
|
||||||
h := hasher()
|
|
||||||
for atomic.AddInt32(&i, 1) < count {
|
|
||||||
h.Reset()
|
|
||||||
h.Write(data)
|
|
||||||
h.Sum(nil)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
wg.Wait()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func benchmarkHasher(n int, t *testing.B) {
|
|
||||||
tdata := testDataReader(n)
|
|
||||||
data := make([]byte, n)
|
|
||||||
tdata.Read(data)
|
|
||||||
|
|
||||||
size := 1
|
|
||||||
hasher := sha3.NewKeccak256
|
|
||||||
segmentCount := 128
|
|
||||||
pool := NewTreePool(hasher, segmentCount, size)
|
|
||||||
bmt := New(pool)
|
|
||||||
|
|
||||||
t.ReportAllocs()
|
|
||||||
t.ResetTimer()
|
|
||||||
for i := 0; i < t.N; i++ {
|
|
||||||
bmt.Reset()
|
|
||||||
bmt.Write(data)
|
|
||||||
bmt.Sum(nil)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func benchmarkHasherReuse(poolsize, n int, t *testing.B) {
|
|
||||||
tdata := testDataReader(n)
|
|
||||||
data := make([]byte, n)
|
|
||||||
tdata.Read(data)
|
|
||||||
|
|
||||||
hasher := sha3.NewKeccak256
|
|
||||||
segmentCount := 128
|
|
||||||
pool := NewTreePool(hasher, segmentCount, poolsize)
|
|
||||||
cycles := 200
|
|
||||||
|
|
||||||
t.ReportAllocs()
|
|
||||||
t.ResetTimer()
|
|
||||||
for i := 0; i < t.N; i++ {
|
|
||||||
wg := sync.WaitGroup{}
|
|
||||||
wg.Add(cycles)
|
|
||||||
for j := 0; j < cycles; j++ {
|
|
||||||
bmt := New(pool)
|
|
||||||
go func() {
|
|
||||||
defer wg.Done()
|
|
||||||
bmt.Reset()
|
|
||||||
bmt.Write(data)
|
|
||||||
bmt.Sum(nil)
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
wg.Wait()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func benchmarkSHA3(n int, t *testing.B) {
|
|
||||||
data := make([]byte, n)
|
|
||||||
tdata := testDataReader(n)
|
|
||||||
tdata.Read(data)
|
|
||||||
hasher := sha3.NewKeccak256
|
|
||||||
h := hasher()
|
|
||||||
|
|
||||||
t.ReportAllocs()
|
|
||||||
t.ResetTimer()
|
|
||||||
for i := 0; i < t.N; i++ {
|
|
||||||
h.Reset()
|
|
||||||
h.Write(data)
|
|
||||||
h.Sum(nil)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func benchmarkRefHasher(n int, t *testing.B) {
|
|
||||||
data := make([]byte, n)
|
|
||||||
tdata := testDataReader(n)
|
|
||||||
tdata.Read(data)
|
|
||||||
hasher := sha3.NewKeccak256
|
|
||||||
rbmt := NewRefHasher(hasher, 128)
|
|
||||||
|
|
||||||
t.ReportAllocs()
|
|
||||||
t.ResetTimer()
|
|
||||||
for i := 0; i < t.N; i++ {
|
|
||||||
rbmt.Hash(data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
218
build/ci.go
@@ -26,7 +26,7 @@ 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 artefacts
|
archive [ -arch architecture ] [ -type zip|tar ] [ -signer 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
|
||||||
@@ -59,6 +59,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/internal/build"
|
"github.com/ethereum/go-ethereum/internal/build"
|
||||||
|
"github.com/ethereum/go-ethereum/params"
|
||||||
|
sv "github.com/ethereum/go-ethereum/swarm/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -77,52 +79,84 @@ var (
|
|||||||
executablePath("geth"),
|
executablePath("geth"),
|
||||||
executablePath("puppeth"),
|
executablePath("puppeth"),
|
||||||
executablePath("rlpdump"),
|
executablePath("rlpdump"),
|
||||||
executablePath("swarm"),
|
|
||||||
executablePath("wnode"),
|
executablePath("wnode"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Files that end up in the swarm*.zip archive.
|
||||||
|
swarmArchiveFiles = []string{
|
||||||
|
"COPYING",
|
||||||
|
executablePath("swarm"),
|
||||||
|
}
|
||||||
|
|
||||||
// A debian package is created for all executables listed here.
|
// A debian package is created for all executables listed here.
|
||||||
debExecutables = []debExecutable{
|
debExecutables = []debExecutable{
|
||||||
{
|
{
|
||||||
Name: "abigen",
|
BinaryName: "abigen",
|
||||||
Description: "Source code generator to convert Ethereum contract definitions into easy to use, compile-time type-safe Go packages.",
|
Description: "Source code generator to convert Ethereum contract definitions into easy to use, compile-time type-safe Go packages.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "bootnode",
|
BinaryName: "bootnode",
|
||||||
Description: "Ethereum bootnode.",
|
Description: "Ethereum bootnode.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "evm",
|
BinaryName: "evm",
|
||||||
Description: "Developer utility version of the EVM (Ethereum Virtual Machine) that is capable of running bytecode snippets within a configurable environment and execution mode.",
|
Description: "Developer utility version of the EVM (Ethereum Virtual Machine) that is capable of running bytecode snippets within a configurable environment and execution mode.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "geth",
|
BinaryName: "geth",
|
||||||
Description: "Ethereum CLI client.",
|
Description: "Ethereum CLI client.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "puppeth",
|
BinaryName: "puppeth",
|
||||||
Description: "Ethereum private network manager.",
|
Description: "Ethereum private network manager.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "rlpdump",
|
BinaryName: "rlpdump",
|
||||||
Description: "Developer utility tool that prints RLP structures.",
|
Description: "Developer utility tool that prints RLP structures.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "swarm",
|
BinaryName: "wnode",
|
||||||
Description: "Ethereum Swarm daemon and tools",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "wnode",
|
|
||||||
Description: "Ethereum Whisper diagnostic tool",
|
Description: "Ethereum Whisper diagnostic tool",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A debian package is created for all executables listed here.
|
||||||
|
debSwarmExecutables = []debExecutable{
|
||||||
|
{
|
||||||
|
BinaryName: "swarm",
|
||||||
|
PackageName: "ethereum-swarm",
|
||||||
|
Description: "Ethereum Swarm daemon and tools",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
debEthereum = debPackage{
|
||||||
|
Name: "ethereum",
|
||||||
|
Version: params.Version,
|
||||||
|
Executables: debExecutables,
|
||||||
|
}
|
||||||
|
|
||||||
|
debSwarm = debPackage{
|
||||||
|
Name: "ethereum-swarm",
|
||||||
|
Version: sv.Version,
|
||||||
|
Executables: debSwarmExecutables,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Debian meta packages to build and push to Ubuntu PPA
|
||||||
|
debPackages = []debPackage{
|
||||||
|
debSwarm,
|
||||||
|
debEthereum,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Packages to be cross-compiled by the xgo command
|
||||||
|
allCrossCompiledArchiveFiles = append(allToolsArchiveFiles, swarmArchiveFiles...)
|
||||||
|
|
||||||
// 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 lanchpad.
|
// Note: wily is unsupported because it was officially deprecated on lanchpad.
|
||||||
// Note: yakkety is unsupported because it was officially deprecated on lanchpad.
|
// Note: yakkety is unsupported because it was officially deprecated on lanchpad.
|
||||||
// Note: zesty is unsupported because it was officially deprecated on lanchpad.
|
// Note: zesty is unsupported because it was officially deprecated on lanchpad.
|
||||||
debDistros = []string{"trusty", "xenial", "artful", "bionic"}
|
// Note: artful is unsupported because it was officially deprecated on lanchpad.
|
||||||
|
debDistros = []string{"trusty", "xenial", "bionic", "cosmic"}
|
||||||
)
|
)
|
||||||
|
|
||||||
var GOBIN, _ = filepath.Abs(filepath.Join("build", "bin"))
|
var GOBIN, _ = filepath.Abs(filepath.Join("build", "bin"))
|
||||||
@@ -286,9 +320,7 @@ func goToolArch(arch string, cc string, subcmd string, args ...string) *exec.Cmd
|
|||||||
// "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) {
|
||||||
var (
|
coverage := flag.Bool("coverage", false, "Whether to record code coverage")
|
||||||
coverage = flag.Bool("coverage", false, "Whether to record code coverage")
|
|
||||||
)
|
|
||||||
flag.CommandLine.Parse(cmdline)
|
flag.CommandLine.Parse(cmdline)
|
||||||
env := build.Env()
|
env := build.Env()
|
||||||
|
|
||||||
@@ -298,14 +330,11 @@ func doTest(cmdline []string) {
|
|||||||
}
|
}
|
||||||
packages = build.ExpandPackagesNoVendor(packages)
|
packages = build.ExpandPackagesNoVendor(packages)
|
||||||
|
|
||||||
// Run analysis tools before the tests.
|
|
||||||
build.MustRun(goTool("vet", packages...))
|
|
||||||
|
|
||||||
// Run the actual tests.
|
// Run the actual tests.
|
||||||
gotest := goTool("test", buildFlags(env)...)
|
|
||||||
// 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.Args = append(gotest.Args, "-p", "1")
|
gotest := goTool("test", buildFlags(env)...)
|
||||||
|
gotest.Args = append(gotest.Args, "-p", "1", "-timeout", "5m")
|
||||||
if *coverage {
|
if *coverage {
|
||||||
gotest.Args = append(gotest.Args, "-covermode=atomic", "-cover")
|
gotest.Args = append(gotest.Args, "-covermode=atomic", "-cover")
|
||||||
}
|
}
|
||||||
@@ -330,6 +359,7 @@ func doLint(cmdline []string) {
|
|||||||
configs := []string{
|
configs := []string{
|
||||||
"--vendor",
|
"--vendor",
|
||||||
"--tests",
|
"--tests",
|
||||||
|
"--deadline=2m",
|
||||||
"--disable-all",
|
"--disable-all",
|
||||||
"--enable=goimports",
|
"--enable=goimports",
|
||||||
"--enable=varcheck",
|
"--enable=varcheck",
|
||||||
@@ -349,7 +379,6 @@ func doLint(cmdline []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")
|
||||||
@@ -369,10 +398,14 @@ func doArchive(cmdline []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
env = build.Env()
|
env = build.Env()
|
||||||
base = archiveBasename(*arch, env)
|
|
||||||
geth = "geth-" + base + ext
|
basegeth = archiveBasename(*arch, params.ArchiveVersion(env.Commit))
|
||||||
alltools = "geth-alltools-" + base + ext
|
geth = "geth-" + basegeth + ext
|
||||||
|
alltools = "geth-alltools-" + basegeth + ext
|
||||||
|
|
||||||
|
baseswarm = archiveBasename(*arch, sv.ArchiveVersion(env.Commit))
|
||||||
|
swarm = "swarm-" + baseswarm + ext
|
||||||
)
|
)
|
||||||
maybeSkipArchive(env)
|
maybeSkipArchive(env)
|
||||||
if err := build.WriteArchive(geth, gethArchiveFiles); err != nil {
|
if err := build.WriteArchive(geth, gethArchiveFiles); err != nil {
|
||||||
@@ -381,14 +414,17 @@ func doArchive(cmdline []string) {
|
|||||||
if err := build.WriteArchive(alltools, allToolsArchiveFiles); err != nil {
|
if err := build.WriteArchive(alltools, allToolsArchiveFiles); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
for _, archive := range []string{geth, alltools} {
|
if err := build.WriteArchive(swarm, swarmArchiveFiles); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
for _, archive := range []string{geth, alltools, swarm} {
|
||||||
if err := archiveUpload(archive, *upload, *signer); err != nil {
|
if err := archiveUpload(archive, *upload, *signer); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func archiveBasename(arch string, env build.Environment) string {
|
func archiveBasename(arch string, archiveVersion string) string {
|
||||||
platform := runtime.GOOS + "-" + arch
|
platform := runtime.GOOS + "-" + arch
|
||||||
if arch == "arm" {
|
if arch == "arm" {
|
||||||
platform += os.Getenv("GOARM")
|
platform += os.Getenv("GOARM")
|
||||||
@@ -399,18 +435,7 @@ func archiveBasename(arch string, env build.Environment) string {
|
|||||||
if arch == "ios" {
|
if arch == "ios" {
|
||||||
platform = "ios-all"
|
platform = "ios-all"
|
||||||
}
|
}
|
||||||
return platform + "-" + archiveVersion(env)
|
return platform + "-" + archiveVersion
|
||||||
}
|
|
||||||
|
|
||||||
func archiveVersion(env build.Environment) string {
|
|
||||||
version := build.VERSION()
|
|
||||||
if isUnstableBuild(env) {
|
|
||||||
version += "-unstable"
|
|
||||||
}
|
|
||||||
if env.Commit != "" {
|
|
||||||
version += "-" + env.Commit[:8]
|
|
||||||
}
|
|
||||||
return version
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func archiveUpload(archive string, blobstore string, signer string) error {
|
func archiveUpload(archive string, blobstore string, signer string) error {
|
||||||
@@ -460,7 +485,6 @@ func maybeSkipArchive(env build.Environment) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Debian Packaging
|
// Debian Packaging
|
||||||
|
|
||||||
func doDebianSource(cmdline []string) {
|
func doDebianSource(cmdline []string) {
|
||||||
var (
|
var (
|
||||||
signer = flag.String("signer", "", `Signing key name, also used as package author`)
|
signer = flag.String("signer", "", `Signing key name, also used as package author`)
|
||||||
@@ -484,21 +508,23 @@ func doDebianSource(cmdline []string) {
|
|||||||
build.MustRun(gpg)
|
build.MustRun(gpg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the packages.
|
// Create Debian packages and upload them
|
||||||
for _, distro := range debDistros {
|
for _, pkg := range debPackages {
|
||||||
meta := newDebMetadata(distro, *signer, env, now)
|
for _, distro := range debDistros {
|
||||||
pkgdir := stageDebianSource(*workdir, meta)
|
meta := newDebMetadata(distro, *signer, env, now, pkg.Name, pkg.Version, pkg.Executables)
|
||||||
debuild := exec.Command("debuild", "-S", "-sa", "-us", "-uc")
|
pkgdir := stageDebianSource(*workdir, meta)
|
||||||
debuild.Dir = pkgdir
|
debuild := exec.Command("debuild", "-S", "-sa", "-us", "-uc")
|
||||||
build.MustRun(debuild)
|
debuild.Dir = pkgdir
|
||||||
|
build.MustRun(debuild)
|
||||||
|
|
||||||
changes := fmt.Sprintf("%s_%s_source.changes", meta.Name(), meta.VersionString())
|
changes := fmt.Sprintf("%s_%s_source.changes", meta.Name(), meta.VersionString())
|
||||||
changes = filepath.Join(*workdir, changes)
|
changes = filepath.Join(*workdir, changes)
|
||||||
if *signer != "" {
|
if *signer != "" {
|
||||||
build.MustRunCommand("debsign", changes)
|
build.MustRunCommand("debsign", changes)
|
||||||
}
|
}
|
||||||
if *upload != "" {
|
if *upload != "" {
|
||||||
build.MustRunCommand("dput", *upload, changes)
|
build.MustRunCommand("dput", *upload, changes)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -523,9 +549,17 @@ func isUnstableBuild(env build.Environment) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type debPackage struct {
|
||||||
|
Name string // the name of the Debian package to produce, e.g. "ethereum", or "ethereum-swarm"
|
||||||
|
Version string // the clean version of the debPackage, e.g. 1.8.12 or 0.3.0, without any metadata
|
||||||
|
Executables []debExecutable // executables to be included in the package
|
||||||
|
}
|
||||||
|
|
||||||
type debMetadata struct {
|
type debMetadata struct {
|
||||||
Env build.Environment
|
Env build.Environment
|
||||||
|
|
||||||
|
PackageName string
|
||||||
|
|
||||||
// go-ethereum version being built. Note that this
|
// go-ethereum version being built. Note that this
|
||||||
// is not the debian package version. The package version
|
// is not the debian package version. The package version
|
||||||
// is constructed by VersionString.
|
// is constructed by VersionString.
|
||||||
@@ -537,21 +571,33 @@ type debMetadata struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type debExecutable struct {
|
type debExecutable struct {
|
||||||
Name, Description string
|
PackageName string
|
||||||
|
BinaryName string
|
||||||
|
Description string
|
||||||
}
|
}
|
||||||
|
|
||||||
func newDebMetadata(distro, author string, env build.Environment, t time.Time) debMetadata {
|
// Package returns the name of the package if present, or
|
||||||
|
// fallbacks to BinaryName
|
||||||
|
func (d debExecutable) Package() string {
|
||||||
|
if d.PackageName != "" {
|
||||||
|
return d.PackageName
|
||||||
|
}
|
||||||
|
return d.BinaryName
|
||||||
|
}
|
||||||
|
|
||||||
|
func newDebMetadata(distro, author string, env build.Environment, t time.Time, name string, version string, exes []debExecutable) debMetadata {
|
||||||
if author == "" {
|
if author == "" {
|
||||||
// No signing key, use default author.
|
// No signing key, use default author.
|
||||||
author = "Ethereum Builds <fjl@ethereum.org>"
|
author = "Ethereum Builds <fjl@ethereum.org>"
|
||||||
}
|
}
|
||||||
return debMetadata{
|
return debMetadata{
|
||||||
|
PackageName: name,
|
||||||
Env: env,
|
Env: env,
|
||||||
Author: author,
|
Author: author,
|
||||||
Distro: distro,
|
Distro: distro,
|
||||||
Version: build.VERSION(),
|
Version: version,
|
||||||
Time: t.Format(time.RFC1123Z),
|
Time: t.Format(time.RFC1123Z),
|
||||||
Executables: debExecutables,
|
Executables: exes,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -559,9 +605,9 @@ func newDebMetadata(distro, author string, env build.Environment, t time.Time) d
|
|||||||
// on all executable packages.
|
// on all executable packages.
|
||||||
func (meta debMetadata) Name() string {
|
func (meta debMetadata) Name() string {
|
||||||
if isUnstableBuild(meta.Env) {
|
if isUnstableBuild(meta.Env) {
|
||||||
return "ethereum-unstable"
|
return meta.PackageName + "-unstable"
|
||||||
}
|
}
|
||||||
return "ethereum"
|
return meta.PackageName
|
||||||
}
|
}
|
||||||
|
|
||||||
// VersionString returns the debian version of the packages.
|
// VersionString returns the debian version of the packages.
|
||||||
@@ -588,9 +634,9 @@ func (meta debMetadata) ExeList() string {
|
|||||||
// ExeName returns the package name of an executable package.
|
// ExeName returns the package name of an executable package.
|
||||||
func (meta debMetadata) ExeName(exe debExecutable) string {
|
func (meta debMetadata) ExeName(exe debExecutable) string {
|
||||||
if isUnstableBuild(meta.Env) {
|
if isUnstableBuild(meta.Env) {
|
||||||
return exe.Name + "-unstable"
|
return exe.Package() + "-unstable"
|
||||||
}
|
}
|
||||||
return exe.Name
|
return exe.Package()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExeConflicts returns the content of the Conflicts field
|
// ExeConflicts returns the content of the Conflicts field
|
||||||
@@ -605,7 +651,7 @@ func (meta debMetadata) ExeConflicts(exe debExecutable) string {
|
|||||||
// be preferred and the conflicting files should be handled via
|
// be preferred and the conflicting files should be handled via
|
||||||
// alternates. We might do this eventually but using a conflict is
|
// alternates. We might do this eventually but using a conflict is
|
||||||
// easier now.
|
// easier now.
|
||||||
return "ethereum, " + exe.Name
|
return "ethereum, " + exe.Package()
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
@@ -622,24 +668,23 @@ func stageDebianSource(tmpdir string, meta debMetadata) (pkgdir string) {
|
|||||||
|
|
||||||
// Put the debian build files in place.
|
// Put the debian build files in place.
|
||||||
debian := filepath.Join(pkgdir, "debian")
|
debian := filepath.Join(pkgdir, "debian")
|
||||||
build.Render("build/deb.rules", filepath.Join(debian, "rules"), 0755, meta)
|
build.Render("build/deb/"+meta.PackageName+"/deb.rules", filepath.Join(debian, "rules"), 0755, meta)
|
||||||
build.Render("build/deb.changelog", filepath.Join(debian, "changelog"), 0644, meta)
|
build.Render("build/deb/"+meta.PackageName+"/deb.changelog", filepath.Join(debian, "changelog"), 0644, meta)
|
||||||
build.Render("build/deb.control", filepath.Join(debian, "control"), 0644, meta)
|
build.Render("build/deb/"+meta.PackageName+"/deb.control", filepath.Join(debian, "control"), 0644, meta)
|
||||||
build.Render("build/deb.copyright", filepath.Join(debian, "copyright"), 0644, meta)
|
build.Render("build/deb/"+meta.PackageName+"/deb.copyright", filepath.Join(debian, "copyright"), 0644, meta)
|
||||||
build.RenderString("8\n", filepath.Join(debian, "compat"), 0644, meta)
|
build.RenderString("8\n", filepath.Join(debian, "compat"), 0644, meta)
|
||||||
build.RenderString("3.0 (native)\n", filepath.Join(debian, "source/format"), 0644, meta)
|
build.RenderString("3.0 (native)\n", filepath.Join(debian, "source/format"), 0644, meta)
|
||||||
for _, exe := range meta.Executables {
|
for _, exe := range meta.Executables {
|
||||||
install := filepath.Join(debian, meta.ExeName(exe)+".install")
|
install := filepath.Join(debian, meta.ExeName(exe)+".install")
|
||||||
docs := filepath.Join(debian, meta.ExeName(exe)+".docs")
|
docs := filepath.Join(debian, meta.ExeName(exe)+".docs")
|
||||||
build.Render("build/deb.install", install, 0644, exe)
|
build.Render("build/deb/"+meta.PackageName+"/deb.install", install, 0644, exe)
|
||||||
build.Render("build/deb.docs", docs, 0644, exe)
|
build.Render("build/deb/"+meta.PackageName+"/deb.docs", docs, 0644, exe)
|
||||||
}
|
}
|
||||||
|
|
||||||
return pkgdir
|
return pkgdir
|
||||||
}
|
}
|
||||||
|
|
||||||
// Windows installer
|
// Windows installer
|
||||||
|
|
||||||
func doWindowsInstaller(cmdline []string) {
|
func doWindowsInstaller(cmdline []string) {
|
||||||
// Parse the flags and make skip installer generation on PRs
|
// Parse the flags and make skip installer generation on PRs
|
||||||
var (
|
var (
|
||||||
@@ -689,11 +734,11 @@ func doWindowsInstaller(cmdline []string) {
|
|||||||
// 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
|
||||||
// minimum).
|
// minimum).
|
||||||
version := strings.Split(build.VERSION(), ".")
|
version := strings.Split(params.Version, ".")
|
||||||
if env.Commit != "" {
|
if env.Commit != "" {
|
||||||
version[2] += "-" + env.Commit[:8]
|
version[2] += "-" + env.Commit[:8]
|
||||||
}
|
}
|
||||||
installer, _ := filepath.Abs("geth-" + archiveBasename(*arch, env) + ".exe")
|
installer, _ := filepath.Abs("geth-" + archiveBasename(*arch, params.ArchiveVersion(env.Commit)) + ".exe")
|
||||||
build.MustRunCommand("makensis.exe",
|
build.MustRunCommand("makensis.exe",
|
||||||
"/DOUTPUTFILE="+installer,
|
"/DOUTPUTFILE="+installer,
|
||||||
"/DMAJORVERSION="+version[0],
|
"/DMAJORVERSION="+version[0],
|
||||||
@@ -745,7 +790,7 @@ func doAndroidArchive(cmdline []string) {
|
|||||||
maybeSkipArchive(env)
|
maybeSkipArchive(env)
|
||||||
|
|
||||||
// Sign and upload the archive to Azure
|
// Sign and upload the archive to Azure
|
||||||
archive := "geth-" + archiveBasename("android", env) + ".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); err != nil {
|
||||||
@@ -830,7 +875,7 @@ func newMavenMetadata(env build.Environment) mavenMetadata {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Render the version and package strings
|
// Render the version and package strings
|
||||||
version := build.VERSION()
|
version := params.Version
|
||||||
if isUnstableBuild(env) {
|
if isUnstableBuild(env) {
|
||||||
version += "-SNAPSHOT"
|
version += "-SNAPSHOT"
|
||||||
}
|
}
|
||||||
@@ -865,7 +910,7 @@ func doXCodeFramework(cmdline []string) {
|
|||||||
build.MustRun(bind)
|
build.MustRun(bind)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
archive := "geth-" + archiveBasename("ios", env)
|
archive := "geth-" + archiveBasename("ios", params.ArchiveVersion(env.Commit))
|
||||||
if err := os.Mkdir(archive, os.ModePerm); err != nil {
|
if err := os.Mkdir(archive, os.ModePerm); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -921,7 +966,7 @@ func newPodMetadata(env build.Environment, archive string) podMetadata {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
version := build.VERSION()
|
version := params.Version
|
||||||
if isUnstableBuild(env) {
|
if isUnstableBuild(env) {
|
||||||
version += "-unstable." + env.Buildnum
|
version += "-unstable." + env.Buildnum
|
||||||
}
|
}
|
||||||
@@ -951,7 +996,7 @@ func doXgo(cmdline []string) {
|
|||||||
|
|
||||||
if *alltools {
|
if *alltools {
|
||||||
args = append(args, []string{"--dest", GOBIN}...)
|
args = append(args, []string{"--dest", GOBIN}...)
|
||||||
for _, res := range allToolsArchiveFiles {
|
for _, res := range allCrossCompiledArchiveFiles {
|
||||||
if strings.HasPrefix(res, GOBIN) {
|
if strings.HasPrefix(res, GOBIN) {
|
||||||
// Binary tool found, cross build it explicitly
|
// Binary tool found, cross build it explicitly
|
||||||
args = append(args, "./"+filepath.Join("cmd", filepath.Base(res)))
|
args = append(args, "./"+filepath.Join("cmd", filepath.Base(res)))
|
||||||
@@ -990,7 +1035,7 @@ func xgoTool(args []string) *exec.Cmd {
|
|||||||
func doPurge(cmdline []string) {
|
func doPurge(cmdline []string) {
|
||||||
var (
|
var (
|
||||||
store = flag.String("store", "", `Destination from where to purge archives (usually "gethstore/builds")`)
|
store = flag.String("store", "", `Destination from where to purge archives (usually "gethstore/builds")`)
|
||||||
limit = flag.Int("days", 30, `Age threshold above which to delete unstalbe archives`)
|
limit = flag.Int("days", 30, `Age threshold above which to delete unstable archives`)
|
||||||
)
|
)
|
||||||
flag.CommandLine.Parse(cmdline)
|
flag.CommandLine.Parse(cmdline)
|
||||||
|
|
||||||
@@ -1017,23 +1062,14 @@ func doPurge(cmdline []string) {
|
|||||||
}
|
}
|
||||||
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++ {
|
||||||
iTime, err := time.Parse(time.RFC1123, blobs[i].Properties.LastModified)
|
if blobs[i].Properties.LastModified.After(blobs[j].Properties.LastModified) {
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
jTime, err := time.Parse(time.RFC1123, blobs[j].Properties.LastModified)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
if iTime.After(jTime) {
|
|
||||||
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 {
|
||||||
timestamp, _ := time.Parse(time.RFC1123, blob.Properties.LastModified)
|
if time.Since(blob.Properties.LastModified) < time.Duration(*limit)*24*time.Hour {
|
||||||
if time.Since(timestamp) < time.Duration(*limit)*24*time.Hour {
|
|
||||||
blobs = blobs[:i]
|
blobs = blobs[:i]
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
19
build/clean_go_build_cache.sh
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Cleaning the Go cache only makes sense if we actually have Go installed... or
|
||||||
|
# if Go is actually callable. This does not hold true during deb packaging, so
|
||||||
|
# we need an explicit check to avoid build failures.
|
||||||
|
if ! command -v go > /dev/null; then
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
version_gt() {
|
||||||
|
test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
golang_version=$(go version |cut -d' ' -f3 |sed 's/go//')
|
||||||
|
|
||||||
|
# Clean go build cache when go version is greater than or equal to 1.10
|
||||||
|
if !(version_gt 1.10 $golang_version); then
|
||||||
|
go clean -cache
|
||||||
|
fi
|
||||||
@@ -1 +0,0 @@
|
|||||||
build/bin/{{.Name}} usr/bin
|
|
||||||
19
build/deb/ethereum-swarm/deb.control
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
Source: {{.Name}}
|
||||||
|
Section: science
|
||||||
|
Priority: extra
|
||||||
|
Maintainer: {{.Author}}
|
||||||
|
Build-Depends: debhelper (>= 8.0.0), golang-1.10
|
||||||
|
Standards-Version: 3.9.5
|
||||||
|
Homepage: https://ethereum.org
|
||||||
|
Vcs-Git: git://github.com/ethereum/go-ethereum.git
|
||||||
|
Vcs-Browser: https://github.com/ethereum/go-ethereum
|
||||||
|
|
||||||
|
{{range .Executables}}
|
||||||
|
Package: {{$.ExeName .}}
|
||||||
|
Conflicts: {{$.ExeConflicts .}}
|
||||||
|
Architecture: any
|
||||||
|
Depends: ${shlibs:Depends}, ${misc:Depends}
|
||||||
|
Built-Using: ${misc:Built-Using}
|
||||||
|
Description: {{.Description}}
|
||||||
|
{{.Description}}
|
||||||
|
{{end}}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
Copyright 2016 The go-ethereum Authors
|
Copyright 2018 The go-ethereum Authors
|
||||||
|
|
||||||
go-ethereum 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 General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
1
build/deb/ethereum-swarm/deb.install
Normal file
@@ -0,0 +1 @@
|
|||||||
|
build/bin/{{.BinaryName}} usr/bin
|
||||||
5
build/deb/ethereum/deb.changelog
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{{.Name}} ({{.VersionString}}) {{.Distro}}; urgency=low
|
||||||
|
|
||||||
|
* git build of {{.Env.Commit}}
|
||||||
|
|
||||||
|
-- {{.Author}} {{.Time}}
|
||||||
@@ -11,8 +11,8 @@ Vcs-Browser: https://github.com/ethereum/go-ethereum
|
|||||||
Package: {{.Name}}
|
Package: {{.Name}}
|
||||||
Architecture: any
|
Architecture: any
|
||||||
Depends: ${misc:Depends}, {{.ExeList}}
|
Depends: ${misc:Depends}, {{.ExeList}}
|
||||||
Description: Meta-package to install geth and other tools
|
Description: Meta-package to install geth, swarm, and other tools
|
||||||
Meta-package to install geth and other tools
|
Meta-package to install geth, swarm and other tools
|
||||||
|
|
||||||
{{range .Executables}}
|
{{range .Executables}}
|
||||||
Package: {{$.ExeName .}}
|
Package: {{$.ExeName .}}
|
||||||
14
build/deb/ethereum/deb.copyright
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
Copyright 2018 The go-ethereum Authors
|
||||||
|
|
||||||
|
go-ethereum 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.
|
||||||
|
|
||||||
|
go-ethereum 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 go-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||||
1
build/deb/ethereum/deb.docs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
AUTHORS
|
||||||
1
build/deb/ethereum/deb.install
Normal file
@@ -0,0 +1 @@
|
|||||||
|
build/bin/{{.BinaryName}} usr/bin
|
||||||
13
build/deb/ethereum/deb.rules
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/make -f
|
||||||
|
# -*- makefile -*-
|
||||||
|
|
||||||
|
# Uncomment this to turn on verbose mode.
|
||||||
|
#export DH_VERBOSE=1
|
||||||
|
|
||||||
|
override_dh_auto_build:
|
||||||
|
build/env.sh /usr/lib/go-1.10/bin/go run build/ci.go install -git-commit={{.Env.Commit}} -git-branch={{.Env.Branch}} -git-tag={{.Env.Tag}} -buildnum={{.Env.Buildnum}} -pull-request={{.Env.IsPullRequest}}
|
||||||
|
|
||||||
|
override_dh_auto_test:
|
||||||
|
|
||||||
|
%:
|
||||||
|
dh $@
|
||||||
@@ -1,18 +1,18 @@
|
|||||||
#!/usr/bin/env bash
|
#!/bin/sh
|
||||||
|
|
||||||
find_files() {
|
find_files() {
|
||||||
find . -not \( \
|
find . ! \( \
|
||||||
\( \
|
\( \
|
||||||
-wholename '.github' \
|
-path '.github' \
|
||||||
-o -wholename './build/_workspace' \
|
-o -path './build/_workspace' \
|
||||||
-o -wholename './build/bin' \
|
-o -path './build/bin' \
|
||||||
-o -wholename './crypto/bn256' \
|
-o -path './crypto/bn256' \
|
||||||
-o -wholename '*/vendor/*' \
|
-o -path '*/vendor/*' \
|
||||||
\) -prune \
|
\) -prune \
|
||||||
\) -name '*.go'
|
\) -name '*.go'
|
||||||
}
|
}
|
||||||
|
|
||||||
GOFMT="gofmt -s -w";
|
GOFMT="gofmt -s -w"
|
||||||
GOIMPORTS="goimports -w";
|
GOIMPORTS="goimports -w"
|
||||||
find_files | xargs $GOFMT;
|
find_files | xargs $GOFMT
|
||||||
find_files | xargs $GOIMPORTS;
|
find_files | xargs $GOIMPORTS
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ func main() {
|
|||||||
bins []string
|
bins []string
|
||||||
types []string
|
types []string
|
||||||
)
|
)
|
||||||
if *solFlag != "" || *abiFlag == "-" {
|
if *solFlag != "" || (*abiFlag == "-" && *pkgFlag == "") {
|
||||||
// Generate the list of types to exclude from binding
|
// Generate the list of types to exclude from binding
|
||||||
exclude := make(map[string]bool)
|
exclude := make(map[string]bool)
|
||||||
for _, kind := range strings.Split(*excFlag, ",") {
|
for _, kind := range strings.Split(*excFlag, ",") {
|
||||||
@@ -111,7 +111,13 @@ func main() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Otherwise load up the ABI, optional bytecode and type name from the parameters
|
// Otherwise load up the ABI, optional bytecode and type name from the parameters
|
||||||
abi, err := ioutil.ReadFile(*abiFlag)
|
var abi []byte
|
||||||
|
var err error
|
||||||
|
if *abiFlag == "-" {
|
||||||
|
abi, err = ioutil.ReadAll(os.Stdin)
|
||||||
|
} else {
|
||||||
|
abi, err = ioutil.ReadFile(*abiFlag)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Failed to read input ABI: %v\n", err)
|
fmt.Printf("Failed to read input ABI: %v\n", err)
|
||||||
os.Exit(-1)
|
os.Exit(-1)
|
||||||
@@ -155,6 +161,5 @@ func contractsFromStdin() (map[string]*compiler.Contract, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return compiler.ParseCombinedJSON(bytes, "", "", "", "")
|
return compiler.ParseCombinedJSON(bytes, "", "", "", "")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import (
|
|||||||
"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/discv5"
|
||||||
|
"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"
|
||||||
)
|
)
|
||||||
@@ -37,7 +38,7 @@ func main() {
|
|||||||
var (
|
var (
|
||||||
listenAddr = flag.String("addr", ":30301", "listen address")
|
listenAddr = flag.String("addr", ":30301", "listen address")
|
||||||
genKey = flag.String("genkey", "", "generate a node key")
|
genKey = flag.String("genkey", "", "generate a node key")
|
||||||
writeAddr = flag.Bool("writeaddress", false, "write out the node's pubkey hash and quit")
|
writeAddr = flag.Bool("writeaddress", false, "write out the node's public key and quit")
|
||||||
nodeKeyFile = flag.String("nodekey", "", "private key filename")
|
nodeKeyFile = flag.String("nodekey", "", "private key filename")
|
||||||
nodeKeyHex = flag.String("nodekeyhex", "", "private key as hex (for testing)")
|
nodeKeyHex = flag.String("nodekeyhex", "", "private key as hex (for testing)")
|
||||||
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>)")
|
||||||
@@ -85,7 +86,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if *writeAddr {
|
if *writeAddr {
|
||||||
fmt.Printf("%v\n", discover.PubkeyID(&nodeKey.PublicKey))
|
fmt.Printf("%x\n", crypto.FromECDSAPub(&nodeKey.PublicKey)[1:])
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,16 +119,17 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if *runv5 {
|
if *runv5 {
|
||||||
if _, err := discv5.ListenUDP(nodeKey, conn, realaddr, "", restrictList); err != nil {
|
if _, err := discv5.ListenUDP(nodeKey, conn, "", restrictList); err != nil {
|
||||||
utils.Fatalf("%v", err)
|
utils.Fatalf("%v", err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
db, _ := enode.OpenDB("")
|
||||||
|
ln := enode.NewLocalNode(db, nodeKey)
|
||||||
cfg := discover.Config{
|
cfg := discover.Config{
|
||||||
PrivateKey: nodeKey,
|
PrivateKey: nodeKey,
|
||||||
AnnounceAddr: realaddr,
|
NetRestrict: restrictList,
|
||||||
NetRestrict: restrictList,
|
|
||||||
}
|
}
|
||||||
if _, err := discover.ListenUDP(conn, cfg); err != nil {
|
if _, err := discover.ListenUDP(conn, ln, cfg); err != nil {
|
||||||
utils.Fatalf("%v", err)
|
utils.Fatalf("%v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ invoking methods with the following info:
|
|||||||
* [x] Version info about the signer
|
* [x] Version info about the signer
|
||||||
* [x] Address of API (http/ipc)
|
* [x] Address of API (http/ipc)
|
||||||
* [ ] List of known accounts
|
* [ ] List of known accounts
|
||||||
* [ ] Have a default timeout on signing operations, so that if the user has not answered withing e.g. 60 seconds, the request is rejected.
|
* [ ] Have a default timeout on signing operations, so that if the user has not answered within e.g. 60 seconds, the request is rejected.
|
||||||
* [ ] `account_signRawTransaction`
|
* [ ] `account_signRawTransaction`
|
||||||
* [ ] `account_bulkSignTransactions([] transactions)` should
|
* [ ] `account_bulkSignTransactions([] transactions)` should
|
||||||
* only exist if enabled via config/flag
|
* only exist if enabled via config/flag
|
||||||
@@ -129,7 +129,7 @@ The signer listens to HTTP requests on `rpcaddr`:`rpcport`, with the same JSONRP
|
|||||||
expected to be JSON [jsonrpc 2.0 standard](http://www.jsonrpc.org/specification).
|
expected to be JSON [jsonrpc 2.0 standard](http://www.jsonrpc.org/specification).
|
||||||
|
|
||||||
Some of these call can require user interaction. Clients must be aware that responses
|
Some of these call can require user interaction. Clients must be aware that responses
|
||||||
may be delayed significanlty or may never be received if a users decides to ignore the confirmation request.
|
may be delayed significantly or may never be received if a users decides to ignore the confirmation request.
|
||||||
|
|
||||||
The External API is **untrusted** : it does not accept credentials over this api, nor does it expect
|
The External API is **untrusted** : it does not accept credentials over this api, nor does it expect
|
||||||
that requests have any authority.
|
that requests have any authority.
|
||||||
@@ -862,7 +862,7 @@ A UI should conform to the following rules.
|
|||||||
* A UI SHOULD inform the user about the `SHA256` or `MD5` hash of the binary being executed
|
* A UI SHOULD inform the user about the `SHA256` or `MD5` hash of the binary being executed
|
||||||
* A UI SHOULD NOT maintain a secondary storage of data, e.g. list of accounts
|
* A UI SHOULD NOT maintain a secondary storage of data, e.g. list of accounts
|
||||||
* The signer provides accounts
|
* The signer provides accounts
|
||||||
* A UI SHOULD, to the best extent possible, use static linking / bundling, so that requried libraries are bundled
|
* A UI SHOULD, to the best extent possible, use static linking / bundling, so that required libraries are bundled
|
||||||
along with the UI.
|
along with the UI.
|
||||||
|
|
||||||
|
|
||||||
@@ -875,3 +875,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)|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 36 KiB |
@@ -1,6 +1,13 @@
|
|||||||
### Changelog for external API
|
### Changelog for external API
|
||||||
|
|
||||||
|
#### 4.0.0
|
||||||
|
|
||||||
|
* The external `account_Ecrecover`-method was removed.
|
||||||
|
* The external `account_Import`-method was removed.
|
||||||
|
|
||||||
|
#### 3.0.0
|
||||||
|
|
||||||
|
* The external `account_List`-method was changed to not expose `url`, which contained info about the local filesystem. It now returns only a list of addresses.
|
||||||
|
|
||||||
#### 2.0.0
|
#### 2.0.0
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,24 @@
|
|||||||
### Changelog for internal API (ui-api)
|
### Changelog for internal API (ui-api)
|
||||||
|
|
||||||
|
### 3.0.0
|
||||||
|
|
||||||
|
* Make use of `OnInputRequired(info UserInputRequest)` for obtaining master password during startup
|
||||||
|
|
||||||
|
### 2.1.0
|
||||||
|
|
||||||
|
* Add `OnInputRequired(info UserInputRequest)` to internal API. This method is used when Clef needs user input, e.g. passwords.
|
||||||
|
|
||||||
|
The following structures are used:
|
||||||
|
```golang
|
||||||
|
UserInputRequest struct {
|
||||||
|
Prompt string `json:"prompt"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
IsPassword bool `json:"isPassword"`
|
||||||
|
}
|
||||||
|
UserInputResponse struct {
|
||||||
|
Text string `json:"text"`
|
||||||
|
}
|
||||||
|
|
||||||
### 2.0.0
|
### 2.0.0
|
||||||
|
|
||||||
* Modify how `call_info` on a transaction is conveyed. New format:
|
* Modify how `call_info` on a transaction is conveyed. New format:
|
||||||
|
|||||||
221
cmd/clef/main.go
@@ -35,8 +35,10 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/accounts/keystore"
|
||||||
"github.com/ethereum/go-ethereum/cmd/utils"
|
"github.com/ethereum/go-ethereum/cmd/utils"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/console"
|
||||||
"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/node"
|
"github.com/ethereum/go-ethereum/node"
|
||||||
@@ -48,10 +50,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ExternalAPIVersion -- see extapi_changelog.md
|
// ExternalAPIVersion -- see extapi_changelog.md
|
||||||
const ExternalAPIVersion = "2.0.0"
|
const ExternalAPIVersion = "4.0.0"
|
||||||
|
|
||||||
// InternalAPIVersion -- see intapi_changelog.md
|
// InternalAPIVersion -- see intapi_changelog.md
|
||||||
const InternalAPIVersion = "2.0.0"
|
const InternalAPIVersion = "3.0.0"
|
||||||
|
|
||||||
const legalWarning = `
|
const legalWarning = `
|
||||||
WARNING!
|
WARNING!
|
||||||
@@ -70,6 +72,10 @@ var (
|
|||||||
Value: 4,
|
Value: 4,
|
||||||
Usage: "log level to emit to the screen",
|
Usage: "log level to emit to the screen",
|
||||||
}
|
}
|
||||||
|
advancedMode = cli.BoolFlag{
|
||||||
|
Name: "advanced",
|
||||||
|
Usage: "If enabled, issues warnings instead of rejections for suspicious requests. Default off",
|
||||||
|
}
|
||||||
keystoreFlag = cli.StringFlag{
|
keystoreFlag = cli.StringFlag{
|
||||||
Name: "keystore",
|
Name: "keystore",
|
||||||
Value: filepath.Join(node.DefaultDataDir(), "keystore"),
|
Value: filepath.Join(node.DefaultDataDir(), "keystore"),
|
||||||
@@ -87,7 +93,7 @@ var (
|
|||||||
}
|
}
|
||||||
signerSecretFlag = cli.StringFlag{
|
signerSecretFlag = cli.StringFlag{
|
||||||
Name: "signersecret",
|
Name: "signersecret",
|
||||||
Usage: "A file containing the password used to encrypt Clef credentials, 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",
|
||||||
}
|
}
|
||||||
dBFlag = cli.StringFlag{
|
dBFlag = cli.StringFlag{
|
||||||
Name: "4bytedb",
|
Name: "4bytedb",
|
||||||
@@ -151,18 +157,18 @@ Whenever you make an edit to the rule file, you need to use attestation to tell
|
|||||||
Clef that the file is 'safe' to execute.`,
|
Clef that the file is 'safe' to execute.`,
|
||||||
}
|
}
|
||||||
|
|
||||||
addCredentialCommand = cli.Command{
|
setCredentialCommand = cli.Command{
|
||||||
Action: utils.MigrateFlags(addCredential),
|
Action: utils.MigrateFlags(setCredential),
|
||||||
Name: "addpw",
|
Name: "setpw",
|
||||||
Usage: "Store a credential for a keystore file",
|
Usage: "Store a credential for a keystore file",
|
||||||
ArgsUsage: "<address> <password>",
|
ArgsUsage: "<address>",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
logLevelFlag,
|
logLevelFlag,
|
||||||
configdirFlag,
|
configdirFlag,
|
||||||
signerSecretFlag,
|
signerSecretFlag,
|
||||||
},
|
},
|
||||||
Description: `
|
Description: `
|
||||||
The addpw command stores a password for a given address (keyfile). If you invoke it with only one parameter, it will
|
The setpw command stores a password for a given address (keyfile). If you enter a blank passphrase, it will
|
||||||
remove any stored credential for that address (keyfile)
|
remove any stored credential for that address (keyfile)
|
||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
@@ -191,9 +197,10 @@ func init() {
|
|||||||
ruleFlag,
|
ruleFlag,
|
||||||
stdiouiFlag,
|
stdiouiFlag,
|
||||||
testFlag,
|
testFlag,
|
||||||
|
advancedMode,
|
||||||
}
|
}
|
||||||
app.Action = signer
|
app.Action = signer
|
||||||
app.Commands = []cli.Command{initCommand, attestCommand, addCredentialCommand}
|
app.Commands = []cli.Command{initCommand, attestCommand, setCredentialCommand}
|
||||||
|
|
||||||
}
|
}
|
||||||
func main() {
|
func main() {
|
||||||
@@ -207,25 +214,45 @@ func initializeSecrets(c *cli.Context) error {
|
|||||||
if err := initialize(c); err != nil {
|
if err := initialize(c); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
configDir := c.String(configdirFlag.Name)
|
configDir := c.GlobalString(configdirFlag.Name)
|
||||||
|
|
||||||
masterSeed := make([]byte, 256)
|
masterSeed := make([]byte, 256)
|
||||||
n, err := io.ReadFull(rand.Reader, masterSeed)
|
num, err := io.ReadFull(rand.Reader, masterSeed)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if n != len(masterSeed) {
|
if num != len(masterSeed) {
|
||||||
return fmt.Errorf("failed to read enough random")
|
return fmt.Errorf("failed to read enough random")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
n, p := keystore.StandardScryptN, keystore.StandardScryptP
|
||||||
|
if c.GlobalBool(utils.LightKDFFlag.Name) {
|
||||||
|
n, p = keystore.LightScryptN, keystore.LightScryptP
|
||||||
|
}
|
||||||
|
text := "The master seed of clef is locked with a password. Please give a password. Do not forget this password."
|
||||||
|
var password string
|
||||||
|
for {
|
||||||
|
password = getPassPhrase(text, true)
|
||||||
|
if err := core.ValidatePasswordFormat(password); err != nil {
|
||||||
|
fmt.Printf("invalid password: %v\n", err)
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cipherSeed, err := encryptSeed(masterSeed, []byte(password), n, p)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to encrypt master seed: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
err = os.Mkdir(configDir, 0700)
|
err = os.Mkdir(configDir, 0700)
|
||||||
if err != nil && !os.IsExist(err) {
|
if err != nil && !os.IsExist(err) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
location := filepath.Join(configDir, "secrets.dat")
|
location := filepath.Join(configDir, "masterseed.json")
|
||||||
if _, err := os.Stat(location); err == nil {
|
if _, err := os.Stat(location); err == nil {
|
||||||
return fmt.Errorf("file %v already exists, will not overwrite", location)
|
return fmt.Errorf("file %v already exists, will not overwrite", location)
|
||||||
}
|
}
|
||||||
err = ioutil.WriteFile(location, masterSeed, 0700)
|
err = ioutil.WriteFile(location, cipherSeed, 0400)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -250,11 +277,11 @@ func attestFile(ctx *cli.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
stretchedKey, err := readMasterKey(ctx)
|
stretchedKey, err := readMasterKey(ctx, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf(err.Error())
|
utils.Fatalf(err.Error())
|
||||||
}
|
}
|
||||||
configDir := ctx.String(configdirFlag.Name)
|
configDir := ctx.GlobalString(configdirFlag.Name)
|
||||||
vaultLocation := filepath.Join(configDir, common.Bytes2Hex(crypto.Keccak256([]byte("vault"), stretchedKey)[:10]))
|
vaultLocation := filepath.Join(configDir, common.Bytes2Hex(crypto.Keccak256([]byte("vault"), stretchedKey)[:10]))
|
||||||
confKey := crypto.Keccak256([]byte("config"), stretchedKey)
|
confKey := crypto.Keccak256([]byte("config"), stretchedKey)
|
||||||
|
|
||||||
@@ -266,38 +293,36 @@ func attestFile(ctx *cli.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func addCredential(ctx *cli.Context) error {
|
func setCredential(ctx *cli.Context) error {
|
||||||
if len(ctx.Args()) < 1 {
|
if len(ctx.Args()) < 1 {
|
||||||
utils.Fatalf("This command requires at leaste one argument.")
|
utils.Fatalf("This command requires an address to be passed as an argument.")
|
||||||
}
|
}
|
||||||
if err := initialize(ctx); err != nil {
|
if err := initialize(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
stretchedKey, err := readMasterKey(ctx)
|
address := ctx.Args().First()
|
||||||
|
password := getPassPhrase("Enter a passphrase to store with this address.", true)
|
||||||
|
|
||||||
|
stretchedKey, err := readMasterKey(ctx, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf(err.Error())
|
utils.Fatalf(err.Error())
|
||||||
}
|
}
|
||||||
configDir := ctx.String(configdirFlag.Name)
|
configDir := ctx.GlobalString(configdirFlag.Name)
|
||||||
vaultLocation := filepath.Join(configDir, common.Bytes2Hex(crypto.Keccak256([]byte("vault"), stretchedKey)[:10]))
|
vaultLocation := filepath.Join(configDir, common.Bytes2Hex(crypto.Keccak256([]byte("vault"), stretchedKey)[:10]))
|
||||||
pwkey := crypto.Keccak256([]byte("credentials"), stretchedKey)
|
pwkey := crypto.Keccak256([]byte("credentials"), stretchedKey)
|
||||||
|
|
||||||
// Initialize the encrypted storages
|
// Initialize the encrypted storages
|
||||||
pwStorage := storage.NewAESEncryptedStorage(filepath.Join(vaultLocation, "credentials.json"), pwkey)
|
pwStorage := storage.NewAESEncryptedStorage(filepath.Join(vaultLocation, "credentials.json"), pwkey)
|
||||||
key := ctx.Args().First()
|
pwStorage.Put(address, password)
|
||||||
value := ""
|
log.Info("Credential store updated", "key", address)
|
||||||
if len(ctx.Args()) > 1 {
|
|
||||||
value = ctx.Args().Get(1)
|
|
||||||
}
|
|
||||||
pwStorage.Put(key, value)
|
|
||||||
log.Info("Credential store updated", "key", key)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func initialize(c *cli.Context) error {
|
func initialize(c *cli.Context) error {
|
||||||
// Set up the logger to print everything
|
// Set up the logger to print everything
|
||||||
logOutput := os.Stdout
|
logOutput := os.Stdout
|
||||||
if c.Bool(stdiouiFlag.Name) {
|
if c.GlobalBool(stdiouiFlag.Name) {
|
||||||
logOutput = os.Stderr
|
logOutput = os.Stderr
|
||||||
// If using the stdioui, we can't do the 'confirm'-flow
|
// If using the stdioui, we can't do the 'confirm'-flow
|
||||||
fmt.Fprintf(logOutput, legalWarning)
|
fmt.Fprintf(logOutput, legalWarning)
|
||||||
@@ -318,26 +343,28 @@ func signer(c *cli.Context) error {
|
|||||||
var (
|
var (
|
||||||
ui core.SignerUI
|
ui core.SignerUI
|
||||||
)
|
)
|
||||||
if c.Bool(stdiouiFlag.Name) {
|
if c.GlobalBool(stdiouiFlag.Name) {
|
||||||
log.Info("Using stdin/stdout as UI-channel")
|
log.Info("Using stdin/stdout as UI-channel")
|
||||||
ui = core.NewStdIOUI()
|
ui = core.NewStdIOUI()
|
||||||
} else {
|
} else {
|
||||||
log.Info("Using CLI as UI-channel")
|
log.Info("Using CLI as UI-channel")
|
||||||
ui = core.NewCommandlineUI()
|
ui = core.NewCommandlineUI()
|
||||||
}
|
}
|
||||||
db, err := core.NewAbiDBFromFiles(c.String(dBFlag.Name), c.String(customDBFlag.Name))
|
fourByteDb := c.GlobalString(dBFlag.Name)
|
||||||
|
fourByteLocal := c.GlobalString(customDBFlag.Name)
|
||||||
|
db, err := core.NewAbiDBFromFiles(fourByteDb, fourByteLocal)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf(err.Error())
|
utils.Fatalf(err.Error())
|
||||||
}
|
}
|
||||||
log.Info("Loaded 4byte db", "signatures", db.Size(), "file", c.String("4bytedb"))
|
log.Info("Loaded 4byte db", "signatures", db.Size(), "file", fourByteDb, "local", fourByteLocal)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
api core.ExternalAPI
|
api core.ExternalAPI
|
||||||
)
|
)
|
||||||
|
|
||||||
configDir := c.String(configdirFlag.Name)
|
configDir := c.GlobalString(configdirFlag.Name)
|
||||||
if stretchedKey, err := readMasterKey(c); err != nil {
|
if stretchedKey, err := readMasterKey(c, ui); err != nil {
|
||||||
log.Info("No master seed provided, rules disabled")
|
log.Info("No master seed provided, rules disabled", "error", err)
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -356,7 +383,7 @@ func signer(c *cli.Context) error {
|
|||||||
configStorage := storage.NewAESEncryptedStorage(filepath.Join(vaultLocation, "config.json"), confkey)
|
configStorage := storage.NewAESEncryptedStorage(filepath.Join(vaultLocation, "config.json"), confkey)
|
||||||
|
|
||||||
//Do we have a rule-file?
|
//Do we have a rule-file?
|
||||||
ruleJS, err := ioutil.ReadFile(c.String(ruleFlag.Name))
|
ruleJS, err := ioutil.ReadFile(c.GlobalString(ruleFlag.Name))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Info("Could not load rulefile, rules not enabled", "file", "rulefile")
|
log.Info("Could not load rulefile, rules not enabled", "file", "rulefile")
|
||||||
} else {
|
} else {
|
||||||
@@ -380,16 +407,15 @@ func signer(c *cli.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
apiImpl := core.NewSignerAPI(
|
apiImpl := core.NewSignerAPI(
|
||||||
c.Int64(utils.NetworkIdFlag.Name),
|
c.GlobalInt64(utils.NetworkIdFlag.Name),
|
||||||
c.String(keystoreFlag.Name),
|
c.GlobalString(keystoreFlag.Name),
|
||||||
c.Bool(utils.NoUSBFlag.Name),
|
c.GlobalBool(utils.NoUSBFlag.Name),
|
||||||
ui, db,
|
ui, db,
|
||||||
c.Bool(utils.LightKDFFlag.Name))
|
c.GlobalBool(utils.LightKDFFlag.Name),
|
||||||
|
c.GlobalBool(advancedMode.Name))
|
||||||
api = apiImpl
|
api = apiImpl
|
||||||
|
|
||||||
// Audit logging
|
// Audit logging
|
||||||
if logfile := c.String(auditLogFlag.Name); logfile != "" {
|
if logfile := c.GlobalString(auditLogFlag.Name); logfile != "" {
|
||||||
api, err = core.NewAuditLogger(logfile, api)
|
api, err = core.NewAuditLogger(logfile, api)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf(err.Error())
|
utils.Fatalf(err.Error())
|
||||||
@@ -408,14 +434,14 @@ func signer(c *cli.Context) error {
|
|||||||
Service: api,
|
Service: api,
|
||||||
Version: "1.0"},
|
Version: "1.0"},
|
||||||
}
|
}
|
||||||
if c.Bool(utils.RPCEnabledFlag.Name) {
|
if c.GlobalBool(utils.RPCEnabledFlag.Name) {
|
||||||
|
|
||||||
vhosts := splitAndTrim(c.GlobalString(utils.RPCVirtualHostsFlag.Name))
|
vhosts := splitAndTrim(c.GlobalString(utils.RPCVirtualHostsFlag.Name))
|
||||||
cors := splitAndTrim(c.GlobalString(utils.RPCCORSDomainFlag.Name))
|
cors := splitAndTrim(c.GlobalString(utils.RPCCORSDomainFlag.Name))
|
||||||
|
|
||||||
// start http server
|
// start http server
|
||||||
httpEndpoint := fmt.Sprintf("%s:%d", c.String(utils.RPCListenAddrFlag.Name), c.Int(rpcPortFlag.Name))
|
httpEndpoint := fmt.Sprintf("%s:%d", c.GlobalString(utils.RPCListenAddrFlag.Name), c.Int(rpcPortFlag.Name))
|
||||||
listener, _, err := rpc.StartHTTPEndpoint(httpEndpoint, rpcAPI, []string{"account"}, cors, vhosts)
|
listener, _, err := rpc.StartHTTPEndpoint(httpEndpoint, rpcAPI, []string{"account"}, cors, vhosts, rpc.DefaultHTTPTimeouts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf("Could not start RPC api: %v", err)
|
utils.Fatalf("Could not start RPC api: %v", err)
|
||||||
}
|
}
|
||||||
@@ -428,9 +454,9 @@ func signer(c *cli.Context) error {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
}
|
}
|
||||||
if !c.Bool(utils.IPCDisabledFlag.Name) {
|
if !c.GlobalBool(utils.IPCDisabledFlag.Name) {
|
||||||
if c.IsSet(utils.IPCPathFlag.Name) {
|
if c.IsSet(utils.IPCPathFlag.Name) {
|
||||||
ipcapiURL = c.String(utils.IPCPathFlag.Name)
|
ipcapiURL = c.GlobalString(utils.IPCPathFlag.Name)
|
||||||
} else {
|
} else {
|
||||||
ipcapiURL = filepath.Join(configDir, "clef.ipc")
|
ipcapiURL = filepath.Join(configDir, "clef.ipc")
|
||||||
}
|
}
|
||||||
@@ -447,7 +473,7 @@ func signer(c *cli.Context) error {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.Bool(testFlag.Name) {
|
if c.GlobalBool(testFlag.Name) {
|
||||||
log.Info("Performing UI test")
|
log.Info("Performing UI test")
|
||||||
go testExternalUI(apiImpl)
|
go testExternalUI(apiImpl)
|
||||||
}
|
}
|
||||||
@@ -506,48 +532,64 @@ func homeDir() string {
|
|||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
func readMasterKey(ctx *cli.Context) ([]byte, error) {
|
func readMasterKey(ctx *cli.Context, ui core.SignerUI) ([]byte, error) {
|
||||||
var (
|
var (
|
||||||
file string
|
file string
|
||||||
configDir = ctx.String(configdirFlag.Name)
|
configDir = ctx.GlobalString(configdirFlag.Name)
|
||||||
)
|
)
|
||||||
if ctx.IsSet(signerSecretFlag.Name) {
|
if ctx.GlobalIsSet(signerSecretFlag.Name) {
|
||||||
file = ctx.String(signerSecretFlag.Name)
|
file = ctx.GlobalString(signerSecretFlag.Name)
|
||||||
} else {
|
} else {
|
||||||
file = filepath.Join(configDir, "secrets.dat")
|
file = filepath.Join(configDir, "masterseed.json")
|
||||||
}
|
}
|
||||||
if err := checkFile(file); err != nil {
|
if err := checkFile(file); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
masterKey, err := ioutil.ReadFile(file)
|
cipherKey, err := ioutil.ReadFile(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if len(masterKey) < 256 {
|
var password string
|
||||||
return nil, fmt.Errorf("master key of insufficient length, expected >255 bytes, got %d", len(masterKey))
|
// If ui is not nil, get the password from ui.
|
||||||
|
if ui != nil {
|
||||||
|
resp, err := ui.OnInputRequired(core.UserInputRequest{
|
||||||
|
Title: "Master Password",
|
||||||
|
Prompt: "Please enter the password to decrypt the master seed",
|
||||||
|
IsPassword: true})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
password = resp.Text
|
||||||
|
} else {
|
||||||
|
password = getPassPhrase("Decrypt master seed of clef", false)
|
||||||
}
|
}
|
||||||
|
masterSeed, err := decryptSeed(cipherKey, password)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to decrypt the master seed of clef")
|
||||||
|
}
|
||||||
|
if len(masterSeed) < 256 {
|
||||||
|
return nil, fmt.Errorf("master seed of insufficient length, expected >255 bytes, got %d", len(masterSeed))
|
||||||
|
}
|
||||||
|
|
||||||
// Create vault location
|
// Create vault location
|
||||||
vaultLocation := filepath.Join(configDir, common.Bytes2Hex(crypto.Keccak256([]byte("vault"), masterKey)[:10]))
|
vaultLocation := filepath.Join(configDir, common.Bytes2Hex(crypto.Keccak256([]byte("vault"), masterSeed)[:10]))
|
||||||
err = os.Mkdir(vaultLocation, 0700)
|
err = os.Mkdir(vaultLocation, 0700)
|
||||||
if err != nil && !os.IsExist(err) {
|
if err != nil && !os.IsExist(err) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
//!TODO, use KDF to stretch the master key
|
return masterSeed, nil
|
||||||
// stretched_key := stretch_key(master_key)
|
|
||||||
|
|
||||||
return masterKey, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// checkFile is a convenience function to check if a file
|
// checkFile is a convenience function to check if a file
|
||||||
// * exists
|
// * exists
|
||||||
// * is mode 0600
|
// * is mode 0400
|
||||||
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()&077 != 0 {
|
if 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
|
||||||
@@ -613,6 +655,59 @@ func testExternalUI(api *core.SignerAPI) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getPassPhrase retrieves the password associated with clef, either fetched
|
||||||
|
// from a list of preloaded passphrases, or requested interactively from the user.
|
||||||
|
// TODO: there are many `getPassPhrase` functions, it will be better to abstract them into one.
|
||||||
|
func getPassPhrase(prompt string, confirmation bool) string {
|
||||||
|
fmt.Println(prompt)
|
||||||
|
password, err := console.Stdin.PromptPassword("Passphrase: ")
|
||||||
|
if err != nil {
|
||||||
|
utils.Fatalf("Failed to read passphrase: %v", err)
|
||||||
|
}
|
||||||
|
if confirmation {
|
||||||
|
confirm, err := console.Stdin.PromptPassword("Repeat passphrase: ")
|
||||||
|
if err != nil {
|
||||||
|
utils.Fatalf("Failed to read passphrase confirmation: %v", err)
|
||||||
|
}
|
||||||
|
if password != confirm {
|
||||||
|
utils.Fatalf("Passphrases do not match")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return password
|
||||||
|
}
|
||||||
|
|
||||||
|
type encryptedSeedStorage struct {
|
||||||
|
Description string `json:"description"`
|
||||||
|
Version int `json:"version"`
|
||||||
|
Params keystore.CryptoJSON `json:"params"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// encryptSeed uses a similar scheme as the keystore uses, but with a different wrapping,
|
||||||
|
// to encrypt the master seed
|
||||||
|
func encryptSeed(seed []byte, auth []byte, scryptN, scryptP int) ([]byte, error) {
|
||||||
|
cryptoStruct, err := keystore.EncryptDataV3(seed, auth, scryptN, scryptP)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return json.Marshal(&encryptedSeedStorage{"Clef seed", 1, cryptoStruct})
|
||||||
|
}
|
||||||
|
|
||||||
|
// decryptSeed decrypts the master seed
|
||||||
|
func decryptSeed(keyjson []byte, auth string) ([]byte, error) {
|
||||||
|
var encSeed encryptedSeedStorage
|
||||||
|
if err := json.Unmarshal(keyjson, &encSeed); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if encSeed.Version != 1 {
|
||||||
|
log.Warn(fmt.Sprintf("unsupported encryption format of seed: %d, operation will likely fail", encSeed.Version))
|
||||||
|
}
|
||||||
|
seed, err := keystore.DecryptDataV3(encSeed.Params, auth)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return seed, err
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
//Create Account
|
//Create Account
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 20 KiB |
@@ -31,43 +31,51 @@ NOTE: This file does not contain your accounts. Those need to be backed up separ
|
|||||||
|
|
||||||
## Creating rules
|
## Creating rules
|
||||||
|
|
||||||
Now, you can create a rule-file.
|
Now, you can create a rule-file. Note that it is not mandatory to use predefined rules, but it's really handy.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
function ApproveListing(){
|
function ApproveListing(){
|
||||||
return "Approve"
|
return "Approve"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
Get the `sha256` hash....
|
|
||||||
|
Get the `sha256` hash. If you have openssl, you can do `openssl sha256 rules.js`...
|
||||||
```text
|
```text
|
||||||
#sha256sum rules.js
|
#sha256sum rules.js
|
||||||
6c21d1737429d6d4f2e55146da0797782f3c0a0355227f19d702df377c165d72 rules.js
|
6c21d1737429d6d4f2e55146da0797782f3c0a0355227f19d702df377c165d72 rules.js
|
||||||
```
|
```
|
||||||
...And then `attest` the file:
|
...now `attest` the file...
|
||||||
```text
|
```text
|
||||||
#./signer attest 6c21d1737429d6d4f2e55146da0797782f3c0a0355227f19d702df377c165d72
|
#./signer attest 6c21d1737429d6d4f2e55146da0797782f3c0a0355227f19d702df377c165d72
|
||||||
|
|
||||||
INFO [02-21|12:14:38] Ruleset attestation updated sha256=6c21d1737429d6d4f2e55146da0797782f3c0a0355227f19d702df377c165d72
|
INFO [02-21|12:14:38] Ruleset attestation updated sha256=6c21d1737429d6d4f2e55146da0797782f3c0a0355227f19d702df377c165d72
|
||||||
```
|
```
|
||||||
At this point, we then start the signer with the rule-file:
|
|
||||||
|
|
||||||
|
...and (this is required only for non-production versions) load a mock-up `4byte.json` by copying the file from the source to your current working directory:
|
||||||
```text
|
```text
|
||||||
#./signer --rules rules.json
|
#cp $GOPATH/src/github.com/ethereum/go-ethereum/cmd/clef/4byte.json $PWD
|
||||||
|
```
|
||||||
|
|
||||||
INFO [02-21|12:15:18] Using CLI as UI-channel
|
At this point, we can start the signer with the rule-file:
|
||||||
INFO [02-21|12:15:18] Loaded 4byte db signatures=5509 file=./4byte.json
|
```text
|
||||||
INFO [02-21|12:15:18] Could not load rulefile, rules not enabled file=rulefile
|
#./signer --rules rules.js --rpc
|
||||||
DEBUG[02-21|12:15:18] FS scan times list=35.335µs set=5.536µs diff=5.073µs
|
|
||||||
DEBUG[02-21|12:15:18] Ledger support enabled
|
INFO [09-25|20:28:11.866] Using CLI as UI-channel
|
||||||
DEBUG[02-21|12:15:18] Trezor support enabled
|
INFO [09-25|20:28:11.876] Loaded 4byte db signatures=5509 file=./4byte.json
|
||||||
INFO [02-21|12:15:18] Audit logs configured file=audit.log
|
INFO [09-25|20:28:11.877] Rule engine configured file=./rules.js
|
||||||
INFO [02-21|12:15:18] HTTP endpoint opened url=http://localhost:8550
|
DEBUG[09-25|20:28:11.877] FS scan times list=100.781µs set=13.253µs diff=5.761µs
|
||||||
|
DEBUG[09-25|20:28:11.884] Ledger support enabled
|
||||||
|
DEBUG[09-25|20:28:11.888] Trezor support enabled
|
||||||
|
INFO [09-25|20:28:11.888] Audit logs configured file=audit.log
|
||||||
|
DEBUG[09-25|20:28:11.888] HTTP registered namespace=account
|
||||||
|
INFO [09-25|20:28:11.890] HTTP endpoint opened url=http://localhost:8550
|
||||||
|
DEBUG[09-25|20:28:11.890] IPC registered namespace=account
|
||||||
|
INFO [09-25|20:28:11.890] IPC endpoint opened url=<nil>
|
||||||
------- Signer info -------
|
------- Signer info -------
|
||||||
|
* extapi_version : 2.0.0
|
||||||
|
* intapi_version : 2.0.0
|
||||||
* extapi_http : http://localhost:8550
|
* extapi_http : http://localhost:8550
|
||||||
* extapi_ipc : <nil>
|
* extapi_ipc : <nil>
|
||||||
* extapi_version : 2.0.0
|
|
||||||
* intapi_version : 1.2.0
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Any list-requests will now be auto-approved by our rule-file.
|
Any list-requests will now be auto-approved by our rule-file.
|
||||||
@@ -107,16 +115,16 @@ The `master_seed` was then used to derive a few other things:
|
|||||||
|
|
||||||
## Adding credentials
|
## Adding credentials
|
||||||
|
|
||||||
In order to make more useful rules; sign transactions, the signer needs access to the passwords needed to unlock keystores.
|
In order to make more useful rules like signing transactions, the signer needs access to the passwords needed to unlock keystores.
|
||||||
|
|
||||||
```text
|
```text
|
||||||
#./signer addpw 0x694267f14675d7e1b9494fd8d72fefe1755710fa test
|
#./signer addpw "0x694267f14675d7e1b9494fd8d72fefe1755710fa" "test_password"
|
||||||
|
|
||||||
INFO [02-21|13:43:21] Credential store updated key=0x694267f14675d7e1b9494fd8d72fefe1755710fa
|
INFO [02-21|13:43:21] Credential store updated key=0x694267f14675d7e1b9494fd8d72fefe1755710fa
|
||||||
```
|
```
|
||||||
## More advanced rules
|
## More advanced rules
|
||||||
|
|
||||||
Now let's update the rules to make use of credentials
|
Now let's update the rules to make use of credentials:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
function ApproveListing(){
|
function ApproveListing(){
|
||||||
@@ -134,13 +142,15 @@ function ApproveSignData(r){
|
|||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
In this example,
|
In this example:
|
||||||
* any requests to sign data with the account `0x694...` will be
|
* Any requests to sign data with the account `0x694...` will be
|
||||||
* auto-approved if the message contains with `bazonk`,
|
* auto-approved if the message contains with `bazonk`
|
||||||
* and auto-rejected if it does not.
|
* auto-rejected if it does not.
|
||||||
* Any other signing-requests will be passed along for manual approve/reject.
|
* Any other signing-requests will be passed along for manual approve/reject.
|
||||||
|
|
||||||
..attest the new file
|
_Note: make sure that `0x694...` is an account you have access to. You can create it either via the clef or the traditional account cli tool. If the latter was chosen, make sure both clef and geth use the same keystore by specifing `--keystore path/to/your/keystore` when running clef._
|
||||||
|
|
||||||
|
Attest the new file...
|
||||||
```text
|
```text
|
||||||
#sha256sum rules.js
|
#sha256sum rules.js
|
||||||
2a0cb661dacfc804b6e95d935d813fd17c0997a7170e4092ffbc34ca976acd9f rules.js
|
2a0cb661dacfc804b6e95d935d813fd17c0997a7170e4092ffbc34ca976acd9f rules.js
|
||||||
@@ -153,23 +163,26 @@ INFO [02-21|14:36:30] Ruleset attestation updated sha256=2a0cb661da
|
|||||||
And start the signer:
|
And start the signer:
|
||||||
|
|
||||||
```
|
```
|
||||||
#./signer --rules rules.js
|
#./signer --rules rules.js --rpc
|
||||||
|
|
||||||
INFO [02-21|14:41:56] Using CLI as UI-channel
|
INFO [09-25|21:02:16.450] Using CLI as UI-channel
|
||||||
INFO [02-21|14:41:56] Loaded 4byte db signatures=5509 file=./4byte.json
|
INFO [09-25|21:02:16.466] Loaded 4byte db signatures=5509 file=./4byte.json
|
||||||
INFO [02-21|14:41:56] Rule engine configured file=rules.js
|
INFO [09-25|21:02:16.467] Rule engine configured file=./rules.js
|
||||||
DEBUG[02-21|14:41:56] FS scan times list=34.607µs set=4.509µs diff=4.87µs
|
DEBUG[09-25|21:02:16.468] FS scan times list=1.45262ms set=21.926µs diff=6.944µs
|
||||||
DEBUG[02-21|14:41:56] Ledger support enabled
|
DEBUG[09-25|21:02:16.473] Ledger support enabled
|
||||||
DEBUG[02-21|14:41:56] Trezor support enabled
|
DEBUG[09-25|21:02:16.475] Trezor support enabled
|
||||||
INFO [02-21|14:41:56] Audit logs configured file=audit.log
|
INFO [09-25|21:02:16.476] Audit logs configured file=audit.log
|
||||||
INFO [02-21|14:41:56] HTTP endpoint opened url=http://localhost:8550
|
DEBUG[09-25|21:02:16.476] HTTP registered namespace=account
|
||||||
|
INFO [09-25|21:02:16.478] HTTP endpoint opened url=http://localhost:8550
|
||||||
|
DEBUG[09-25|21:02:16.478] IPC registered namespace=account
|
||||||
|
INFO [09-25|21:02:16.478] IPC endpoint opened url=<nil>
|
||||||
------- Signer info -------
|
------- Signer info -------
|
||||||
* extapi_version : 2.0.0
|
* extapi_version : 2.0.0
|
||||||
* intapi_version : 1.2.0
|
* intapi_version : 2.0.0
|
||||||
* extapi_http : http://localhost:8550
|
* extapi_http : http://localhost:8550
|
||||||
* extapi_ipc : <nil>
|
* extapi_ipc : <nil>
|
||||||
INFO [02-21|14:41:56] error occurred during execution error="ReferenceError: 'OnSignerStartup' is not defined"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
And then test signing, once with `bazonk` and once without:
|
And then test signing, once with `bazonk` and once without:
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -190,9 +203,9 @@ INFO [02-21|14:42:56] Op rejected
|
|||||||
The signer also stores all traffic over the external API in a log file. The last 4 lines shows the two requests and their responses:
|
The signer also stores all traffic over the external API in a log file. The last 4 lines shows the two requests and their responses:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
#tail audit.log -n 4
|
#tail -n 4 audit.log
|
||||||
t=2018-02-21T14:42:41+0100 lvl=info msg=Sign api=signer type=request metadata="{\"remote\":\"127.0.0.1:49706\",\"local\":\"localhost:8550\",\"scheme\":\"HTTP/1.1\"}" addr="0x694267f14675d7e1b9494fd8d72fefe1755710fa [chksum INVALID]" data=202062617a6f6e6b2062617a2067617a0a
|
t=2018-02-21T14:42:41+0100 lvl=info msg=Sign api=signer type=request metadata="{\"remote\":\"127.0.0.1:49706\",\"local\":\"localhost:8550\",\"scheme\":\"HTTP/1.1\"}" addr="0x694267f14675d7e1b9494fd8d72fefe1755710fa [chksum INVALID]" data=202062617a6f6e6b2062617a2067617a0a
|
||||||
t=2018-02-21T14:42:42+0100 lvl=info msg=Sign api=signer type=response data=93e6161840c3ae1efc26dc68dedab6e8fc233bb3fefa1b4645dbf6609b93dace160572ea4ab33240256bb6d3dadb60dcd9c515d6374d3cf614ee897408d41d541c error=nil
|
t=2018-02-21T14:42:42+0100 lvl=info msg=Sign api=signer type=response data=93e6161840c3ae1efc26dc68dedab6e8fc233bb3fefa1b4645dbf6609b93dace160572ea4ab33240256bb6d3dadb60dcd9c515d6374d3cf614ee897408d41d541c error=nil
|
||||||
t=2018-02-21T14:42:56+0100 lvl=info msg=Sign api=signer type=request metadata="{\"remote\":\"127.0.0.1:49708\",\"local\":\"localhost:8550\",\"scheme\":\"HTTP/1.1\"}" addr="0x694267f14675d7e1b9494fd8d72fefe1755710fa [chksum INVALID]" data=2020626f6e6b2062617a2067617a0a
|
t=2018-02-21T14:42:56+0100 lvl=info msg=Sign api=signer type=request metadata="{\"remote\":\"127.0.0.1:49708\",\"local\":\"localhost:8550\",\"scheme\":\"HTTP/1.1\"}" addr="0x694267f14675d7e1b9494fd8d72fefe1755710fa [chksum INVALID]" data=2020626f6e6b2062617a2067617a0a
|
||||||
t=2018-02-21T14:42:56+0100 lvl=info msg=Sign api=signer type=response data= error="Request denied"
|
t=2018-02-21T14:42:56+0100 lvl=info msg=Sign api=signer type=response data= error="Request denied"
|
||||||
```
|
```
|
||||||
@@ -21,21 +21,33 @@ Private key information can be printed by using the `--private` flag;
|
|||||||
make sure to use this feature with great caution!
|
make sure to use this feature with great caution!
|
||||||
|
|
||||||
|
|
||||||
### `ethkey sign <keyfile> <message/file>`
|
### `ethkey signmessage <keyfile> <message/file>`
|
||||||
|
|
||||||
Sign the message with a keyfile.
|
Sign the message with a keyfile.
|
||||||
It is possible to refer to a file containing the message.
|
It is possible to refer to a file containing the message.
|
||||||
|
To sign a message contained in a file, use the `--msgfile` flag.
|
||||||
|
|
||||||
|
|
||||||
### `ethkey verify <address> <signature> <message/file>`
|
### `ethkey verifymessage <address> <signature> <message/file>`
|
||||||
|
|
||||||
Verify the signature of the message.
|
Verify the signature of the message.
|
||||||
It is possible to refer to a file containing the message.
|
It is possible to refer to a file containing the message.
|
||||||
|
To sign a message contained in a file, use the --msgfile flag.
|
||||||
|
|
||||||
|
|
||||||
|
### `ethkey changepassphrase <keyfile>`
|
||||||
|
|
||||||
|
Change the passphrase of a keyfile.
|
||||||
|
use the `--newpasswordfile` to point to the new password file.
|
||||||
|
|
||||||
|
|
||||||
## Passphrases
|
## Passphrases
|
||||||
|
|
||||||
For every command that uses a keyfile, you will be prompted to provide the
|
For every command that uses a keyfile, you will be prompted to provide the
|
||||||
passphrase for decrypting the keyfile. To avoid this message, it is possible
|
passphrase for decrypting the keyfile. To avoid this message, it is possible
|
||||||
to pass the passphrase by using the `--passphrase` flag pointing to a file that
|
to pass the passphrase by using the `--passwordfile` flag pointing to a file that
|
||||||
contains the passphrase.
|
contains the passphrase.
|
||||||
|
|
||||||
|
## JSON
|
||||||
|
|
||||||
|
In case you need to output the result in a JSON format, you shall by using the `--json` flag.
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ func disasmCmd(ctx *cli.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
code := strings.TrimSpace(string(in[:]))
|
code := strings.TrimSpace(string(in))
|
||||||
fmt.Printf("%v\n", code)
|
fmt.Printf("%v\n", code)
|
||||||
return asm.PrintDisassembled(code)
|
return asm.PrintDisassembled(code)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,16 +80,16 @@ func runCmd(ctx *cli.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
tracer vm.Tracer
|
tracer vm.Tracer
|
||||||
debugLogger *vm.StructLogger
|
debugLogger *vm.StructLogger
|
||||||
statedb *state.StateDB
|
statedb *state.StateDB
|
||||||
chainConfig *params.ChainConfig
|
chainConfig *params.ChainConfig
|
||||||
sender = common.BytesToAddress([]byte("sender"))
|
sender = common.BytesToAddress([]byte("sender"))
|
||||||
receiver = common.BytesToAddress([]byte("receiver"))
|
receiver = common.BytesToAddress([]byte("receiver"))
|
||||||
blockNumber uint64
|
genesisConfig *core.Genesis
|
||||||
)
|
)
|
||||||
if ctx.GlobalBool(MachineFlag.Name) {
|
if ctx.GlobalBool(MachineFlag.Name) {
|
||||||
tracer = NewJSONLogger(logconfig, os.Stdout)
|
tracer = vm.NewJSONLogger(logconfig, os.Stdout)
|
||||||
} else if ctx.GlobalBool(DebugFlag.Name) {
|
} else if ctx.GlobalBool(DebugFlag.Name) {
|
||||||
debugLogger = vm.NewStructLogger(logconfig)
|
debugLogger = vm.NewStructLogger(logconfig)
|
||||||
tracer = debugLogger
|
tracer = debugLogger
|
||||||
@@ -98,13 +98,14 @@ func runCmd(ctx *cli.Context) error {
|
|||||||
}
|
}
|
||||||
if ctx.GlobalString(GenesisFlag.Name) != "" {
|
if ctx.GlobalString(GenesisFlag.Name) != "" {
|
||||||
gen := readGenesis(ctx.GlobalString(GenesisFlag.Name))
|
gen := readGenesis(ctx.GlobalString(GenesisFlag.Name))
|
||||||
|
genesisConfig = gen
|
||||||
db := ethdb.NewMemDatabase()
|
db := ethdb.NewMemDatabase()
|
||||||
genesis := gen.ToBlock(db)
|
genesis := gen.ToBlock(db)
|
||||||
statedb, _ = state.New(genesis.Root(), state.NewDatabase(db))
|
statedb, _ = state.New(genesis.Root(), state.NewDatabase(db))
|
||||||
chainConfig = gen.Config
|
chainConfig = gen.Config
|
||||||
blockNumber = gen.Number
|
|
||||||
} else {
|
} else {
|
||||||
statedb, _ = state.New(common.Hash{}, state.NewDatabase(ethdb.NewMemDatabase()))
|
statedb, _ = state.New(common.Hash{}, state.NewDatabase(ethdb.NewMemDatabase()))
|
||||||
|
genesisConfig = new(core.Genesis)
|
||||||
}
|
}
|
||||||
if ctx.GlobalString(SenderFlag.Name) != "" {
|
if ctx.GlobalString(SenderFlag.Name) != "" {
|
||||||
sender = common.HexToAddress(ctx.GlobalString(SenderFlag.Name))
|
sender = common.HexToAddress(ctx.GlobalString(SenderFlag.Name))
|
||||||
@@ -156,13 +157,19 @@ func runCmd(ctx *cli.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
initialGas := ctx.GlobalUint64(GasFlag.Name)
|
initialGas := ctx.GlobalUint64(GasFlag.Name)
|
||||||
|
if genesisConfig.GasLimit != 0 {
|
||||||
|
initialGas = genesisConfig.GasLimit
|
||||||
|
}
|
||||||
runtimeConfig := runtime.Config{
|
runtimeConfig := runtime.Config{
|
||||||
Origin: sender,
|
Origin: sender,
|
||||||
State: statedb,
|
State: statedb,
|
||||||
GasLimit: initialGas,
|
GasLimit: initialGas,
|
||||||
GasPrice: utils.GlobalBig(ctx, PriceFlag.Name),
|
GasPrice: utils.GlobalBig(ctx, PriceFlag.Name),
|
||||||
Value: utils.GlobalBig(ctx, ValueFlag.Name),
|
Value: utils.GlobalBig(ctx, ValueFlag.Name),
|
||||||
BlockNumber: new(big.Int).SetUint64(blockNumber),
|
Difficulty: genesisConfig.Difficulty,
|
||||||
|
Time: new(big.Int).SetUint64(genesisConfig.Timestamp),
|
||||||
|
Coinbase: genesisConfig.Coinbase,
|
||||||
|
BlockNumber: new(big.Int).SetUint64(genesisConfig.Number),
|
||||||
EVMConfig: vm.Config{
|
EVMConfig: vm.Config{
|
||||||
Tracer: tracer,
|
Tracer: tracer,
|
||||||
Debug: ctx.GlobalBool(DebugFlag.Name) || ctx.GlobalBool(MachineFlag.Name),
|
Debug: ctx.GlobalBool(DebugFlag.Name) || ctx.GlobalBool(MachineFlag.Name),
|
||||||
@@ -199,6 +206,7 @@ func runCmd(ctx *cli.Context) error {
|
|||||||
execTime := time.Since(tstart)
|
execTime := time.Since(tstart)
|
||||||
|
|
||||||
if ctx.GlobalBool(DumpFlag.Name) {
|
if ctx.GlobalBool(DumpFlag.Name) {
|
||||||
|
statedb.Commit(true)
|
||||||
statedb.IntermediateRoot(true)
|
statedb.IntermediateRoot(true)
|
||||||
fmt.Println(string(statedb.Dump()))
|
fmt.Println(string(statedb.Dump()))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ func stateTestCmd(ctx *cli.Context) error {
|
|||||||
)
|
)
|
||||||
switch {
|
switch {
|
||||||
case ctx.GlobalBool(MachineFlag.Name):
|
case ctx.GlobalBool(MachineFlag.Name):
|
||||||
tracer = NewJSONLogger(config, os.Stderr)
|
tracer = vm.NewJSONLogger(config, os.Stderr)
|
||||||
|
|
||||||
case ctx.GlobalBool(DebugFlag.Name):
|
case ctx.GlobalBool(DebugFlag.Name):
|
||||||
debugger = vm.NewStructLogger(config)
|
debugger = vm.NewStructLogger(config)
|
||||||
@@ -97,6 +97,10 @@ func stateTestCmd(ctx *cli.Context) error {
|
|||||||
// Run the test and aggregate the result
|
// Run the test and aggregate the result
|
||||||
result := &StatetestResult{Name: key, Fork: st.Fork, Pass: true}
|
result := &StatetestResult{Name: key, Fork: st.Fork, Pass: true}
|
||||||
state, err := test.Run(st, cfg)
|
state, err := test.Run(st, cfg)
|
||||||
|
// print state root for evmlab tracing
|
||||||
|
if ctx.GlobalBool(MachineFlag.Name) && state != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "{\"stateRoot\": \"%x\"}\n", state.IntermediateRoot(false))
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Test failed, mark as so and dump any state to aid debugging
|
// Test failed, mark as so and dump any state to aid debugging
|
||||||
result.Pass, result.Error = false, err.Error()
|
result.Pass, result.Error = false, err.Error()
|
||||||
@@ -105,10 +109,6 @@ func stateTestCmd(ctx *cli.Context) error {
|
|||||||
result.State = &dump
|
result.State = &dump
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// print state root for evmlab tracing (already committed above, so no need to delete objects again
|
|
||||||
if ctx.GlobalBool(MachineFlag.Name) && state != nil {
|
|
||||||
fmt.Fprintf(os.Stderr, "{\"stateRoot\": \"%x\"}\n", state.IntermediateRoot(false))
|
|
||||||
}
|
|
||||||
|
|
||||||
results = append(results, *result)
|
results = append(results, *result)
|
||||||
|
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/node"
|
"github.com/ethereum/go-ethereum/node"
|
||||||
"github.com/ethereum/go-ethereum/p2p"
|
"github.com/ethereum/go-ethereum/p2p"
|
||||||
"github.com/ethereum/go-ethereum/p2p/discover"
|
|
||||||
"github.com/ethereum/go-ethereum/p2p/discv5"
|
"github.com/ethereum/go-ethereum/p2p/discv5"
|
||||||
|
"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/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"golang.org/x/net/websocket"
|
"golang.org/x/net/websocket"
|
||||||
@@ -77,9 +77,6 @@ var (
|
|||||||
accJSONFlag = flag.String("account.json", "", "Key json file to fund user requests with")
|
accJSONFlag = flag.String("account.json", "", "Key json file to fund user requests with")
|
||||||
accPassFlag = flag.String("account.pass", "", "Decryption password to access faucet funds")
|
accPassFlag = flag.String("account.pass", "", "Decryption password to access faucet funds")
|
||||||
|
|
||||||
githubUser = flag.String("github.user", "", "GitHub user to authenticate with for Gist access")
|
|
||||||
githubToken = flag.String("github.token", "", "GitHub personal token to access Gists with")
|
|
||||||
|
|
||||||
captchaToken = flag.String("captcha.token", "", "Recaptcha site key to authenticate client side")
|
captchaToken = flag.String("captcha.token", "", "Recaptcha site key to authenticate client side")
|
||||||
captchaSecret = flag.String("captcha.secret", "", "Recaptcha secret key to authenticate server side")
|
captchaSecret = flag.String("captcha.secret", "", "Recaptcha secret key to authenticate server side")
|
||||||
|
|
||||||
@@ -160,7 +157,8 @@ func main() {
|
|||||||
if blob, err = ioutil.ReadFile(*accPassFlag); err != nil {
|
if blob, err = ioutil.ReadFile(*accPassFlag); err != nil {
|
||||||
log.Crit("Failed to read account password contents", "file", *accPassFlag, "err", err)
|
log.Crit("Failed to read account password contents", "file", *accPassFlag, "err", err)
|
||||||
}
|
}
|
||||||
pass := string(blob)
|
// Delete trailing newline in password
|
||||||
|
pass := strings.TrimSuffix(string(blob), "\n")
|
||||||
|
|
||||||
ks := keystore.NewKeyStore(filepath.Join(os.Getenv("HOME"), ".faucet", "keys"), keystore.StandardScryptN, keystore.StandardScryptP)
|
ks := keystore.NewKeyStore(filepath.Join(os.Getenv("HOME"), ".faucet", "keys"), keystore.StandardScryptN, keystore.StandardScryptP)
|
||||||
if blob, err = ioutil.ReadFile(*accJSONFlag); err != nil {
|
if blob, err = ioutil.ReadFile(*accJSONFlag); err != nil {
|
||||||
@@ -201,6 +199,8 @@ type faucet struct {
|
|||||||
|
|
||||||
keystore *keystore.KeyStore // Keystore containing the single signer
|
keystore *keystore.KeyStore // Keystore containing the single signer
|
||||||
account accounts.Account // Account funding user faucet requests
|
account accounts.Account // Account funding user faucet requests
|
||||||
|
head *types.Header // Current head header of the faucet
|
||||||
|
balance *big.Int // Current balance of the faucet
|
||||||
nonce uint64 // Current pending nonce of the faucet
|
nonce uint64 // Current pending nonce of the faucet
|
||||||
price *big.Int // Current gas price to issue funds with
|
price *big.Int // Current gas price to issue funds with
|
||||||
|
|
||||||
@@ -216,7 +216,7 @@ func newFaucet(genesis *core.Genesis, port int, enodes []*discv5.Node, network u
|
|||||||
// Assemble the raw devp2p protocol stack
|
// Assemble the raw devp2p protocol stack
|
||||||
stack, err := node.New(&node.Config{
|
stack, err := node.New(&node.Config{
|
||||||
Name: "geth",
|
Name: "geth",
|
||||||
Version: params.Version,
|
Version: params.VersionWithMeta,
|
||||||
DataDir: filepath.Join(os.Getenv("HOME"), ".faucet"),
|
DataDir: filepath.Join(os.Getenv("HOME"), ".faucet"),
|
||||||
P2P: p2p.Config{
|
P2P: p2p.Config{
|
||||||
NAT: nat.Any(),
|
NAT: nat.Any(),
|
||||||
@@ -255,8 +255,10 @@ func newFaucet(genesis *core.Genesis, port int, enodes []*discv5.Node, network u
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, boot := range enodes {
|
for _, boot := range enodes {
|
||||||
old, _ := discover.ParseNode(boot.String())
|
old, err := enode.ParseV4(boot.String())
|
||||||
stack.Server().AddPeer(old)
|
if err == nil {
|
||||||
|
stack.Server().AddPeer(old)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Attach to the client and retrieve and interesting metadatas
|
// Attach to the client and retrieve and interesting metadatas
|
||||||
api, err := stack.Attach()
|
api, err := stack.Attach()
|
||||||
@@ -326,33 +328,30 @@ func (f *faucet) apiHandler(conn *websocket.Conn) {
|
|||||||
nonce uint64
|
nonce uint64
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
for {
|
for head == nil || balance == nil {
|
||||||
// Attempt to retrieve the stats, may error on no faucet connectivity
|
// Retrieve the current stats cached by the faucet
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
f.lock.RLock()
|
||||||
head, err = f.client.HeaderByNumber(ctx, nil)
|
if f.head != nil {
|
||||||
if err == nil {
|
head = types.CopyHeader(f.head)
|
||||||
balance, err = f.client.BalanceAt(ctx, f.account.Address, head.Number)
|
|
||||||
if err == nil {
|
|
||||||
nonce, err = f.client.NonceAt(ctx, f.account.Address, nil)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
cancel()
|
if f.balance != nil {
|
||||||
|
balance = new(big.Int).Set(f.balance)
|
||||||
|
}
|
||||||
|
nonce = f.nonce
|
||||||
|
f.lock.RUnlock()
|
||||||
|
|
||||||
// If stats retrieval failed, wait a bit and retry
|
if head == nil || balance == nil {
|
||||||
if err != nil {
|
// Report the faucet offline until initial stats are ready
|
||||||
if err = sendError(conn, errors.New("Faucet offline: "+err.Error())); err != nil {
|
if err = sendError(conn, errors.New("Faucet offline")); err != nil {
|
||||||
log.Warn("Failed to send faucet error to client", "err", err)
|
log.Warn("Failed to send faucet error to client", "err", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
time.Sleep(3 * time.Second)
|
time.Sleep(3 * time.Second)
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
// Initial stats reported successfully, proceed with user interaction
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
// Send over the initial stats and the latest header
|
// Send over the initial stats and the latest header
|
||||||
if err = send(conn, map[string]interface{}{
|
if err = send(conn, map[string]interface{}{
|
||||||
"funds": balance.Div(balance, ether),
|
"funds": new(big.Int).Div(balance, ether),
|
||||||
"funded": nonce,
|
"funded": nonce,
|
||||||
"peers": f.stack.Server().PeerCount(),
|
"peers": f.stack.Server().PeerCount(),
|
||||||
"requests": f.reqs,
|
"requests": f.reqs,
|
||||||
@@ -522,6 +521,47 @@ func (f *faucet) apiHandler(conn *websocket.Conn) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// refresh attempts to retrieve the latest header from the chain and extract the
|
||||||
|
// associated faucet balance and nonce for connectivity caching.
|
||||||
|
func (f *faucet) refresh(head *types.Header) error {
|
||||||
|
// Ensure a state update does not run for too long
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
// If no header was specified, use the current chain head
|
||||||
|
var err error
|
||||||
|
if head == nil {
|
||||||
|
if head, err = f.client.HeaderByNumber(ctx, nil); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Retrieve the balance, nonce and gas price from the current head
|
||||||
|
var (
|
||||||
|
balance *big.Int
|
||||||
|
nonce uint64
|
||||||
|
price *big.Int
|
||||||
|
)
|
||||||
|
if balance, err = f.client.BalanceAt(ctx, f.account.Address, head.Number); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if nonce, err = f.client.NonceAt(ctx, f.account.Address, head.Number); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if price, err = f.client.SuggestGasPrice(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Everything succeeded, update the cached stats and eject old requests
|
||||||
|
f.lock.Lock()
|
||||||
|
f.head, f.balance = head, balance
|
||||||
|
f.price, f.nonce = price, nonce
|
||||||
|
for len(f.reqs) > 0 && f.reqs[0].Tx.Nonce() < f.nonce {
|
||||||
|
f.reqs = f.reqs[1:]
|
||||||
|
}
|
||||||
|
f.lock.Unlock()
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// loop keeps waiting for interesting events and pushes them out to connected
|
// loop keeps waiting for interesting events and pushes them out to connected
|
||||||
// websockets.
|
// websockets.
|
||||||
func (f *faucet) loop() {
|
func (f *faucet) loop() {
|
||||||
@@ -539,45 +579,27 @@ func (f *faucet) loop() {
|
|||||||
go func() {
|
go func() {
|
||||||
for head := range update {
|
for head := range update {
|
||||||
// New chain head arrived, query the current stats and stream to clients
|
// New chain head arrived, query the current stats and stream to clients
|
||||||
var (
|
timestamp := time.Unix(head.Time.Int64(), 0)
|
||||||
balance *big.Int
|
if time.Since(timestamp) > time.Hour {
|
||||||
nonce uint64
|
log.Warn("Skipping faucet refresh, head too old", "number", head.Number, "hash", head.Hash(), "age", common.PrettyAge(timestamp))
|
||||||
price *big.Int
|
continue
|
||||||
err error
|
|
||||||
)
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
|
||||||
balance, err = f.client.BalanceAt(ctx, f.account.Address, head.Number)
|
|
||||||
if err == nil {
|
|
||||||
nonce, err = f.client.NonceAt(ctx, f.account.Address, nil)
|
|
||||||
if err == nil {
|
|
||||||
price, err = f.client.SuggestGasPrice(ctx)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
cancel()
|
if err := f.refresh(head); err != nil {
|
||||||
|
|
||||||
// If querying the data failed, try for the next block
|
|
||||||
if err != nil {
|
|
||||||
log.Warn("Failed to update faucet state", "block", head.Number, "hash", head.Hash(), "err", err)
|
log.Warn("Failed to update faucet state", "block", head.Number, "hash", head.Hash(), "err", err)
|
||||||
continue
|
continue
|
||||||
} else {
|
|
||||||
log.Info("Updated faucet state", "block", head.Number, "hash", head.Hash(), "balance", balance, "nonce", nonce, "price", price)
|
|
||||||
}
|
}
|
||||||
// Faucet state retrieved, update locally and send to clients
|
// Faucet state retrieved, update locally and send to clients
|
||||||
balance = new(big.Int).Div(balance, ether)
|
|
||||||
|
|
||||||
f.lock.Lock()
|
|
||||||
f.price, f.nonce = price, nonce
|
|
||||||
for len(f.reqs) > 0 && f.reqs[0].Tx.Nonce() < f.nonce {
|
|
||||||
f.reqs = f.reqs[1:]
|
|
||||||
}
|
|
||||||
f.lock.Unlock()
|
|
||||||
|
|
||||||
f.lock.RLock()
|
f.lock.RLock()
|
||||||
|
log.Info("Updated faucet state", "number", head.Number, "hash", head.Hash(), "age", common.PrettyAge(timestamp), "balance", f.balance, "nonce", f.nonce, "price", f.price)
|
||||||
|
|
||||||
|
balance := new(big.Int).Div(f.balance, ether)
|
||||||
|
peers := f.stack.Server().PeerCount()
|
||||||
|
|
||||||
for _, conn := range f.conns {
|
for _, conn := range f.conns {
|
||||||
if err := send(conn, map[string]interface{}{
|
if err := send(conn, map[string]interface{}{
|
||||||
"funds": balance,
|
"funds": balance,
|
||||||
"funded": f.nonce,
|
"funded": f.nonce,
|
||||||
"peers": f.stack.Server().PeerCount(),
|
"peers": peers,
|
||||||
"requests": f.reqs,
|
"requests": f.reqs,
|
||||||
}, time.Second); err != nil {
|
}, time.Second); err != nil {
|
||||||
log.Warn("Failed to send stats to client", "err", err)
|
log.Warn("Failed to send stats to client", "err", err)
|
||||||
@@ -638,59 +660,6 @@ func sendSuccess(conn *websocket.Conn, msg string) error {
|
|||||||
return send(conn, map[string]string{"success": msg}, time.Second)
|
return send(conn, map[string]string{"success": msg}, time.Second)
|
||||||
}
|
}
|
||||||
|
|
||||||
// authGitHub tries to authenticate a faucet request using GitHub gists, returning
|
|
||||||
// the username, avatar URL and Ethereum address to fund on success.
|
|
||||||
func authGitHub(url string) (string, string, common.Address, error) {
|
|
||||||
// Retrieve the gist from the GitHub Gist APIs
|
|
||||||
parts := strings.Split(url, "/")
|
|
||||||
req, _ := http.NewRequest("GET", "https://api.github.com/gists/"+parts[len(parts)-1], nil)
|
|
||||||
if *githubUser != "" {
|
|
||||||
req.SetBasicAuth(*githubUser, *githubToken)
|
|
||||||
}
|
|
||||||
res, err := http.DefaultClient.Do(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", "", common.Address{}, err
|
|
||||||
}
|
|
||||||
var gist struct {
|
|
||||||
Owner struct {
|
|
||||||
Login string `json:"login"`
|
|
||||||
} `json:"owner"`
|
|
||||||
Files map[string]struct {
|
|
||||||
Content string `json:"content"`
|
|
||||||
} `json:"files"`
|
|
||||||
}
|
|
||||||
err = json.NewDecoder(res.Body).Decode(&gist)
|
|
||||||
res.Body.Close()
|
|
||||||
if err != nil {
|
|
||||||
return "", "", common.Address{}, err
|
|
||||||
}
|
|
||||||
if gist.Owner.Login == "" {
|
|
||||||
return "", "", common.Address{}, errors.New("Anonymous Gists not allowed")
|
|
||||||
}
|
|
||||||
// Iterate over all the files and look for Ethereum addresses
|
|
||||||
var address common.Address
|
|
||||||
for _, file := range gist.Files {
|
|
||||||
content := strings.TrimSpace(file.Content)
|
|
||||||
if len(content) == 2+common.AddressLength*2 {
|
|
||||||
address = common.HexToAddress(content)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if address == (common.Address{}) {
|
|
||||||
return "", "", common.Address{}, errors.New("No Ethereum address found to fund")
|
|
||||||
}
|
|
||||||
// Validate the user's existence since the API is unhelpful here
|
|
||||||
if res, err = http.Head("https://github.com/" + gist.Owner.Login); err != nil {
|
|
||||||
return "", "", common.Address{}, err
|
|
||||||
}
|
|
||||||
res.Body.Close()
|
|
||||||
|
|
||||||
if res.StatusCode != 200 {
|
|
||||||
return "", "", common.Address{}, errors.New("Invalid user... boom!")
|
|
||||||
}
|
|
||||||
// Everything passed validation, return the gathered infos
|
|
||||||
return gist.Owner.Login + "@github", fmt.Sprintf("https://github.com/%s.png?size=64", gist.Owner.Login), address, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// authTwitter tries to authenticate a faucet request using Twitter posts, returning
|
// authTwitter tries to authenticate a faucet request using Twitter posts, returning
|
||||||
// the username, avatar URL and Ethereum address to fund on success.
|
// the username, avatar URL and Ethereum address to fund on success.
|
||||||
func authTwitter(url string) (string, string, common.Address, error) {
|
func authTwitter(url string) (string, string, common.Address, error) {
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ func reportBug(ctx *cli.Context) error {
|
|||||||
|
|
||||||
fmt.Fprintln(&buff, "#### System information")
|
fmt.Fprintln(&buff, "#### System information")
|
||||||
fmt.Fprintln(&buff)
|
fmt.Fprintln(&buff)
|
||||||
fmt.Fprintln(&buff, "Version:", params.Version)
|
fmt.Fprintln(&buff, "Version:", params.VersionWithMeta)
|
||||||
fmt.Fprintln(&buff, "Go Version:", runtime.Version())
|
fmt.Fprintln(&buff, "Go Version:", runtime.Version())
|
||||||
fmt.Fprintln(&buff, "OS:", runtime.GOOS)
|
fmt.Fprintln(&buff, "OS:", runtime.GOOS)
|
||||||
printOSDetails(&buff)
|
printOSDetails(&buff)
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ var (
|
|||||||
ArgsUsage: "<genesisPath>",
|
ArgsUsage: "<genesisPath>",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
utils.DataDirFlag,
|
utils.DataDirFlag,
|
||||||
utils.LightModeFlag,
|
|
||||||
},
|
},
|
||||||
Category: "BLOCKCHAIN COMMANDS",
|
Category: "BLOCKCHAIN COMMANDS",
|
||||||
Description: `
|
Description: `
|
||||||
@@ -66,7 +65,7 @@ It expects the genesis file as argument.`,
|
|||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
utils.DataDirFlag,
|
utils.DataDirFlag,
|
||||||
utils.CacheFlag,
|
utils.CacheFlag,
|
||||||
utils.LightModeFlag,
|
utils.SyncModeFlag,
|
||||||
utils.GCModeFlag,
|
utils.GCModeFlag,
|
||||||
utils.CacheDatabaseFlag,
|
utils.CacheDatabaseFlag,
|
||||||
utils.CacheGCFlag,
|
utils.CacheGCFlag,
|
||||||
@@ -87,14 +86,15 @@ processing will proceed even if an individual RLP-file import failure occurs.`,
|
|||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
utils.DataDirFlag,
|
utils.DataDirFlag,
|
||||||
utils.CacheFlag,
|
utils.CacheFlag,
|
||||||
utils.LightModeFlag,
|
utils.SyncModeFlag,
|
||||||
},
|
},
|
||||||
Category: "BLOCKCHAIN COMMANDS",
|
Category: "BLOCKCHAIN COMMANDS",
|
||||||
Description: `
|
Description: `
|
||||||
Requires a first argument of the file to write to.
|
Requires a first argument of the file to write to.
|
||||||
Optional second and third arguments control the first and
|
Optional second and third arguments control the first and
|
||||||
last block to write. In this mode, the file will be appended
|
last block to write. In this mode, the file will be appended
|
||||||
if already existing.`,
|
if already existing. If the file ends with .gz, the output will
|
||||||
|
be gzipped.`,
|
||||||
}
|
}
|
||||||
importPreimagesCommand = cli.Command{
|
importPreimagesCommand = cli.Command{
|
||||||
Action: utils.MigrateFlags(importPreimages),
|
Action: utils.MigrateFlags(importPreimages),
|
||||||
@@ -104,7 +104,7 @@ if already existing.`,
|
|||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
utils.DataDirFlag,
|
utils.DataDirFlag,
|
||||||
utils.CacheFlag,
|
utils.CacheFlag,
|
||||||
utils.LightModeFlag,
|
utils.SyncModeFlag,
|
||||||
},
|
},
|
||||||
Category: "BLOCKCHAIN COMMANDS",
|
Category: "BLOCKCHAIN COMMANDS",
|
||||||
Description: `
|
Description: `
|
||||||
@@ -118,7 +118,7 @@ if already existing.`,
|
|||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
utils.DataDirFlag,
|
utils.DataDirFlag,
|
||||||
utils.CacheFlag,
|
utils.CacheFlag,
|
||||||
utils.LightModeFlag,
|
utils.SyncModeFlag,
|
||||||
},
|
},
|
||||||
Category: "BLOCKCHAIN COMMANDS",
|
Category: "BLOCKCHAIN COMMANDS",
|
||||||
Description: `
|
Description: `
|
||||||
@@ -148,7 +148,6 @@ The first argument must be the directory containing the blockchain to download f
|
|||||||
ArgsUsage: " ",
|
ArgsUsage: " ",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
utils.DataDirFlag,
|
utils.DataDirFlag,
|
||||||
utils.LightModeFlag,
|
|
||||||
},
|
},
|
||||||
Category: "BLOCKCHAIN COMMANDS",
|
Category: "BLOCKCHAIN COMMANDS",
|
||||||
Description: `
|
Description: `
|
||||||
@@ -162,7 +161,7 @@ Remove blockchain and state databases`,
|
|||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
utils.DataDirFlag,
|
utils.DataDirFlag,
|
||||||
utils.CacheFlag,
|
utils.CacheFlag,
|
||||||
utils.LightModeFlag,
|
utils.SyncModeFlag,
|
||||||
},
|
},
|
||||||
Category: "BLOCKCHAIN COMMANDS",
|
Category: "BLOCKCHAIN COMMANDS",
|
||||||
Description: `
|
Description: `
|
||||||
@@ -341,9 +340,9 @@ func importPreimages(ctx *cli.Context) error {
|
|||||||
|
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
if err := utils.ImportPreimages(diskdb, ctx.Args().First()); err != nil {
|
if err := utils.ImportPreimages(diskdb, ctx.Args().First()); err != nil {
|
||||||
utils.Fatalf("Export error: %v\n", err)
|
utils.Fatalf("Import error: %v\n", err)
|
||||||
}
|
}
|
||||||
fmt.Printf("Export done in %v\n", time.Since(start))
|
fmt.Printf("Import done in %v\n", time.Since(start))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"unicode"
|
"unicode"
|
||||||
@@ -152,7 +153,9 @@ func enableWhisper(ctx *cli.Context) bool {
|
|||||||
|
|
||||||
func makeFullNode(ctx *cli.Context) *node.Node {
|
func makeFullNode(ctx *cli.Context) *node.Node {
|
||||||
stack, cfg := makeConfigNode(ctx)
|
stack, cfg := makeConfigNode(ctx)
|
||||||
|
if ctx.GlobalIsSet(utils.ConstantinopleOverrideFlag.Name) {
|
||||||
|
cfg.Eth.ConstantinopleOverride = new(big.Int).SetUint64(ctx.GlobalUint64(utils.ConstantinopleOverrideFlag.Name))
|
||||||
|
}
|
||||||
utils.RegisterEthService(stack, &cfg.Eth)
|
utils.RegisterEthService(stack, &cfg.Eth)
|
||||||
|
|
||||||
if ctx.GlobalBool(utils.DashboardEnabledFlag.Name) {
|
if ctx.GlobalBool(utils.DashboardEnabledFlag.Name) {
|
||||||
@@ -168,6 +171,9 @@ func makeFullNode(ctx *cli.Context) *node.Node {
|
|||||||
if ctx.GlobalIsSet(utils.WhisperMinPOWFlag.Name) {
|
if ctx.GlobalIsSet(utils.WhisperMinPOWFlag.Name) {
|
||||||
cfg.Shh.MinimumAcceptedPOW = ctx.Float64(utils.WhisperMinPOWFlag.Name)
|
cfg.Shh.MinimumAcceptedPOW = ctx.Float64(utils.WhisperMinPOWFlag.Name)
|
||||||
}
|
}
|
||||||
|
if ctx.GlobalIsSet(utils.WhisperRestrictConnectionBetweenLightClientsFlag.Name) {
|
||||||
|
cfg.Shh.RestrictConnectionBetweenLightClients = true
|
||||||
|
}
|
||||||
utils.RegisterShhService(stack, &cfg.Shh)
|
utils.RegisterShhService(stack, &cfg.Shh)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ipcAPIs = "admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 shh:1.0 txpool:1.0 web3:1.0"
|
ipcAPIs = "admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 shh:1.0 txpool:1.0 web3:1.0"
|
||||||
httpAPIs = "eth:1.0 net:1.0 rpc:1.0 web3:1.0"
|
httpAPIs = "eth:1.0 net:1.0 rpc:1.0 web3:1.0"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ func TestConsoleWelcome(t *testing.T) {
|
|||||||
geth.SetTemplateFunc("goos", func() string { return runtime.GOOS })
|
geth.SetTemplateFunc("goos", func() string { return runtime.GOOS })
|
||||||
geth.SetTemplateFunc("goarch", func() string { return runtime.GOARCH })
|
geth.SetTemplateFunc("goarch", func() string { return runtime.GOARCH })
|
||||||
geth.SetTemplateFunc("gover", runtime.Version)
|
geth.SetTemplateFunc("gover", runtime.Version)
|
||||||
geth.SetTemplateFunc("gethver", func() string { return params.Version })
|
geth.SetTemplateFunc("gethver", func() string { return params.VersionWithMeta })
|
||||||
geth.SetTemplateFunc("niltime", func() string { return time.Unix(0, 0).Format(time.RFC1123) })
|
geth.SetTemplateFunc("niltime", func() string { return time.Unix(0, 0).Format(time.RFC1123) })
|
||||||
geth.SetTemplateFunc("apis", func() string { return ipcAPIs })
|
geth.SetTemplateFunc("apis", func() string { return ipcAPIs })
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ func testAttachWelcome(t *testing.T, geth *testgeth, endpoint, apis string) {
|
|||||||
attach.SetTemplateFunc("goos", func() string { return runtime.GOOS })
|
attach.SetTemplateFunc("goos", func() string { return runtime.GOOS })
|
||||||
attach.SetTemplateFunc("goarch", func() string { return runtime.GOARCH })
|
attach.SetTemplateFunc("goarch", func() string { return runtime.GOARCH })
|
||||||
attach.SetTemplateFunc("gover", runtime.Version)
|
attach.SetTemplateFunc("gover", runtime.Version)
|
||||||
attach.SetTemplateFunc("gethver", func() string { return params.Version })
|
attach.SetTemplateFunc("gethver", func() string { return params.VersionWithMeta })
|
||||||
attach.SetTemplateFunc("etherbase", func() string { return geth.Etherbase })
|
attach.SetTemplateFunc("etherbase", func() string { return geth.Etherbase })
|
||||||
attach.SetTemplateFunc("niltime", func() string { return time.Unix(0, 0).Format(time.RFC1123) })
|
attach.SetTemplateFunc("niltime", func() string { return time.Unix(0, 0).Format(time.RFC1123) })
|
||||||
attach.SetTemplateFunc("ipc", func() bool { return strings.HasPrefix(endpoint, "ipc") })
|
attach.SetTemplateFunc("ipc", func() bool { return strings.HasPrefix(endpoint, "ipc") })
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ var customGenesisTests = []struct {
|
|||||||
"homesteadBlock" : 314,
|
"homesteadBlock" : 314,
|
||||||
"daoForkBlock" : 141,
|
"daoForkBlock" : 141,
|
||||||
"daoForkSupport" : true
|
"daoForkSupport" : true
|
||||||
},
|
}
|
||||||
}`,
|
}`,
|
||||||
query: "eth.getBlock(0).nonce",
|
query: "eth.getBlock(0).nonce",
|
||||||
result: "0x0000000000000042",
|
result: "0x0000000000000042",
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
|
||||||
godebug "runtime/debug"
|
godebug "runtime/debug"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -72,6 +71,7 @@ var (
|
|||||||
utils.EthashDatasetDirFlag,
|
utils.EthashDatasetDirFlag,
|
||||||
utils.EthashDatasetsInMemoryFlag,
|
utils.EthashDatasetsInMemoryFlag,
|
||||||
utils.EthashDatasetsOnDiskFlag,
|
utils.EthashDatasetsOnDiskFlag,
|
||||||
|
utils.TxPoolLocalsFlag,
|
||||||
utils.TxPoolNoLocalsFlag,
|
utils.TxPoolNoLocalsFlag,
|
||||||
utils.TxPoolJournalFlag,
|
utils.TxPoolJournalFlag,
|
||||||
utils.TxPoolRejournalFlag,
|
utils.TxPoolRejournalFlag,
|
||||||
@@ -82,25 +82,35 @@ var (
|
|||||||
utils.TxPoolAccountQueueFlag,
|
utils.TxPoolAccountQueueFlag,
|
||||||
utils.TxPoolGlobalQueueFlag,
|
utils.TxPoolGlobalQueueFlag,
|
||||||
utils.TxPoolLifetimeFlag,
|
utils.TxPoolLifetimeFlag,
|
||||||
utils.FastSyncFlag,
|
|
||||||
utils.LightModeFlag,
|
|
||||||
utils.SyncModeFlag,
|
utils.SyncModeFlag,
|
||||||
utils.GCModeFlag,
|
utils.GCModeFlag,
|
||||||
utils.LightServFlag,
|
utils.LightServFlag,
|
||||||
utils.LightPeersFlag,
|
utils.LightPeersFlag,
|
||||||
utils.LightKDFFlag,
|
utils.LightKDFFlag,
|
||||||
|
utils.WhitelistFlag,
|
||||||
utils.CacheFlag,
|
utils.CacheFlag,
|
||||||
utils.CacheDatabaseFlag,
|
utils.CacheDatabaseFlag,
|
||||||
|
utils.CacheTrieFlag,
|
||||||
utils.CacheGCFlag,
|
utils.CacheGCFlag,
|
||||||
utils.TrieCacheGenFlag,
|
utils.TrieCacheGenFlag,
|
||||||
utils.ListenPortFlag,
|
utils.ListenPortFlag,
|
||||||
utils.MaxPeersFlag,
|
utils.MaxPeersFlag,
|
||||||
utils.MaxPendingPeersFlag,
|
utils.MaxPendingPeersFlag,
|
||||||
utils.EtherbaseFlag,
|
|
||||||
utils.GasPriceFlag,
|
|
||||||
utils.MinerThreadsFlag,
|
|
||||||
utils.MiningEnabledFlag,
|
utils.MiningEnabledFlag,
|
||||||
utils.TargetGasLimitFlag,
|
utils.MinerThreadsFlag,
|
||||||
|
utils.MinerLegacyThreadsFlag,
|
||||||
|
utils.MinerNotifyFlag,
|
||||||
|
utils.MinerGasTargetFlag,
|
||||||
|
utils.MinerLegacyGasTargetFlag,
|
||||||
|
utils.MinerGasLimitFlag,
|
||||||
|
utils.MinerGasPriceFlag,
|
||||||
|
utils.MinerLegacyGasPriceFlag,
|
||||||
|
utils.MinerEtherbaseFlag,
|
||||||
|
utils.MinerLegacyEtherbaseFlag,
|
||||||
|
utils.MinerExtraDataFlag,
|
||||||
|
utils.MinerLegacyExtraDataFlag,
|
||||||
|
utils.MinerRecommitIntervalFlag,
|
||||||
|
utils.MinerNoVerfiyFlag,
|
||||||
utils.NATFlag,
|
utils.NATFlag,
|
||||||
utils.NoDiscoverFlag,
|
utils.NoDiscoverFlag,
|
||||||
utils.DiscoveryV5Flag,
|
utils.DiscoveryV5Flag,
|
||||||
@@ -113,6 +123,7 @@ var (
|
|||||||
utils.RinkebyFlag,
|
utils.RinkebyFlag,
|
||||||
utils.VMEnableDebugFlag,
|
utils.VMEnableDebugFlag,
|
||||||
utils.NetworkIdFlag,
|
utils.NetworkIdFlag,
|
||||||
|
utils.ConstantinopleOverrideFlag,
|
||||||
utils.RPCCORSDomainFlag,
|
utils.RPCCORSDomainFlag,
|
||||||
utils.RPCVirtualHostsFlag,
|
utils.RPCVirtualHostsFlag,
|
||||||
utils.EthStatsURLFlag,
|
utils.EthStatsURLFlag,
|
||||||
@@ -121,7 +132,8 @@ var (
|
|||||||
utils.NoCompactionFlag,
|
utils.NoCompactionFlag,
|
||||||
utils.GpoBlocksFlag,
|
utils.GpoBlocksFlag,
|
||||||
utils.GpoPercentileFlag,
|
utils.GpoPercentileFlag,
|
||||||
utils.ExtraDataFlag,
|
utils.EWASMInterpreterFlag,
|
||||||
|
utils.EVMInterpreterFlag,
|
||||||
configFileFlag,
|
configFileFlag,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,6 +155,16 @@ var (
|
|||||||
utils.WhisperEnabledFlag,
|
utils.WhisperEnabledFlag,
|
||||||
utils.WhisperMaxMessageSizeFlag,
|
utils.WhisperMaxMessageSizeFlag,
|
||||||
utils.WhisperMinPOWFlag,
|
utils.WhisperMinPOWFlag,
|
||||||
|
utils.WhisperRestrictConnectionBetweenLightClientsFlag,
|
||||||
|
}
|
||||||
|
|
||||||
|
metricsFlags = []cli.Flag{
|
||||||
|
utils.MetricsEnableInfluxDBFlag,
|
||||||
|
utils.MetricsInfluxDBEndpointFlag,
|
||||||
|
utils.MetricsInfluxDBDatabaseFlag,
|
||||||
|
utils.MetricsInfluxDBUsernameFlag,
|
||||||
|
utils.MetricsInfluxDBPasswordFlag,
|
||||||
|
utils.MetricsInfluxDBHostTagFlag,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -186,13 +208,17 @@ func init() {
|
|||||||
app.Flags = append(app.Flags, consoleFlags...)
|
app.Flags = append(app.Flags, consoleFlags...)
|
||||||
app.Flags = append(app.Flags, debug.Flags...)
|
app.Flags = append(app.Flags, debug.Flags...)
|
||||||
app.Flags = append(app.Flags, whisperFlags...)
|
app.Flags = append(app.Flags, whisperFlags...)
|
||||||
|
app.Flags = append(app.Flags, metricsFlags...)
|
||||||
|
|
||||||
app.Before = func(ctx *cli.Context) error {
|
app.Before = func(ctx *cli.Context) error {
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
logdir := ""
|
||||||
if err := debug.Setup(ctx); err != nil {
|
if ctx.GlobalBool(utils.DashboardEnabledFlag.Name) {
|
||||||
|
logdir = (&node.Config{DataDir: utils.MakeDataDir(ctx)}).ResolvePath("logs")
|
||||||
|
}
|
||||||
|
if err := debug.Setup(ctx, logdir); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Cap the cache allowance and tune the garbage colelctor
|
// Cap the cache allowance and tune the garbage collector
|
||||||
var mem gosigar.Mem
|
var mem gosigar.Mem
|
||||||
if err := mem.Get(); err == nil {
|
if err := mem.Get(); err == nil {
|
||||||
allowance := int(mem.Total / 1024 / 1024 / 3)
|
allowance := int(mem.Total / 1024 / 1024 / 3)
|
||||||
@@ -208,10 +234,12 @@ func init() {
|
|||||||
log.Debug("Sanitizing Go's GC trigger", "percent", int(gogc))
|
log.Debug("Sanitizing Go's GC trigger", "percent", int(gogc))
|
||||||
godebug.SetGCPercent(int(gogc))
|
godebug.SetGCPercent(int(gogc))
|
||||||
|
|
||||||
|
// Start metrics export if enabled
|
||||||
|
utils.SetupMetrics(ctx)
|
||||||
|
|
||||||
// Start system runtime metrics collection
|
// Start system runtime metrics collection
|
||||||
go metrics.CollectProcessMetrics(3 * time.Second)
|
go metrics.CollectProcessMetrics(3 * time.Second)
|
||||||
|
|
||||||
utils.SetupNetwork(ctx)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,6 +261,9 @@ func main() {
|
|||||||
// It creates a default node based on the command line arguments and runs it in
|
// It creates a default node based on the command line arguments and runs it in
|
||||||
// blocking mode, waiting for it to be shut down.
|
// blocking mode, waiting for it to be shut down.
|
||||||
func geth(ctx *cli.Context) error {
|
func geth(ctx *cli.Context) error {
|
||||||
|
if args := ctx.Args(); len(args) > 0 {
|
||||||
|
return fmt.Errorf("invalid command: %q", args[0])
|
||||||
|
}
|
||||||
node := makeFullNode(ctx)
|
node := makeFullNode(ctx)
|
||||||
startNode(ctx, node)
|
startNode(ctx, node)
|
||||||
node.Wait()
|
node.Wait()
|
||||||
@@ -287,11 +318,11 @@ func startNode(ctx *cli.Context, stack *node.Node) {
|
|||||||
status, _ := event.Wallet.Status()
|
status, _ := event.Wallet.Status()
|
||||||
log.Info("New wallet appeared", "url", event.Wallet.URL(), "status", status)
|
log.Info("New wallet appeared", "url", event.Wallet.URL(), "status", status)
|
||||||
|
|
||||||
|
derivationPath := accounts.DefaultBaseDerivationPath
|
||||||
if event.Wallet.URL().Scheme == "ledger" {
|
if event.Wallet.URL().Scheme == "ledger" {
|
||||||
event.Wallet.SelfDerive(accounts.DefaultLedgerBaseDerivationPath, stateReader)
|
derivationPath = accounts.DefaultLedgerBaseDerivationPath
|
||||||
} else {
|
|
||||||
event.Wallet.SelfDerive(accounts.DefaultBaseDerivationPath, stateReader)
|
|
||||||
}
|
}
|
||||||
|
event.Wallet.SelfDerive(derivationPath, stateReader)
|
||||||
|
|
||||||
case accounts.WalletDropped:
|
case accounts.WalletDropped:
|
||||||
log.Info("Old wallet dropped", "url", event.Wallet.URL())
|
log.Info("Old wallet dropped", "url", event.Wallet.URL())
|
||||||
@@ -302,25 +333,25 @@ func startNode(ctx *cli.Context, stack *node.Node) {
|
|||||||
// Start auxiliary services if enabled
|
// Start auxiliary services if enabled
|
||||||
if ctx.GlobalBool(utils.MiningEnabledFlag.Name) || ctx.GlobalBool(utils.DeveloperFlag.Name) {
|
if ctx.GlobalBool(utils.MiningEnabledFlag.Name) || ctx.GlobalBool(utils.DeveloperFlag.Name) {
|
||||||
// Mining only makes sense if a full Ethereum node is running
|
// Mining only makes sense if a full Ethereum node is running
|
||||||
if ctx.GlobalBool(utils.LightModeFlag.Name) || ctx.GlobalString(utils.SyncModeFlag.Name) == "light" {
|
if ctx.GlobalString(utils.SyncModeFlag.Name) == "light" {
|
||||||
utils.Fatalf("Light clients do not support mining")
|
utils.Fatalf("Light clients do not support mining")
|
||||||
}
|
}
|
||||||
var ethereum *eth.Ethereum
|
var ethereum *eth.Ethereum
|
||||||
if err := stack.Service(ðereum); err != nil {
|
if err := stack.Service(ðereum); err != nil {
|
||||||
utils.Fatalf("Ethereum service not running: %v", err)
|
utils.Fatalf("Ethereum service not running: %v", err)
|
||||||
}
|
}
|
||||||
// Use a reduced number of threads if requested
|
|
||||||
if threads := ctx.GlobalInt(utils.MinerThreadsFlag.Name); threads > 0 {
|
|
||||||
type threaded interface {
|
|
||||||
SetThreads(threads int)
|
|
||||||
}
|
|
||||||
if th, ok := ethereum.Engine().(threaded); ok {
|
|
||||||
th.SetThreads(threads)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Set the gas price to the limits from the CLI and start mining
|
// Set the gas price to the limits from the CLI and start mining
|
||||||
ethereum.TxPool().SetGasPrice(utils.GlobalBig(ctx, utils.GasPriceFlag.Name))
|
gasprice := utils.GlobalBig(ctx, utils.MinerLegacyGasPriceFlag.Name)
|
||||||
if err := ethereum.StartMining(true); err != nil {
|
if ctx.IsSet(utils.MinerGasPriceFlag.Name) {
|
||||||
|
gasprice = utils.GlobalBig(ctx, utils.MinerGasPriceFlag.Name)
|
||||||
|
}
|
||||||
|
ethereum.TxPool().SetGasPrice(gasprice)
|
||||||
|
|
||||||
|
threads := ctx.GlobalInt(utils.MinerLegacyThreadsFlag.Name)
|
||||||
|
if ctx.GlobalIsSet(utils.MinerThreadsFlag.Name) {
|
||||||
|
threads = ctx.GlobalInt(utils.MinerThreadsFlag.Name)
|
||||||
|
}
|
||||||
|
if err := ethereum.StartMining(threads); err != nil {
|
||||||
utils.Fatalf("Failed to start mining: %v", err)
|
utils.Fatalf("Failed to start mining: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ func makedag(ctx *cli.Context) error {
|
|||||||
|
|
||||||
func version(ctx *cli.Context) error {
|
func version(ctx *cli.Context) error {
|
||||||
fmt.Println(strings.Title(clientIdentifier))
|
fmt.Println(strings.Title(clientIdentifier))
|
||||||
fmt.Println("Version:", params.Version)
|
fmt.Println("Version:", params.VersionWithMeta)
|
||||||
if gitCommit != "" {
|
if gitCommit != "" {
|
||||||
fmt.Println("Git Commit:", gitCommit)
|
fmt.Println("Git Commit:", gitCommit)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -185,12 +185,12 @@ func resolveMetric(metrics map[string]interface{}, pattern string, path string)
|
|||||||
parts := strings.SplitN(pattern, "/", 2)
|
parts := strings.SplitN(pattern, "/", 2)
|
||||||
if len(parts) > 1 {
|
if len(parts) > 1 {
|
||||||
for _, variation := range strings.Split(parts[0], ",") {
|
for _, variation := range strings.Split(parts[0], ",") {
|
||||||
if submetrics, ok := metrics[variation].(map[string]interface{}); !ok {
|
submetrics, ok := metrics[variation].(map[string]interface{})
|
||||||
|
if !ok {
|
||||||
utils.Fatalf("Failed to retrieve system metrics: %s", path+variation)
|
utils.Fatalf("Failed to retrieve system metrics: %s", path+variation)
|
||||||
return nil
|
return nil
|
||||||
} else {
|
|
||||||
results = append(results, resolveMetric(submetrics, parts[1], path+variation+"/")...)
|
|
||||||
}
|
}
|
||||||
|
results = append(results, resolveMetric(submetrics, parts[1], path+variation+"/")...)
|
||||||
}
|
}
|
||||||
return results
|
return results
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,9 +81,11 @@ var AppHelpFlagGroups = []flagGroup{
|
|||||||
utils.LightServFlag,
|
utils.LightServFlag,
|
||||||
utils.LightPeersFlag,
|
utils.LightPeersFlag,
|
||||||
utils.LightKDFFlag,
|
utils.LightKDFFlag,
|
||||||
|
utils.WhitelistFlag,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{Name: "DEVELOPER CHAIN",
|
{
|
||||||
|
Name: "DEVELOPER CHAIN",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
utils.DeveloperFlag,
|
utils.DeveloperFlag,
|
||||||
utils.DeveloperPeriodFlag,
|
utils.DeveloperPeriodFlag,
|
||||||
@@ -113,6 +115,7 @@ var AppHelpFlagGroups = []flagGroup{
|
|||||||
{
|
{
|
||||||
Name: "TRANSACTION POOL",
|
Name: "TRANSACTION POOL",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
|
utils.TxPoolLocalsFlag,
|
||||||
utils.TxPoolNoLocalsFlag,
|
utils.TxPoolNoLocalsFlag,
|
||||||
utils.TxPoolJournalFlag,
|
utils.TxPoolJournalFlag,
|
||||||
utils.TxPoolRejournalFlag,
|
utils.TxPoolRejournalFlag,
|
||||||
@@ -130,6 +133,7 @@ var AppHelpFlagGroups = []flagGroup{
|
|||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
utils.CacheFlag,
|
utils.CacheFlag,
|
||||||
utils.CacheDatabaseFlag,
|
utils.CacheDatabaseFlag,
|
||||||
|
utils.CacheTrieFlag,
|
||||||
utils.CacheGCFlag,
|
utils.CacheGCFlag,
|
||||||
utils.TrieCacheGenFlag,
|
utils.TrieCacheGenFlag,
|
||||||
},
|
},
|
||||||
@@ -184,10 +188,14 @@ var AppHelpFlagGroups = []flagGroup{
|
|||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
utils.MiningEnabledFlag,
|
utils.MiningEnabledFlag,
|
||||||
utils.MinerThreadsFlag,
|
utils.MinerThreadsFlag,
|
||||||
utils.EtherbaseFlag,
|
utils.MinerNotifyFlag,
|
||||||
utils.TargetGasLimitFlag,
|
utils.MinerGasPriceFlag,
|
||||||
utils.GasPriceFlag,
|
utils.MinerGasTargetFlag,
|
||||||
utils.ExtraDataFlag,
|
utils.MinerGasLimitFlag,
|
||||||
|
utils.MinerEtherbaseFlag,
|
||||||
|
utils.MinerExtraDataFlag,
|
||||||
|
utils.MinerRecommitIntervalFlag,
|
||||||
|
utils.MinerNoVerfiyFlag,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -201,16 +209,29 @@ var AppHelpFlagGroups = []flagGroup{
|
|||||||
Name: "VIRTUAL MACHINE",
|
Name: "VIRTUAL MACHINE",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
utils.VMEnableDebugFlag,
|
utils.VMEnableDebugFlag,
|
||||||
|
utils.EVMInterpreterFlag,
|
||||||
|
utils.EWASMInterpreterFlag,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "LOGGING AND DEBUGGING",
|
Name: "LOGGING AND DEBUGGING",
|
||||||
Flags: append([]cli.Flag{
|
Flags: append([]cli.Flag{
|
||||||
utils.MetricsEnabledFlag,
|
|
||||||
utils.FakePoWFlag,
|
utils.FakePoWFlag,
|
||||||
utils.NoCompactionFlag,
|
utils.NoCompactionFlag,
|
||||||
}, debug.Flags...),
|
}, debug.Flags...),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "METRICS AND STATS",
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
utils.MetricsEnabledFlag,
|
||||||
|
utils.MetricsEnableInfluxDBFlag,
|
||||||
|
utils.MetricsInfluxDBEndpointFlag,
|
||||||
|
utils.MetricsInfluxDBDatabaseFlag,
|
||||||
|
utils.MetricsInfluxDBUsernameFlag,
|
||||||
|
utils.MetricsInfluxDBPasswordFlag,
|
||||||
|
utils.MetricsInfluxDBHostTagFlag,
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Name: "WHISPER (EXPERIMENTAL)",
|
Name: "WHISPER (EXPERIMENTAL)",
|
||||||
Flags: whisperFlags,
|
Flags: whisperFlags,
|
||||||
@@ -218,8 +239,11 @@ var AppHelpFlagGroups = []flagGroup{
|
|||||||
{
|
{
|
||||||
Name: "DEPRECATED",
|
Name: "DEPRECATED",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
utils.FastSyncFlag,
|
utils.MinerLegacyThreadsFlag,
|
||||||
utils.LightModeFlag,
|
utils.MinerLegacyGasTargetFlag,
|
||||||
|
utils.MinerLegacyGasPriceFlag,
|
||||||
|
utils.MinerLegacyEtherbaseFlag,
|
||||||
|
utils.MinerLegacyExtraDataFlag,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ import (
|
|||||||
|
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/p2p"
|
"github.com/ethereum/go-ethereum/p2p"
|
||||||
"github.com/ethereum/go-ethereum/p2p/discover"
|
"github.com/ethereum/go-ethereum/p2p/enode"
|
||||||
"github.com/ethereum/go-ethereum/p2p/simulations"
|
"github.com/ethereum/go-ethereum/p2p/simulations"
|
||||||
"github.com/ethereum/go-ethereum/p2p/simulations/adapters"
|
"github.com/ethereum/go-ethereum/p2p/simulations/adapters"
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
@@ -180,7 +180,10 @@ func main() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
app.Run(os.Args)
|
if err := app.Run(os.Args); err != nil {
|
||||||
|
fmt.Fprintln(os.Stderr, err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func showNetwork(ctx *cli.Context) error {
|
func showNetwork(ctx *cli.Context) error {
|
||||||
@@ -275,15 +278,14 @@ func createNode(ctx *cli.Context) error {
|
|||||||
if len(ctx.Args()) != 0 {
|
if len(ctx.Args()) != 0 {
|
||||||
return cli.ShowCommandHelp(ctx, ctx.Command.Name)
|
return cli.ShowCommandHelp(ctx, ctx.Command.Name)
|
||||||
}
|
}
|
||||||
config := &adapters.NodeConfig{
|
config := adapters.RandomNodeConfig()
|
||||||
Name: ctx.String("name"),
|
config.Name = ctx.String("name")
|
||||||
}
|
|
||||||
if key := ctx.String("key"); key != "" {
|
if key := ctx.String("key"); key != "" {
|
||||||
privKey, err := crypto.HexToECDSA(key)
|
privKey, err := crypto.HexToECDSA(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
config.ID = discover.PubkeyID(&privKey.PublicKey)
|
config.ID = enode.PubkeyToIDV4(&privKey.PublicKey)
|
||||||
config.PrivateKey = privKey
|
config.PrivateKey = privKey
|
||||||
}
|
}
|
||||||
if services := ctx.String("services"); services != "" {
|
if services := ctx.String("services"); services != "" {
|
||||||
|
|||||||
@@ -20,35 +20,41 @@ import (
|
|||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"errors"
|
"errors"
|
||||||
"math"
|
"math"
|
||||||
|
"math/big"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
|
math2 "github.com/ethereum/go-ethereum/common/math"
|
||||||
"github.com/ethereum/go-ethereum/consensus/ethash"
|
"github.com/ethereum/go-ethereum/consensus/ethash"
|
||||||
"github.com/ethereum/go-ethereum/core"
|
"github.com/ethereum/go-ethereum/core"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
// cppEthereumGenesisSpec represents the genesis specification format used by the
|
// alethGenesisSpec represents the genesis specification format used by the
|
||||||
// C++ Ethereum implementation.
|
// C++ Ethereum implementation.
|
||||||
type cppEthereumGenesisSpec struct {
|
type alethGenesisSpec struct {
|
||||||
SealEngine string `json:"sealEngine"`
|
SealEngine string `json:"sealEngine"`
|
||||||
Params struct {
|
Params struct {
|
||||||
AccountStartNonce hexutil.Uint64 `json:"accountStartNonce"`
|
AccountStartNonce math2.HexOrDecimal64 `json:"accountStartNonce"`
|
||||||
HomesteadForkBlock hexutil.Uint64 `json:"homesteadForkBlock"`
|
MaximumExtraDataSize hexutil.Uint64 `json:"maximumExtraDataSize"`
|
||||||
EIP150ForkBlock hexutil.Uint64 `json:"EIP150ForkBlock"`
|
HomesteadForkBlock hexutil.Uint64 `json:"homesteadForkBlock"`
|
||||||
EIP158ForkBlock hexutil.Uint64 `json:"EIP158ForkBlock"`
|
DaoHardforkBlock math2.HexOrDecimal64 `json:"daoHardforkBlock"`
|
||||||
ByzantiumForkBlock hexutil.Uint64 `json:"byzantiumForkBlock"`
|
EIP150ForkBlock hexutil.Uint64 `json:"EIP150ForkBlock"`
|
||||||
ConstantinopleForkBlock hexutil.Uint64 `json:"constantinopleForkBlock"`
|
EIP158ForkBlock hexutil.Uint64 `json:"EIP158ForkBlock"`
|
||||||
NetworkID hexutil.Uint64 `json:"networkID"`
|
ByzantiumForkBlock hexutil.Uint64 `json:"byzantiumForkBlock"`
|
||||||
ChainID hexutil.Uint64 `json:"chainID"`
|
ConstantinopleForkBlock hexutil.Uint64 `json:"constantinopleForkBlock"`
|
||||||
MaximumExtraDataSize hexutil.Uint64 `json:"maximumExtraDataSize"`
|
MinGasLimit hexutil.Uint64 `json:"minGasLimit"`
|
||||||
MinGasLimit hexutil.Uint64 `json:"minGasLimit"`
|
MaxGasLimit hexutil.Uint64 `json:"maxGasLimit"`
|
||||||
MaxGasLimit hexutil.Uint64 `json:"maxGasLimit"`
|
TieBreakingGas bool `json:"tieBreakingGas"`
|
||||||
GasLimitBoundDivisor hexutil.Uint64 `json:"gasLimitBoundDivisor"`
|
GasLimitBoundDivisor math2.HexOrDecimal64 `json:"gasLimitBoundDivisor"`
|
||||||
MinimumDifficulty *hexutil.Big `json:"minimumDifficulty"`
|
MinimumDifficulty *hexutil.Big `json:"minimumDifficulty"`
|
||||||
DifficultyBoundDivisor *hexutil.Big `json:"difficultyBoundDivisor"`
|
DifficultyBoundDivisor *math2.HexOrDecimal256 `json:"difficultyBoundDivisor"`
|
||||||
DurationLimit *hexutil.Big `json:"durationLimit"`
|
DurationLimit *math2.HexOrDecimal256 `json:"durationLimit"`
|
||||||
BlockReward *hexutil.Big `json:"blockReward"`
|
BlockReward *hexutil.Big `json:"blockReward"`
|
||||||
|
NetworkID hexutil.Uint64 `json:"networkID"`
|
||||||
|
ChainID hexutil.Uint64 `json:"chainID"`
|
||||||
|
AllowFutureBlocks bool `json:"allowFutureBlocks"`
|
||||||
} `json:"params"`
|
} `json:"params"`
|
||||||
|
|
||||||
Genesis struct {
|
Genesis struct {
|
||||||
@@ -62,57 +68,68 @@ type cppEthereumGenesisSpec struct {
|
|||||||
GasLimit hexutil.Uint64 `json:"gasLimit"`
|
GasLimit hexutil.Uint64 `json:"gasLimit"`
|
||||||
} `json:"genesis"`
|
} `json:"genesis"`
|
||||||
|
|
||||||
Accounts map[common.Address]*cppEthereumGenesisSpecAccount `json:"accounts"`
|
Accounts map[common.UnprefixedAddress]*alethGenesisSpecAccount `json:"accounts"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// cppEthereumGenesisSpecAccount is the prefunded genesis account and/or precompiled
|
// alethGenesisSpecAccount is the prefunded genesis account and/or precompiled
|
||||||
// contract definition.
|
// contract definition.
|
||||||
type cppEthereumGenesisSpecAccount struct {
|
type alethGenesisSpecAccount struct {
|
||||||
Balance *hexutil.Big `json:"balance"`
|
Balance *math2.HexOrDecimal256 `json:"balance"`
|
||||||
Nonce uint64 `json:"nonce,omitempty"`
|
Nonce uint64 `json:"nonce,omitempty"`
|
||||||
Precompiled *cppEthereumGenesisSpecBuiltin `json:"precompiled,omitempty"`
|
Precompiled *alethGenesisSpecBuiltin `json:"precompiled,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// cppEthereumGenesisSpecBuiltin is the precompiled contract definition.
|
// alethGenesisSpecBuiltin is the precompiled contract definition.
|
||||||
type cppEthereumGenesisSpecBuiltin struct {
|
type alethGenesisSpecBuiltin struct {
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
StartingBlock hexutil.Uint64 `json:"startingBlock,omitempty"`
|
StartingBlock hexutil.Uint64 `json:"startingBlock,omitempty"`
|
||||||
Linear *cppEthereumGenesisSpecLinearPricing `json:"linear,omitempty"`
|
Linear *alethGenesisSpecLinearPricing `json:"linear,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type cppEthereumGenesisSpecLinearPricing struct {
|
type alethGenesisSpecLinearPricing struct {
|
||||||
Base uint64 `json:"base"`
|
Base uint64 `json:"base"`
|
||||||
Word uint64 `json:"word"`
|
Word uint64 `json:"word"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// newCppEthereumGenesisSpec converts a go-ethereum genesis block into a Parity specific
|
// newAlethGenesisSpec converts a go-ethereum genesis block into a Aleth-specific
|
||||||
// chain specification format.
|
// chain specification format.
|
||||||
func newCppEthereumGenesisSpec(network string, genesis *core.Genesis) (*cppEthereumGenesisSpec, error) {
|
func newAlethGenesisSpec(network string, genesis *core.Genesis) (*alethGenesisSpec, error) {
|
||||||
// Only ethash is currently supported between go-ethereum and cpp-ethereum
|
// Only ethash is currently supported between go-ethereum and aleth
|
||||||
if genesis.Config.Ethash == nil {
|
if genesis.Config.Ethash == nil {
|
||||||
return nil, errors.New("unsupported consensus engine")
|
return nil, errors.New("unsupported consensus engine")
|
||||||
}
|
}
|
||||||
// Reconstruct the chain spec in Parity's format
|
// Reconstruct the chain spec in Aleth format
|
||||||
spec := &cppEthereumGenesisSpec{
|
spec := &alethGenesisSpec{
|
||||||
SealEngine: "Ethash",
|
SealEngine: "Ethash",
|
||||||
}
|
}
|
||||||
|
// Some defaults
|
||||||
spec.Params.AccountStartNonce = 0
|
spec.Params.AccountStartNonce = 0
|
||||||
|
spec.Params.TieBreakingGas = false
|
||||||
|
spec.Params.AllowFutureBlocks = false
|
||||||
|
spec.Params.DaoHardforkBlock = 0
|
||||||
|
|
||||||
spec.Params.HomesteadForkBlock = (hexutil.Uint64)(genesis.Config.HomesteadBlock.Uint64())
|
spec.Params.HomesteadForkBlock = (hexutil.Uint64)(genesis.Config.HomesteadBlock.Uint64())
|
||||||
spec.Params.EIP150ForkBlock = (hexutil.Uint64)(genesis.Config.EIP150Block.Uint64())
|
spec.Params.EIP150ForkBlock = (hexutil.Uint64)(genesis.Config.EIP150Block.Uint64())
|
||||||
spec.Params.EIP158ForkBlock = (hexutil.Uint64)(genesis.Config.EIP158Block.Uint64())
|
spec.Params.EIP158ForkBlock = (hexutil.Uint64)(genesis.Config.EIP158Block.Uint64())
|
||||||
spec.Params.ByzantiumForkBlock = (hexutil.Uint64)(genesis.Config.ByzantiumBlock.Uint64())
|
|
||||||
spec.Params.ConstantinopleForkBlock = (hexutil.Uint64)(math.MaxUint64)
|
// Byzantium
|
||||||
|
if num := genesis.Config.ByzantiumBlock; num != nil {
|
||||||
|
spec.setByzantium(num)
|
||||||
|
}
|
||||||
|
// Constantinople
|
||||||
|
if num := genesis.Config.ConstantinopleBlock; num != nil {
|
||||||
|
spec.setConstantinople(num)
|
||||||
|
}
|
||||||
|
|
||||||
spec.Params.NetworkID = (hexutil.Uint64)(genesis.Config.ChainID.Uint64())
|
spec.Params.NetworkID = (hexutil.Uint64)(genesis.Config.ChainID.Uint64())
|
||||||
spec.Params.ChainID = (hexutil.Uint64)(genesis.Config.ChainID.Uint64())
|
spec.Params.ChainID = (hexutil.Uint64)(genesis.Config.ChainID.Uint64())
|
||||||
|
|
||||||
spec.Params.MaximumExtraDataSize = (hexutil.Uint64)(params.MaximumExtraDataSize)
|
spec.Params.MaximumExtraDataSize = (hexutil.Uint64)(params.MaximumExtraDataSize)
|
||||||
spec.Params.MinGasLimit = (hexutil.Uint64)(params.MinGasLimit)
|
spec.Params.MinGasLimit = (hexutil.Uint64)(params.MinGasLimit)
|
||||||
spec.Params.MaxGasLimit = (hexutil.Uint64)(math.MaxUint64)
|
spec.Params.MaxGasLimit = (hexutil.Uint64)(math.MaxInt64)
|
||||||
spec.Params.MinimumDifficulty = (*hexutil.Big)(params.MinimumDifficulty)
|
spec.Params.MinimumDifficulty = (*hexutil.Big)(params.MinimumDifficulty)
|
||||||
spec.Params.DifficultyBoundDivisor = (*hexutil.Big)(params.DifficultyBoundDivisor)
|
spec.Params.DifficultyBoundDivisor = (*math2.HexOrDecimal256)(params.DifficultyBoundDivisor)
|
||||||
spec.Params.GasLimitBoundDivisor = (hexutil.Uint64)(params.GasLimitBoundDivisor)
|
spec.Params.GasLimitBoundDivisor = (math2.HexOrDecimal64)(params.GasLimitBoundDivisor)
|
||||||
spec.Params.DurationLimit = (*hexutil.Big)(params.DurationLimit)
|
spec.Params.DurationLimit = (*math2.HexOrDecimal256)(params.DurationLimit)
|
||||||
spec.Params.BlockReward = (*hexutil.Big)(ethash.FrontierBlockReward)
|
spec.Params.BlockReward = (*hexutil.Big)(ethash.FrontierBlockReward)
|
||||||
|
|
||||||
spec.Genesis.Nonce = (hexutil.Bytes)(make([]byte, 8))
|
spec.Genesis.Nonce = (hexutil.Bytes)(make([]byte, 8))
|
||||||
@@ -126,77 +143,104 @@ func newCppEthereumGenesisSpec(network string, genesis *core.Genesis) (*cppEther
|
|||||||
spec.Genesis.ExtraData = (hexutil.Bytes)(genesis.ExtraData)
|
spec.Genesis.ExtraData = (hexutil.Bytes)(genesis.ExtraData)
|
||||||
spec.Genesis.GasLimit = (hexutil.Uint64)(genesis.GasLimit)
|
spec.Genesis.GasLimit = (hexutil.Uint64)(genesis.GasLimit)
|
||||||
|
|
||||||
spec.Accounts = make(map[common.Address]*cppEthereumGenesisSpecAccount)
|
|
||||||
for address, account := range genesis.Alloc {
|
for address, account := range genesis.Alloc {
|
||||||
spec.Accounts[address] = &cppEthereumGenesisSpecAccount{
|
spec.setAccount(address, account)
|
||||||
Balance: (*hexutil.Big)(account.Balance),
|
|
||||||
Nonce: account.Nonce,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
spec.Accounts[common.BytesToAddress([]byte{1})].Precompiled = &cppEthereumGenesisSpecBuiltin{
|
|
||||||
Name: "ecrecover", Linear: &cppEthereumGenesisSpecLinearPricing{Base: 3000},
|
|
||||||
}
|
|
||||||
spec.Accounts[common.BytesToAddress([]byte{2})].Precompiled = &cppEthereumGenesisSpecBuiltin{
|
|
||||||
Name: "sha256", Linear: &cppEthereumGenesisSpecLinearPricing{Base: 60, Word: 12},
|
|
||||||
}
|
|
||||||
spec.Accounts[common.BytesToAddress([]byte{3})].Precompiled = &cppEthereumGenesisSpecBuiltin{
|
|
||||||
Name: "ripemd160", Linear: &cppEthereumGenesisSpecLinearPricing{Base: 600, Word: 120},
|
|
||||||
}
|
|
||||||
spec.Accounts[common.BytesToAddress([]byte{4})].Precompiled = &cppEthereumGenesisSpecBuiltin{
|
|
||||||
Name: "identity", Linear: &cppEthereumGenesisSpecLinearPricing{Base: 15, Word: 3},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spec.setPrecompile(1, &alethGenesisSpecBuiltin{Name: "ecrecover",
|
||||||
|
Linear: &alethGenesisSpecLinearPricing{Base: 3000}})
|
||||||
|
spec.setPrecompile(2, &alethGenesisSpecBuiltin{Name: "sha256",
|
||||||
|
Linear: &alethGenesisSpecLinearPricing{Base: 60, Word: 12}})
|
||||||
|
spec.setPrecompile(3, &alethGenesisSpecBuiltin{Name: "ripemd160",
|
||||||
|
Linear: &alethGenesisSpecLinearPricing{Base: 600, Word: 120}})
|
||||||
|
spec.setPrecompile(4, &alethGenesisSpecBuiltin{Name: "identity",
|
||||||
|
Linear: &alethGenesisSpecLinearPricing{Base: 15, Word: 3}})
|
||||||
if genesis.Config.ByzantiumBlock != nil {
|
if genesis.Config.ByzantiumBlock != nil {
|
||||||
spec.Accounts[common.BytesToAddress([]byte{5})].Precompiled = &cppEthereumGenesisSpecBuiltin{
|
spec.setPrecompile(5, &alethGenesisSpecBuiltin{Name: "modexp",
|
||||||
Name: "modexp", StartingBlock: (hexutil.Uint64)(genesis.Config.ByzantiumBlock.Uint64()),
|
StartingBlock: (hexutil.Uint64)(genesis.Config.ByzantiumBlock.Uint64())})
|
||||||
}
|
spec.setPrecompile(6, &alethGenesisSpecBuiltin{Name: "alt_bn128_G1_add",
|
||||||
spec.Accounts[common.BytesToAddress([]byte{6})].Precompiled = &cppEthereumGenesisSpecBuiltin{
|
StartingBlock: (hexutil.Uint64)(genesis.Config.ByzantiumBlock.Uint64()),
|
||||||
Name: "alt_bn128_G1_add", StartingBlock: (hexutil.Uint64)(genesis.Config.ByzantiumBlock.Uint64()), Linear: &cppEthereumGenesisSpecLinearPricing{Base: 500},
|
Linear: &alethGenesisSpecLinearPricing{Base: 500}})
|
||||||
}
|
spec.setPrecompile(7, &alethGenesisSpecBuiltin{Name: "alt_bn128_G1_mul",
|
||||||
spec.Accounts[common.BytesToAddress([]byte{7})].Precompiled = &cppEthereumGenesisSpecBuiltin{
|
StartingBlock: (hexutil.Uint64)(genesis.Config.ByzantiumBlock.Uint64()),
|
||||||
Name: "alt_bn128_G1_mul", StartingBlock: (hexutil.Uint64)(genesis.Config.ByzantiumBlock.Uint64()), Linear: &cppEthereumGenesisSpecLinearPricing{Base: 40000},
|
Linear: &alethGenesisSpecLinearPricing{Base: 40000}})
|
||||||
}
|
spec.setPrecompile(8, &alethGenesisSpecBuiltin{Name: "alt_bn128_pairing_product",
|
||||||
spec.Accounts[common.BytesToAddress([]byte{8})].Precompiled = &cppEthereumGenesisSpecBuiltin{
|
StartingBlock: (hexutil.Uint64)(genesis.Config.ByzantiumBlock.Uint64())})
|
||||||
Name: "alt_bn128_pairing_product", StartingBlock: (hexutil.Uint64)(genesis.Config.ByzantiumBlock.Uint64()),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return spec, nil
|
return spec, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (spec *alethGenesisSpec) setPrecompile(address byte, data *alethGenesisSpecBuiltin) {
|
||||||
|
if spec.Accounts == nil {
|
||||||
|
spec.Accounts = make(map[common.UnprefixedAddress]*alethGenesisSpecAccount)
|
||||||
|
}
|
||||||
|
spec.Accounts[common.UnprefixedAddress(common.BytesToAddress([]byte{address}))].Precompiled = data
|
||||||
|
}
|
||||||
|
|
||||||
|
func (spec *alethGenesisSpec) setAccount(address common.Address, account core.GenesisAccount) {
|
||||||
|
if spec.Accounts == nil {
|
||||||
|
spec.Accounts = make(map[common.UnprefixedAddress]*alethGenesisSpecAccount)
|
||||||
|
}
|
||||||
|
|
||||||
|
a, exist := spec.Accounts[common.UnprefixedAddress(address)]
|
||||||
|
if !exist {
|
||||||
|
a = &alethGenesisSpecAccount{}
|
||||||
|
spec.Accounts[common.UnprefixedAddress(address)] = a
|
||||||
|
}
|
||||||
|
a.Balance = (*math2.HexOrDecimal256)(account.Balance)
|
||||||
|
a.Nonce = account.Nonce
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (spec *alethGenesisSpec) setByzantium(num *big.Int) {
|
||||||
|
spec.Params.ByzantiumForkBlock = hexutil.Uint64(num.Uint64())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (spec *alethGenesisSpec) setConstantinople(num *big.Int) {
|
||||||
|
spec.Params.ConstantinopleForkBlock = hexutil.Uint64(num.Uint64())
|
||||||
|
}
|
||||||
|
|
||||||
// parityChainSpec is the chain specification format used by Parity.
|
// parityChainSpec is the chain specification format used by Parity.
|
||||||
type parityChainSpec struct {
|
type parityChainSpec struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Engine struct {
|
Datadir string `json:"dataDir"`
|
||||||
|
Engine struct {
|
||||||
Ethash struct {
|
Ethash struct {
|
||||||
Params struct {
|
Params struct {
|
||||||
MinimumDifficulty *hexutil.Big `json:"minimumDifficulty"`
|
MinimumDifficulty *hexutil.Big `json:"minimumDifficulty"`
|
||||||
DifficultyBoundDivisor *hexutil.Big `json:"difficultyBoundDivisor"`
|
DifficultyBoundDivisor *hexutil.Big `json:"difficultyBoundDivisor"`
|
||||||
DurationLimit *hexutil.Big `json:"durationLimit"`
|
DurationLimit *hexutil.Big `json:"durationLimit"`
|
||||||
BlockReward *hexutil.Big `json:"blockReward"`
|
BlockReward map[string]string `json:"blockReward"`
|
||||||
HomesteadTransition uint64 `json:"homesteadTransition"`
|
DifficultyBombDelays map[string]string `json:"difficultyBombDelays"`
|
||||||
EIP150Transition uint64 `json:"eip150Transition"`
|
HomesteadTransition hexutil.Uint64 `json:"homesteadTransition"`
|
||||||
EIP160Transition uint64 `json:"eip160Transition"`
|
EIP100bTransition hexutil.Uint64 `json:"eip100bTransition"`
|
||||||
EIP161abcTransition uint64 `json:"eip161abcTransition"`
|
|
||||||
EIP161dTransition uint64 `json:"eip161dTransition"`
|
|
||||||
EIP649Reward *hexutil.Big `json:"eip649Reward"`
|
|
||||||
EIP100bTransition uint64 `json:"eip100bTransition"`
|
|
||||||
EIP649Transition uint64 `json:"eip649Transition"`
|
|
||||||
} `json:"params"`
|
} `json:"params"`
|
||||||
} `json:"Ethash"`
|
} `json:"Ethash"`
|
||||||
} `json:"engine"`
|
} `json:"engine"`
|
||||||
|
|
||||||
Params struct {
|
Params struct {
|
||||||
MaximumExtraDataSize hexutil.Uint64 `json:"maximumExtraDataSize"`
|
AccountStartNonce hexutil.Uint64 `json:"accountStartNonce"`
|
||||||
MinGasLimit hexutil.Uint64 `json:"minGasLimit"`
|
MaximumExtraDataSize hexutil.Uint64 `json:"maximumExtraDataSize"`
|
||||||
GasLimitBoundDivisor hexutil.Uint64 `json:"gasLimitBoundDivisor"`
|
MinGasLimit hexutil.Uint64 `json:"minGasLimit"`
|
||||||
NetworkID hexutil.Uint64 `json:"networkID"`
|
GasLimitBoundDivisor math2.HexOrDecimal64 `json:"gasLimitBoundDivisor"`
|
||||||
MaxCodeSize uint64 `json:"maxCodeSize"`
|
NetworkID hexutil.Uint64 `json:"networkID"`
|
||||||
EIP155Transition uint64 `json:"eip155Transition"`
|
ChainID hexutil.Uint64 `json:"chainID"`
|
||||||
EIP98Transition uint64 `json:"eip98Transition"`
|
MaxCodeSize hexutil.Uint64 `json:"maxCodeSize"`
|
||||||
EIP86Transition uint64 `json:"eip86Transition"`
|
MaxCodeSizeTransition hexutil.Uint64 `json:"maxCodeSizeTransition"`
|
||||||
EIP140Transition uint64 `json:"eip140Transition"`
|
EIP98Transition hexutil.Uint64 `json:"eip98Transition"`
|
||||||
EIP211Transition uint64 `json:"eip211Transition"`
|
EIP150Transition hexutil.Uint64 `json:"eip150Transition"`
|
||||||
EIP214Transition uint64 `json:"eip214Transition"`
|
EIP160Transition hexutil.Uint64 `json:"eip160Transition"`
|
||||||
EIP658Transition uint64 `json:"eip658Transition"`
|
EIP161abcTransition hexutil.Uint64 `json:"eip161abcTransition"`
|
||||||
|
EIP161dTransition hexutil.Uint64 `json:"eip161dTransition"`
|
||||||
|
EIP155Transition hexutil.Uint64 `json:"eip155Transition"`
|
||||||
|
EIP140Transition hexutil.Uint64 `json:"eip140Transition"`
|
||||||
|
EIP211Transition hexutil.Uint64 `json:"eip211Transition"`
|
||||||
|
EIP214Transition hexutil.Uint64 `json:"eip214Transition"`
|
||||||
|
EIP658Transition hexutil.Uint64 `json:"eip658Transition"`
|
||||||
|
EIP145Transition hexutil.Uint64 `json:"eip145Transition"`
|
||||||
|
EIP1014Transition hexutil.Uint64 `json:"eip1014Transition"`
|
||||||
|
EIP1052Transition hexutil.Uint64 `json:"eip1052Transition"`
|
||||||
|
EIP1283Transition hexutil.Uint64 `json:"eip1283Transition"`
|
||||||
} `json:"params"`
|
} `json:"params"`
|
||||||
|
|
||||||
Genesis struct {
|
Genesis struct {
|
||||||
@@ -215,22 +259,22 @@ type parityChainSpec struct {
|
|||||||
GasLimit hexutil.Uint64 `json:"gasLimit"`
|
GasLimit hexutil.Uint64 `json:"gasLimit"`
|
||||||
} `json:"genesis"`
|
} `json:"genesis"`
|
||||||
|
|
||||||
Nodes []string `json:"nodes"`
|
Nodes []string `json:"nodes"`
|
||||||
Accounts map[common.Address]*parityChainSpecAccount `json:"accounts"`
|
Accounts map[common.UnprefixedAddress]*parityChainSpecAccount `json:"accounts"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// parityChainSpecAccount is the prefunded genesis account and/or precompiled
|
// parityChainSpecAccount is the prefunded genesis account and/or precompiled
|
||||||
// contract definition.
|
// contract definition.
|
||||||
type parityChainSpecAccount struct {
|
type parityChainSpecAccount struct {
|
||||||
Balance *hexutil.Big `json:"balance"`
|
Balance math2.HexOrDecimal256 `json:"balance"`
|
||||||
Nonce uint64 `json:"nonce,omitempty"`
|
Nonce math2.HexOrDecimal64 `json:"nonce,omitempty"`
|
||||||
Builtin *parityChainSpecBuiltin `json:"builtin,omitempty"`
|
Builtin *parityChainSpecBuiltin `json:"builtin,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// parityChainSpecBuiltin is the precompiled contract definition.
|
// parityChainSpecBuiltin is the precompiled contract definition.
|
||||||
type parityChainSpecBuiltin struct {
|
type parityChainSpecBuiltin struct {
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
ActivateAt uint64 `json:"activate_at,omitempty"`
|
ActivateAt math2.HexOrDecimal64 `json:"activate_at,omitempty"`
|
||||||
Pricing *parityChainSpecPricing `json:"pricing,omitempty"`
|
Pricing *parityChainSpecPricing `json:"pricing,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,34 +309,51 @@ func newParityChainSpec(network string, genesis *core.Genesis, bootnodes []strin
|
|||||||
}
|
}
|
||||||
// Reconstruct the chain spec in Parity's format
|
// Reconstruct the chain spec in Parity's format
|
||||||
spec := &parityChainSpec{
|
spec := &parityChainSpec{
|
||||||
Name: network,
|
Name: network,
|
||||||
Nodes: bootnodes,
|
Nodes: bootnodes,
|
||||||
|
Datadir: strings.ToLower(network),
|
||||||
}
|
}
|
||||||
|
spec.Engine.Ethash.Params.BlockReward = make(map[string]string)
|
||||||
|
spec.Engine.Ethash.Params.DifficultyBombDelays = make(map[string]string)
|
||||||
|
// Frontier
|
||||||
spec.Engine.Ethash.Params.MinimumDifficulty = (*hexutil.Big)(params.MinimumDifficulty)
|
spec.Engine.Ethash.Params.MinimumDifficulty = (*hexutil.Big)(params.MinimumDifficulty)
|
||||||
spec.Engine.Ethash.Params.DifficultyBoundDivisor = (*hexutil.Big)(params.DifficultyBoundDivisor)
|
spec.Engine.Ethash.Params.DifficultyBoundDivisor = (*hexutil.Big)(params.DifficultyBoundDivisor)
|
||||||
spec.Engine.Ethash.Params.DurationLimit = (*hexutil.Big)(params.DurationLimit)
|
spec.Engine.Ethash.Params.DurationLimit = (*hexutil.Big)(params.DurationLimit)
|
||||||
spec.Engine.Ethash.Params.BlockReward = (*hexutil.Big)(ethash.FrontierBlockReward)
|
spec.Engine.Ethash.Params.BlockReward["0x0"] = hexutil.EncodeBig(ethash.FrontierBlockReward)
|
||||||
spec.Engine.Ethash.Params.HomesteadTransition = genesis.Config.HomesteadBlock.Uint64()
|
|
||||||
spec.Engine.Ethash.Params.EIP150Transition = genesis.Config.EIP150Block.Uint64()
|
|
||||||
spec.Engine.Ethash.Params.EIP160Transition = genesis.Config.EIP155Block.Uint64()
|
|
||||||
spec.Engine.Ethash.Params.EIP161abcTransition = genesis.Config.EIP158Block.Uint64()
|
|
||||||
spec.Engine.Ethash.Params.EIP161dTransition = genesis.Config.EIP158Block.Uint64()
|
|
||||||
spec.Engine.Ethash.Params.EIP649Reward = (*hexutil.Big)(ethash.ByzantiumBlockReward)
|
|
||||||
spec.Engine.Ethash.Params.EIP100bTransition = genesis.Config.ByzantiumBlock.Uint64()
|
|
||||||
spec.Engine.Ethash.Params.EIP649Transition = genesis.Config.ByzantiumBlock.Uint64()
|
|
||||||
|
|
||||||
|
// Homestead
|
||||||
|
spec.Engine.Ethash.Params.HomesteadTransition = hexutil.Uint64(genesis.Config.HomesteadBlock.Uint64())
|
||||||
|
|
||||||
|
// Tangerine Whistle : 150
|
||||||
|
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-608.md
|
||||||
|
spec.Params.EIP150Transition = hexutil.Uint64(genesis.Config.EIP150Block.Uint64())
|
||||||
|
|
||||||
|
// Spurious Dragon: 155, 160, 161, 170
|
||||||
|
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-607.md
|
||||||
|
spec.Params.EIP155Transition = hexutil.Uint64(genesis.Config.EIP155Block.Uint64())
|
||||||
|
spec.Params.EIP160Transition = hexutil.Uint64(genesis.Config.EIP155Block.Uint64())
|
||||||
|
spec.Params.EIP161abcTransition = hexutil.Uint64(genesis.Config.EIP158Block.Uint64())
|
||||||
|
spec.Params.EIP161dTransition = hexutil.Uint64(genesis.Config.EIP158Block.Uint64())
|
||||||
|
|
||||||
|
// Byzantium
|
||||||
|
if num := genesis.Config.ByzantiumBlock; num != nil {
|
||||||
|
spec.setByzantium(num)
|
||||||
|
}
|
||||||
|
// Constantinople
|
||||||
|
if num := genesis.Config.ConstantinopleBlock; num != nil {
|
||||||
|
spec.setConstantinople(num)
|
||||||
|
}
|
||||||
spec.Params.MaximumExtraDataSize = (hexutil.Uint64)(params.MaximumExtraDataSize)
|
spec.Params.MaximumExtraDataSize = (hexutil.Uint64)(params.MaximumExtraDataSize)
|
||||||
spec.Params.MinGasLimit = (hexutil.Uint64)(params.MinGasLimit)
|
spec.Params.MinGasLimit = (hexutil.Uint64)(params.MinGasLimit)
|
||||||
spec.Params.GasLimitBoundDivisor = (hexutil.Uint64)(params.GasLimitBoundDivisor)
|
spec.Params.GasLimitBoundDivisor = (math2.HexOrDecimal64)(params.GasLimitBoundDivisor)
|
||||||
spec.Params.NetworkID = (hexutil.Uint64)(genesis.Config.ChainID.Uint64())
|
spec.Params.NetworkID = (hexutil.Uint64)(genesis.Config.ChainID.Uint64())
|
||||||
|
spec.Params.ChainID = (hexutil.Uint64)(genesis.Config.ChainID.Uint64())
|
||||||
spec.Params.MaxCodeSize = params.MaxCodeSize
|
spec.Params.MaxCodeSize = params.MaxCodeSize
|
||||||
spec.Params.EIP155Transition = genesis.Config.EIP155Block.Uint64()
|
// geth has it set from zero
|
||||||
spec.Params.EIP98Transition = math.MaxUint64
|
spec.Params.MaxCodeSizeTransition = 0
|
||||||
spec.Params.EIP86Transition = math.MaxUint64
|
|
||||||
spec.Params.EIP140Transition = genesis.Config.ByzantiumBlock.Uint64()
|
// Disable this one
|
||||||
spec.Params.EIP211Transition = genesis.Config.ByzantiumBlock.Uint64()
|
spec.Params.EIP98Transition = math.MaxInt64
|
||||||
spec.Params.EIP214Transition = genesis.Config.ByzantiumBlock.Uint64()
|
|
||||||
spec.Params.EIP658Transition = genesis.Config.ByzantiumBlock.Uint64()
|
|
||||||
|
|
||||||
spec.Genesis.Seal.Ethereum.Nonce = (hexutil.Bytes)(make([]byte, 8))
|
spec.Genesis.Seal.Ethereum.Nonce = (hexutil.Bytes)(make([]byte, 8))
|
||||||
binary.LittleEndian.PutUint64(spec.Genesis.Seal.Ethereum.Nonce[:], genesis.Nonce)
|
binary.LittleEndian.PutUint64(spec.Genesis.Seal.Ethereum.Nonce[:], genesis.Nonce)
|
||||||
@@ -305,42 +366,77 @@ func newParityChainSpec(network string, genesis *core.Genesis, bootnodes []strin
|
|||||||
spec.Genesis.ExtraData = (hexutil.Bytes)(genesis.ExtraData)
|
spec.Genesis.ExtraData = (hexutil.Bytes)(genesis.ExtraData)
|
||||||
spec.Genesis.GasLimit = (hexutil.Uint64)(genesis.GasLimit)
|
spec.Genesis.GasLimit = (hexutil.Uint64)(genesis.GasLimit)
|
||||||
|
|
||||||
spec.Accounts = make(map[common.Address]*parityChainSpecAccount)
|
spec.Accounts = make(map[common.UnprefixedAddress]*parityChainSpecAccount)
|
||||||
for address, account := range genesis.Alloc {
|
for address, account := range genesis.Alloc {
|
||||||
spec.Accounts[address] = &parityChainSpecAccount{
|
bal := math2.HexOrDecimal256(*account.Balance)
|
||||||
Balance: (*hexutil.Big)(account.Balance),
|
|
||||||
Nonce: account.Nonce,
|
spec.Accounts[common.UnprefixedAddress(address)] = &parityChainSpecAccount{
|
||||||
|
Balance: bal,
|
||||||
|
Nonce: math2.HexOrDecimal64(account.Nonce),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
spec.Accounts[common.BytesToAddress([]byte{1})].Builtin = &parityChainSpecBuiltin{
|
spec.setPrecompile(1, &parityChainSpecBuiltin{Name: "ecrecover",
|
||||||
Name: "ecrecover", Pricing: &parityChainSpecPricing{Linear: &parityChainSpecLinearPricing{Base: 3000}},
|
Pricing: &parityChainSpecPricing{Linear: &parityChainSpecLinearPricing{Base: 3000}}})
|
||||||
}
|
|
||||||
spec.Accounts[common.BytesToAddress([]byte{2})].Builtin = &parityChainSpecBuiltin{
|
spec.setPrecompile(2, &parityChainSpecBuiltin{
|
||||||
Name: "sha256", Pricing: &parityChainSpecPricing{Linear: &parityChainSpecLinearPricing{Base: 60, Word: 12}},
|
Name: "sha256", Pricing: &parityChainSpecPricing{Linear: &parityChainSpecLinearPricing{Base: 60, Word: 12}},
|
||||||
}
|
})
|
||||||
spec.Accounts[common.BytesToAddress([]byte{3})].Builtin = &parityChainSpecBuiltin{
|
spec.setPrecompile(3, &parityChainSpecBuiltin{
|
||||||
Name: "ripemd160", Pricing: &parityChainSpecPricing{Linear: &parityChainSpecLinearPricing{Base: 600, Word: 120}},
|
Name: "ripemd160", Pricing: &parityChainSpecPricing{Linear: &parityChainSpecLinearPricing{Base: 600, Word: 120}},
|
||||||
}
|
})
|
||||||
spec.Accounts[common.BytesToAddress([]byte{4})].Builtin = &parityChainSpecBuiltin{
|
spec.setPrecompile(4, &parityChainSpecBuiltin{
|
||||||
Name: "identity", Pricing: &parityChainSpecPricing{Linear: &parityChainSpecLinearPricing{Base: 15, Word: 3}},
|
Name: "identity", Pricing: &parityChainSpecPricing{Linear: &parityChainSpecLinearPricing{Base: 15, Word: 3}},
|
||||||
}
|
})
|
||||||
if genesis.Config.ByzantiumBlock != nil {
|
if genesis.Config.ByzantiumBlock != nil {
|
||||||
spec.Accounts[common.BytesToAddress([]byte{5})].Builtin = &parityChainSpecBuiltin{
|
blnum := math2.HexOrDecimal64(genesis.Config.ByzantiumBlock.Uint64())
|
||||||
Name: "modexp", ActivateAt: genesis.Config.ByzantiumBlock.Uint64(), Pricing: &parityChainSpecPricing{ModExp: &parityChainSpecModExpPricing{Divisor: 20}},
|
spec.setPrecompile(5, &parityChainSpecBuiltin{
|
||||||
}
|
Name: "modexp", ActivateAt: blnum, Pricing: &parityChainSpecPricing{ModExp: &parityChainSpecModExpPricing{Divisor: 20}},
|
||||||
spec.Accounts[common.BytesToAddress([]byte{6})].Builtin = &parityChainSpecBuiltin{
|
})
|
||||||
Name: "alt_bn128_add", ActivateAt: genesis.Config.ByzantiumBlock.Uint64(), Pricing: &parityChainSpecPricing{Linear: &parityChainSpecLinearPricing{Base: 500}},
|
spec.setPrecompile(6, &parityChainSpecBuiltin{
|
||||||
}
|
Name: "alt_bn128_add", ActivateAt: blnum, Pricing: &parityChainSpecPricing{Linear: &parityChainSpecLinearPricing{Base: 500}},
|
||||||
spec.Accounts[common.BytesToAddress([]byte{7})].Builtin = &parityChainSpecBuiltin{
|
})
|
||||||
Name: "alt_bn128_mul", ActivateAt: genesis.Config.ByzantiumBlock.Uint64(), Pricing: &parityChainSpecPricing{Linear: &parityChainSpecLinearPricing{Base: 40000}},
|
spec.setPrecompile(7, &parityChainSpecBuiltin{
|
||||||
}
|
Name: "alt_bn128_mul", ActivateAt: blnum, Pricing: &parityChainSpecPricing{Linear: &parityChainSpecLinearPricing{Base: 40000}},
|
||||||
spec.Accounts[common.BytesToAddress([]byte{8})].Builtin = &parityChainSpecBuiltin{
|
})
|
||||||
Name: "alt_bn128_pairing", ActivateAt: genesis.Config.ByzantiumBlock.Uint64(), Pricing: &parityChainSpecPricing{AltBnPairing: &parityChainSpecAltBnPairingPricing{Base: 100000, Pair: 80000}},
|
spec.setPrecompile(8, &parityChainSpecBuiltin{
|
||||||
}
|
Name: "alt_bn128_pairing", ActivateAt: blnum, Pricing: &parityChainSpecPricing{AltBnPairing: &parityChainSpecAltBnPairingPricing{Base: 100000, Pair: 80000}},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
return spec, nil
|
return spec, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (spec *parityChainSpec) setPrecompile(address byte, data *parityChainSpecBuiltin) {
|
||||||
|
if spec.Accounts == nil {
|
||||||
|
spec.Accounts = make(map[common.UnprefixedAddress]*parityChainSpecAccount)
|
||||||
|
}
|
||||||
|
a := common.UnprefixedAddress(common.BytesToAddress([]byte{address}))
|
||||||
|
if _, exist := spec.Accounts[a]; !exist {
|
||||||
|
spec.Accounts[a] = &parityChainSpecAccount{}
|
||||||
|
}
|
||||||
|
spec.Accounts[a].Builtin = data
|
||||||
|
}
|
||||||
|
|
||||||
|
func (spec *parityChainSpec) setByzantium(num *big.Int) {
|
||||||
|
spec.Engine.Ethash.Params.BlockReward[hexutil.EncodeBig(num)] = hexutil.EncodeBig(ethash.ByzantiumBlockReward)
|
||||||
|
spec.Engine.Ethash.Params.DifficultyBombDelays[hexutil.EncodeBig(num)] = hexutil.EncodeUint64(3000000)
|
||||||
|
n := hexutil.Uint64(num.Uint64())
|
||||||
|
spec.Engine.Ethash.Params.EIP100bTransition = n
|
||||||
|
spec.Params.EIP140Transition = n
|
||||||
|
spec.Params.EIP211Transition = n
|
||||||
|
spec.Params.EIP214Transition = n
|
||||||
|
spec.Params.EIP658Transition = n
|
||||||
|
}
|
||||||
|
|
||||||
|
func (spec *parityChainSpec) setConstantinople(num *big.Int) {
|
||||||
|
spec.Engine.Ethash.Params.BlockReward[hexutil.EncodeBig(num)] = hexutil.EncodeBig(ethash.ConstantinopleBlockReward)
|
||||||
|
spec.Engine.Ethash.Params.DifficultyBombDelays[hexutil.EncodeBig(num)] = hexutil.EncodeUint64(2000000)
|
||||||
|
n := hexutil.Uint64(num.Uint64())
|
||||||
|
spec.Params.EIP145Transition = n
|
||||||
|
spec.Params.EIP1014Transition = n
|
||||||
|
spec.Params.EIP1052Transition = n
|
||||||
|
spec.Params.EIP1283Transition = n
|
||||||
|
}
|
||||||
|
|
||||||
// pyEthereumGenesisSpec represents the genesis specification format used by the
|
// pyEthereumGenesisSpec represents the genesis specification format used by the
|
||||||
// Python Ethereum implementation.
|
// Python Ethereum implementation.
|
||||||
type pyEthereumGenesisSpec struct {
|
type pyEthereumGenesisSpec struct {
|
||||||
|
|||||||
109
cmd/puppeth/genesis_test.go
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
// Copyright 2018 The go-ethereum Authors
|
||||||
|
// This file is part of go-ethereum.
|
||||||
|
//
|
||||||
|
// go-ethereum 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.
|
||||||
|
//
|
||||||
|
// go-ethereum 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 go-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"reflect"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/davecgh/go-spew/spew"
|
||||||
|
"github.com/ethereum/go-ethereum/core"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Tests the go-ethereum to Aleth chainspec conversion for the Stureby testnet.
|
||||||
|
func TestAlethSturebyConverter(t *testing.T) {
|
||||||
|
blob, err := ioutil.ReadFile("testdata/stureby_geth.json")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("could not read file: %v", err)
|
||||||
|
}
|
||||||
|
var genesis core.Genesis
|
||||||
|
if err := json.Unmarshal(blob, &genesis); err != nil {
|
||||||
|
t.Fatalf("failed parsing genesis: %v", err)
|
||||||
|
}
|
||||||
|
spec, err := newAlethGenesisSpec("stureby", &genesis)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("failed creating chainspec: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
expBlob, err := ioutil.ReadFile("testdata/stureby_aleth.json")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("could not read file: %v", err)
|
||||||
|
}
|
||||||
|
expspec := &alethGenesisSpec{}
|
||||||
|
if err := json.Unmarshal(expBlob, expspec); err != nil {
|
||||||
|
t.Fatalf("failed parsing genesis: %v", err)
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(expspec, spec) {
|
||||||
|
t.Errorf("chainspec mismatch")
|
||||||
|
c := spew.ConfigState{
|
||||||
|
DisablePointerAddresses: true,
|
||||||
|
SortKeys: true,
|
||||||
|
}
|
||||||
|
exp := strings.Split(c.Sdump(expspec), "\n")
|
||||||
|
got := strings.Split(c.Sdump(spec), "\n")
|
||||||
|
for i := 0; i < len(exp) && i < len(got); i++ {
|
||||||
|
if exp[i] != got[i] {
|
||||||
|
fmt.Printf("got: %v\nexp: %v\n", exp[i], got[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tests the go-ethereum to Parity chainspec conversion for the Stureby testnet.
|
||||||
|
func TestParitySturebyConverter(t *testing.T) {
|
||||||
|
blob, err := ioutil.ReadFile("testdata/stureby_geth.json")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("could not read file: %v", err)
|
||||||
|
}
|
||||||
|
var genesis core.Genesis
|
||||||
|
if err := json.Unmarshal(blob, &genesis); err != nil {
|
||||||
|
t.Fatalf("failed parsing genesis: %v", err)
|
||||||
|
}
|
||||||
|
spec, err := newParityChainSpec("Stureby", &genesis, []string{})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("failed creating chainspec: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
expBlob, err := ioutil.ReadFile("testdata/stureby_parity.json")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("could not read file: %v", err)
|
||||||
|
}
|
||||||
|
expspec := &parityChainSpec{}
|
||||||
|
if err := json.Unmarshal(expBlob, expspec); err != nil {
|
||||||
|
t.Fatalf("failed parsing genesis: %v", err)
|
||||||
|
}
|
||||||
|
expspec.Nodes = []string{}
|
||||||
|
|
||||||
|
if !reflect.DeepEqual(expspec, spec) {
|
||||||
|
t.Errorf("chainspec mismatch")
|
||||||
|
c := spew.ConfigState{
|
||||||
|
DisablePointerAddresses: true,
|
||||||
|
SortKeys: true,
|
||||||
|
}
|
||||||
|
exp := strings.Split(c.Sdump(expspec), "\n")
|
||||||
|
got := strings.Split(c.Sdump(spec), "\n")
|
||||||
|
for i := 0; i < len(exp) && i < len(got); i++ {
|
||||||
|
if exp[i] != got[i] {
|
||||||
|
fmt.Printf("got: %v\nexp: %v\n", exp[i], got[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -640,7 +640,7 @@ func deployDashboard(client *sshClient, network string, conf *config, config *da
|
|||||||
files[filepath.Join(workdir, network+".json")] = genesis
|
files[filepath.Join(workdir, network+".json")] = genesis
|
||||||
|
|
||||||
if conf.Genesis.Config.Ethash != nil {
|
if conf.Genesis.Config.Ethash != nil {
|
||||||
cppSpec, err := newCppEthereumGenesisSpec(network, conf.Genesis)
|
cppSpec, err := newAlethGenesisSpec(network, conf.Genesis)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -678,9 +678,9 @@ func deployDashboard(client *sshClient, network string, conf *config, config *da
|
|||||||
|
|
||||||
// Build and deploy the dashboard service
|
// Build and deploy the dashboard service
|
||||||
if nocache {
|
if nocache {
|
||||||
return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s build --pull --no-cache && docker-compose -p %s up -d --force-recreate", workdir, network, network))
|
return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s build --pull --no-cache && docker-compose -p %s up -d --force-recreate --timeout 60", workdir, network, network))
|
||||||
}
|
}
|
||||||
return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s up -d --build --force-recreate", workdir, network))
|
return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s up -d --build --force-recreate --timeout 60", workdir, network))
|
||||||
}
|
}
|
||||||
|
|
||||||
// dashboardInfos is returned from a dashboard status check to allow reporting
|
// dashboardInfos is returned from a dashboard status check to allow reporting
|
||||||
|
|||||||
@@ -43,7 +43,8 @@ version: '2'
|
|||||||
services:
|
services:
|
||||||
ethstats:
|
ethstats:
|
||||||
build: .
|
build: .
|
||||||
image: {{.Network}}/ethstats{{if not .VHost}}
|
image: {{.Network}}/ethstats
|
||||||
|
container_name: {{.Network}}_ethstats_1{{if not .VHost}}
|
||||||
ports:
|
ports:
|
||||||
- "{{.Port}}:3000"{{end}}
|
- "{{.Port}}:3000"{{end}}
|
||||||
environment:
|
environment:
|
||||||
@@ -100,9 +101,9 @@ func deployEthstats(client *sshClient, network string, port int, secret string,
|
|||||||
|
|
||||||
// Build and deploy the ethstats service
|
// Build and deploy the ethstats service
|
||||||
if nocache {
|
if nocache {
|
||||||
return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s build --pull --no-cache && docker-compose -p %s up -d --force-recreate", workdir, network, network))
|
return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s build --pull --no-cache && docker-compose -p %s up -d --force-recreate --timeout 60", workdir, network, network))
|
||||||
}
|
}
|
||||||
return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s up -d --build --force-recreate", workdir, network))
|
return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s up -d --build --force-recreate --timeout 60", workdir, network))
|
||||||
}
|
}
|
||||||
|
|
||||||
// ethstatsInfos is returned from an ethstats status check to allow reporting
|
// ethstatsInfos is returned from an ethstats status check to allow reporting
|
||||||
@@ -122,7 +123,7 @@ func (info *ethstatsInfos) Report() map[string]string {
|
|||||||
"Website address": info.host,
|
"Website address": info.host,
|
||||||
"Website listener port": strconv.Itoa(info.port),
|
"Website listener port": strconv.Itoa(info.port),
|
||||||
"Login secret": info.secret,
|
"Login secret": info.secret,
|
||||||
"Banned addresses": fmt.Sprintf("%v", info.banned),
|
"Banned addresses": strings.Join(info.banned, "\n"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ ADD chain.json /chain.json
|
|||||||
RUN \
|
RUN \
|
||||||
echo '(cd ../eth-net-intelligence-api && pm2 start /ethstats.json)' > explorer.sh && \
|
echo '(cd ../eth-net-intelligence-api && pm2 start /ethstats.json)' > explorer.sh && \
|
||||||
echo '(cd ../etherchain-light && npm start &)' >> explorer.sh && \
|
echo '(cd ../etherchain-light && npm start &)' >> explorer.sh && \
|
||||||
echo '/parity/parity --chain=/chain.json --port={{.NodePort}} --tracing=on --fat-db=on --pruning=archive' >> explorer.sh
|
echo 'exec /parity/parity --chain=/chain.json --port={{.NodePort}} --tracing=on --fat-db=on --pruning=archive' >> explorer.sh
|
||||||
|
|
||||||
ENTRYPOINT ["/bin/sh", "explorer.sh"]
|
ENTRYPOINT ["/bin/sh", "explorer.sh"]
|
||||||
`
|
`
|
||||||
@@ -77,6 +77,7 @@ services:
|
|||||||
explorer:
|
explorer:
|
||||||
build: .
|
build: .
|
||||||
image: {{.Network}}/explorer
|
image: {{.Network}}/explorer
|
||||||
|
container_name: {{.Network}}_explorer_1
|
||||||
ports:
|
ports:
|
||||||
- "{{.NodePort}}:{{.NodePort}}"
|
- "{{.NodePort}}:{{.NodePort}}"
|
||||||
- "{{.NodePort}}:{{.NodePort}}/udp"{{if not .VHost}}
|
- "{{.NodePort}}:{{.NodePort}}/udp"{{if not .VHost}}
|
||||||
@@ -140,9 +141,9 @@ func deployExplorer(client *sshClient, network string, chainspec []byte, config
|
|||||||
|
|
||||||
// Build and deploy the boot or seal node service
|
// Build and deploy the boot or seal node service
|
||||||
if nocache {
|
if nocache {
|
||||||
return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s build --pull --no-cache && docker-compose -p %s up -d --force-recreate", workdir, network, network))
|
return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s build --pull --no-cache && docker-compose -p %s up -d --force-recreate --timeout 60", workdir, network, network))
|
||||||
}
|
}
|
||||||
return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s up -d --build --force-recreate", workdir, network))
|
return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s up -d --build --force-recreate --timeout 60", workdir, network))
|
||||||
}
|
}
|
||||||
|
|
||||||
// explorerInfos is returned from a block explorer status check to allow reporting
|
// explorerInfos is returned from a block explorer status check to allow reporting
|
||||||
|
|||||||
@@ -56,8 +56,10 @@ services:
|
|||||||
faucet:
|
faucet:
|
||||||
build: .
|
build: .
|
||||||
image: {{.Network}}/faucet
|
image: {{.Network}}/faucet
|
||||||
|
container_name: {{.Network}}_faucet_1
|
||||||
ports:
|
ports:
|
||||||
- "{{.EthPort}}:{{.EthPort}}"{{if not .VHost}}
|
- "{{.EthPort}}:{{.EthPort}}"
|
||||||
|
- "{{.EthPort}}:{{.EthPort}}/udp"{{if not .VHost}}
|
||||||
- "{{.ApiPort}}:8080"{{end}}
|
- "{{.ApiPort}}:8080"{{end}}
|
||||||
volumes:
|
volumes:
|
||||||
- {{.Datadir}}:/root/.faucet
|
- {{.Datadir}}:/root/.faucet
|
||||||
@@ -133,9 +135,9 @@ func deployFaucet(client *sshClient, network string, bootnodes []string, config
|
|||||||
|
|
||||||
// Build and deploy the faucet service
|
// Build and deploy the faucet service
|
||||||
if nocache {
|
if nocache {
|
||||||
return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s build --pull --no-cache && docker-compose -p %s up -d --force-recreate", workdir, network, network))
|
return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s build --pull --no-cache && docker-compose -p %s up -d --force-recreate --timeout 60", workdir, network, network))
|
||||||
}
|
}
|
||||||
return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s up -d --build --force-recreate", workdir, network))
|
return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s up -d --build --force-recreate --timeout 60", workdir, network))
|
||||||
}
|
}
|
||||||
|
|
||||||
// faucetInfos is returned from a faucet status check to allow reporting various
|
// faucetInfos is returned from a faucet status check to allow reporting various
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ services:
|
|||||||
nginx:
|
nginx:
|
||||||
build: .
|
build: .
|
||||||
image: {{.Network}}/nginx
|
image: {{.Network}}/nginx
|
||||||
|
container_name: {{.Network}}_nginx_1
|
||||||
ports:
|
ports:
|
||||||
- "{{.Port}}:80"
|
- "{{.Port}}:80"
|
||||||
volumes:
|
volumes:
|
||||||
@@ -81,9 +82,9 @@ func deployNginx(client *sshClient, network string, port int, nocache bool) ([]b
|
|||||||
|
|
||||||
// Build and deploy the reverse-proxy service
|
// Build and deploy the reverse-proxy service
|
||||||
if nocache {
|
if nocache {
|
||||||
return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s build --pull --no-cache && docker-compose -p %s up -d --force-recreate", workdir, network, network))
|
return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s build --pull --no-cache && docker-compose -p %s up -d --force-recreate --timeout 60", workdir, network, network))
|
||||||
}
|
}
|
||||||
return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s up -d --build --force-recreate", workdir, network))
|
return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s up -d --build --force-recreate --timeout 60", workdir, network))
|
||||||
}
|
}
|
||||||
|
|
||||||
// nginxInfos is returned from an nginx reverse-proxy status check to allow
|
// nginxInfos is returned from an nginx reverse-proxy status check to allow
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ ADD genesis.json /genesis.json
|
|||||||
RUN \
|
RUN \
|
||||||
echo 'geth --cache 512 init /genesis.json' > geth.sh && \{{if .Unlock}}
|
echo 'geth --cache 512 init /genesis.json' > geth.sh && \{{if .Unlock}}
|
||||||
echo 'mkdir -p /root/.ethereum/keystore/ && cp /signer.json /root/.ethereum/keystore/' >> geth.sh && \{{end}}
|
echo 'mkdir -p /root/.ethereum/keystore/ && cp /signer.json /root/.ethereum/keystore/' >> geth.sh && \{{end}}
|
||||||
echo $'geth --networkid {{.NetworkID}} --cache 512 --port {{.Port}} --maxpeers {{.Peers}} {{.LightFlag}} --ethstats \'{{.Ethstats}}\' {{if .Bootnodes}}--bootnodes {{.Bootnodes}}{{end}} {{if .Etherbase}}--etherbase {{.Etherbase}} --mine --minerthreads 1{{end}} {{if .Unlock}}--unlock 0 --password /signer.pass --mine{{end}} --targetgaslimit {{.GasTarget}} --gasprice {{.GasPrice}}' >> geth.sh
|
echo $'exec geth --networkid {{.NetworkID}} --cache 512 --port {{.Port}} --nat extip:{{.IP}} --maxpeers {{.Peers}} {{.LightFlag}} --ethstats \'{{.Ethstats}}\' {{if .Bootnodes}}--bootnodes {{.Bootnodes}}{{end}} {{if .Etherbase}}--miner.etherbase {{.Etherbase}} --mine --miner.threads 1{{end}} {{if .Unlock}}--unlock 0 --password /signer.pass --mine{{end}} --miner.gastarget {{.GasTarget}} --miner.gaslimit {{.GasLimit}} --miner.gasprice {{.GasPrice}}' >> geth.sh
|
||||||
|
|
||||||
ENTRYPOINT ["/bin/sh", "geth.sh"]
|
ENTRYPOINT ["/bin/sh", "geth.sh"]
|
||||||
`
|
`
|
||||||
@@ -55,6 +55,7 @@ services:
|
|||||||
{{.Type}}:
|
{{.Type}}:
|
||||||
build: .
|
build: .
|
||||||
image: {{.Network}}/{{.Type}}
|
image: {{.Network}}/{{.Type}}
|
||||||
|
container_name: {{.Network}}_{{.Type}}_1
|
||||||
ports:
|
ports:
|
||||||
- "{{.Port}}:{{.Port}}"
|
- "{{.Port}}:{{.Port}}"
|
||||||
- "{{.Port}}:{{.Port}}/udp"
|
- "{{.Port}}:{{.Port}}/udp"
|
||||||
@@ -68,6 +69,7 @@ services:
|
|||||||
- STATS_NAME={{.Ethstats}}
|
- STATS_NAME={{.Ethstats}}
|
||||||
- MINER_NAME={{.Etherbase}}
|
- MINER_NAME={{.Etherbase}}
|
||||||
- GAS_TARGET={{.GasTarget}}
|
- GAS_TARGET={{.GasTarget}}
|
||||||
|
- GAS_LIMIT={{.GasLimit}}
|
||||||
- GAS_PRICE={{.GasPrice}}
|
- GAS_PRICE={{.GasPrice}}
|
||||||
logging:
|
logging:
|
||||||
driver: "json-file"
|
driver: "json-file"
|
||||||
@@ -98,12 +100,14 @@ func deployNode(client *sshClient, network string, bootnodes []string, config *n
|
|||||||
template.Must(template.New("").Parse(nodeDockerfile)).Execute(dockerfile, map[string]interface{}{
|
template.Must(template.New("").Parse(nodeDockerfile)).Execute(dockerfile, map[string]interface{}{
|
||||||
"NetworkID": config.network,
|
"NetworkID": config.network,
|
||||||
"Port": config.port,
|
"Port": config.port,
|
||||||
|
"IP": client.address,
|
||||||
"Peers": config.peersTotal,
|
"Peers": config.peersTotal,
|
||||||
"LightFlag": lightFlag,
|
"LightFlag": lightFlag,
|
||||||
"Bootnodes": strings.Join(bootnodes, ","),
|
"Bootnodes": strings.Join(bootnodes, ","),
|
||||||
"Ethstats": config.ethstats,
|
"Ethstats": config.ethstats,
|
||||||
"Etherbase": config.etherbase,
|
"Etherbase": config.etherbase,
|
||||||
"GasTarget": uint64(1000000 * config.gasTarget),
|
"GasTarget": uint64(1000000 * config.gasTarget),
|
||||||
|
"GasLimit": uint64(1000000 * config.gasLimit),
|
||||||
"GasPrice": uint64(1000000000 * config.gasPrice),
|
"GasPrice": uint64(1000000000 * config.gasPrice),
|
||||||
"Unlock": config.keyJSON != "",
|
"Unlock": config.keyJSON != "",
|
||||||
})
|
})
|
||||||
@@ -122,6 +126,7 @@ func deployNode(client *sshClient, network string, bootnodes []string, config *n
|
|||||||
"Ethstats": config.ethstats[:strings.Index(config.ethstats, ":")],
|
"Ethstats": config.ethstats[:strings.Index(config.ethstats, ":")],
|
||||||
"Etherbase": config.etherbase,
|
"Etherbase": config.etherbase,
|
||||||
"GasTarget": config.gasTarget,
|
"GasTarget": config.gasTarget,
|
||||||
|
"GasLimit": config.gasLimit,
|
||||||
"GasPrice": config.gasPrice,
|
"GasPrice": config.gasPrice,
|
||||||
})
|
})
|
||||||
files[filepath.Join(workdir, "docker-compose.yaml")] = composefile.Bytes()
|
files[filepath.Join(workdir, "docker-compose.yaml")] = composefile.Bytes()
|
||||||
@@ -139,9 +144,9 @@ func deployNode(client *sshClient, network string, bootnodes []string, config *n
|
|||||||
|
|
||||||
// Build and deploy the boot or seal node service
|
// Build and deploy the boot or seal node service
|
||||||
if nocache {
|
if nocache {
|
||||||
return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s build --pull --no-cache && docker-compose -p %s up -d --force-recreate", workdir, network, network))
|
return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s build --pull --no-cache && docker-compose -p %s up -d --force-recreate --timeout 60", workdir, network, network))
|
||||||
}
|
}
|
||||||
return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s up -d --build --force-recreate", workdir, network))
|
return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s up -d --build --force-recreate --timeout 60", workdir, network))
|
||||||
}
|
}
|
||||||
|
|
||||||
// nodeInfos is returned from a boot or seal node status check to allow reporting
|
// nodeInfos is returned from a boot or seal node status check to allow reporting
|
||||||
@@ -160,6 +165,7 @@ type nodeInfos struct {
|
|||||||
keyJSON string
|
keyJSON string
|
||||||
keyPass string
|
keyPass string
|
||||||
gasTarget float64
|
gasTarget float64
|
||||||
|
gasLimit float64
|
||||||
gasPrice float64
|
gasPrice float64
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,8 +181,9 @@ func (info *nodeInfos) Report() map[string]string {
|
|||||||
}
|
}
|
||||||
if info.gasTarget > 0 {
|
if info.gasTarget > 0 {
|
||||||
// Miner or signer node
|
// Miner or signer node
|
||||||
report["Gas limit (baseline target)"] = fmt.Sprintf("%0.3f MGas", info.gasTarget)
|
|
||||||
report["Gas price (minimum accepted)"] = fmt.Sprintf("%0.3f GWei", info.gasPrice)
|
report["Gas price (minimum accepted)"] = fmt.Sprintf("%0.3f GWei", info.gasPrice)
|
||||||
|
report["Gas floor (baseline target)"] = fmt.Sprintf("%0.3f MGas", info.gasTarget)
|
||||||
|
report["Gas ceil (target maximum)"] = fmt.Sprintf("%0.3f MGas", info.gasLimit)
|
||||||
|
|
||||||
if info.etherbase != "" {
|
if info.etherbase != "" {
|
||||||
// Ethash proof-of-work miner
|
// Ethash proof-of-work miner
|
||||||
@@ -217,14 +224,15 @@ func checkNode(client *sshClient, network string, boot bool) (*nodeInfos, error)
|
|||||||
totalPeers, _ := strconv.Atoi(infos.envvars["TOTAL_PEERS"])
|
totalPeers, _ := strconv.Atoi(infos.envvars["TOTAL_PEERS"])
|
||||||
lightPeers, _ := strconv.Atoi(infos.envvars["LIGHT_PEERS"])
|
lightPeers, _ := strconv.Atoi(infos.envvars["LIGHT_PEERS"])
|
||||||
gasTarget, _ := strconv.ParseFloat(infos.envvars["GAS_TARGET"], 64)
|
gasTarget, _ := strconv.ParseFloat(infos.envvars["GAS_TARGET"], 64)
|
||||||
|
gasLimit, _ := strconv.ParseFloat(infos.envvars["GAS_LIMIT"], 64)
|
||||||
gasPrice, _ := strconv.ParseFloat(infos.envvars["GAS_PRICE"], 64)
|
gasPrice, _ := strconv.ParseFloat(infos.envvars["GAS_PRICE"], 64)
|
||||||
|
|
||||||
// Container available, retrieve its node ID and its genesis json
|
// Container available, retrieve its node ID and its genesis json
|
||||||
var out []byte
|
var out []byte
|
||||||
if out, err = client.Run(fmt.Sprintf("docker exec %s_%s_1 geth --exec admin.nodeInfo.id attach", network, kind)); err != nil {
|
if out, err = client.Run(fmt.Sprintf("docker exec %s_%s_1 geth --exec admin.nodeInfo.enode --cache=16 attach", network, kind)); err != nil {
|
||||||
return nil, ErrServiceUnreachable
|
return nil, ErrServiceUnreachable
|
||||||
}
|
}
|
||||||
id := bytes.Trim(bytes.TrimSpace(out), "\"")
|
enode := bytes.Trim(bytes.TrimSpace(out), "\"")
|
||||||
|
|
||||||
if out, err = client.Run(fmt.Sprintf("docker exec %s_%s_1 cat /genesis.json", network, kind)); err != nil {
|
if out, err = client.Run(fmt.Sprintf("docker exec %s_%s_1 cat /genesis.json", network, kind)); err != nil {
|
||||||
return nil, ErrServiceUnreachable
|
return nil, ErrServiceUnreachable
|
||||||
@@ -256,9 +264,10 @@ func checkNode(client *sshClient, network string, boot bool) (*nodeInfos, error)
|
|||||||
keyJSON: keyJSON,
|
keyJSON: keyJSON,
|
||||||
keyPass: keyPass,
|
keyPass: keyPass,
|
||||||
gasTarget: gasTarget,
|
gasTarget: gasTarget,
|
||||||
|
gasLimit: gasLimit,
|
||||||
gasPrice: gasPrice,
|
gasPrice: gasPrice,
|
||||||
}
|
}
|
||||||
stats.enode = fmt.Sprintf("enode://%s@%s:%d", id, client.address, stats.port)
|
stats.enode = string(enode)
|
||||||
|
|
||||||
return stats, nil
|
return stats, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ ADD genesis.json /genesis.json
|
|||||||
RUN \
|
RUN \
|
||||||
echo 'node server.js &' > wallet.sh && \
|
echo 'node server.js &' > wallet.sh && \
|
||||||
echo 'geth --cache 512 init /genesis.json' >> wallet.sh && \
|
echo 'geth --cache 512 init /genesis.json' >> wallet.sh && \
|
||||||
echo $'geth --networkid {{.NetworkID}} --port {{.NodePort}} --bootnodes {{.Bootnodes}} --ethstats \'{{.Ethstats}}\' --cache=512 --rpc --rpcaddr=0.0.0.0 --rpccorsdomain "*" --rpcvhosts "*"' >> wallet.sh
|
echo $'exec geth --networkid {{.NetworkID}} --port {{.NodePort}} --bootnodes {{.Bootnodes}} --ethstats \'{{.Ethstats}}\' --cache=512 --rpc --rpcaddr=0.0.0.0 --rpccorsdomain "*" --rpcvhosts "*"' >> wallet.sh
|
||||||
|
|
||||||
RUN \
|
RUN \
|
||||||
sed -i 's/PuppethNetworkID/{{.NetworkID}}/g' dist/js/etherwallet-master.js && \
|
sed -i 's/PuppethNetworkID/{{.NetworkID}}/g' dist/js/etherwallet-master.js && \
|
||||||
@@ -57,6 +57,7 @@ services:
|
|||||||
wallet:
|
wallet:
|
||||||
build: .
|
build: .
|
||||||
image: {{.Network}}/wallet
|
image: {{.Network}}/wallet
|
||||||
|
container_name: {{.Network}}_wallet_1
|
||||||
ports:
|
ports:
|
||||||
- "{{.NodePort}}:{{.NodePort}}"
|
- "{{.NodePort}}:{{.NodePort}}"
|
||||||
- "{{.NodePort}}:{{.NodePort}}/udp"
|
- "{{.NodePort}}:{{.NodePort}}/udp"
|
||||||
@@ -120,9 +121,9 @@ func deployWallet(client *sshClient, network string, bootnodes []string, config
|
|||||||
|
|
||||||
// Build and deploy the boot or seal node service
|
// Build and deploy the boot or seal node service
|
||||||
if nocache {
|
if nocache {
|
||||||
return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s build --pull --no-cache && docker-compose -p %s up -d --force-recreate", workdir, network, network))
|
return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s build --pull --no-cache && docker-compose -p %s up -d --force-recreate --timeout 60", workdir, network, network))
|
||||||
}
|
}
|
||||||
return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s up -d --build --force-recreate", workdir, network))
|
return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s up -d --build --force-recreate --timeout 60", workdir, network))
|
||||||
}
|
}
|
||||||
|
|
||||||
// walletInfos is returned from a web wallet status check to allow reporting
|
// walletInfos is returned from a web wallet status check to allow reporting
|
||||||
|
|||||||
@@ -43,18 +43,23 @@ func main() {
|
|||||||
Usage: "log level to emit to the screen",
|
Usage: "log level to emit to the screen",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
app.Action = func(c *cli.Context) error {
|
app.Before = func(c *cli.Context) error {
|
||||||
// Set up the logger to print everything and the random generator
|
// Set up the logger to print everything and the random generator
|
||||||
log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(c.Int("loglevel")), log.StreamHandler(os.Stdout, log.TerminalFormat(true))))
|
log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(c.Int("loglevel")), log.StreamHandler(os.Stdout, log.TerminalFormat(true))))
|
||||||
rand.Seed(time.Now().UnixNano())
|
rand.Seed(time.Now().UnixNano())
|
||||||
|
|
||||||
network := c.String("network")
|
|
||||||
if strings.Contains(network, " ") || strings.Contains(network, "-") {
|
|
||||||
log.Crit("No spaces or hyphens allowed in network name")
|
|
||||||
}
|
|
||||||
// Start the wizard and relinquish control
|
|
||||||
makeWizard(c.String("network")).run()
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
app.Action = runWizard
|
||||||
app.Run(os.Args)
|
app.Run(os.Args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// runWizard start the wizard and relinquish control to it.
|
||||||
|
func runWizard(c *cli.Context) error {
|
||||||
|
network := c.String("network")
|
||||||
|
if strings.Contains(network, " ") || strings.Contains(network, "-") || strings.ToLower(network) != network {
|
||||||
|
log.Crit("No spaces, hyphens or capital letters allowed in network name")
|
||||||
|
}
|
||||||
|
makeWizard(c.String("network")).run()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||