Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
efd2dff0ca | ||
|
|
44748775ff | ||
|
|
f729c6b7f5 | ||
|
|
22fafc7054 | ||
|
|
e09d291e5d | ||
|
|
97a97fe992 | ||
|
|
f4f5ef6f83 | ||
|
|
a1281273bc | ||
|
|
42216184e1 | ||
|
|
2c945d33ee | ||
|
|
1c1d23d142 | ||
|
|
3fc791b0e8 | ||
|
|
7d39542522 | ||
|
|
6c5ed3f07f | ||
|
|
a2278e26af | ||
|
|
b28b8b9649 | ||
|
|
f1ab1af617 | ||
|
|
91a43c477c | ||
|
|
c46e1574dd | ||
|
|
a876a0ba44 | ||
|
|
819180f739 | ||
|
|
476e7992e8 | ||
|
|
e27fc03f55 | ||
|
|
ed4bf9b8fe | ||
|
|
773714792f | ||
|
|
dcf2735836 | ||
|
|
77f81fc49b | ||
|
|
46fb0e74cd | ||
|
|
2967c4ec10 | ||
|
|
88ada66280 | ||
|
|
3cf2fd595f | ||
|
|
3153ab9ae3 | ||
|
|
c91774be3b | ||
|
|
441d7ff790 | ||
|
|
bc24fdbd14 | ||
|
|
ab070f2ebe | ||
|
|
5314ba8c6d | ||
|
|
f96698b54d | ||
|
|
fc15888697 | ||
|
|
9b91628d85 | ||
|
|
1dc69e397e | ||
|
|
d56da1b014 | ||
|
|
d33dd4f7bc | ||
|
|
63f026f7c3 | ||
|
|
3f0106cfe5 | ||
|
|
4bab784e40 | ||
|
|
916421b247 | ||
|
|
a41bf74bad | ||
|
|
0ab2459fce | ||
|
|
f9a896f6f2 | ||
|
|
24ae9205fe | ||
|
|
4cf0c105eb | ||
|
|
025663118f | ||
|
|
f7934b083c | ||
|
|
46ed0142db | ||
|
|
29913f4c41 | ||
|
|
1096f8acc6 | ||
|
|
14588d1fd2 | ||
|
|
901f7d2b4c | ||
|
|
0b5e4a9612 | ||
|
|
5663b2d697 | ||
|
|
44b52941f7 | ||
|
|
58a85f378c | ||
|
|
d3ddd3bff9 | ||
|
|
d9f2b909ac | ||
|
|
a79291070e | ||
|
|
d9951cdff4 | ||
|
|
c1a9cf7edd | ||
|
|
dfaad08a8b | ||
|
|
d607ca6118 | ||
|
|
49a94b7cba | ||
|
|
ab53abf04e | ||
|
|
cfa041ca8a | ||
|
|
a307e4593a | ||
|
|
286fe04271 | ||
|
|
f135ec8468 | ||
|
|
b355eb75eb | ||
|
|
a95e34f742 | ||
|
|
ed285f1114 | ||
|
|
b25dd2a00d | ||
|
|
b3d0a5fb4a | ||
|
|
0d2c8196c6 | ||
|
|
c401d2ec4e | ||
|
|
6b40e1e30d | ||
|
|
7c3f638f68 | ||
|
|
35bce5a5c6 | ||
|
|
1bf3b4989d | ||
|
|
c130806c37 | ||
|
|
f741ce6e30 | ||
|
|
4a7055c328 | ||
|
|
8285eda8e5 | ||
|
|
e60027c00a | ||
|
|
24df873498 | ||
|
|
8747c6083e | ||
|
|
6050401652 | ||
|
|
298efa221c | ||
|
|
fb2b25c297 | ||
|
|
7109e95f5e | ||
|
|
c3046f487c | ||
|
|
ccd0a67b01 | ||
|
|
eadc61c37a | ||
|
|
70faa36b7f | ||
|
|
9afdda4584 | ||
|
|
0dfd4f3e63 | ||
|
|
0cd45ab82b | ||
|
|
37108ebf8f | ||
|
|
694463ffbe | ||
|
|
fce423c743 | ||
|
|
37de154a7c | ||
|
|
daa441b989 | ||
|
|
8bd6791e58 | ||
|
|
f2a0779bb9 | ||
|
|
b2ee59024f | ||
|
|
ac7007d1d0 | ||
|
|
db2a20da6c | ||
|
|
4121063ca4 | ||
|
|
aa081dbc6d | ||
|
|
984eee8cd6 | ||
|
|
26bbd9fb9d | ||
|
|
57c1eac37a | ||
|
|
8419dda84b | ||
|
|
dcc5643473 | ||
|
|
5bcfee0042 | ||
|
|
dc58f71604 | ||
|
|
ae38970526 | ||
|
|
708aa368e1 | ||
|
|
18bc59b93b | ||
|
|
1a101e53a6 | ||
|
|
a894c1e8e6 | ||
|
|
b85b50afbc | ||
|
|
14a4acec8c | ||
|
|
c40c1361f0 | ||
|
|
82b95e34b7 | ||
|
|
68e884ee44 | ||
|
|
6eda53565f | ||
|
|
6dfc40abc1 | ||
|
|
2946561dec | ||
|
|
d7948fcbcd | ||
|
|
fb605f6d7f | ||
|
|
2a428f09e6 | ||
|
|
8a4b629f40 | ||
|
|
b984e94a87 | ||
|
|
05a233f84d | ||
|
|
35f6e10646 | ||
|
|
61c0b8c3db | ||
|
|
e632643801 | ||
|
|
12e76bc1af | ||
|
|
31ff5230bb | ||
|
|
97064f1d15 | ||
|
|
053cfc1cc7 | ||
|
|
7bf165c73a | ||
|
|
691bd9f442 | ||
|
|
e2295c372a | ||
|
|
b60614982e | ||
|
|
9e48dd211a | ||
|
|
b5ba7a0fad | ||
|
|
81004ea39e | ||
|
|
bf2e3baa8f | ||
|
|
d5af25b76c | ||
|
|
80b6994fe2 | ||
|
|
7115485b0a | ||
|
|
f56602c588 | ||
|
|
b530f25f09 | ||
|
|
c66ebc50c1 | ||
|
|
2aef7f7c07 | ||
|
|
665d23cb8e | ||
|
|
3b00c6838a | ||
|
|
a6b7791d32 | ||
|
|
34d31d8124 | ||
|
|
6656e5a6c8 | ||
|
|
487765548e | ||
|
|
ecd115c002 | ||
|
|
ccce1a9715 | ||
|
|
5a8ee0dd2a | ||
|
|
4fbb322fa2 | ||
|
|
56f223bfc3 | ||
|
|
0ff5a71114 | ||
|
|
b0677ab38e | ||
|
|
f4f80b25d1 | ||
|
|
3f67c4524e | ||
|
|
ed74091c20 | ||
|
|
b4115021c5 | ||
|
|
b78ffd18c6 | ||
|
|
c9a8f3b8a0 | ||
|
|
d870c74a5e | ||
|
|
3d61a37fcf | ||
|
|
0c41522ebf | ||
|
|
362fc180ec | ||
|
|
2db7b8c998 | ||
|
|
72d19f369b | ||
|
|
90853e24cf | ||
|
|
b4ee519282 | ||
|
|
e04331b07c | ||
|
|
05c11531b1 | ||
|
|
808051d34e | ||
|
|
e2cf0c4d4c | ||
|
|
5c69249ba3 | ||
|
|
fa9be9a627 | ||
|
|
454c382e7e | ||
|
|
937ff4e9ae | ||
|
|
952f2c2f1e | ||
|
|
92471d41d6 | ||
|
|
02bc5fab26 | ||
|
|
e1ba4eb5c4 | ||
|
|
4e01fad0d4 | ||
|
|
ed4caac9bf | ||
|
|
0c1c19c6ef | ||
|
|
91e9573863 | ||
|
|
c64f983900 | ||
|
|
24756ac056 | ||
|
|
53384e83d7 | ||
|
|
4cd92d8576 | ||
|
|
6bf7976add | ||
|
|
00c6397ec9 | ||
|
|
d4a7732d0a | ||
|
|
ae326ce65d | ||
|
|
531b7bf92d | ||
|
|
9dad38c9a5 | ||
|
|
4419850195 | ||
|
|
4dabab5ce6 | ||
|
|
84fa22110f | ||
|
|
e22aa74865 | ||
|
|
285fc69f6a | ||
|
|
72216fe917 | ||
|
|
692027f625 | ||
|
|
801e01bca0 | ||
|
|
6665a9ca69 | ||
|
|
1c02a417db | ||
|
|
9ec26e776d | ||
|
|
cf82483420 | ||
|
|
db998e9c0f | ||
|
|
f0f15f899c | ||
|
|
36f920bcd7 | ||
|
|
7dc091052a | ||
|
|
17e44af542 | ||
|
|
ac8ef29d35 | ||
|
|
48e47ddc23 | ||
|
|
6acd3d6028 | ||
|
|
7fd5c81674 | ||
|
|
7fa6c1e8d0 | ||
|
|
cc4d5306eb | ||
|
|
02dcb5e182 | ||
|
|
f9ea3935ff | ||
|
|
2088335b9d | ||
|
|
9804310cc8 | ||
|
|
07e574db44 | ||
|
|
dd841f32db | ||
|
|
665f93bbb7 | ||
|
|
32eeb96ce7 | ||
|
|
172bfacae0 | ||
|
|
0a5494dd79 | ||
|
|
044202b37f | ||
|
|
d68ec37942 | ||
|
|
0edcae9e04 | ||
|
|
d1850ea27d | ||
|
|
60a031a713 | ||
|
|
8a05fe86d6 | ||
|
|
8a21198f56 | ||
|
|
b212368a70 | ||
|
|
954ff32503 | ||
|
|
7c13fa95d1 | ||
|
|
09e9d6d778 | ||
|
|
fb3f710523 | ||
|
|
06ec571c20 | ||
|
|
683a58195e | ||
|
|
86607452d7 | ||
|
|
05aa5f2d38 | ||
|
|
68097132fe | ||
|
|
6d29d75724 | ||
|
|
38f87981c1 | ||
|
|
3a34856dfe | ||
|
|
973738d30f | ||
|
|
747b34c2c8 | ||
|
|
dcae513487 | ||
|
|
18c025f10e | ||
|
|
e45a7749b0 | ||
|
|
b7ea145f38 | ||
|
|
6c61ff0e9e | ||
|
|
45a5eaf913 | ||
|
|
3401cb349b | ||
|
|
d3594835c4 | ||
|
|
8b9a3ea6c3 | ||
|
|
d5aef296ea | ||
|
|
aa83a4c1f5 | ||
|
|
b83463ca76 | ||
|
|
c1ca24e8bc | ||
|
|
b78fe0b898 | ||
|
|
bf1036c78f | ||
|
|
2e3ff9e401 | ||
|
|
eabdf74946 | ||
|
|
cf9820137c | ||
|
|
c017d0fbaf | ||
|
|
16f7d5801b | ||
|
|
62b2963781 | ||
|
|
cd9858420f | ||
|
|
4410da98be | ||
|
|
b89aa02d77 | ||
|
|
3dfb3e641b | ||
|
|
a3f228d05a | ||
|
|
eaf9ebc2ca | ||
|
|
55e4183825 | ||
|
|
aeb3437a9f | ||
|
|
6e7de3c8d9 | ||
|
|
d0175392c0 | ||
|
|
c4b3970c70 | ||
|
|
72eb17d314 | ||
|
|
0efe5ee7d5 | ||
|
|
0e3dd3cb3b | ||
|
|
56b237e7b8 | ||
|
|
2865a0367b | ||
|
|
232cc320bd | ||
|
|
e7edc46daf | ||
|
|
6813ab4e65 | ||
|
|
fd714cbceb | ||
|
|
db6bd890d9 | ||
|
|
7a46c5ff31 | ||
|
|
98a9042c07 | ||
|
|
4170e18dea | ||
|
|
230ef2484d | ||
|
|
beba92aed4 | ||
|
|
cbb693e99e | ||
|
|
774e068436 | ||
|
|
86ba21029d | ||
|
|
316ac61875 | ||
|
|
d5d264d13b | ||
|
|
c71e1adc93 | ||
|
|
564d0ae974 | ||
|
|
9a48ec194e | ||
|
|
bb0a7f91cc | ||
|
|
73e54352cd | ||
|
|
64fa6fd9e5 | ||
|
|
2d3f92aeed | ||
|
|
df5750a21c | ||
|
|
e996a5246b | ||
|
|
bbac86f745 | ||
|
|
22556fb24c | ||
|
|
2374cb1bc5 | ||
|
|
c7b0241a48 | ||
|
|
5e445f5a48 | ||
|
|
e86a74156e | ||
|
|
64d150e215 | ||
|
|
dc85a276cd | ||
|
|
9e9856bb45 | ||
|
|
890e6280df | ||
|
|
c94ff3430c | ||
|
|
da7e4b3a09 | ||
|
|
a214069586 | ||
|
|
d4b185be5e | ||
|
|
747a7de168 | ||
|
|
bfa47b3663 | ||
|
|
0e7f14159a | ||
|
|
b755ce9528 | ||
|
|
f3cae55bd4 | ||
|
|
f64bd55bc6 | ||
|
|
4c8bb846ea | ||
|
|
bd14fb90fc | ||
|
|
9e5bce90f4 | ||
|
|
72c7d4c886 | ||
|
|
558b637b07 | ||
|
|
767341b279 | ||
|
|
5e7737f55d | ||
|
|
c73916b4e7 | ||
|
|
0361ca1c39 | ||
|
|
cd4cd22928 | ||
|
|
e1a0cf6ca5 | ||
|
|
73bb9d5afb | ||
|
|
183df4c135 | ||
|
|
f2b238f50a | ||
|
|
09194aa613 | ||
|
|
e58327d4ed | ||
|
|
8414aa6e4b | ||
|
|
7d1d690eb7 | ||
|
|
47ad7ccb5f | ||
|
|
679c4183e7 | ||
|
|
8807c75c51 | ||
|
|
be9d8f7ce3 | ||
|
|
a7a43a1124 | ||
|
|
7a6ceebb34 | ||
|
|
8b2862a1b8 | ||
|
|
1d4b5c201e | ||
|
|
f983145897 | ||
|
|
d369f542c5 | ||
|
|
6c8a44b056 | ||
|
|
ef18f93609 | ||
|
|
540afb1573 | ||
|
|
2d7a924275 | ||
|
|
702799290f | ||
|
|
f7d3d371f7 | ||
|
|
311d20eeb2 | ||
|
|
afa913f2ed | ||
|
|
f0554676dd | ||
|
|
3337b9a98f | ||
|
|
22fdb9594d | ||
|
|
93a0052219 | ||
|
|
5c852e26c2 | ||
|
|
7d2118cd97 | ||
|
|
5e3c178b9e | ||
|
|
35aa78dad9 | ||
|
|
7747f5a3fa | ||
|
|
a2f1e76fea | ||
|
|
cf515bc5ca | ||
|
|
97cbfa11b7 | ||
|
|
f2b76d8b3b | ||
|
|
e2a6d02570 | ||
|
|
1d78ffc04d | ||
|
|
42b9d42a8f | ||
|
|
7dbbe84086 | ||
|
|
e9b85f5acb | ||
|
|
cb3b0ab2bb | ||
|
|
de772bf1f9 | ||
|
|
91a9bae308 | ||
|
|
fe7c152c97 | ||
|
|
333c7ce1c9 | ||
|
|
ef2303bc5d | ||
|
|
6d2b4ab775 | ||
|
|
b3dedfedc0 | ||
|
|
2a3743ff84 | ||
|
|
a5afd83c7b | ||
|
|
e8d1bab914 | ||
|
|
de654de911 | ||
|
|
37c0f75499 | ||
|
|
5c5c1c80cf | ||
|
|
e91ee9f62a | ||
|
|
213b4eace8 | ||
|
|
f695c0c164 | ||
|
|
194b6eb9d8 | ||
|
|
2aba16e2c9 | ||
|
|
0b09082450 | ||
|
|
29aa972f18 | ||
|
|
06b814b627 | ||
|
|
8c0994e290 | ||
|
|
b1d251e950 | ||
|
|
63cdbef219 | ||
|
|
8a8f0ab3ec | ||
|
|
1ef0359731 | ||
|
|
38863d3025 | ||
|
|
44f4372ca3 | ||
|
|
46d3769a44 | ||
|
|
65b7d71bdf | ||
|
|
1d67e38f78 | ||
|
|
3697a1af4d | ||
|
|
26ff596983 | ||
|
|
b33db9c1ab | ||
|
|
867469e9b3 | ||
|
|
a4fc5c6975 | ||
|
|
e87ccbfa22 | ||
|
|
17c15a74a2 | ||
|
|
8bbdf2e7cb | ||
|
|
b66058e417 | ||
|
|
4fce0181ab | ||
|
|
ba9678bd61 | ||
|
|
74e577610a | ||
|
|
37ec1a978e | ||
|
|
27fa9969f3 | ||
|
|
4045ffea3c | ||
|
|
e9e067eebf | ||
|
|
93176c91f4 | ||
|
|
7ee5973400 | ||
|
|
043e62ab63 | ||
|
|
f91f665f3f | ||
|
|
f985f42e93 | ||
|
|
c77f5f6252 | ||
|
|
60cae87bfa | ||
|
|
eda33f7d11 | ||
|
|
d1cf445327 | ||
|
|
8e3dd11f81 | ||
|
|
80a4beace6 | ||
|
|
6dc821186e | ||
|
|
26ec0716b9 | ||
|
|
97af576f6a | ||
|
|
0e986df7e5 | ||
|
|
45011c0fad | ||
|
|
ca919dddd6 | ||
|
|
6eea5dd109 | ||
|
|
46ee2eeded | ||
|
|
3741186656 | ||
|
|
704db225d1 | ||
|
|
ce0e9594df | ||
|
|
835b7eb6f7 | ||
|
|
172ff846fd | ||
|
|
97fddc45d9 | ||
|
|
8a018ce3ba | ||
|
|
baaec9db87 | ||
|
|
5d5c964d06 | ||
|
|
502d3fb335 | ||
|
|
5654322f54 | ||
|
|
bea31fdcb0 | ||
|
|
529002c2b7 | ||
|
|
4367d74102 | ||
|
|
04e34b8ca7 | ||
|
|
5ad8e23eae | ||
|
|
2db4b57013 | ||
|
|
d678fe4bfa | ||
|
|
be7fb9d3df | ||
|
|
39755a294a | ||
|
|
a8dcea1422 | ||
|
|
2080458f0d | ||
|
|
3398426293 | ||
|
|
878ffafb51 | ||
|
|
2233751668 | ||
|
|
b86831356b | ||
|
|
453e826a0f | ||
|
|
55b1456d45 | ||
|
|
47c59afea0 | ||
|
|
41222792ed | ||
|
|
5659faf7f0 | ||
|
|
2e75d9c80a | ||
|
|
0fcf8838cc | ||
|
|
758aae8556 | ||
|
|
ffbbd968c2 | ||
|
|
0d0dd250ee | ||
|
|
e3aaedbc33 | ||
|
|
81e674ad36 | ||
|
|
f6f5405a2c | ||
|
|
551ff6a6fb | ||
|
|
d3e5092b43 | ||
|
|
3fe8cdece3 | ||
|
|
69f203a718 | ||
|
|
a97f978cad | ||
|
|
07a4553e6e | ||
|
|
e33798ff90 | ||
|
|
d9faff19a5 | ||
|
|
4f0ab4f226 | ||
|
|
05740e0f64 | ||
|
|
666dc65b8e | ||
|
|
76a1b3286b | ||
|
|
9d9d2a2a98 | ||
|
|
219c8b927d | ||
|
|
c616958557 | ||
|
|
453ab95e54 | ||
|
|
7fdab46729 | ||
|
|
798061506e | ||
|
|
0ad0d4ea11 | ||
|
|
f7b52d16f5 | ||
|
|
e24a29b146 | ||
|
|
ffb2640736 | ||
|
|
f9492691a6 | ||
|
|
1c0e6d76f0 | ||
|
|
88c04ce959 | ||
|
|
5ead23a8d4 | ||
|
|
d0ccb54aba | ||
|
|
aaad01105e | ||
|
|
6bdd433570 | ||
|
|
c767e5ebed | ||
|
|
4718efab9b | ||
|
|
145493388a | ||
|
|
16bd0d134e | ||
|
|
f58cbc2594 | ||
|
|
1e190e462a | ||
|
|
70da2b7b4d | ||
|
|
2297c58ab6 | ||
|
|
5e97e29f95 | ||
|
|
5037282b98 | ||
|
|
0b3685e529 | ||
|
|
2adb80729b | ||
|
|
c074c8d0ca | ||
|
|
2b62573b65 | ||
|
|
16fd12024e | ||
|
|
bf3466f3cb | ||
|
|
eebd2efcbf | ||
|
|
c573310c77 | ||
|
|
d6691fe9d8 | ||
|
|
275f071b12 | ||
|
|
35a8f7ebca | ||
|
|
ad8d550d73 | ||
|
|
fceeaf42ca | ||
|
|
30fdff17b5 | ||
|
|
6d53862142 | ||
|
|
1c27a0c1cf | ||
|
|
5ef753bfa8 | ||
|
|
52ce80f2b4 | ||
|
|
d8a790a13c | ||
|
|
20801263ec | ||
|
|
4cf52ea025 | ||
|
|
de132d39ec | ||
|
|
114c0ea85c | ||
|
|
51ef39592f | ||
|
|
eb3ca82fa0 | ||
|
|
0a4c473a7c | ||
|
|
1ec534d607 | ||
|
|
905168e72e | ||
|
|
a081dc7674 | ||
|
|
924fd82d7f | ||
|
|
2177fd59ef | ||
|
|
d81feb05d1 | ||
|
|
0a620514b7 | ||
|
|
e52232d85f | ||
|
|
4cdd81ec86 | ||
|
|
6e711ed739 | ||
|
|
8778787091 | ||
|
|
ce8bcf7932 | ||
|
|
abaef98fd8 | ||
|
|
ddc5e57d4d | ||
|
|
d46f684bb8 | ||
|
|
c723554d2e | ||
|
|
021f4a881c | ||
|
|
ada5e6ae68 | ||
|
|
8e7a8d8c97 | ||
|
|
9151f8b492 | ||
|
|
86cb865fdd | ||
|
|
38cb2601d7 | ||
|
|
94173c273a | ||
|
|
01449e486c | ||
|
|
8111b227c4 | ||
|
|
8bb471bccd | ||
|
|
5074b526d0 | ||
|
|
1608cd2d53 | ||
|
|
a123ef6fce | ||
|
|
23ec780a13 | ||
|
|
5569f96885 | ||
|
|
930be3d0e5 | ||
|
|
97ff90f8fa | ||
|
|
f84b1d0de9 | ||
|
|
8423325a6e | ||
|
|
97273655dc | ||
|
|
10acc04ba5 | ||
|
|
d20b6adfd2 | ||
|
|
a4c650316a | ||
|
|
28f57667f0 | ||
|
|
f53d2e3a46 | ||
|
|
7b76aa2078 | ||
|
|
d76a3b87c5 | ||
|
|
da6d384300 | ||
|
|
4c489d18a2 | ||
|
|
9785f14df8 | ||
|
|
d35b273dbf | ||
|
|
13c828f112 | ||
|
|
ea6ee8e899 | ||
|
|
1d3a21f6c8 | ||
|
|
3daa0b5e63 | ||
|
|
5426ef0b46 | ||
|
|
860a6a231d | ||
|
|
da7fc8dbb3 | ||
|
|
f03f4775fc | ||
|
|
0e39d62c9d | ||
|
|
d196e4a8df | ||
|
|
a59dadccc9 | ||
|
|
05db79ee35 | ||
|
|
d552803f56 | ||
|
|
d2a10413a1 | ||
|
|
ca8f5861fe | ||
|
|
7536744dcf | ||
|
|
8ba0385b3a | ||
|
|
4554c4bda9 | ||
|
|
3206f92063 | ||
|
|
fd04a19544 | ||
|
|
f046af337a | ||
|
|
9a5542100a | ||
|
|
ac152abc75 | ||
|
|
0b6a182a44 | ||
|
|
b774563ec3 | ||
|
|
ca7aa69597 | ||
|
|
5aeabe39b5 | ||
|
|
5f79ff340d | ||
|
|
5a2b439773 | ||
|
|
cfbbcd420f | ||
|
|
59f765f7be | ||
|
|
528e39fcb3 | ||
|
|
2b16e69e90 | ||
|
|
09ebd1a557 | ||
|
|
edc2a28f1d | ||
|
|
7fe8580da5 | ||
|
|
7cc9c83ab8 | ||
|
|
0962292f92 | ||
|
|
b7f2487c4f | ||
|
|
db86647e3a | ||
|
|
7415627d95 | ||
|
|
fa6bae988e | ||
|
|
2c98bf0cc7 | ||
|
|
351313523c | ||
|
|
80ecbeddbb | ||
|
|
8222f803d5 | ||
|
|
d5b33671c2 | ||
|
|
e86749dfe2 | ||
|
|
ec5903ca19 | ||
|
|
b5dcb5964a | ||
|
|
8417f516e5 | ||
|
|
9532441ed4 | ||
|
|
630dfb9b55 | ||
|
|
f31dc791e4 | ||
|
|
ba881eb4cf | ||
|
|
ad5793e446 | ||
|
|
997d49b63f | ||
|
|
72fb6afae2 | ||
|
|
f9df806f15 | ||
|
|
01737ef1cc | ||
|
|
3321f36b51 | ||
|
|
64bdd620ac | ||
|
|
82f5984de1 | ||
|
|
b8bbbf3ea3 | ||
|
|
247b5205fb | ||
|
|
2b83089da8 | ||
|
|
7290431cb0 | ||
|
|
95a75daf9f | ||
|
|
80ed6b8c25 | ||
|
|
49d64f7f7e | ||
|
|
f09f38085e | ||
|
|
04a9822573 | ||
|
|
5848877734 | ||
|
|
93814cc85a | ||
|
|
4f30311971 | ||
|
|
cfe5134375 | ||
|
|
219d3c9f18 | ||
|
|
9110776a01 | ||
|
|
625c6951bb | ||
|
|
56235aee90 | ||
|
|
e14c80360d | ||
|
|
98d51d3d80 | ||
|
|
4f45c623a5 | ||
|
|
c96613a499 | ||
|
|
e1e01524e7 | ||
|
|
0926f95979 | ||
|
|
a4decaa188 | ||
|
|
27f7d3a658 | ||
|
|
0e6ff668eb | ||
|
|
fba3ed7b4d | ||
|
|
648130eec5 | ||
|
|
606a58bc6b | ||
|
|
09a645e455 | ||
|
|
d972a47c84 | ||
|
|
494c774303 | ||
|
|
28ac2fce61 | ||
|
|
5095e6f07b | ||
|
|
9a3b2abbab | ||
|
|
4e5b11b1d5 | ||
|
|
7eb2710e67 | ||
|
|
0a36db06ed | ||
|
|
e86f90fe8d | ||
|
|
953effcc43 | ||
|
|
a62e44c4e5 | ||
|
|
84a632787c | ||
|
|
16f0daab90 | ||
|
|
3149390b3b | ||
|
|
0185090cbb | ||
|
|
806f7dd15f | ||
|
|
013ebc617e | ||
|
|
63a60cdd75 | ||
|
|
4bcc71c68f | ||
|
|
7f1374e058 | ||
|
|
3935fd77ac | ||
|
|
9d0c8ae3dd | ||
|
|
4e7fd5b6d7 | ||
|
|
a4ded8c2b9 | ||
|
|
4a75e1e4b4 | ||
|
|
11b11e416b | ||
|
|
1f660c9e04 | ||
|
|
20ffce5c0d | ||
|
|
a7ef61279c | ||
|
|
5ee85dc263 | ||
|
|
93dc33687a | ||
|
|
932ab61c2d | ||
|
|
1d9b1f4aab | ||
|
|
7aed16ce4c | ||
|
|
9f4506bda5 | ||
|
|
fa6f9f4ae0 | ||
|
|
78ff5e270c | ||
|
|
6d1682a27e | ||
|
|
64768f093d | ||
|
|
a24db6c584 | ||
|
|
050a0ec5e4 | ||
|
|
0254e4b365 | ||
|
|
3ebe4ebb3d | ||
|
|
094baf8aa9 | ||
|
|
ff5ac51c54 | ||
|
|
9e130af9e7 | ||
|
|
bed7158212 | ||
|
|
398cbd7f2c | ||
|
|
5aa90b0478 | ||
|
|
86c936759b | ||
|
|
22bdc43023 | ||
|
|
ec2bc0baf6 | ||
|
|
5b860261a0 | ||
|
|
010e32d778 | ||
|
|
1097d29213 | ||
|
|
a6492b1ed6 | ||
|
|
59d2034cbb | ||
|
|
39ef3a701b | ||
|
|
7fdffc0340 | ||
|
|
f2bd680cc5 | ||
|
|
59f554b658 | ||
|
|
0ad38fe38f | ||
|
|
5c4db23da4 | ||
|
|
708a8b6543 | ||
|
|
d8e58e67c6 | ||
|
|
6c7874c883 | ||
|
|
15204a9b90 | ||
|
|
489d5239a5 | ||
|
|
f934ebd429 | ||
|
|
fccdd70524 | ||
|
|
5e40dda3bc | ||
|
|
fb8340acb2 | ||
|
|
20fbd66c90 | ||
|
|
b27ee8241a | ||
|
|
7806a9885a | ||
|
|
6e4889d340 | ||
|
|
679a8e0c24 | ||
|
|
6c3d8ec1de | ||
|
|
29078aaae9 | ||
|
|
8a45148070 | ||
|
|
df635579c4 | ||
|
|
788c7dbf48 | ||
|
|
99ecef89b8 | ||
|
|
51ca460f18 | ||
|
|
e236173417 | ||
|
|
15191ff80f | ||
|
|
efd2129187 | ||
|
|
73da4b9eed | ||
|
|
36ff37ba47 | ||
|
|
a33784c434 | ||
|
|
deb013cecb | ||
|
|
cb411637cc | ||
|
|
be89466367 | ||
|
|
111c7cf688 | ||
|
|
75e0387be2 | ||
|
|
c4e32fac1f | ||
|
|
038e83b647 | ||
|
|
82ef0529d8 | ||
|
|
6abfbbddd5 | ||
|
|
ad889a7240 | ||
|
|
e22ae9f826 | ||
|
|
d3e95d6b77 | ||
|
|
8db262c941 | ||
|
|
793eda986b | ||
|
|
1cd49cec39 | ||
|
|
10c1399474 | ||
|
|
4709e231b8 | ||
|
|
f8a14184c7 | ||
|
|
0155a31d1f | ||
|
|
8848c549a0 | ||
|
|
4919a005d3 | ||
|
|
dabe14889d | ||
|
|
cb8e105a94 | ||
|
|
efdfd3ee3e | ||
|
|
4e1ef09751 | ||
|
|
6d1e711b2a | ||
|
|
e19087722f | ||
|
|
d3ac243cea | ||
|
|
348dadf7ae | ||
|
|
cba5ae81ed | ||
|
|
6d328c0a71 | ||
|
|
7a7066896e | ||
|
|
a2c0c10d2a | ||
|
|
c473d3c682 | ||
|
|
bedbdcaf13 | ||
|
|
87e6c0973a | ||
|
|
78876947a4 | ||
|
|
b59f58435c | ||
|
|
4adb83eaae | ||
|
|
4ac9828b0c | ||
|
|
77f6e0d4f8 | ||
|
|
835dbfe001 | ||
|
|
f5eb3fd086 | ||
|
|
da9630c561 | ||
|
|
a89faa72ea | ||
|
|
e042ce21f6 | ||
|
|
d4fef1b5f8 | ||
|
|
d5c4b66ec7 | ||
|
|
0009f7c8dc | ||
|
|
cd2e794d3f | ||
|
|
9bb862d025 | ||
|
|
91bb559bdf | ||
|
|
7fb4851eb9 | ||
|
|
6c2fa9086e | ||
|
|
0d61e0d717 | ||
|
|
d0585ca7bb | ||
|
|
14cda27e9f | ||
|
|
cf177bfea5 | ||
|
|
f84bbd4520 | ||
|
|
2bf8fb8c84 | ||
|
|
a553db4b82 | ||
|
|
121be5c6e8 | ||
|
|
e23e3db5b5 | ||
|
|
babaab20ea | ||
|
|
9d67c16ab9 | ||
|
|
9908031b0b | ||
|
|
6b3282150b | ||
|
|
58cfac9f67 | ||
|
|
340d11be38 | ||
|
|
62b15ecc12 | ||
|
|
6b9d392d0e | ||
|
|
9c68123ede | ||
|
|
7049b6478c | ||
|
|
0e6d34c0c9 | ||
|
|
a01fa11a26 | ||
|
|
fb033a3719 | ||
|
|
a03931daab | ||
|
|
6ed1c9e905 | ||
|
|
e38f4219c5 | ||
|
|
30b6f38704 | ||
|
|
04e4bab313 | ||
|
|
dddf7951ef | ||
|
|
b13681df32 | ||
|
|
a21234cd54 | ||
|
|
4f4cebadc7 | ||
|
|
f1c452754f | ||
|
|
b9d67296ef | ||
|
|
483e82e14b | ||
|
|
a0c0d9c98a | ||
|
|
322b33197c | ||
|
|
cc859d3948 | ||
|
|
200b0f72cc | ||
|
|
8f19fff1ec | ||
|
|
b534ab9d3c | ||
|
|
2ea5abdfb5 | ||
|
|
d53c6f2599 | ||
|
|
5e2c28d7e9 | ||
|
|
bca516b028 | ||
|
|
92598237c3 | ||
|
|
5074ce5a38 | ||
|
|
b8475114ba | ||
|
|
443473f833 | ||
|
|
4e82cf369c | ||
|
|
d547c2588c | ||
|
|
cb8e209f78 | ||
|
|
3bd9d55a15 | ||
|
|
d6e6eedd58 | ||
|
|
7459ec6bba | ||
|
|
226786c1da | ||
|
|
4d2d8b2d11 | ||
|
|
becbff0b13 | ||
|
|
4bcf01938c | ||
|
|
bef7d64e66 | ||
|
|
695f6cfe45 |
+94
-2
@@ -113,7 +113,7 @@ jobs:
|
|||||||
test: &test
|
test: &test
|
||||||
description: |
|
description: |
|
||||||
Run tests with gotestsum.
|
Run tests with gotestsum.
|
||||||
parameters:
|
parameters: &test-params
|
||||||
executor:
|
executor:
|
||||||
type: executor
|
type: executor
|
||||||
default: golang
|
default: golang
|
||||||
@@ -161,6 +161,7 @@ jobs:
|
|||||||
name: go test
|
name: go test
|
||||||
environment:
|
environment:
|
||||||
LOTUS_TEST_WINDOW_POST: << parameters.winpost-test >>
|
LOTUS_TEST_WINDOW_POST: << parameters.winpost-test >>
|
||||||
|
SKIP_CONFORMANCE: "1"
|
||||||
command: |
|
command: |
|
||||||
mkdir -p /tmp/test-reports/<< parameters.test-suite-name >>
|
mkdir -p /tmp/test-reports/<< parameters.test-suite-name >>
|
||||||
mkdir -p /tmp/test-artifacts
|
mkdir -p /tmp/test-artifacts
|
||||||
@@ -191,6 +192,87 @@ jobs:
|
|||||||
<<: *test
|
<<: *test
|
||||||
test-window-post:
|
test-window-post:
|
||||||
<<: *test
|
<<: *test
|
||||||
|
test-conformance:
|
||||||
|
description: |
|
||||||
|
Run tests using a corpus of interoperable test vectors for Filecoin
|
||||||
|
implementations to test their correctness and compliance with the Filecoin
|
||||||
|
specifications.
|
||||||
|
parameters:
|
||||||
|
<<: *test-params
|
||||||
|
vectors-branch:
|
||||||
|
type: string
|
||||||
|
default: ""
|
||||||
|
description: |
|
||||||
|
Branch on github.com/filecoin-project/test-vectors to checkout and
|
||||||
|
test with. If empty (the default) the commit defined by the git
|
||||||
|
submodule is used.
|
||||||
|
executor: << parameters.executor >>
|
||||||
|
steps:
|
||||||
|
- install-deps
|
||||||
|
- prepare
|
||||||
|
- run:
|
||||||
|
command: make deps lotus
|
||||||
|
no_output_timeout: 30m
|
||||||
|
- download-params
|
||||||
|
- when:
|
||||||
|
condition:
|
||||||
|
not:
|
||||||
|
equal: [ "", << parameters.vectors-branch >> ]
|
||||||
|
steps:
|
||||||
|
- run:
|
||||||
|
name: checkout vectors branch
|
||||||
|
command: |
|
||||||
|
cd extern/test-vectors
|
||||||
|
git fetch
|
||||||
|
git checkout origin/<< parameters.vectors-branch >>
|
||||||
|
- go/install-gotestsum:
|
||||||
|
gobin: $HOME/.local/bin
|
||||||
|
version: 0.5.2
|
||||||
|
- run:
|
||||||
|
name: install statediff globally
|
||||||
|
command: |
|
||||||
|
## statediff is optional; we succeed even if compilation fails.
|
||||||
|
mkdir -p /tmp/statediff
|
||||||
|
git clone https://github.com/filecoin-project/statediff.git /tmp/statediff
|
||||||
|
cd /tmp/statediff
|
||||||
|
go install ./cmd/statediff || exit 0
|
||||||
|
- run:
|
||||||
|
name: go test
|
||||||
|
environment:
|
||||||
|
SKIP_CONFORMANCE: "0"
|
||||||
|
command: |
|
||||||
|
mkdir -p /tmp/test-reports
|
||||||
|
mkdir -p /tmp/test-artifacts
|
||||||
|
gotestsum \
|
||||||
|
--format pkgname-and-test-fails \
|
||||||
|
--junitfile /tmp/test-reports/junit.xml \
|
||||||
|
-- \
|
||||||
|
-v -coverpkg ./chain/vm/,github.com/filecoin-project/specs-actors/... -coverprofile=/tmp/conformance.out ./conformance/
|
||||||
|
go tool cover -html=/tmp/conformance.out -o /tmp/test-artifacts/conformance-coverage.html
|
||||||
|
no_output_timeout: 30m
|
||||||
|
- store_test_results:
|
||||||
|
path: /tmp/test-reports
|
||||||
|
- store_artifacts:
|
||||||
|
path: /tmp/test-artifacts/conformance-coverage.html
|
||||||
|
build-lotus-soup:
|
||||||
|
description: |
|
||||||
|
Compile `lotus-soup` Testground test plan using the current version of Lotus.
|
||||||
|
parameters:
|
||||||
|
<<: *test-params
|
||||||
|
executor: << parameters.executor >>
|
||||||
|
steps:
|
||||||
|
- install-deps
|
||||||
|
- prepare
|
||||||
|
- run: cd extern/oni && git submodule sync
|
||||||
|
- run: cd extern/oni && git submodule update --init
|
||||||
|
- run: cd extern/filecoin-ffi && make
|
||||||
|
- run:
|
||||||
|
name: "replace lotus, filecoin-ffi, blst and fil-blst deps"
|
||||||
|
command: cd extern/oni/lotus-soup && go mod edit -replace github.com/filecoin-project/lotus=../../../ && go mod edit -replace github.com/filecoin-project/filecoin-ffi=../../filecoin-ffi && go mod edit -replace github.com/supranational/blst=../../fil-blst/blst && go mod edit -replace github.com/filecoin-project/fil-blst=../../fil-blst
|
||||||
|
- run:
|
||||||
|
name: "build lotus-soup testplan"
|
||||||
|
command: pushd extern/oni/lotus-soup && go build -tags=testground .
|
||||||
|
|
||||||
|
|
||||||
build-macos:
|
build-macos:
|
||||||
description: build darwin lotus binary
|
description: build darwin lotus binary
|
||||||
@@ -337,7 +419,8 @@ workflows:
|
|||||||
version: 2.1
|
version: 2.1
|
||||||
ci:
|
ci:
|
||||||
jobs:
|
jobs:
|
||||||
- lint-all
|
- lint-all:
|
||||||
|
concurrency: "16" # expend all docker 2xlarge CPUs.
|
||||||
- mod-tidy-check
|
- mod-tidy-check
|
||||||
- gofmt
|
- gofmt
|
||||||
- cbor-gen-check
|
- cbor-gen-check
|
||||||
@@ -356,6 +439,15 @@ workflows:
|
|||||||
tags:
|
tags:
|
||||||
only:
|
only:
|
||||||
- /^v\d+\.\d+\.\d+$/
|
- /^v\d+\.\d+\.\d+$/
|
||||||
|
- test-conformance:
|
||||||
|
test-suite-name: conformance
|
||||||
|
packages: "./conformance"
|
||||||
|
- test-conformance:
|
||||||
|
name: test-conformance-bleeding-edge
|
||||||
|
test-suite-name: conformance-bleeding-edge
|
||||||
|
packages: "./conformance"
|
||||||
|
vectors-branch: master
|
||||||
|
- build-lotus-soup
|
||||||
- build-debug
|
- build-debug
|
||||||
- build-all:
|
- build-all:
|
||||||
requires:
|
requires:
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
comment: off
|
comment: off
|
||||||
ignore:
|
ignore:
|
||||||
- "cbor_gen.go"
|
- "cbor_gen.go"
|
||||||
|
github_checks:
|
||||||
|
annotations: false
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
## filecoin-project/lotus CODEOWNERS
|
||||||
|
## Refer to https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners.
|
||||||
|
##
|
||||||
|
## These users or groups will be automatically assigned as reviewers every time
|
||||||
|
## a PR is submitted that modifies code in the specified locations.
|
||||||
|
##
|
||||||
|
## The Lotus repo configuration requires that at least ONE codeowner approves
|
||||||
|
## the PR before merging.
|
||||||
|
|
||||||
|
### Global owners.
|
||||||
|
* @magik6k @whyrusleeping @Kubuxu
|
||||||
|
|
||||||
|
### Conformance testing.
|
||||||
|
conformance/ @raulk
|
||||||
|
extern/test-vectors @raulk
|
||||||
+8
-2
@@ -26,11 +26,14 @@
|
|||||||
color: 00A4E2
|
color: 00A4E2
|
||||||
description: "Area: Chain/VM"
|
description: "Area: Chain/VM"
|
||||||
- name: area/chain/sync
|
- name: area/chain/sync
|
||||||
color: 00A4E2
|
color: 00A4E4
|
||||||
description: "Area: Chain/Sync"
|
description: "Area: Chain/Sync"
|
||||||
- name: area/chain/misc
|
- name: area/chain/misc
|
||||||
color: 00A4E2
|
color: 00A4E6
|
||||||
description: "Area: Chain/Misc"
|
description: "Area: Chain/Misc"
|
||||||
|
- name: area/markets
|
||||||
|
color: 00A4E8
|
||||||
|
description: "Area: Markets"
|
||||||
- name: area/sealing/fsm
|
- name: area/sealing/fsm
|
||||||
color: 0bb1ed
|
color: 0bb1ed
|
||||||
description: "Area: Sealing/FSM"
|
description: "Area: Sealing/FSM"
|
||||||
@@ -149,6 +152,9 @@
|
|||||||
- name: impact/test-flakiness
|
- name: impact/test-flakiness
|
||||||
color: DDE1E4
|
color: DDE1E4
|
||||||
description: "Impact: Test Flakiness"
|
description: "Impact: Test Flakiness"
|
||||||
|
- name: impact/consensus
|
||||||
|
color: b20014
|
||||||
|
description: "Impact: Consensus"
|
||||||
|
|
||||||
###
|
###
|
||||||
### Topics
|
### Topics
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
/lotus-fountain
|
/lotus-fountain
|
||||||
/lotus-stats
|
/lotus-stats
|
||||||
/lotus-bench
|
/lotus-bench
|
||||||
|
/lotus-gateway
|
||||||
|
/lotus-pcr
|
||||||
/bench.json
|
/bench.json
|
||||||
/lotuspond/front/node_modules
|
/lotuspond/front/node_modules
|
||||||
/lotuspond/front/build
|
/lotuspond/front/build
|
||||||
|
|||||||
@@ -5,3 +5,12 @@
|
|||||||
[submodule "extern/serialization-vectors"]
|
[submodule "extern/serialization-vectors"]
|
||||||
path = extern/serialization-vectors
|
path = extern/serialization-vectors
|
||||||
url = https://github.com/filecoin-project/serialization-vectors
|
url = https://github.com/filecoin-project/serialization-vectors
|
||||||
|
[submodule "extern/test-vectors"]
|
||||||
|
path = extern/test-vectors
|
||||||
|
url = https://github.com/filecoin-project/test-vectors.git
|
||||||
|
[submodule "extern/fil-blst"]
|
||||||
|
path = extern/fil-blst
|
||||||
|
url = https://github.com/filecoin-project/fil-blst.git
|
||||||
|
[submodule "extern/oni"]
|
||||||
|
path = extern/oni
|
||||||
|
url = https://github.com/filecoin-project/oni
|
||||||
|
|||||||
+345
@@ -1,5 +1,350 @@
|
|||||||
# Lotus changelog
|
# Lotus changelog
|
||||||
|
|
||||||
|
# 0.7.2 / 2020-09-23
|
||||||
|
|
||||||
|
This optional release of Lotus introduces a major refactor around how a Lotus node interacts with code from the specs-actors repo. We now use interfaces to read the state of actors, which is required to be able to reason about different versions of actors code at the same time.
|
||||||
|
|
||||||
|
Additionally, this release introduces various improvements to the sync process, as well as changes to better the overall UX experience.
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
|
||||||
|
#### Core Lotus
|
||||||
|
|
||||||
|
- Network upgrade support (https://github.com/filecoin-project/lotus/pull/3781)
|
||||||
|
- Upgrade markets to `v0.6.2` (https://github.com/filecoin-project/lotus/pull/3974)
|
||||||
|
- Validate chain sync response indices when fetching messages (https://github.com/filecoin-project/lotus/pull/3939)
|
||||||
|
- Add height diff to sync wait (https://github.com/filecoin-project/lotus/pull/3926)
|
||||||
|
- Replace Requires with Wants (https://github.com/filecoin-project/lotus/pull/3898)
|
||||||
|
- Update state diffing for market actor (https://github.com/filecoin-project/lotus/pull/3889)
|
||||||
|
- Parallel fetch for sync (https://github.com/filecoin-project/lotus/pull/3887)
|
||||||
|
- Fix SectorState (https://github.com/filecoin-project/lotus/pull/3881)
|
||||||
|
|
||||||
|
#### User Experience
|
||||||
|
|
||||||
|
- Add basic deal stats api server for spacerace slingshot (https://github.com/filecoin-project/lotus/pull/3963)
|
||||||
|
- When doing `sectors update-state`, show a list of existing states if user inputs an invalid one (https://github.com/filecoin-project/lotus/pull/3944)
|
||||||
|
- Fix `lotus-miner storage find` error (https://github.com/filecoin-project/lotus/pull/3927)
|
||||||
|
- Log shutdown method for lotus daemon and miner (https://github.com/filecoin-project/lotus/pull/3925)
|
||||||
|
- Update build and setup instruction link (https://github.com/filecoin-project/lotus/pull/3919)
|
||||||
|
- Add an option to hide removed sectors from `sectors list` output (https://github.com/filecoin-project/lotus/pull/3903)
|
||||||
|
|
||||||
|
#### Testing and validation
|
||||||
|
|
||||||
|
- Add init.State#Remove() for testing (https://github.com/filecoin-project/lotus/pull/3971)
|
||||||
|
- lotus-shed: add consensus check command (https://github.com/filecoin-project/lotus/pull/3933)
|
||||||
|
- Add keyinfo verify and jwt token command to lotus-shed (https://github.com/filecoin-project/lotus/pull/3914)
|
||||||
|
- Fix conformance gen (https://github.com/filecoin-project/lotus/pull/3892)
|
||||||
|
|
||||||
|
# 0.7.1 / 2020-09-17
|
||||||
|
|
||||||
|
This optional release of Lotus introduces some critical fixes to the window PoSt process. It also upgrades some core dependencies, and introduces many improvements to the mining process, deal-making cycle, and overall User Experience.
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
|
||||||
|
#### Some notable improvements:
|
||||||
|
|
||||||
|
- Correctly construct params for `SubmitWindowedPoSt` messages (https://github.com/filecoin-project/lotus/pull/3909)
|
||||||
|
- Skip sectors correctly for Window PoSt (https://github.com/filecoin-project/lotus/pull/3839)
|
||||||
|
- Split window PoST submission into multiple messages (https://github.com/filecoin-project/lotus/pull/3689)
|
||||||
|
- Improve journal coverage (https://github.com/filecoin-project/lotus/pull/2455)
|
||||||
|
- Allow retrievals while sealing (https://github.com/filecoin-project/lotus/pull/3778)
|
||||||
|
- Don't prune locally published messages (https://github.com/filecoin-project/lotus/pull/3772)
|
||||||
|
- Add get-ask, set-ask retrieval commands (https://github.com/filecoin-project/lotus/pull/3886)
|
||||||
|
- Consistently name winning and window post in logs (https://github.com/filecoin-project/lotus/pull/3873))
|
||||||
|
- Add auto flag to mpool replace (https://github.com/filecoin-project/lotus/pull/3752))
|
||||||
|
|
||||||
|
#### Dependencies
|
||||||
|
|
||||||
|
- Upgrade markets to `v0.6.1` (https://github.com/filecoin-project/lotus/pull/3906)
|
||||||
|
- Upgrade specs-actors to `v0.9.10` (https://github.com/filecoin-project/lotus/pull/3846)
|
||||||
|
- Upgrade badger (https://github.com/filecoin-project/lotus/pull/3739)
|
||||||
|
|
||||||
|
# 0.7.0 / 2020-09-10
|
||||||
|
|
||||||
|
This consensus-breaking release of Lotus is designed to test a network upgrade on the space race testnet. The changes that break consensus are:
|
||||||
|
|
||||||
|
- Upgrading the Drand network used from the test Drand network to the League of Entropy main drand network. This is the same Drand network that will be used in the Filecoin mainnet.
|
||||||
|
- Upgrading to specs-actors v0.9.8, which adds a new method to the Multisig actor.
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
|
||||||
|
#### Core Lotus
|
||||||
|
|
||||||
|
- Fix IsAncestorOf (https://github.com/filecoin-project/lotus/pull/3717)
|
||||||
|
- Update to specs-actors v0.9.8 (https://github.com/filecoin-project/lotus/pull/3725)
|
||||||
|
- Increase chain throughput by 20% (https://github.com/filecoin-project/lotus/pull/3732)
|
||||||
|
- Updare to go-libp2p-pubsub `master` (https://github.com/filecoin-project/lotus/pull/3735)
|
||||||
|
- Drand upgrade (https://github.com/filecoin-project/lotus/pull/3670)
|
||||||
|
- Multisig API additions (https://github.com/filecoin-project/lotus/pull/3590)
|
||||||
|
|
||||||
|
#### Storage Miner
|
||||||
|
|
||||||
|
- Increase the number of times precommit2 is attempted before moving back to precommit1 (https://github.com/filecoin-project/lotus/pull/3720)
|
||||||
|
|
||||||
|
#### Message pool
|
||||||
|
|
||||||
|
- Relax mpool add strictness checks for local pushes (https://github.com/filecoin-project/lotus/pull/3724)
|
||||||
|
|
||||||
|
|
||||||
|
#### Maintenance
|
||||||
|
|
||||||
|
- Fix devnets (https://github.com/filecoin-project/lotus/pull/3712)
|
||||||
|
- Fix(chainwatch): compare prev miner with cur miner (https://github.com/filecoin-project/lotus/pull/3715)
|
||||||
|
- CI: fix statediff build; make optional (https://github.com/filecoin-project/lotus/pull/3729)
|
||||||
|
- Feat: Chaos abort (https://github.com/filecoin-project/lotus/pull/3733)
|
||||||
|
|
||||||
|
## Contributors
|
||||||
|
|
||||||
|
The following contributors had commits go into this release.
|
||||||
|
We are grateful for every contribution!
|
||||||
|
|
||||||
|
| Contributor | Commits | Lines ± |
|
||||||
|
|--------------------|---------|---------------|
|
||||||
|
| arajasek | 28 | +1144/-239 |
|
||||||
|
| Kubuxu | 19 | +452/-261 |
|
||||||
|
| whyrusleeping | 13 | +456/-87 |
|
||||||
|
| vyzo | 11 | +318/-20 |
|
||||||
|
| raulk | 10 | +1289/-350 |
|
||||||
|
| magik6k | 6 | +188/-55 |
|
||||||
|
| dirkmc | 3 | +31/-8 |
|
||||||
|
| alanshaw | 3 | +176/-37 |
|
||||||
|
| Stebalien | 2 | +9/-12 |
|
||||||
|
| lanzafame | 1 | +1/-1 |
|
||||||
|
| frrist | 1 | +1/-1 |
|
||||||
|
| mishmosh | 1 | +1/-1 |
|
||||||
|
| nonsense | 1 | +1/-0 |
|
||||||
|
|
||||||
|
# 0.6.2 / 2020-09-09
|
||||||
|
|
||||||
|
This release introduces some critical fixes to message selection and gas estimation logic. It also adds the ability for nodes to mark a certain tipset as checkpointed, as well as various minor improvements and bugfixes.
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
|
||||||
|
#### Messagepool
|
||||||
|
|
||||||
|
- Warn when optimal selection fails to pack a block and we fall back to random selection (https://github.com/filecoin-project/lotus/pull/3708)
|
||||||
|
- Add basic command for printing gas performance of messages in the mpool (https://github.com/filecoin-project/lotus/pull/3701)
|
||||||
|
- Adjust optimal selection to always try to fill blocks (https://github.com/filecoin-project/lotus/pull/3685)
|
||||||
|
- Fix very minor bug in repub baseFeeLowerBound (https://github.com/filecoin-project/lotus/pull/3663)
|
||||||
|
- Add an auto flag to mpool replace (https://github.com/filecoin-project/lotus/pull/3676)
|
||||||
|
- Fix mpool optimal selection packing failure (https://github.com/filecoin-project/lotus/pull/3698)
|
||||||
|
|
||||||
|
#### Core Lotus
|
||||||
|
|
||||||
|
- Don't use latency as initital estimate for blocksync (https://github.com/filecoin-project/lotus/pull/3648)
|
||||||
|
- Add niceSleep 1 second when drand errors (https://github.com/filecoin-project/lotus/pull/3664)
|
||||||
|
- Fix isChainNearSync check in block validator (https://github.com/filecoin-project/lotus/pull/3650)
|
||||||
|
- Add peer to peer manager before fetching the tipset (https://github.com/filecoin-project/lotus/pull/3667)
|
||||||
|
- Add StageFetchingMessages to sync status (https://github.com/filecoin-project/lotus/pull/3668)
|
||||||
|
- Pass tipset through upgrade logic (https://github.com/filecoin-project/lotus/pull/3673)
|
||||||
|
- Allow nodes to mark tipsets as checkpointed (https://github.com/filecoin-project/lotus/pull/3680)
|
||||||
|
- Remove hard-coded late-fee in window PoSt (https://github.com/filecoin-project/lotus/pull/3702)
|
||||||
|
- Gas: Fix median calc (https://github.com/filecoin-project/lotus/pull/3686)
|
||||||
|
|
||||||
|
#### Storage
|
||||||
|
|
||||||
|
- Storage manager: bail out with an error if unsealed cid is undefined (https://github.com/filecoin-project/lotus/pull/3655)
|
||||||
|
- Storage: return true from Sealer.ReadPiece() on success (https://github.com/filecoin-project/lotus/pull/3657)
|
||||||
|
|
||||||
|
#### Maintenance
|
||||||
|
|
||||||
|
- Resolve lotus, test-vectors, statediff dependency cycle (https://github.com/filecoin-project/lotus/pull/3688)
|
||||||
|
- Paych: add docs on how to use paych status (https://github.com/filecoin-project/lotus/pull/3690)
|
||||||
|
- Initial CODEOWNERS (https://github.com/filecoin-project/lotus/pull/3691)
|
||||||
|
|
||||||
|
# 0.6.1 / 2020-09-08
|
||||||
|
|
||||||
|
This optional release introduces a minor improvement to the sync process, ensuring nodes don't fall behind and then resync.
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
|
||||||
|
- Update `test-vectors` (https://github.com/filecoin-project/lotus/pull/3645)
|
||||||
|
- Revert "only subscribe to pubsub topics once we are synced" (https://github.com/filecoin-project/lotus/pull/3643)
|
||||||
|
|
||||||
|
# 0.6.0 / 2020-09-07
|
||||||
|
|
||||||
|
This consensus-breaking release of Lotus is designed to test a network upgrade on the space race testnet. The changes that break consensus are:
|
||||||
|
|
||||||
|
- Tweaking of some cryptoecon parameters in specs-actors 0.9.7 (https://github.com/filecoin-project/specs-actors/releases/tag/v0.9.7)
|
||||||
|
- Rebalancing FIL distribution to make testnet FIL scarce, which prevents base fee spikes and sets better expectations for mainnet
|
||||||
|
|
||||||
|
This release also introduces many improvements to Lotus! Among them are a new version of go-fil-markets that supports non-blocking retrieval, various spam reduction measures in the messagepool and p2p logic, and UX improvements to payment channels, dealmaking, and state inspection.
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
|
||||||
|
#### Core Lotus and dependencies
|
||||||
|
|
||||||
|
- Implement faucet funds reallocation logic (https://github.com/filecoin-project/lotus/pull/3632)
|
||||||
|
- Network upgrade: Upgrade to correct fork threshold (https://github.com/filecoin-project/lotus/pull/3628)
|
||||||
|
- Update to specs 0.9.7 and markets 0.6.0 (https://github.com/filecoin-project/lotus/pull/3627)
|
||||||
|
- Network upgrade: Perform base fee tamping (https://github.com/filecoin-project/lotus/pull/3623)
|
||||||
|
- Chain events: if cache best() is nil, return chain head (https://github.com/filecoin-project/lotus/pull/3611)
|
||||||
|
- Update to specs actors v0.9.6 (https://github.com/filecoin-project/lotus/pull/3603)
|
||||||
|
|
||||||
|
#### Messagepool
|
||||||
|
|
||||||
|
- Temporarily allow negative chains (https://github.com/filecoin-project/lotus/pull/3625)
|
||||||
|
- Improve publish/republish logic (https://github.com/filecoin-project/lotus/pull/3592)
|
||||||
|
- Fix selection bug; priority messages were not included if other chains were negative (https://github.com/filecoin-project/lotus/pull/3580)
|
||||||
|
- Add defensive check for minimum GasFeeCap for inclusion within the next 20 blocks (https://github.com/filecoin-project/lotus/pull/3579)
|
||||||
|
- Add additional info about gas premium (https://github.com/filecoin-project/lotus/pull/3578)
|
||||||
|
- Fix GasPremium capping logic (https://github.com/filecoin-project/lotus/pull/3552)
|
||||||
|
|
||||||
|
#### Payment channels
|
||||||
|
|
||||||
|
- Get available funds by address or by from/to (https://github.com/filecoin-project/lotus/pull/3547)
|
||||||
|
- Create `lotus paych status` command (https://github.com/filecoin-project/lotus/pull/3523)
|
||||||
|
- Rename CLI command from "paych get" to "paych add-funds" (https://github.com/filecoin-project/lotus/pull/3520)
|
||||||
|
|
||||||
|
#### Peer-to-peer
|
||||||
|
|
||||||
|
- Only subscribe to pubsub topics once we are synced (https://github.com/filecoin-project/lotus/pull/3602)
|
||||||
|
- Reduce mpool add failure log spam (https://github.com/filecoin-project/lotus/pull/3562)
|
||||||
|
- Republish messages even if the chains have negative performance(https://github.com/filecoin-project/lotus/pull/3557)
|
||||||
|
- Adjust gossipsub gossip factor (https://github.com/filecoin-project/lotus/pull/3556)
|
||||||
|
- Integrate pubsub Random Early Drop (https://github.com/filecoin-project/lotus/pull/3518)
|
||||||
|
|
||||||
|
#### Miscellaneous
|
||||||
|
|
||||||
|
- Fix panic in OnDealExpiredSlashed (https://github.com/filecoin-project/lotus/pull/3553)
|
||||||
|
- Robustify state manager against holes in actor method numbers (https://github.com/filecoin-project/lotus/pull/3538)
|
||||||
|
|
||||||
|
#### UX
|
||||||
|
|
||||||
|
- VM: Fix an error message (https://github.com/filecoin-project/lotus/pull/3608)
|
||||||
|
- Documentation: Batch replacement,update lotus-storage-miner to lotus-miner (https://github.com/filecoin-project/lotus/pull/3571)
|
||||||
|
- CLI: Robust actor lookup (https://github.com/filecoin-project/lotus/pull/3535)
|
||||||
|
- Add agent flag to net peers (https://github.com/filecoin-project/lotus/pull/3534)
|
||||||
|
- Add watch option to storage-deals list (https://github.com/filecoin-project/lotus/pull/3527)
|
||||||
|
|
||||||
|
#### Testing & tooling
|
||||||
|
|
||||||
|
- Decommission chain-validation (https://github.com/filecoin-project/lotus/pull/3606)
|
||||||
|
- Metrics: add expected height metric (https://github.com/filecoin-project/lotus/pull/3586)
|
||||||
|
- PCR: Use current tipset during refund (https://github.com/filecoin-project/lotus/pull/3570)
|
||||||
|
- Lotus-shed: Add math command (https://github.com/filecoin-project/lotus/pull/3568)
|
||||||
|
- PCR: Add tipset aggergation (https://github.com/filecoin-project/lotus/pull/3565)- Fix broken paych tests (https://github.com/filecoin-project/lotus/pull/3551)
|
||||||
|
- Make chain export ~1000x times faster (https://github.com/filecoin-project/lotus/pull/3533)
|
||||||
|
- Chainwatch: Stop SyncIncomingBlocks from leaking into chainwatch processing; No panics during processing (https://github.com/filecoin-project/lotus/pull/3526)
|
||||||
|
- Conformance: various changes (https://github.com/filecoin-project/lotus/pull/3521)
|
||||||
|
|
||||||
|
# 0.5.10 / 2020-09-03
|
||||||
|
|
||||||
|
This patch includes a crucial fix to the message pool selection logic, strongly disfavouring messages that might cause a miner penalty.
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
|
||||||
|
- Fix calculation of GasReward in messagepool (https://github.com/filecoin-project/lotus/pull/3528)
|
||||||
|
|
||||||
|
# 0.5.9 / 2020-09-03
|
||||||
|
|
||||||
|
This patch includes a hotfix to the `GasEstimateFeeCap` method, capping the estimated fee to a reasonable level by default.
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
|
||||||
|
- Added target height to sync wait (https://github.com/filecoin-project/lotus/pull/3502)
|
||||||
|
- Disable codecov annotations (https://github.com/filecoin-project/lotus/pull/3514)
|
||||||
|
- Cap fees to reasonable level by default (https://github.com/filecoin-project/lotus/pull/3516)
|
||||||
|
- Add APIs and command to inspect bandwidth usage (https://github.com/filecoin-project/lotus/pull/3497)
|
||||||
|
- Track expected nonce in mpool, ignore messages with large nonce gaps (https://github.com/filecoin-project/lotus/pull/3450)
|
||||||
|
|
||||||
|
# 0.5.8 / 2020-09-02
|
||||||
|
|
||||||
|
This patch includes some bugfixes to the sector sealing process, and updates go-fil-markets. It also improves the performance of blocksync, adds a method to export chain state trees, and improves chainwatch.
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
|
||||||
|
- Upgrade markets to v0.5.9 (https://github.com/filecoin-project/lotus/pull/3496)
|
||||||
|
- Improve blocksync to load fewer messages: (https://github.com/filecoin-project/lotus/pull/3494)
|
||||||
|
- Fix a panic in the ffi-wrapper's `ReadPiece` (https://github.com/filecoin-project/lotus/pull/3492/files)
|
||||||
|
- Fix a deadlock in the sealing scheduler (https://github.com/filecoin-project/lotus/pull/3489)
|
||||||
|
- Add test vectors for tipset tests (https://github.com/filecoin-project/lotus/pull/3485/files)
|
||||||
|
- Improve the advance-block debug command (https://github.com/filecoin-project/lotus/pull/3476)
|
||||||
|
- Add toggle for message processing to Lotus PCR (https://github.com/filecoin-project/lotus/pull/3470)
|
||||||
|
- Allow exporting recent chain state trees (https://github.com/filecoin-project/lotus/pull/3463)
|
||||||
|
- Remove height from chain rand (https://github.com/filecoin-project/lotus/pull/3458)
|
||||||
|
- Disable GC on chain badger datastore (https://github.com/filecoin-project/lotus/pull/3457)
|
||||||
|
- Account for `GasPremium` in `GasEstimateFeeCap` (https://github.com/filecoin-project/lotus/pull/3456)
|
||||||
|
- Update go-libp2p-pubsub to `master` (https://github.com/filecoin-project/lotus/pull/3455)
|
||||||
|
- Chainwatch improvements (https://github.com/filecoin-project/lotus/pull/3442)
|
||||||
|
|
||||||
|
# 0.5.7 / 2020-08-31
|
||||||
|
|
||||||
|
This patch release includes some bugfixes and enhancements to the sector lifecycle and message pool logic.
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
|
||||||
|
- Rebuild unsealed infos on miner restart (https://github.com/filecoin-project/lotus/pull/3401)
|
||||||
|
- CLI to attach storage paths to workers (https://github.com/filecoin-project/lotus/pull/3405)
|
||||||
|
- Do not select negative performing message chains for inclusion (https://github.com/filecoin-project/lotus/pull/3392)
|
||||||
|
- Remove a redundant error-check (https://github.com/filecoin-project/lotus/pull/3421)
|
||||||
|
- Correctly move unsealed sectors in `FinalizeSectors` (https://github.com/filecoin-project/lotus/pull/3424)
|
||||||
|
- Improve worker selection logic (https://github.com/filecoin-project/lotus/pull/3425)
|
||||||
|
- Don't use context to close bitswap (https://github.com/filecoin-project/lotus/pull/3430)
|
||||||
|
- Correctly estimate gas premium when there is only one message on chain (https://github.com/filecoin-project/lotus/pull/3428)
|
||||||
|
|
||||||
|
# 0.5.6 / 2020-08-29
|
||||||
|
|
||||||
|
Hotfix release that fixes a panic in the sealing scheduler (https://github.com/filecoin-project/lotus/pull/3389).
|
||||||
|
|
||||||
|
# 0.5.5
|
||||||
|
|
||||||
|
This patch release introduces a large number of improvements to the sealing process.
|
||||||
|
It also updates go-fil-markets to
|
||||||
|
[version 0.5.8](https://github.com/filecoin-project/go-fil-markets/releases/tag/v0.5.8),
|
||||||
|
and go-libp2p-pubsub to [v0.3.5](https://github.com/libp2p/go-libp2p-pubsub/releases/tag/v0.3.5).
|
||||||
|
|
||||||
|
#### Downstream upgrades
|
||||||
|
|
||||||
|
- Upgrades markets to v0.5.8 (https://github.com/filecoin-project/lotus/pull/3384)
|
||||||
|
- Upgrades go-libp2p-pubsub to v0.3.5 (https://github.com/filecoin-project/lotus/pull/3305)
|
||||||
|
|
||||||
|
#### Sector sealing
|
||||||
|
|
||||||
|
- The following improvements were introduced in https://github.com/filecoin-project/lotus/pull/3350.
|
||||||
|
|
||||||
|
- Allow `lotus-miner sectors remove` to remove a sector in any state.
|
||||||
|
- Create a separate state in the storage FSM dedicated to submitting the Commit message.
|
||||||
|
- Recovery for when the Deal IDs of deals in a sector get changed in a reorg.
|
||||||
|
- Auto-retry sending Precommit and Commit messages if they run out of gas
|
||||||
|
- Auto-retry sector remove tasks when they fail
|
||||||
|
- Compact worker windows, and allow their tasks to be executed in any order
|
||||||
|
|
||||||
|
- Don't simply skip PoSt for bad sectors (https://github.com/filecoin-project/lotus/pull/3323)
|
||||||
|
|
||||||
|
#### Message Pool
|
||||||
|
|
||||||
|
- Spam Protection: Track required funds for pending messages (https://github.com/filecoin-project/lotus/pull/3313)
|
||||||
|
|
||||||
|
#### Chainwatch
|
||||||
|
|
||||||
|
- Add more power and reward metrics (https://github.com/filecoin-project/lotus/pull/3367)
|
||||||
|
- Fix raciness in sector deal table (https://github.com/filecoin-project/lotus/pull/3275)
|
||||||
|
- Parallelize miner processing (https://github.com/filecoin-project/lotus/pull/3380)
|
||||||
|
- Accept Lotus API and token (https://github.com/filecoin-project/lotus/pull/3337)
|
||||||
|
|
||||||
|
# 0.5.4
|
||||||
|
|
||||||
|
A patch release, containing a few nice bugfixes and improvements:
|
||||||
|
|
||||||
|
- Fix parsing of peer ID in `lotus-miner actor set-peer-id` (@whyrusleeping)
|
||||||
|
- Update dependencies, fixing several bugs (@Stebalien)
|
||||||
|
- Fix remaining linter warnings (@Stebalien)
|
||||||
|
- Use safe string truncation (@Ingar)
|
||||||
|
- Allow tweaking of blocksync message window size (@whyrusleeping)
|
||||||
|
- Add some additional gas stats to metrics (@Kubuxu)
|
||||||
|
- Fix an edge case bug in message selection, add many tests (@vyzo)
|
||||||
|
|
||||||
|
# 0.5.3
|
||||||
|
|
||||||
|
Yet another hotfix release.
|
||||||
|
A lesson for readers, having people who have been awake for 12+ hours review
|
||||||
|
your hotfix PR is not a good idea. Find someone who has enough slept recently
|
||||||
|
enough to give you good code review, otherwise you'll end up quickly bumping
|
||||||
|
versions again.
|
||||||
|
|
||||||
|
- Fixed a bug in the mempool that was introduced in v0.5.2
|
||||||
|
|
||||||
# 0.5.2 / 2020-08-24
|
# 0.5.2 / 2020-08-24
|
||||||
|
|
||||||
This is a hotfix release.
|
This is a hotfix release.
|
||||||
|
|||||||
@@ -92,6 +92,12 @@ lotus-shed: $(BUILD_DEPS)
|
|||||||
.PHONY: lotus-shed
|
.PHONY: lotus-shed
|
||||||
BINS+=lotus-shed
|
BINS+=lotus-shed
|
||||||
|
|
||||||
|
lotus-gateway: $(BUILD_DEPS)
|
||||||
|
rm -f lotus-gateway
|
||||||
|
go build $(GOFLAGS) -o lotus-gateway ./cmd/lotus-gateway
|
||||||
|
.PHONY: lotus-gateway
|
||||||
|
BINS+=lotus-gateway
|
||||||
|
|
||||||
build: lotus lotus-miner lotus-worker
|
build: lotus lotus-miner lotus-worker
|
||||||
@[[ $$(type -P "lotus") ]] && echo "Caution: you have \
|
@[[ $$(type -P "lotus") ]] && echo "Caution: you have \
|
||||||
an existing lotus binary in your PATH. This may cause problems if you don't run 'sudo make install'" || true
|
an existing lotus binary in your PATH. This may cause problems if you don't run 'sudo make install'" || true
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ Lotus is an implementation of the Filecoin Distributed Storage Network. For more
|
|||||||
|
|
||||||
## Building & Documentation
|
## Building & Documentation
|
||||||
|
|
||||||
For instructions on how to build lotus from source, please visit [https://lotu.sh](https://lotu.sh) or read the source [here](https://github.com/filecoin-project/lotus/tree/master/documentation).
|
For instructions on how to build lotus from source, please visit [Lotus build and setup instruction](https://docs.filecoin.io/get-started/lotus/installation/#minimal-requirements) or read the source [here](https://github.com/filecoin-project/lotus/tree/master/documentation).
|
||||||
|
|
||||||
## Reporting a Vulnerability
|
## Reporting a Vulnerability
|
||||||
|
|
||||||
@@ -40,9 +40,6 @@ All work is tracked via issues. An attempt at keeping an up-to-date view on rema
|
|||||||
The lotus Filecoin implementation unfolds into the following packages:
|
The lotus Filecoin implementation unfolds into the following packages:
|
||||||
|
|
||||||
- [This repo](https://github.com/filecoin-project/lotus)
|
- [This repo](https://github.com/filecoin-project/lotus)
|
||||||
- [storage-fsm](https://github.com/filecoin-project/storage-fsm)
|
|
||||||
- [sector-storage](https://github.com/filecoin-project/sector-storage)
|
|
||||||
- [specs-storage](https://github.com/filecoin-project/specs-storage)
|
|
||||||
- [go-fil-markets](https://github.com/filecoin-project/go-fil-markets) which has its own [kanban work tracker available here](https://app.zenhub.com/workspaces/markets-shared-components-5daa144a7046a60001c6e253/board)
|
- [go-fil-markets](https://github.com/filecoin-project/go-fil-markets) which has its own [kanban work tracker available here](https://app.zenhub.com/workspaces/markets-shared-components-5daa144a7046a60001c6e253/board)
|
||||||
- [spec-actors](https://github.com/filecoin-project/specs-actors) which has its own [kanban work tracker available here](https://app.zenhub.com/workspaces/actors-5ee6f3aa87591f0016c05685/board)
|
- [spec-actors](https://github.com/filecoin-project/specs-actors) which has its own [kanban work tracker available here](https://app.zenhub.com/workspaces/actors-5ee6f3aa87591f0016c05685/board)
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,10 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-jsonrpc/auth"
|
"github.com/filecoin-project/go-jsonrpc/auth"
|
||||||
|
metrics "github.com/libp2p/go-libp2p-core/metrics"
|
||||||
"github.com/libp2p/go-libp2p-core/network"
|
"github.com/libp2p/go-libp2p-core/network"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
|
protocol "github.com/libp2p/go-libp2p-core/protocol"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
)
|
)
|
||||||
@@ -28,6 +30,19 @@ type Common interface {
|
|||||||
NetFindPeer(context.Context, peer.ID) (peer.AddrInfo, error)
|
NetFindPeer(context.Context, peer.ID) (peer.AddrInfo, error)
|
||||||
NetPubsubScores(context.Context) ([]PubsubScore, error)
|
NetPubsubScores(context.Context) ([]PubsubScore, error)
|
||||||
NetAutoNatStatus(context.Context) (NatInfo, error)
|
NetAutoNatStatus(context.Context) (NatInfo, error)
|
||||||
|
NetAgentVersion(ctx context.Context, p peer.ID) (string, error)
|
||||||
|
|
||||||
|
// NetBandwidthStats returns statistics about the nodes total bandwidth
|
||||||
|
// usage and current rate across all peers and protocols.
|
||||||
|
NetBandwidthStats(ctx context.Context) (metrics.Stats, error)
|
||||||
|
|
||||||
|
// NetBandwidthStatsByPeer returns statistics about the nodes bandwidth
|
||||||
|
// usage and current rate per peer
|
||||||
|
NetBandwidthStatsByPeer(ctx context.Context) (map[string]metrics.Stats, error)
|
||||||
|
|
||||||
|
// NetBandwidthStatsByProtocol returns statistics about the nodes bandwidth
|
||||||
|
// usage and current rate per protocol
|
||||||
|
NetBandwidthStatsByProtocol(ctx context.Context) (map[protocol.ID]metrics.Stats, error)
|
||||||
|
|
||||||
// MethodGroup: Common
|
// MethodGroup: Common
|
||||||
|
|
||||||
|
|||||||
+158
-54
@@ -2,24 +2,29 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-state-types/network"
|
||||||
|
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/go-bitfield"
|
||||||
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
|
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
|
||||||
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
||||||
"github.com/filecoin-project/go-multistore"
|
"github.com/filecoin-project/go-multistore"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
"github.com/filecoin-project/go-state-types/big"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/market"
|
"github.com/filecoin-project/go-state-types/crypto"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
"github.com/filecoin-project/go-state-types/dline"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/paych"
|
"github.com/filecoin-project/lotus/chain/actors/builtin/market"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/power"
|
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
|
"github.com/filecoin-project/lotus/chain/actors/builtin/paych"
|
||||||
"github.com/filecoin-project/specs-actors/actors/crypto"
|
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/builtin/power"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
marketevents "github.com/filecoin-project/lotus/markets/loggers"
|
marketevents "github.com/filecoin-project/lotus/markets/loggers"
|
||||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||||
@@ -71,6 +76,9 @@ type FullNode interface {
|
|||||||
// blockstore and returns raw bytes.
|
// blockstore and returns raw bytes.
|
||||||
ChainReadObj(context.Context, cid.Cid) ([]byte, error)
|
ChainReadObj(context.Context, cid.Cid) ([]byte, error)
|
||||||
|
|
||||||
|
// ChainDeleteObj deletes node referenced by the given CID
|
||||||
|
ChainDeleteObj(context.Context, cid.Cid) error
|
||||||
|
|
||||||
// ChainHasObj checks if a given CID exists in the chain blockstore.
|
// ChainHasObj checks if a given CID exists in the chain blockstore.
|
||||||
ChainHasObj(context.Context, cid.Cid) (bool, error)
|
ChainHasObj(context.Context, cid.Cid) (bool, error)
|
||||||
|
|
||||||
@@ -109,7 +117,11 @@ type FullNode interface {
|
|||||||
ChainGetPath(ctx context.Context, from types.TipSetKey, to types.TipSetKey) ([]*HeadChange, error)
|
ChainGetPath(ctx context.Context, from types.TipSetKey, to types.TipSetKey) ([]*HeadChange, error)
|
||||||
|
|
||||||
// ChainExport returns a stream of bytes with CAR dump of chain data.
|
// ChainExport returns a stream of bytes with CAR dump of chain data.
|
||||||
ChainExport(context.Context, types.TipSetKey) (<-chan []byte, error)
|
// The exported chain data includes the header chain from the given tipset
|
||||||
|
// back to genesis, the entire genesis state, and the most recent 'nroots'
|
||||||
|
// state trees.
|
||||||
|
// If oldmsgskip is set, messages from before the requested roots are also not included.
|
||||||
|
ChainExport(ctx context.Context, nroots abi.ChainEpoch, oldmsgskip bool, tsk types.TipSetKey) (<-chan []byte, error)
|
||||||
|
|
||||||
// MethodGroup: Beacon
|
// MethodGroup: Beacon
|
||||||
// The Beacon method group contains methods for interacting with the random beacon (DRAND)
|
// The Beacon method group contains methods for interacting with the random beacon (DRAND)
|
||||||
@@ -150,10 +162,16 @@ type FullNode interface {
|
|||||||
// yet synced block headers.
|
// yet synced block headers.
|
||||||
SyncIncomingBlocks(ctx context.Context) (<-chan *types.BlockHeader, error)
|
SyncIncomingBlocks(ctx context.Context) (<-chan *types.BlockHeader, error)
|
||||||
|
|
||||||
|
// SyncCheckpoint marks a blocks as checkpointed, meaning that it won't ever fork away from it.
|
||||||
|
SyncCheckpoint(ctx context.Context, tsk types.TipSetKey) error
|
||||||
|
|
||||||
// SyncMarkBad marks a blocks as bad, meaning that it won't ever by synced.
|
// SyncMarkBad marks a blocks as bad, meaning that it won't ever by synced.
|
||||||
// Use with extreme caution.
|
// Use with extreme caution.
|
||||||
SyncMarkBad(ctx context.Context, bcid cid.Cid) error
|
SyncMarkBad(ctx context.Context, bcid cid.Cid) error
|
||||||
|
|
||||||
|
// SyncUnmarkBad unmarks a blocks as bad, making it possible to be validated and synced again.
|
||||||
|
SyncUnmarkBad(ctx context.Context, bcid cid.Cid) error
|
||||||
|
|
||||||
// SyncCheckBad checks if a block was marked as bad, and if it was, returns
|
// SyncCheckBad checks if a block was marked as bad, and if it was, returns
|
||||||
// the reason.
|
// the reason.
|
||||||
SyncCheckBad(ctx context.Context, bcid cid.Cid) (string, error)
|
SyncCheckBad(ctx context.Context, bcid cid.Cid) (string, error)
|
||||||
@@ -215,7 +233,7 @@ type FullNode interface {
|
|||||||
WalletSignMessage(context.Context, address.Address, *types.Message) (*types.SignedMessage, error)
|
WalletSignMessage(context.Context, address.Address, *types.Message) (*types.SignedMessage, error)
|
||||||
// WalletVerify takes an address, a signature, and some bytes, and indicates whether the signature is valid.
|
// WalletVerify takes an address, a signature, and some bytes, and indicates whether the signature is valid.
|
||||||
// The address does not have to be in the wallet.
|
// The address does not have to be in the wallet.
|
||||||
WalletVerify(context.Context, address.Address, []byte, *crypto.Signature) bool
|
WalletVerify(context.Context, address.Address, []byte, *crypto.Signature) (bool, error)
|
||||||
// WalletDefaultAddress returns the address marked as default in the wallet.
|
// WalletDefaultAddress returns the address marked as default in the wallet.
|
||||||
WalletDefaultAddress(context.Context) (address.Address, error)
|
WalletDefaultAddress(context.Context) (address.Address, error)
|
||||||
// WalletSetDefault marks the given address as as the default one.
|
// WalletSetDefault marks the given address as as the default one.
|
||||||
@@ -243,6 +261,8 @@ type FullNode interface {
|
|||||||
ClientGetDealInfo(context.Context, cid.Cid) (*DealInfo, error)
|
ClientGetDealInfo(context.Context, cid.Cid) (*DealInfo, error)
|
||||||
// ClientListDeals returns information about the deals made by the local client.
|
// ClientListDeals returns information about the deals made by the local client.
|
||||||
ClientListDeals(ctx context.Context) ([]DealInfo, error)
|
ClientListDeals(ctx context.Context) ([]DealInfo, error)
|
||||||
|
// ClientGetDealUpdates returns the status of updated deals
|
||||||
|
ClientGetDealUpdates(ctx context.Context) (<-chan DealInfo, error)
|
||||||
// ClientHasLocal indicates whether a certain CID is locally stored.
|
// ClientHasLocal indicates whether a certain CID is locally stored.
|
||||||
ClientHasLocal(ctx context.Context, root cid.Cid) (bool, error)
|
ClientHasLocal(ctx context.Context, root cid.Cid) (bool, error)
|
||||||
// ClientFindData identifies peers that have a certain file, and returns QueryOffers (one per peer).
|
// ClientFindData identifies peers that have a certain file, and returns QueryOffers (one per peer).
|
||||||
@@ -265,6 +285,9 @@ type FullNode interface {
|
|||||||
// ClientListTransfers returns the status of all ongoing transfers of data
|
// ClientListTransfers returns the status of all ongoing transfers of data
|
||||||
ClientListDataTransfers(ctx context.Context) ([]DataTransferChannel, error)
|
ClientListDataTransfers(ctx context.Context) ([]DataTransferChannel, error)
|
||||||
ClientDataTransferUpdates(ctx context.Context) (<-chan DataTransferChannel, error)
|
ClientDataTransferUpdates(ctx context.Context) (<-chan DataTransferChannel, error)
|
||||||
|
// ClientRetrieveTryRestartInsufficientFunds attempts to restart stalled retrievals on a given payment channel
|
||||||
|
// which are stuck due to insufficient funds
|
||||||
|
ClientRetrieveTryRestartInsufficientFunds(ctx context.Context, paymentChannel address.Address) error
|
||||||
|
|
||||||
// ClientUnimport removes references to the specified file from filestore
|
// ClientUnimport removes references to the specified file from filestore
|
||||||
//ClientUnimport(path string)
|
//ClientUnimport(path string)
|
||||||
@@ -293,28 +316,26 @@ type FullNode interface {
|
|||||||
// StateNetworkName returns the name of the network the node is synced to
|
// StateNetworkName returns the name of the network the node is synced to
|
||||||
StateNetworkName(context.Context) (dtypes.NetworkName, error)
|
StateNetworkName(context.Context) (dtypes.NetworkName, error)
|
||||||
// StateMinerSectors returns info about the given miner's sectors. If the filter bitfield is nil, all sectors are included.
|
// StateMinerSectors returns info about the given miner's sectors. If the filter bitfield is nil, all sectors are included.
|
||||||
// If the filterOut boolean is set to true, any sectors in the filter are excluded.
|
StateMinerSectors(context.Context, address.Address, *bitfield.BitField, types.TipSetKey) ([]*miner.SectorOnChainInfo, error)
|
||||||
// If false, only those sectors in the filter are included.
|
|
||||||
StateMinerSectors(context.Context, address.Address, *abi.BitField, bool, types.TipSetKey) ([]*ChainSectorInfo, error)
|
|
||||||
// StateMinerActiveSectors returns info about sectors that a given miner is actively proving.
|
// StateMinerActiveSectors returns info about sectors that a given miner is actively proving.
|
||||||
StateMinerActiveSectors(context.Context, address.Address, types.TipSetKey) ([]*ChainSectorInfo, error)
|
StateMinerActiveSectors(context.Context, address.Address, types.TipSetKey) ([]*miner.SectorOnChainInfo, error)
|
||||||
// StateMinerProvingDeadline calculates the deadline at some epoch for a proving period
|
// StateMinerProvingDeadline calculates the deadline at some epoch for a proving period
|
||||||
// and returns the deadline-related calculations.
|
// and returns the deadline-related calculations.
|
||||||
StateMinerProvingDeadline(context.Context, address.Address, types.TipSetKey) (*miner.DeadlineInfo, error)
|
StateMinerProvingDeadline(context.Context, address.Address, types.TipSetKey) (*dline.Info, error)
|
||||||
// StateMinerPower returns the power of the indicated miner
|
// StateMinerPower returns the power of the indicated miner
|
||||||
StateMinerPower(context.Context, address.Address, types.TipSetKey) (*MinerPower, error)
|
StateMinerPower(context.Context, address.Address, types.TipSetKey) (*MinerPower, error)
|
||||||
// StateMinerInfo returns info about the indicated miner
|
// StateMinerInfo returns info about the indicated miner
|
||||||
StateMinerInfo(context.Context, address.Address, types.TipSetKey) (MinerInfo, error)
|
StateMinerInfo(context.Context, address.Address, types.TipSetKey) (miner.MinerInfo, error)
|
||||||
// StateMinerDeadlines returns all the proving deadlines for the given miner
|
// StateMinerDeadlines returns all the proving deadlines for the given miner
|
||||||
StateMinerDeadlines(context.Context, address.Address, types.TipSetKey) ([]*miner.Deadline, error)
|
StateMinerDeadlines(context.Context, address.Address, types.TipSetKey) ([]Deadline, error)
|
||||||
// StateMinerPartitions loads miner partitions for the specified miner/deadline
|
// StateMinerPartitions returns all partitions in the specified deadline
|
||||||
StateMinerPartitions(context.Context, address.Address, uint64, types.TipSetKey) ([]*miner.Partition, error)
|
StateMinerPartitions(ctx context.Context, m address.Address, dlIdx uint64, tsk types.TipSetKey) ([]Partition, error)
|
||||||
// StateMinerFaults returns a bitfield indicating the faulty sectors of the given miner
|
// StateMinerFaults returns a bitfield indicating the faulty sectors of the given miner
|
||||||
StateMinerFaults(context.Context, address.Address, types.TipSetKey) (abi.BitField, error)
|
StateMinerFaults(context.Context, address.Address, types.TipSetKey) (bitfield.BitField, error)
|
||||||
// StateAllMinerFaults returns all non-expired Faults that occur within lookback epochs of the given tipset
|
// StateAllMinerFaults returns all non-expired Faults that occur within lookback epochs of the given tipset
|
||||||
StateAllMinerFaults(ctx context.Context, lookback abi.ChainEpoch, ts types.TipSetKey) ([]*Fault, error)
|
StateAllMinerFaults(ctx context.Context, lookback abi.ChainEpoch, ts types.TipSetKey) ([]*Fault, error)
|
||||||
// StateMinerRecoveries returns a bitfield indicating the recovering sectors of the given miner
|
// StateMinerRecoveries returns a bitfield indicating the recovering sectors of the given miner
|
||||||
StateMinerRecoveries(context.Context, address.Address, types.TipSetKey) (abi.BitField, error)
|
StateMinerRecoveries(context.Context, address.Address, types.TipSetKey) (bitfield.BitField, error)
|
||||||
// StateMinerInitialPledgeCollateral returns the precommit deposit for the specified miner's sector
|
// StateMinerInitialPledgeCollateral returns the precommit deposit for the specified miner's sector
|
||||||
StateMinerPreCommitDepositForPower(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (types.BigInt, error)
|
StateMinerPreCommitDepositForPower(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (types.BigInt, error)
|
||||||
// StateMinerInitialPledgeCollateral returns the initial pledge collateral for the specified miner's sector
|
// StateMinerInitialPledgeCollateral returns the initial pledge collateral for the specified miner's sector
|
||||||
@@ -323,16 +344,18 @@ type FullNode interface {
|
|||||||
StateMinerAvailableBalance(context.Context, address.Address, types.TipSetKey) (types.BigInt, error)
|
StateMinerAvailableBalance(context.Context, address.Address, types.TipSetKey) (types.BigInt, error)
|
||||||
// StateSectorPreCommitInfo returns the PreCommit info for the specified miner's sector
|
// StateSectorPreCommitInfo returns the PreCommit info for the specified miner's sector
|
||||||
StateSectorPreCommitInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error)
|
StateSectorPreCommitInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error)
|
||||||
// StateSectorGetInfo returns the on-chain info for the specified miner's sector
|
// StateSectorGetInfo returns the on-chain info for the specified miner's sector. Returns null in case the sector info isn't found
|
||||||
// NOTE: returned info.Expiration may not be accurate in some cases, use StateSectorExpiration to get accurate
|
// NOTE: returned info.Expiration may not be accurate in some cases, use StateSectorExpiration to get accurate
|
||||||
// expiration epoch
|
// expiration epoch
|
||||||
StateSectorGetInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error)
|
StateSectorGetInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error)
|
||||||
// StateSectorExpiration returns epoch at which given sector will expire
|
// StateSectorExpiration returns epoch at which given sector will expire
|
||||||
StateSectorExpiration(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*SectorExpiration, error)
|
StateSectorExpiration(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorExpiration, error)
|
||||||
// StateSectorPartition finds deadline/partition with the specified sector
|
// StateSectorPartition finds deadline/partition with the specified sector
|
||||||
StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*SectorLocation, error)
|
StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*miner.SectorLocation, error)
|
||||||
// StateSearchMsg searches for a message in the chain, and returns its receipt and the tipset where it was executed
|
// StateSearchMsg searches for a message in the chain, and returns its receipt and the tipset where it was executed
|
||||||
StateSearchMsg(context.Context, cid.Cid) (*MsgLookup, error)
|
StateSearchMsg(context.Context, cid.Cid) (*MsgLookup, error)
|
||||||
|
// StateMsgGasCost searches for a message in the chain, and returns details of the messages gas costs, including the penalty and miner tip
|
||||||
|
StateMsgGasCost(context.Context, cid.Cid, types.TipSetKey) (*MsgGasCost, error)
|
||||||
// StateWaitMsg looks back in the chain for a message. If not found, it blocks until the
|
// StateWaitMsg looks back in the chain for a message. If not found, it blocks until the
|
||||||
// message arrives on chain, and gets to the indicated confidence depth.
|
// message arrives on chain, and gets to the indicated confidence depth.
|
||||||
StateWaitMsg(ctx context.Context, cid cid.Cid, confidence uint64) (*MsgLookup, error)
|
StateWaitMsg(ctx context.Context, cid cid.Cid, confidence uint64) (*MsgLookup, error)
|
||||||
@@ -365,13 +388,15 @@ type FullNode interface {
|
|||||||
// StateVerifiedClientStatus returns the data cap for the given address.
|
// StateVerifiedClientStatus returns the data cap for the given address.
|
||||||
// Returns nil if there is no entry in the data cap table for the
|
// Returns nil if there is no entry in the data cap table for the
|
||||||
// address.
|
// address.
|
||||||
StateVerifiedClientStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*verifreg.DataCap, error)
|
StateVerifiedClientStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*abi.StoragePower, error)
|
||||||
// StateDealProviderCollateralBounds returns the min and max collateral a storage provider
|
// StateDealProviderCollateralBounds returns the min and max collateral a storage provider
|
||||||
// can issue. It takes the deal size and verified status as parameters.
|
// can issue. It takes the deal size and verified status as parameters.
|
||||||
StateDealProviderCollateralBounds(context.Context, abi.PaddedPieceSize, bool, types.TipSetKey) (DealCollateralBounds, error)
|
StateDealProviderCollateralBounds(context.Context, abi.PaddedPieceSize, bool, types.TipSetKey) (DealCollateralBounds, error)
|
||||||
|
|
||||||
// StateCirculatingSupply returns the circulating supply of Filecoin at the given tipset
|
// StateCirculatingSupply returns the circulating supply of Filecoin at the given tipset
|
||||||
StateCirculatingSupply(context.Context, types.TipSetKey) (CirculatingSupply, error)
|
StateCirculatingSupply(context.Context, types.TipSetKey) (CirculatingSupply, error)
|
||||||
|
// StateNetworkVersion returns the network version at the given tipset
|
||||||
|
StateNetworkVersion(context.Context, types.TipSetKey) (network.Version, error)
|
||||||
|
|
||||||
// MethodGroup: Msig
|
// MethodGroup: Msig
|
||||||
// The Msig methods are used to interact with multisig wallets on the
|
// The Msig methods are used to interact with multisig wallets on the
|
||||||
@@ -379,6 +404,9 @@ type FullNode interface {
|
|||||||
|
|
||||||
// MsigGetAvailableBalance returns the portion of a multisig's balance that can be withdrawn or spent
|
// MsigGetAvailableBalance returns the portion of a multisig's balance that can be withdrawn or spent
|
||||||
MsigGetAvailableBalance(context.Context, address.Address, types.TipSetKey) (types.BigInt, error)
|
MsigGetAvailableBalance(context.Context, address.Address, types.TipSetKey) (types.BigInt, error)
|
||||||
|
// MsigGetVested returns the amount of FIL that vested in a multisig in a certain period.
|
||||||
|
// It takes the following params: <multisig address>, <start epoch>, <end epoch>
|
||||||
|
MsigGetVested(context.Context, address.Address, types.TipSetKey, types.TipSetKey) (types.BigInt, error)
|
||||||
// MsigCreate creates a multisig wallet
|
// MsigCreate creates a multisig wallet
|
||||||
// It takes the following params: <required number of senders>, <approving addresses>, <unlock duration>
|
// It takes the following params: <required number of senders>, <approving addresses>, <unlock duration>
|
||||||
//<initial balance>, <sender address of the create msg>, <gas price>
|
//<initial balance>, <sender address of the create msg>, <gas price>
|
||||||
@@ -395,17 +423,29 @@ type FullNode interface {
|
|||||||
// It takes the following params: <multisig address>, <proposed message ID>, <recipient address>, <value to transfer>,
|
// It takes the following params: <multisig address>, <proposed message ID>, <recipient address>, <value to transfer>,
|
||||||
// <sender address of the cancel msg>, <method to call in the proposed message>, <params to include in the proposed message>
|
// <sender address of the cancel msg>, <method to call in the proposed message>, <params to include in the proposed message>
|
||||||
MsigCancel(context.Context, address.Address, uint64, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error)
|
MsigCancel(context.Context, address.Address, uint64, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error)
|
||||||
|
// MsigAddPropose proposes adding a signer in the multisig
|
||||||
|
// It takes the following params: <multisig address>, <sender address of the propose msg>,
|
||||||
|
// <new signer>, <whether the number of required signers should be increased>
|
||||||
|
MsigAddPropose(context.Context, address.Address, address.Address, address.Address, bool) (cid.Cid, error)
|
||||||
|
// MsigAddApprove approves a previously proposed AddSigner message
|
||||||
|
// It takes the following params: <multisig address>, <sender address of the approve msg>, <proposed message ID>,
|
||||||
|
// <proposer address>, <new signer>, <whether the number of required signers should be increased>
|
||||||
|
MsigAddApprove(context.Context, address.Address, address.Address, uint64, address.Address, address.Address, bool) (cid.Cid, error)
|
||||||
|
// MsigAddCancel cancels a previously proposed AddSigner message
|
||||||
|
// It takes the following params: <multisig address>, <sender address of the cancel msg>, <proposed message ID>,
|
||||||
|
// <new signer>, <whether the number of required signers should be increased>
|
||||||
|
MsigAddCancel(context.Context, address.Address, address.Address, uint64, address.Address, bool) (cid.Cid, error)
|
||||||
// MsigSwapPropose proposes swapping 2 signers in the multisig
|
// MsigSwapPropose proposes swapping 2 signers in the multisig
|
||||||
// It takes the following params: <multisig address>, <sender address of the propose msg>,
|
// It takes the following params: <multisig address>, <sender address of the propose msg>,
|
||||||
// <old signer> <new signer>
|
// <old signer>, <new signer>
|
||||||
MsigSwapPropose(context.Context, address.Address, address.Address, address.Address, address.Address) (cid.Cid, error)
|
MsigSwapPropose(context.Context, address.Address, address.Address, address.Address, address.Address) (cid.Cid, error)
|
||||||
// MsigSwapApprove approves a previously proposed SwapSigner
|
// MsigSwapApprove approves a previously proposed SwapSigner
|
||||||
// It takes the following params: <multisig address>, <sender address of the approve msg>, <proposed message ID>,
|
// It takes the following params: <multisig address>, <sender address of the approve msg>, <proposed message ID>,
|
||||||
// <proposer address>, <old signer> <new signer>
|
// <proposer address>, <old signer>, <new signer>
|
||||||
MsigSwapApprove(context.Context, address.Address, address.Address, uint64, address.Address, address.Address, address.Address) (cid.Cid, error)
|
MsigSwapApprove(context.Context, address.Address, address.Address, uint64, address.Address, address.Address, address.Address) (cid.Cid, error)
|
||||||
// MsigSwapCancel cancels a previously proposed SwapSigner message
|
// MsigSwapCancel cancels a previously proposed SwapSigner message
|
||||||
// It takes the following params: <multisig address>, <sender address of the cancel msg>, <proposed message ID>,
|
// It takes the following params: <multisig address>, <sender address of the cancel msg>, <proposed message ID>,
|
||||||
// <old signer> <new signer>
|
// <old signer>, <new signer>
|
||||||
MsigSwapCancel(context.Context, address.Address, address.Address, uint64, address.Address, address.Address) (cid.Cid, error)
|
MsigSwapCancel(context.Context, address.Address, address.Address, uint64, address.Address, address.Address) (cid.Cid, error)
|
||||||
|
|
||||||
MarketEnsureAvailable(context.Context, address.Address, address.Address, types.BigInt) (cid.Cid, error)
|
MarketEnsureAvailable(context.Context, address.Address, address.Address, types.BigInt) (cid.Cid, error)
|
||||||
@@ -416,6 +456,8 @@ type FullNode interface {
|
|||||||
|
|
||||||
PaychGet(ctx context.Context, from, to address.Address, amt types.BigInt) (*ChannelInfo, error)
|
PaychGet(ctx context.Context, from, to address.Address, amt types.BigInt) (*ChannelInfo, error)
|
||||||
PaychGetWaitReady(context.Context, cid.Cid) (address.Address, error)
|
PaychGetWaitReady(context.Context, cid.Cid) (address.Address, error)
|
||||||
|
PaychAvailableFunds(ctx context.Context, ch address.Address) (*ChannelAvailableFunds, error)
|
||||||
|
PaychAvailableFundsByFromTo(ctx context.Context, from, to address.Address) (*ChannelAvailableFunds, error)
|
||||||
PaychList(context.Context) ([]address.Address, error)
|
PaychList(context.Context) ([]address.Address, error)
|
||||||
PaychStatus(context.Context, address.Address) (*PaychStatus, error)
|
PaychStatus(context.Context, address.Address) (*PaychStatus, error)
|
||||||
PaychSettle(context.Context, address.Address) (cid.Cid, error)
|
PaychSettle(context.Context, address.Address) (cid.Cid, error)
|
||||||
@@ -424,10 +466,10 @@ type FullNode interface {
|
|||||||
PaychNewPayment(ctx context.Context, from, to address.Address, vouchers []VoucherSpec) (*PaymentInfo, error)
|
PaychNewPayment(ctx context.Context, from, to address.Address, vouchers []VoucherSpec) (*PaymentInfo, error)
|
||||||
PaychVoucherCheckValid(context.Context, address.Address, *paych.SignedVoucher) error
|
PaychVoucherCheckValid(context.Context, address.Address, *paych.SignedVoucher) error
|
||||||
PaychVoucherCheckSpendable(context.Context, address.Address, *paych.SignedVoucher, []byte, []byte) (bool, error)
|
PaychVoucherCheckSpendable(context.Context, address.Address, *paych.SignedVoucher, []byte, []byte) (bool, error)
|
||||||
PaychVoucherCreate(context.Context, address.Address, types.BigInt, uint64) (*paych.SignedVoucher, error)
|
PaychVoucherCreate(context.Context, address.Address, types.BigInt, uint64) (*VoucherCreateResult, error)
|
||||||
PaychVoucherAdd(context.Context, address.Address, *paych.SignedVoucher, []byte, types.BigInt) (types.BigInt, error)
|
PaychVoucherAdd(context.Context, address.Address, *paych.SignedVoucher, []byte, types.BigInt) (types.BigInt, error)
|
||||||
PaychVoucherList(context.Context, address.Address) ([]*paych.SignedVoucher, error)
|
PaychVoucherList(context.Context, address.Address) ([]*paych.SignedVoucher, error)
|
||||||
PaychVoucherSubmit(context.Context, address.Address, *paych.SignedVoucher) (cid.Cid, error)
|
PaychVoucherSubmit(context.Context, address.Address, *paych.SignedVoucher, []byte, []byte) (cid.Cid, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type FileRef struct {
|
type FileRef struct {
|
||||||
@@ -436,21 +478,12 @@ type FileRef struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type MinerSectors struct {
|
type MinerSectors struct {
|
||||||
Sectors uint64
|
// Live sectors that should be proven.
|
||||||
Active uint64
|
Live uint64
|
||||||
}
|
// Sectors actively contributing to power.
|
||||||
|
Active uint64
|
||||||
type SectorExpiration struct {
|
// Sectors with failed proofs.
|
||||||
OnTime abi.ChainEpoch
|
Faulty uint64
|
||||||
|
|
||||||
// non-zero if sector is faulty, epoch at which it will be permanently
|
|
||||||
// removed if it doesn't recover
|
|
||||||
Early abi.ChainEpoch
|
|
||||||
}
|
|
||||||
|
|
||||||
type SectorLocation struct {
|
|
||||||
Deadline uint64
|
|
||||||
Partition uint64
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ImportRes struct {
|
type ImportRes struct {
|
||||||
@@ -493,6 +526,17 @@ type MsgLookup struct {
|
|||||||
Height abi.ChainEpoch
|
Height abi.ChainEpoch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type MsgGasCost struct {
|
||||||
|
Message cid.Cid // Can be different than requested, in case it was replaced, but only gas values changed
|
||||||
|
GasUsed abi.TokenAmount
|
||||||
|
BaseFeeBurn abi.TokenAmount
|
||||||
|
OverEstimationBurn abi.TokenAmount
|
||||||
|
MinerPenalty abi.TokenAmount
|
||||||
|
MinerTip abi.TokenAmount
|
||||||
|
Refund abi.TokenAmount
|
||||||
|
TotalCost abi.TokenAmount
|
||||||
|
}
|
||||||
|
|
||||||
type BlockMessages struct {
|
type BlockMessages struct {
|
||||||
BlsMessages []*types.Message
|
BlsMessages []*types.Message
|
||||||
SecpkMessages []*types.SignedMessage
|
SecpkMessages []*types.SignedMessage
|
||||||
@@ -505,11 +549,6 @@ type Message struct {
|
|||||||
Message *types.Message
|
Message *types.Message
|
||||||
}
|
}
|
||||||
|
|
||||||
type ChainSectorInfo struct {
|
|
||||||
Info miner.SectorOnChainInfo
|
|
||||||
ID abi.SectorNumber
|
|
||||||
}
|
|
||||||
|
|
||||||
type ActorState struct {
|
type ActorState struct {
|
||||||
Balance types.BigInt
|
Balance types.BigInt
|
||||||
State interface{}
|
State interface{}
|
||||||
@@ -533,6 +572,28 @@ type ChannelInfo struct {
|
|||||||
WaitSentinel cid.Cid
|
WaitSentinel cid.Cid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ChannelAvailableFunds struct {
|
||||||
|
// Channel is the address of the channel
|
||||||
|
Channel *address.Address
|
||||||
|
// From is the from address of the channel (channel creator)
|
||||||
|
From address.Address
|
||||||
|
// To is the to address of the channel
|
||||||
|
To address.Address
|
||||||
|
// ConfirmedAmt is the amount of funds that have been confirmed on-chain
|
||||||
|
// for the channel
|
||||||
|
ConfirmedAmt types.BigInt
|
||||||
|
// PendingAmt is the amount of funds that are pending confirmation on-chain
|
||||||
|
PendingAmt types.BigInt
|
||||||
|
// PendingWaitSentinel can be used with PaychGetWaitReady to wait for
|
||||||
|
// confirmation of pending funds
|
||||||
|
PendingWaitSentinel *cid.Cid
|
||||||
|
// QueuedAmt is the amount that is queued up behind a pending request
|
||||||
|
QueuedAmt types.BigInt
|
||||||
|
// VoucherRedeemedAmt is the amount that is redeemed by vouchers on-chain
|
||||||
|
// and in the local datastore
|
||||||
|
VoucherReedeemedAmt types.BigInt
|
||||||
|
}
|
||||||
|
|
||||||
type PaymentInfo struct {
|
type PaymentInfo struct {
|
||||||
Channel address.Address
|
Channel address.Address
|
||||||
WaitSentinel cid.Cid
|
WaitSentinel cid.Cid
|
||||||
@@ -548,9 +609,20 @@ type VoucherSpec struct {
|
|||||||
Extra *paych.ModVerifyParams
|
Extra *paych.ModVerifyParams
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// VoucherCreateResult is the response to calling PaychVoucherCreate
|
||||||
|
type VoucherCreateResult struct {
|
||||||
|
// Voucher that was created, or nil if there was an error or if there
|
||||||
|
// were insufficient funds in the channel
|
||||||
|
Voucher *paych.SignedVoucher
|
||||||
|
// Shortfall is the additional amount that would be needed in the channel
|
||||||
|
// in order to be able to create the voucher
|
||||||
|
Shortfall types.BigInt
|
||||||
|
}
|
||||||
|
|
||||||
type MinerPower struct {
|
type MinerPower struct {
|
||||||
MinerPower power.Claim
|
MinerPower power.Claim
|
||||||
TotalPower power.Claim
|
TotalPower power.Claim
|
||||||
|
HasMinPower bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type QueryOffer struct {
|
type QueryOffer struct {
|
||||||
@@ -664,8 +736,28 @@ const (
|
|||||||
StageMessages
|
StageMessages
|
||||||
StageSyncComplete
|
StageSyncComplete
|
||||||
StageSyncErrored
|
StageSyncErrored
|
||||||
|
StageFetchingMessages
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (v SyncStateStage) String() string {
|
||||||
|
switch v {
|
||||||
|
case StageHeaders:
|
||||||
|
return "header sync"
|
||||||
|
case StagePersistHeaders:
|
||||||
|
return "persisting headers"
|
||||||
|
case StageMessages:
|
||||||
|
return "message sync"
|
||||||
|
case StageSyncComplete:
|
||||||
|
return "complete"
|
||||||
|
case StageSyncErrored:
|
||||||
|
return "error"
|
||||||
|
case StageFetchingMessages:
|
||||||
|
return "fetching messages"
|
||||||
|
default:
|
||||||
|
return fmt.Sprintf("<unknown: %d>", v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type MpoolChange int
|
type MpoolChange int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -699,7 +791,7 @@ type CirculatingSupply struct {
|
|||||||
type MiningBaseInfo struct {
|
type MiningBaseInfo struct {
|
||||||
MinerPower types.BigInt
|
MinerPower types.BigInt
|
||||||
NetworkPower types.BigInt
|
NetworkPower types.BigInt
|
||||||
Sectors []abi.SectorInfo
|
Sectors []builtin.SectorInfo
|
||||||
WorkerKey address.Address
|
WorkerKey address.Address
|
||||||
SectorSize abi.SectorSize
|
SectorSize abi.SectorSize
|
||||||
PrevBeaconEntry types.BeaconEntry
|
PrevBeaconEntry types.BeaconEntry
|
||||||
@@ -716,7 +808,7 @@ type BlockTemplate struct {
|
|||||||
Messages []*types.SignedMessage
|
Messages []*types.SignedMessage
|
||||||
Epoch abi.ChainEpoch
|
Epoch abi.ChainEpoch
|
||||||
Timestamp uint64
|
Timestamp uint64
|
||||||
WinningPoStProof []abi.PoStProof
|
WinningPoStProof []builtin.PoStProof
|
||||||
}
|
}
|
||||||
|
|
||||||
type DataSize struct {
|
type DataSize struct {
|
||||||
@@ -740,6 +832,18 @@ const (
|
|||||||
MsigCancel
|
MsigCancel
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type Deadline struct {
|
||||||
|
PostSubmissions bitfield.BitField
|
||||||
|
}
|
||||||
|
|
||||||
|
type Partition struct {
|
||||||
|
AllSectors bitfield.BitField
|
||||||
|
FaultySectors bitfield.BitField
|
||||||
|
RecoveringSectors bitfield.BitField
|
||||||
|
LiveSectors bitfield.BitField
|
||||||
|
ActiveSectors bitfield.BitField
|
||||||
|
}
|
||||||
|
|
||||||
type Fault struct {
|
type Fault struct {
|
||||||
Miner address.Address
|
Miner address.Address
|
||||||
Epoch abi.ChainEpoch
|
Epoch abi.ChainEpoch
|
||||||
|
|||||||
+16
-14
@@ -11,11 +11,11 @@ import (
|
|||||||
"github.com/filecoin-project/go-fil-markets/piecestore"
|
"github.com/filecoin-project/go-fil-markets/piecestore"
|
||||||
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
|
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
|
||||||
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/extern/sector-storage/fsutil"
|
"github.com/filecoin-project/lotus/extern/sector-storage/fsutil"
|
||||||
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
|
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
|
||||||
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
|
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// StorageMiner is a low-level interface to the Filecoin network storage miner node
|
// StorageMiner is a low-level interface to the Filecoin network storage miner node
|
||||||
@@ -71,9 +71,9 @@ type StorageMiner interface {
|
|||||||
stores.SectorIndex
|
stores.SectorIndex
|
||||||
|
|
||||||
MarketImportDealData(ctx context.Context, propcid cid.Cid, path string) error
|
MarketImportDealData(ctx context.Context, propcid cid.Cid, path string) error
|
||||||
MarketListDeals(ctx context.Context) ([]storagemarket.StorageDeal, error)
|
MarketListDeals(ctx context.Context) ([]MarketDeal, error)
|
||||||
MarketListRetrievalDeals(ctx context.Context) ([]retrievalmarket.ProviderDealState, error)
|
MarketListRetrievalDeals(ctx context.Context) ([]retrievalmarket.ProviderDealState, error)
|
||||||
MarketGetDealUpdates(ctx context.Context, d cid.Cid) (<-chan storagemarket.MinerDeal, error)
|
MarketGetDealUpdates(ctx context.Context) (<-chan storagemarket.MinerDeal, error)
|
||||||
MarketListIncompleteDeals(ctx context.Context) ([]storagemarket.MinerDeal, error)
|
MarketListIncompleteDeals(ctx context.Context) ([]storagemarket.MinerDeal, error)
|
||||||
MarketSetAsk(ctx context.Context, price types.BigInt, verifiedPrice types.BigInt, duration abi.ChainEpoch, minPieceSize abi.PaddedPieceSize, maxPieceSize abi.PaddedPieceSize) error
|
MarketSetAsk(ctx context.Context, price types.BigInt, verifiedPrice types.BigInt, duration abi.ChainEpoch, minPieceSize abi.PaddedPieceSize, maxPieceSize abi.PaddedPieceSize) error
|
||||||
MarketGetAsk(ctx context.Context) (*storagemarket.SignedStorageAsk, error)
|
MarketGetAsk(ctx context.Context) (*storagemarket.SignedStorageAsk, error)
|
||||||
@@ -83,7 +83,7 @@ type StorageMiner interface {
|
|||||||
MarketDataTransferUpdates(ctx context.Context) (<-chan DataTransferChannel, error)
|
MarketDataTransferUpdates(ctx context.Context) (<-chan DataTransferChannel, error)
|
||||||
|
|
||||||
DealsImportData(ctx context.Context, dealPropCid cid.Cid, file string) error
|
DealsImportData(ctx context.Context, dealPropCid cid.Cid, file string) error
|
||||||
DealsList(ctx context.Context) ([]storagemarket.StorageDeal, error)
|
DealsList(ctx context.Context) ([]MarketDeal, error)
|
||||||
DealsConsiderOnlineStorageDeals(context.Context) (bool, error)
|
DealsConsiderOnlineStorageDeals(context.Context) (bool, error)
|
||||||
DealsSetConsiderOnlineStorageDeals(context.Context, bool) error
|
DealsSetConsiderOnlineStorageDeals(context.Context, bool) error
|
||||||
DealsConsiderOnlineRetrievalDeals(context.Context) (bool, error)
|
DealsConsiderOnlineRetrievalDeals(context.Context) (bool, error)
|
||||||
@@ -120,16 +120,18 @@ type SectorLog struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SectorInfo struct {
|
type SectorInfo struct {
|
||||||
SectorID abi.SectorNumber
|
SectorID abi.SectorNumber
|
||||||
State SectorState
|
State SectorState
|
||||||
CommD *cid.Cid
|
CommD *cid.Cid
|
||||||
CommR *cid.Cid
|
CommR *cid.Cid
|
||||||
Proof []byte
|
Proof []byte
|
||||||
Deals []abi.DealID
|
Deals []abi.DealID
|
||||||
Ticket SealTicket
|
Ticket SealTicket
|
||||||
Seed SealSeed
|
Seed SealSeed
|
||||||
Retries uint64
|
PreCommitMsg *cid.Cid
|
||||||
ToUpgrade bool
|
CommitMsg *cid.Cid
|
||||||
|
Retries uint64
|
||||||
|
ToUpgrade bool
|
||||||
|
|
||||||
LastErr string
|
LastErr string
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"reflect"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func goCmd() string {
|
func goCmd() string {
|
||||||
@@ -32,3 +36,68 @@ func TestDoesntDependOnFFI(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestReturnTypes(t *testing.T) {
|
||||||
|
errType := reflect.TypeOf(new(error)).Elem()
|
||||||
|
bareIface := reflect.TypeOf(new(interface{})).Elem()
|
||||||
|
jmarsh := reflect.TypeOf(new(json.Marshaler)).Elem()
|
||||||
|
|
||||||
|
tst := func(api interface{}) func(t *testing.T) {
|
||||||
|
return func(t *testing.T) {
|
||||||
|
ra := reflect.TypeOf(api).Elem()
|
||||||
|
for i := 0; i < ra.NumMethod(); i++ {
|
||||||
|
m := ra.Method(i)
|
||||||
|
switch m.Type.NumOut() {
|
||||||
|
case 1: // if 1 return value, it must be an error
|
||||||
|
require.Equal(t, errType, m.Type.Out(0), m.Name)
|
||||||
|
|
||||||
|
case 2: // if 2 return values, first cant be an interface/function, second must be an error
|
||||||
|
seen := map[reflect.Type]struct{}{}
|
||||||
|
todo := []reflect.Type{m.Type.Out(0)}
|
||||||
|
for len(todo) > 0 {
|
||||||
|
typ := todo[len(todo)-1]
|
||||||
|
todo = todo[:len(todo)-1]
|
||||||
|
|
||||||
|
if _, ok := seen[typ]; ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
seen[typ] = struct{}{}
|
||||||
|
|
||||||
|
if typ.Kind() == reflect.Interface && typ != bareIface && !typ.Implements(jmarsh) {
|
||||||
|
t.Error("methods can't return interfaces", m.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
switch typ.Kind() {
|
||||||
|
case reflect.Ptr:
|
||||||
|
fallthrough
|
||||||
|
case reflect.Array:
|
||||||
|
fallthrough
|
||||||
|
case reflect.Slice:
|
||||||
|
fallthrough
|
||||||
|
case reflect.Chan:
|
||||||
|
todo = append(todo, typ.Elem())
|
||||||
|
case reflect.Map:
|
||||||
|
todo = append(todo, typ.Elem())
|
||||||
|
todo = append(todo, typ.Key())
|
||||||
|
case reflect.Struct:
|
||||||
|
for i := 0; i < typ.NumField(); i++ {
|
||||||
|
todo = append(todo, typ.Field(i).Type)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NotEqual(t, reflect.Func.String(), m.Type.Out(0).Kind().String(), m.Name)
|
||||||
|
require.Equal(t, errType, m.Type.Out(1), m.Name)
|
||||||
|
|
||||||
|
default:
|
||||||
|
t.Error("methods can only have 1 or 2 return values", m.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Run("common", tst(new(Common)))
|
||||||
|
t.Run("full", tst(new(FullNode)))
|
||||||
|
t.Run("miner", tst(new(StorageMiner)))
|
||||||
|
t.Run("worker", tst(new(WorkerAPI)))
|
||||||
|
}
|
||||||
|
|||||||
+4
-2
@@ -6,10 +6,10 @@ import (
|
|||||||
|
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/lotus/extern/sector-storage/sealtasks"
|
"github.com/filecoin-project/lotus/extern/sector-storage/sealtasks"
|
||||||
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
|
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
|
||||||
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
|
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
|
||||||
"github.com/filecoin-project/specs-storage/storage"
|
"github.com/filecoin-project/specs-storage/storage"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
@@ -27,11 +27,13 @@ type WorkerAPI interface {
|
|||||||
|
|
||||||
storage.Sealer
|
storage.Sealer
|
||||||
|
|
||||||
MoveStorage(ctx context.Context, sector abi.SectorID) error
|
MoveStorage(ctx context.Context, sector abi.SectorID, types stores.SectorFileType) error
|
||||||
|
|
||||||
UnsealPiece(context.Context, abi.SectorID, storiface.UnpaddedByteIndex, abi.UnpaddedPieceSize, abi.SealRandomness, cid.Cid) error
|
UnsealPiece(context.Context, abi.SectorID, storiface.UnpaddedByteIndex, abi.UnpaddedPieceSize, abi.SealRandomness, cid.Cid) error
|
||||||
ReadPiece(context.Context, io.Writer, abi.SectorID, storiface.UnpaddedByteIndex, abi.UnpaddedPieceSize) (bool, error)
|
ReadPiece(context.Context, io.Writer, abi.SectorID, storiface.UnpaddedByteIndex, abi.UnpaddedPieceSize) (bool, error)
|
||||||
|
|
||||||
|
StorageAddLocal(ctx context.Context, path string) error
|
||||||
|
|
||||||
Fetch(context.Context, abi.SectorID, stores.SectorFileType, stores.PathType, stores.AcquireMode) error
|
Fetch(context.Context, abi.SectorID, stores.SectorFileType, stores.PathType, stores.AcquireMode) error
|
||||||
|
|
||||||
Closing(context.Context) (<-chan struct{}, error)
|
Closing(context.Context) (<-chan struct{}, error)
|
||||||
|
|||||||
+183
-88
@@ -5,31 +5,36 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
stnetwork "github.com/filecoin-project/go-state-types/network"
|
||||||
|
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
|
metrics "github.com/libp2p/go-libp2p-core/metrics"
|
||||||
"github.com/libp2p/go-libp2p-core/network"
|
"github.com/libp2p/go-libp2p-core/network"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
|
protocol "github.com/libp2p/go-libp2p-core/protocol"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/go-bitfield"
|
||||||
"github.com/filecoin-project/go-fil-markets/piecestore"
|
"github.com/filecoin-project/go-fil-markets/piecestore"
|
||||||
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
|
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
|
||||||
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
||||||
"github.com/filecoin-project/go-jsonrpc/auth"
|
"github.com/filecoin-project/go-jsonrpc/auth"
|
||||||
"github.com/filecoin-project/go-multistore"
|
"github.com/filecoin-project/go-multistore"
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
"github.com/filecoin-project/go-state-types/big"
|
||||||
|
"github.com/filecoin-project/go-state-types/crypto"
|
||||||
|
"github.com/filecoin-project/go-state-types/dline"
|
||||||
"github.com/filecoin-project/lotus/extern/sector-storage/fsutil"
|
"github.com/filecoin-project/lotus/extern/sector-storage/fsutil"
|
||||||
"github.com/filecoin-project/lotus/extern/sector-storage/sealtasks"
|
"github.com/filecoin-project/lotus/extern/sector-storage/sealtasks"
|
||||||
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
|
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
|
||||||
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
|
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
|
||||||
marketevents "github.com/filecoin-project/lotus/markets/loggers"
|
marketevents "github.com/filecoin-project/lotus/markets/loggers"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/paych"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/crypto"
|
|
||||||
"github.com/filecoin-project/specs-storage/storage"
|
"github.com/filecoin-project/specs-storage/storage"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/builtin/paych"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||||
)
|
)
|
||||||
@@ -42,14 +47,18 @@ type CommonStruct struct {
|
|||||||
AuthVerify func(ctx context.Context, token string) ([]auth.Permission, error) `perm:"read"`
|
AuthVerify func(ctx context.Context, token string) ([]auth.Permission, error) `perm:"read"`
|
||||||
AuthNew func(ctx context.Context, perms []auth.Permission) ([]byte, error) `perm:"admin"`
|
AuthNew func(ctx context.Context, perms []auth.Permission) ([]byte, error) `perm:"admin"`
|
||||||
|
|
||||||
NetConnectedness func(context.Context, peer.ID) (network.Connectedness, error) `perm:"read"`
|
NetConnectedness func(context.Context, peer.ID) (network.Connectedness, error) `perm:"read"`
|
||||||
NetPeers func(context.Context) ([]peer.AddrInfo, error) `perm:"read"`
|
NetPeers func(context.Context) ([]peer.AddrInfo, error) `perm:"read"`
|
||||||
NetConnect func(context.Context, peer.AddrInfo) error `perm:"write"`
|
NetConnect func(context.Context, peer.AddrInfo) error `perm:"write"`
|
||||||
NetAddrsListen func(context.Context) (peer.AddrInfo, error) `perm:"read"`
|
NetAddrsListen func(context.Context) (peer.AddrInfo, error) `perm:"read"`
|
||||||
NetDisconnect func(context.Context, peer.ID) error `perm:"write"`
|
NetDisconnect func(context.Context, peer.ID) error `perm:"write"`
|
||||||
NetFindPeer func(context.Context, peer.ID) (peer.AddrInfo, error) `perm:"read"`
|
NetFindPeer func(context.Context, peer.ID) (peer.AddrInfo, error) `perm:"read"`
|
||||||
NetPubsubScores func(context.Context) ([]api.PubsubScore, error) `perm:"read"`
|
NetPubsubScores func(context.Context) ([]api.PubsubScore, error) `perm:"read"`
|
||||||
NetAutoNatStatus func(context.Context) (api.NatInfo, error) `perm:"read"`
|
NetAutoNatStatus func(context.Context) (api.NatInfo, error) `perm:"read"`
|
||||||
|
NetBandwidthStats func(ctx context.Context) (metrics.Stats, error) `perm:"read"`
|
||||||
|
NetBandwidthStatsByPeer func(ctx context.Context) (map[string]metrics.Stats, error) `perm:"read"`
|
||||||
|
NetBandwidthStatsByProtocol func(ctx context.Context) (map[protocol.ID]metrics.Stats, error) `perm:"read"`
|
||||||
|
NetAgentVersion func(ctx context.Context, p peer.ID) (string, error) `perm:"read"`
|
||||||
|
|
||||||
ID func(context.Context) (peer.ID, error) `perm:"read"`
|
ID func(context.Context) (peer.ID, error) `perm:"read"`
|
||||||
Version func(context.Context) (api.Version, error) `perm:"read"`
|
Version func(context.Context) (api.Version, error) `perm:"read"`
|
||||||
@@ -78,6 +87,7 @@ type FullNodeStruct struct {
|
|||||||
ChainGetParentMessages func(context.Context, cid.Cid) ([]api.Message, error) `perm:"read"`
|
ChainGetParentMessages func(context.Context, cid.Cid) ([]api.Message, error) `perm:"read"`
|
||||||
ChainGetTipSetByHeight func(context.Context, abi.ChainEpoch, types.TipSetKey) (*types.TipSet, error) `perm:"read"`
|
ChainGetTipSetByHeight func(context.Context, abi.ChainEpoch, types.TipSetKey) (*types.TipSet, error) `perm:"read"`
|
||||||
ChainReadObj func(context.Context, cid.Cid) ([]byte, error) `perm:"read"`
|
ChainReadObj func(context.Context, cid.Cid) ([]byte, error) `perm:"read"`
|
||||||
|
ChainDeleteObj func(context.Context, cid.Cid) error `perm:"admin"`
|
||||||
ChainHasObj func(context.Context, cid.Cid) (bool, error) `perm:"read"`
|
ChainHasObj func(context.Context, cid.Cid) (bool, error) `perm:"read"`
|
||||||
ChainStatObj func(context.Context, cid.Cid, cid.Cid) (api.ObjStat, error) `perm:"read"`
|
ChainStatObj func(context.Context, cid.Cid, cid.Cid) (api.ObjStat, error) `perm:"read"`
|
||||||
ChainSetHead func(context.Context, types.TipSetKey) error `perm:"admin"`
|
ChainSetHead func(context.Context, types.TipSetKey) error `perm:"admin"`
|
||||||
@@ -86,7 +96,7 @@ type FullNodeStruct struct {
|
|||||||
ChainGetNode func(ctx context.Context, p string) (*api.IpldObject, error) `perm:"read"`
|
ChainGetNode func(ctx context.Context, p string) (*api.IpldObject, error) `perm:"read"`
|
||||||
ChainGetMessage func(context.Context, cid.Cid) (*types.Message, error) `perm:"read"`
|
ChainGetMessage func(context.Context, cid.Cid) (*types.Message, error) `perm:"read"`
|
||||||
ChainGetPath func(context.Context, types.TipSetKey, types.TipSetKey) ([]*api.HeadChange, error) `perm:"read"`
|
ChainGetPath func(context.Context, types.TipSetKey, types.TipSetKey) ([]*api.HeadChange, error) `perm:"read"`
|
||||||
ChainExport func(context.Context, types.TipSetKey) (<-chan []byte, error) `perm:"read"`
|
ChainExport func(context.Context, abi.ChainEpoch, bool, types.TipSetKey) (<-chan []byte, error) `perm:"read"`
|
||||||
|
|
||||||
BeaconGetEntry func(ctx context.Context, epoch abi.ChainEpoch) (*types.BeaconEntry, error) `perm:"read"`
|
BeaconGetEntry func(ctx context.Context, epoch abi.ChainEpoch) (*types.BeaconEntry, error) `perm:"read"`
|
||||||
|
|
||||||
@@ -98,7 +108,9 @@ type FullNodeStruct struct {
|
|||||||
SyncState func(context.Context) (*api.SyncState, error) `perm:"read"`
|
SyncState func(context.Context) (*api.SyncState, error) `perm:"read"`
|
||||||
SyncSubmitBlock func(ctx context.Context, blk *types.BlockMsg) error `perm:"write"`
|
SyncSubmitBlock func(ctx context.Context, blk *types.BlockMsg) error `perm:"write"`
|
||||||
SyncIncomingBlocks func(ctx context.Context) (<-chan *types.BlockHeader, error) `perm:"read"`
|
SyncIncomingBlocks func(ctx context.Context) (<-chan *types.BlockHeader, error) `perm:"read"`
|
||||||
|
SyncCheckpoint func(ctx context.Context, key types.TipSetKey) error `perm:"admin"`
|
||||||
SyncMarkBad func(ctx context.Context, bcid cid.Cid) error `perm:"admin"`
|
SyncMarkBad func(ctx context.Context, bcid cid.Cid) error `perm:"admin"`
|
||||||
|
SyncUnmarkBad func(ctx context.Context, bcid cid.Cid) error `perm:"admin"`
|
||||||
SyncCheckBad func(ctx context.Context, bcid cid.Cid) (string, error) `perm:"read"`
|
SyncCheckBad func(ctx context.Context, bcid cid.Cid) (string, error) `perm:"read"`
|
||||||
|
|
||||||
MpoolGetConfig func(context.Context) (*types.MpoolConfig, error) `perm:"read"`
|
MpoolGetConfig func(context.Context) (*types.MpoolConfig, error) `perm:"read"`
|
||||||
@@ -123,53 +135,56 @@ type FullNodeStruct struct {
|
|||||||
WalletBalance func(context.Context, address.Address) (types.BigInt, error) `perm:"read"`
|
WalletBalance func(context.Context, address.Address) (types.BigInt, error) `perm:"read"`
|
||||||
WalletSign func(context.Context, address.Address, []byte) (*crypto.Signature, error) `perm:"sign"`
|
WalletSign func(context.Context, address.Address, []byte) (*crypto.Signature, error) `perm:"sign"`
|
||||||
WalletSignMessage func(context.Context, address.Address, *types.Message) (*types.SignedMessage, error) `perm:"sign"`
|
WalletSignMessage func(context.Context, address.Address, *types.Message) (*types.SignedMessage, error) `perm:"sign"`
|
||||||
WalletVerify func(context.Context, address.Address, []byte, *crypto.Signature) bool `perm:"read"`
|
WalletVerify func(context.Context, address.Address, []byte, *crypto.Signature) (bool, error) `perm:"read"`
|
||||||
WalletDefaultAddress func(context.Context) (address.Address, error) `perm:"write"`
|
WalletDefaultAddress func(context.Context) (address.Address, error) `perm:"write"`
|
||||||
WalletSetDefault func(context.Context, address.Address) error `perm:"admin"`
|
WalletSetDefault func(context.Context, address.Address) error `perm:"admin"`
|
||||||
WalletExport func(context.Context, address.Address) (*types.KeyInfo, error) `perm:"admin"`
|
WalletExport func(context.Context, address.Address) (*types.KeyInfo, error) `perm:"admin"`
|
||||||
WalletImport func(context.Context, *types.KeyInfo) (address.Address, error) `perm:"admin"`
|
WalletImport func(context.Context, *types.KeyInfo) (address.Address, error) `perm:"admin"`
|
||||||
WalletDelete func(context.Context, address.Address) error `perm:"write"`
|
WalletDelete func(context.Context, address.Address) error `perm:"write"`
|
||||||
|
|
||||||
ClientImport func(ctx context.Context, ref api.FileRef) (*api.ImportRes, error) `perm:"admin"`
|
ClientImport func(ctx context.Context, ref api.FileRef) (*api.ImportRes, error) `perm:"admin"`
|
||||||
ClientListImports func(ctx context.Context) ([]api.Import, error) `perm:"write"`
|
ClientListImports func(ctx context.Context) ([]api.Import, error) `perm:"write"`
|
||||||
ClientRemoveImport func(ctx context.Context, importID multistore.StoreID) error `perm:"admin"`
|
ClientRemoveImport func(ctx context.Context, importID multistore.StoreID) error `perm:"admin"`
|
||||||
ClientHasLocal func(ctx context.Context, root cid.Cid) (bool, error) `perm:"write"`
|
ClientHasLocal func(ctx context.Context, root cid.Cid) (bool, error) `perm:"write"`
|
||||||
ClientFindData func(ctx context.Context, root cid.Cid, piece *cid.Cid) ([]api.QueryOffer, error) `perm:"read"`
|
ClientFindData func(ctx context.Context, root cid.Cid, piece *cid.Cid) ([]api.QueryOffer, error) `perm:"read"`
|
||||||
ClientMinerQueryOffer func(ctx context.Context, miner address.Address, root cid.Cid, piece *cid.Cid) (api.QueryOffer, error) `perm:"read"`
|
ClientMinerQueryOffer func(ctx context.Context, miner address.Address, root cid.Cid, piece *cid.Cid) (api.QueryOffer, error) `perm:"read"`
|
||||||
ClientStartDeal func(ctx context.Context, params *api.StartDealParams) (*cid.Cid, error) `perm:"admin"`
|
ClientStartDeal func(ctx context.Context, params *api.StartDealParams) (*cid.Cid, error) `perm:"admin"`
|
||||||
ClientGetDealInfo func(context.Context, cid.Cid) (*api.DealInfo, error) `perm:"read"`
|
ClientGetDealInfo func(context.Context, cid.Cid) (*api.DealInfo, error) `perm:"read"`
|
||||||
ClientListDeals func(ctx context.Context) ([]api.DealInfo, error) `perm:"write"`
|
ClientListDeals func(ctx context.Context) ([]api.DealInfo, error) `perm:"write"`
|
||||||
ClientRetrieve func(ctx context.Context, order api.RetrievalOrder, ref *api.FileRef) error `perm:"admin"`
|
ClientGetDealUpdates func(ctx context.Context) (<-chan api.DealInfo, error) `perm:"read"`
|
||||||
ClientRetrieveWithEvents func(ctx context.Context, order api.RetrievalOrder, ref *api.FileRef) (<-chan marketevents.RetrievalEvent, error) `perm:"admin"`
|
ClientRetrieve func(ctx context.Context, order api.RetrievalOrder, ref *api.FileRef) error `perm:"admin"`
|
||||||
ClientQueryAsk func(ctx context.Context, p peer.ID, miner address.Address) (*storagemarket.SignedStorageAsk, error) `perm:"read"`
|
ClientRetrieveWithEvents func(ctx context.Context, order api.RetrievalOrder, ref *api.FileRef) (<-chan marketevents.RetrievalEvent, error) `perm:"admin"`
|
||||||
ClientCalcCommP func(ctx context.Context, inpath string) (*api.CommPRet, error) `perm:"read"`
|
ClientQueryAsk func(ctx context.Context, p peer.ID, miner address.Address) (*storagemarket.SignedStorageAsk, error) `perm:"read"`
|
||||||
ClientGenCar func(ctx context.Context, ref api.FileRef, outpath string) error `perm:"write"`
|
ClientCalcCommP func(ctx context.Context, inpath string) (*api.CommPRet, error) `perm:"read"`
|
||||||
ClientDealSize func(ctx context.Context, root cid.Cid) (api.DataSize, error) `perm:"read"`
|
ClientGenCar func(ctx context.Context, ref api.FileRef, outpath string) error `perm:"write"`
|
||||||
ClientListDataTransfers func(ctx context.Context) ([]api.DataTransferChannel, error) `perm:"write"`
|
ClientDealSize func(ctx context.Context, root cid.Cid) (api.DataSize, error) `perm:"read"`
|
||||||
ClientDataTransferUpdates func(ctx context.Context) (<-chan api.DataTransferChannel, error) `perm:"write"`
|
ClientListDataTransfers func(ctx context.Context) ([]api.DataTransferChannel, error) `perm:"write"`
|
||||||
|
ClientDataTransferUpdates func(ctx context.Context) (<-chan api.DataTransferChannel, error) `perm:"write"`
|
||||||
|
ClientRetrieveTryRestartInsufficientFunds func(ctx context.Context, paymentChannel address.Address) error `perm:"write"`
|
||||||
|
|
||||||
StateNetworkName func(context.Context) (dtypes.NetworkName, error) `perm:"read"`
|
StateNetworkName func(context.Context) (dtypes.NetworkName, error) `perm:"read"`
|
||||||
StateMinerSectors func(context.Context, address.Address, *abi.BitField, bool, types.TipSetKey) ([]*api.ChainSectorInfo, error) `perm:"read"`
|
StateMinerSectors func(context.Context, address.Address, *bitfield.BitField, types.TipSetKey) ([]*miner.SectorOnChainInfo, error) `perm:"read"`
|
||||||
StateMinerActiveSectors func(context.Context, address.Address, types.TipSetKey) ([]*api.ChainSectorInfo, error) `perm:"read"`
|
StateMinerActiveSectors func(context.Context, address.Address, types.TipSetKey) ([]*miner.SectorOnChainInfo, error) `perm:"read"`
|
||||||
StateMinerProvingDeadline func(context.Context, address.Address, types.TipSetKey) (*miner.DeadlineInfo, error) `perm:"read"`
|
StateMinerProvingDeadline func(context.Context, address.Address, types.TipSetKey) (*dline.Info, error) `perm:"read"`
|
||||||
StateMinerPower func(context.Context, address.Address, types.TipSetKey) (*api.MinerPower, error) `perm:"read"`
|
StateMinerPower func(context.Context, address.Address, types.TipSetKey) (*api.MinerPower, error) `perm:"read"`
|
||||||
StateMinerInfo func(context.Context, address.Address, types.TipSetKey) (api.MinerInfo, error) `perm:"read"`
|
StateMinerInfo func(context.Context, address.Address, types.TipSetKey) (miner.MinerInfo, error) `perm:"read"`
|
||||||
StateMinerDeadlines func(context.Context, address.Address, types.TipSetKey) ([]*miner.Deadline, error) `perm:"read"`
|
StateMinerDeadlines func(context.Context, address.Address, types.TipSetKey) ([]api.Deadline, error) `perm:"read"`
|
||||||
StateMinerPartitions func(context.Context, address.Address, uint64, types.TipSetKey) ([]*miner.Partition, error) `perm:"read"`
|
StateMinerPartitions func(ctx context.Context, m address.Address, dlIdx uint64, tsk types.TipSetKey) ([]api.Partition, error) `perm:"read"`
|
||||||
StateMinerFaults func(context.Context, address.Address, types.TipSetKey) (abi.BitField, error) `perm:"read"`
|
StateMinerFaults func(context.Context, address.Address, types.TipSetKey) (bitfield.BitField, error) `perm:"read"`
|
||||||
StateAllMinerFaults func(context.Context, abi.ChainEpoch, types.TipSetKey) ([]*api.Fault, error) `perm:"read"`
|
StateAllMinerFaults func(context.Context, abi.ChainEpoch, types.TipSetKey) ([]*api.Fault, error) `perm:"read"`
|
||||||
StateMinerRecoveries func(context.Context, address.Address, types.TipSetKey) (abi.BitField, error) `perm:"read"`
|
StateMinerRecoveries func(context.Context, address.Address, types.TipSetKey) (bitfield.BitField, error) `perm:"read"`
|
||||||
StateMinerPreCommitDepositForPower func(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (types.BigInt, error) `perm:"read"`
|
StateMinerPreCommitDepositForPower func(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (types.BigInt, error) `perm:"read"`
|
||||||
StateMinerInitialPledgeCollateral func(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (types.BigInt, error) `perm:"read"`
|
StateMinerInitialPledgeCollateral func(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (types.BigInt, error) `perm:"read"`
|
||||||
StateMinerAvailableBalance func(context.Context, address.Address, types.TipSetKey) (types.BigInt, error) `perm:"read"`
|
StateMinerAvailableBalance func(context.Context, address.Address, types.TipSetKey) (types.BigInt, error) `perm:"read"`
|
||||||
StateSectorPreCommitInfo func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) `perm:"read"`
|
StateSectorPreCommitInfo func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) `perm:"read"`
|
||||||
StateSectorGetInfo func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error) `perm:"read"`
|
StateSectorGetInfo func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error) `perm:"read"`
|
||||||
StateSectorExpiration func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*api.SectorExpiration, error) `perm:"read"`
|
StateSectorExpiration func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorExpiration, error) `perm:"read"`
|
||||||
StateSectorPartition func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*api.SectorLocation, error) `perm:"read"`
|
StateSectorPartition func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorLocation, error) `perm:"read"`
|
||||||
StateCall func(context.Context, *types.Message, types.TipSetKey) (*api.InvocResult, error) `perm:"read"`
|
StateCall func(context.Context, *types.Message, types.TipSetKey) (*api.InvocResult, error) `perm:"read"`
|
||||||
StateReplay func(context.Context, types.TipSetKey, cid.Cid) (*api.InvocResult, error) `perm:"read"`
|
StateReplay func(context.Context, types.TipSetKey, cid.Cid) (*api.InvocResult, error) `perm:"read"`
|
||||||
StateGetActor func(context.Context, address.Address, types.TipSetKey) (*types.Actor, error) `perm:"read"`
|
StateGetActor func(context.Context, address.Address, types.TipSetKey) (*types.Actor, error) `perm:"read"`
|
||||||
StateReadState func(context.Context, address.Address, types.TipSetKey) (*api.ActorState, error) `perm:"read"`
|
StateReadState func(context.Context, address.Address, types.TipSetKey) (*api.ActorState, error) `perm:"read"`
|
||||||
|
StateMsgGasCost func(context.Context, cid.Cid, types.TipSetKey) (*api.MsgGasCost, error) `perm:"read"`
|
||||||
StateWaitMsg func(ctx context.Context, cid cid.Cid, confidence uint64) (*api.MsgLookup, error) `perm:"read"`
|
StateWaitMsg func(ctx context.Context, cid cid.Cid, confidence uint64) (*api.MsgLookup, error) `perm:"read"`
|
||||||
StateSearchMsg func(context.Context, cid.Cid) (*api.MsgLookup, error) `perm:"read"`
|
StateSearchMsg func(context.Context, cid.Cid) (*api.MsgLookup, error) `perm:"read"`
|
||||||
StateListMiners func(context.Context, types.TipSetKey) ([]address.Address, error) `perm:"read"`
|
StateListMiners func(context.Context, types.TipSetKey) ([]address.Address, error) `perm:"read"`
|
||||||
@@ -185,36 +200,43 @@ type FullNodeStruct struct {
|
|||||||
StateMinerSectorCount func(context.Context, address.Address, types.TipSetKey) (api.MinerSectors, error) `perm:"read"`
|
StateMinerSectorCount func(context.Context, address.Address, types.TipSetKey) (api.MinerSectors, error) `perm:"read"`
|
||||||
StateListMessages func(ctx context.Context, match *types.Message, tsk types.TipSetKey, toht abi.ChainEpoch) ([]cid.Cid, error) `perm:"read"`
|
StateListMessages func(ctx context.Context, match *types.Message, tsk types.TipSetKey, toht abi.ChainEpoch) ([]cid.Cid, error) `perm:"read"`
|
||||||
StateCompute func(context.Context, abi.ChainEpoch, []*types.Message, types.TipSetKey) (*api.ComputeStateOutput, error) `perm:"read"`
|
StateCompute func(context.Context, abi.ChainEpoch, []*types.Message, types.TipSetKey) (*api.ComputeStateOutput, error) `perm:"read"`
|
||||||
StateVerifiedClientStatus func(context.Context, address.Address, types.TipSetKey) (*verifreg.DataCap, error) `perm:"read"`
|
StateVerifiedClientStatus func(context.Context, address.Address, types.TipSetKey) (*abi.StoragePower, error) `perm:"read"`
|
||||||
StateDealProviderCollateralBounds func(context.Context, abi.PaddedPieceSize, bool, types.TipSetKey) (api.DealCollateralBounds, error) `perm:"read"`
|
StateDealProviderCollateralBounds func(context.Context, abi.PaddedPieceSize, bool, types.TipSetKey) (api.DealCollateralBounds, error) `perm:"read"`
|
||||||
StateCirculatingSupply func(context.Context, types.TipSetKey) (api.CirculatingSupply, error) `perm:"read"`
|
StateCirculatingSupply func(context.Context, types.TipSetKey) (api.CirculatingSupply, error) `perm:"read"`
|
||||||
|
StateNetworkVersion func(context.Context, types.TipSetKey) (stnetwork.Version, error) `perm:"read"`
|
||||||
|
|
||||||
MsigGetAvailableBalance func(context.Context, address.Address, types.TipSetKey) (types.BigInt, error) `perm:"read"`
|
MsigGetAvailableBalance func(context.Context, address.Address, types.TipSetKey) (types.BigInt, error) `perm:"read"`
|
||||||
|
MsigGetVested func(context.Context, address.Address, types.TipSetKey, types.TipSetKey) (types.BigInt, error) `perm:"read"`
|
||||||
MsigCreate func(context.Context, uint64, []address.Address, abi.ChainEpoch, types.BigInt, address.Address, types.BigInt) (cid.Cid, error) `perm:"sign"`
|
MsigCreate func(context.Context, uint64, []address.Address, abi.ChainEpoch, types.BigInt, address.Address, types.BigInt) (cid.Cid, error) `perm:"sign"`
|
||||||
MsigPropose func(context.Context, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error) `perm:"sign"`
|
MsigPropose func(context.Context, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error) `perm:"sign"`
|
||||||
MsigApprove func(context.Context, address.Address, uint64, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error) `perm:"sign"`
|
MsigApprove func(context.Context, address.Address, uint64, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error) `perm:"sign"`
|
||||||
MsigCancel func(context.Context, address.Address, uint64, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error) `perm:"sign"`
|
MsigCancel func(context.Context, address.Address, uint64, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error) `perm:"sign"`
|
||||||
|
MsigAddPropose func(context.Context, address.Address, address.Address, address.Address, bool) (cid.Cid, error) `perm:"sign"`
|
||||||
|
MsigAddApprove func(context.Context, address.Address, address.Address, uint64, address.Address, address.Address, bool) (cid.Cid, error) `perm:"sign"`
|
||||||
|
MsigAddCancel func(context.Context, address.Address, address.Address, uint64, address.Address, bool) (cid.Cid, error) `perm:"sign"`
|
||||||
MsigSwapPropose func(context.Context, address.Address, address.Address, address.Address, address.Address) (cid.Cid, error) `perm:"sign"`
|
MsigSwapPropose func(context.Context, address.Address, address.Address, address.Address, address.Address) (cid.Cid, error) `perm:"sign"`
|
||||||
MsigSwapApprove func(context.Context, address.Address, address.Address, uint64, address.Address, address.Address, address.Address) (cid.Cid, error) `perm:"sign"`
|
MsigSwapApprove func(context.Context, address.Address, address.Address, uint64, address.Address, address.Address, address.Address) (cid.Cid, error) `perm:"sign"`
|
||||||
MsigSwapCancel func(context.Context, address.Address, address.Address, uint64, address.Address, address.Address) (cid.Cid, error) `perm:"sign"`
|
MsigSwapCancel func(context.Context, address.Address, address.Address, uint64, address.Address, address.Address) (cid.Cid, error) `perm:"sign"`
|
||||||
|
|
||||||
MarketEnsureAvailable func(context.Context, address.Address, address.Address, types.BigInt) (cid.Cid, error) `perm:"sign"`
|
MarketEnsureAvailable func(context.Context, address.Address, address.Address, types.BigInt) (cid.Cid, error) `perm:"sign"`
|
||||||
|
|
||||||
PaychGet func(ctx context.Context, from, to address.Address, amt types.BigInt) (*api.ChannelInfo, error) `perm:"sign"`
|
PaychGet func(ctx context.Context, from, to address.Address, amt types.BigInt) (*api.ChannelInfo, error) `perm:"sign"`
|
||||||
PaychGetWaitReady func(context.Context, cid.Cid) (address.Address, error) `perm:"sign"`
|
PaychGetWaitReady func(context.Context, cid.Cid) (address.Address, error) `perm:"sign"`
|
||||||
PaychList func(context.Context) ([]address.Address, error) `perm:"read"`
|
PaychAvailableFunds func(context.Context, address.Address) (*api.ChannelAvailableFunds, error) `perm:"sign"`
|
||||||
PaychStatus func(context.Context, address.Address) (*api.PaychStatus, error) `perm:"read"`
|
PaychAvailableFundsByFromTo func(context.Context, address.Address, address.Address) (*api.ChannelAvailableFunds, error) `perm:"sign"`
|
||||||
PaychSettle func(context.Context, address.Address) (cid.Cid, error) `perm:"sign"`
|
PaychList func(context.Context) ([]address.Address, error) `perm:"read"`
|
||||||
PaychCollect func(context.Context, address.Address) (cid.Cid, error) `perm:"sign"`
|
PaychStatus func(context.Context, address.Address) (*api.PaychStatus, error) `perm:"read"`
|
||||||
PaychAllocateLane func(context.Context, address.Address) (uint64, error) `perm:"sign"`
|
PaychSettle func(context.Context, address.Address) (cid.Cid, error) `perm:"sign"`
|
||||||
PaychNewPayment func(ctx context.Context, from, to address.Address, vouchers []api.VoucherSpec) (*api.PaymentInfo, error) `perm:"sign"`
|
PaychCollect func(context.Context, address.Address) (cid.Cid, error) `perm:"sign"`
|
||||||
PaychVoucherCheck func(context.Context, *paych.SignedVoucher) error `perm:"read"`
|
PaychAllocateLane func(context.Context, address.Address) (uint64, error) `perm:"sign"`
|
||||||
PaychVoucherCheckValid func(context.Context, address.Address, *paych.SignedVoucher) error `perm:"read"`
|
PaychNewPayment func(ctx context.Context, from, to address.Address, vouchers []api.VoucherSpec) (*api.PaymentInfo, error) `perm:"sign"`
|
||||||
PaychVoucherCheckSpendable func(context.Context, address.Address, *paych.SignedVoucher, []byte, []byte) (bool, error) `perm:"read"`
|
PaychVoucherCheck func(context.Context, *paych.SignedVoucher) error `perm:"read"`
|
||||||
PaychVoucherAdd func(context.Context, address.Address, *paych.SignedVoucher, []byte, types.BigInt) (types.BigInt, error) `perm:"write"`
|
PaychVoucherCheckValid func(context.Context, address.Address, *paych.SignedVoucher) error `perm:"read"`
|
||||||
PaychVoucherCreate func(context.Context, address.Address, big.Int, uint64) (*paych.SignedVoucher, error) `perm:"sign"`
|
PaychVoucherCheckSpendable func(context.Context, address.Address, *paych.SignedVoucher, []byte, []byte) (bool, error) `perm:"read"`
|
||||||
PaychVoucherList func(context.Context, address.Address) ([]*paych.SignedVoucher, error) `perm:"write"`
|
PaychVoucherAdd func(context.Context, address.Address, *paych.SignedVoucher, []byte, types.BigInt) (types.BigInt, error) `perm:"write"`
|
||||||
PaychVoucherSubmit func(context.Context, address.Address, *paych.SignedVoucher) (cid.Cid, error) `perm:"sign"`
|
PaychVoucherCreate func(context.Context, address.Address, big.Int, uint64) (*api.VoucherCreateResult, error) `perm:"sign"`
|
||||||
|
PaychVoucherList func(context.Context, address.Address) ([]*paych.SignedVoucher, error) `perm:"write"`
|
||||||
|
PaychVoucherSubmit func(context.Context, address.Address, *paych.SignedVoucher, []byte, []byte) (cid.Cid, error) `perm:"sign"`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,9 +254,9 @@ type StorageMinerStruct struct {
|
|||||||
MiningBase func(context.Context) (*types.TipSet, error) `perm:"read"`
|
MiningBase func(context.Context) (*types.TipSet, error) `perm:"read"`
|
||||||
|
|
||||||
MarketImportDealData func(context.Context, cid.Cid, string) error `perm:"write"`
|
MarketImportDealData func(context.Context, cid.Cid, string) error `perm:"write"`
|
||||||
MarketListDeals func(ctx context.Context) ([]storagemarket.StorageDeal, error) `perm:"read"`
|
MarketListDeals func(ctx context.Context) ([]api.MarketDeal, error) `perm:"read"`
|
||||||
MarketListRetrievalDeals func(ctx context.Context) ([]retrievalmarket.ProviderDealState, error) `perm:"read"`
|
MarketListRetrievalDeals func(ctx context.Context) ([]retrievalmarket.ProviderDealState, error) `perm:"read"`
|
||||||
MarketGetDealUpdates func(ctx context.Context, d cid.Cid) (<-chan storagemarket.MinerDeal, error) `perm:"read"`
|
MarketGetDealUpdates func(ctx context.Context) (<-chan storagemarket.MinerDeal, error) `perm:"read"`
|
||||||
MarketListIncompleteDeals func(ctx context.Context) ([]storagemarket.MinerDeal, error) `perm:"read"`
|
MarketListIncompleteDeals func(ctx context.Context) ([]storagemarket.MinerDeal, error) `perm:"read"`
|
||||||
MarketSetAsk func(ctx context.Context, price types.BigInt, verifiedPrice types.BigInt, duration abi.ChainEpoch, minPieceSize abi.PaddedPieceSize, maxPieceSize abi.PaddedPieceSize) error `perm:"admin"`
|
MarketSetAsk func(ctx context.Context, price types.BigInt, verifiedPrice types.BigInt, duration abi.ChainEpoch, minPieceSize abi.PaddedPieceSize, maxPieceSize abi.PaddedPieceSize) error `perm:"admin"`
|
||||||
MarketGetAsk func(ctx context.Context) (*storagemarket.SignedStorageAsk, error) `perm:"read"`
|
MarketGetAsk func(ctx context.Context) (*storagemarket.SignedStorageAsk, error) `perm:"read"`
|
||||||
@@ -277,7 +299,7 @@ type StorageMinerStruct struct {
|
|||||||
StorageTryLock func(ctx context.Context, sector abi.SectorID, read stores.SectorFileType, write stores.SectorFileType) (bool, error) `perm:"admin"`
|
StorageTryLock func(ctx context.Context, sector abi.SectorID, read stores.SectorFileType, write stores.SectorFileType) (bool, error) `perm:"admin"`
|
||||||
|
|
||||||
DealsImportData func(ctx context.Context, dealPropCid cid.Cid, file string) error `perm:"write"`
|
DealsImportData func(ctx context.Context, dealPropCid cid.Cid, file string) error `perm:"write"`
|
||||||
DealsList func(ctx context.Context) ([]storagemarket.StorageDeal, error) `perm:"read"`
|
DealsList func(ctx context.Context) ([]api.MarketDeal, error) `perm:"read"`
|
||||||
DealsConsiderOnlineStorageDeals func(context.Context) (bool, error) `perm:"read"`
|
DealsConsiderOnlineStorageDeals func(context.Context) (bool, error) `perm:"read"`
|
||||||
DealsSetConsiderOnlineStorageDeals func(context.Context, bool) error `perm:"admin"`
|
DealsSetConsiderOnlineStorageDeals func(context.Context, bool) error `perm:"admin"`
|
||||||
DealsConsiderOnlineRetrievalDeals func(context.Context) (bool, error) `perm:"read"`
|
DealsConsiderOnlineRetrievalDeals func(context.Context) (bool, error) `perm:"read"`
|
||||||
@@ -316,7 +338,8 @@ type WorkerStruct struct {
|
|||||||
FinalizeSector func(context.Context, abi.SectorID, []storage.Range) error `perm:"admin"`
|
FinalizeSector func(context.Context, abi.SectorID, []storage.Range) error `perm:"admin"`
|
||||||
ReleaseUnsealed func(ctx context.Context, sector abi.SectorID, safeToFree []storage.Range) error `perm:"admin"`
|
ReleaseUnsealed func(ctx context.Context, sector abi.SectorID, safeToFree []storage.Range) error `perm:"admin"`
|
||||||
Remove func(ctx context.Context, sector abi.SectorID) error `perm:"admin"`
|
Remove func(ctx context.Context, sector abi.SectorID) error `perm:"admin"`
|
||||||
MoveStorage func(ctx context.Context, sector abi.SectorID) error `perm:"admin"`
|
MoveStorage func(ctx context.Context, sector abi.SectorID, types stores.SectorFileType) error `perm:"admin"`
|
||||||
|
StorageAddLocal func(ctx context.Context, path string) error `perm:"admin"`
|
||||||
|
|
||||||
UnsealPiece func(context.Context, abi.SectorID, storiface.UnpaddedByteIndex, abi.UnpaddedPieceSize, abi.SealRandomness, cid.Cid) error `perm:"admin"`
|
UnsealPiece func(context.Context, abi.SectorID, storiface.UnpaddedByteIndex, abi.UnpaddedPieceSize, abi.SealRandomness, cid.Cid) error `perm:"admin"`
|
||||||
ReadPiece func(context.Context, io.Writer, abi.SectorID, storiface.UnpaddedByteIndex, abi.UnpaddedPieceSize) (bool, error) `perm:"admin"`
|
ReadPiece func(context.Context, io.Writer, abi.SectorID, storiface.UnpaddedByteIndex, abi.UnpaddedPieceSize) (bool, error) `perm:"admin"`
|
||||||
@@ -369,6 +392,22 @@ func (c *CommonStruct) NetAutoNatStatus(ctx context.Context) (api.NatInfo, error
|
|||||||
return c.Internal.NetAutoNatStatus(ctx)
|
return c.Internal.NetAutoNatStatus(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *CommonStruct) NetBandwidthStats(ctx context.Context) (metrics.Stats, error) {
|
||||||
|
return c.Internal.NetBandwidthStats(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *CommonStruct) NetBandwidthStatsByPeer(ctx context.Context) (map[string]metrics.Stats, error) {
|
||||||
|
return c.Internal.NetBandwidthStatsByPeer(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *CommonStruct) NetBandwidthStatsByProtocol(ctx context.Context) (map[protocol.ID]metrics.Stats, error) {
|
||||||
|
return c.Internal.NetBandwidthStatsByProtocol(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *CommonStruct) NetAgentVersion(ctx context.Context, p peer.ID) (string, error) {
|
||||||
|
return c.Internal.NetAgentVersion(ctx, p)
|
||||||
|
}
|
||||||
|
|
||||||
// ID implements API.ID
|
// ID implements API.ID
|
||||||
func (c *CommonStruct) ID(ctx context.Context) (peer.ID, error) {
|
func (c *CommonStruct) ID(ctx context.Context) (peer.ID, error) {
|
||||||
return c.Internal.ID(ctx)
|
return c.Internal.ID(ctx)
|
||||||
@@ -433,6 +472,10 @@ func (c *FullNodeStruct) ClientListDeals(ctx context.Context) ([]api.DealInfo, e
|
|||||||
return c.Internal.ClientListDeals(ctx)
|
return c.Internal.ClientListDeals(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *FullNodeStruct) ClientGetDealUpdates(ctx context.Context) (<-chan api.DealInfo, error) {
|
||||||
|
return c.Internal.ClientGetDealUpdates(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) ClientRetrieve(ctx context.Context, order api.RetrievalOrder, ref *api.FileRef) error {
|
func (c *FullNodeStruct) ClientRetrieve(ctx context.Context, order api.RetrievalOrder, ref *api.FileRef) error {
|
||||||
return c.Internal.ClientRetrieve(ctx, order, ref)
|
return c.Internal.ClientRetrieve(ctx, order, ref)
|
||||||
}
|
}
|
||||||
@@ -464,6 +507,10 @@ func (c *FullNodeStruct) ClientDataTransferUpdates(ctx context.Context) (<-chan
|
|||||||
return c.Internal.ClientDataTransferUpdates(ctx)
|
return c.Internal.ClientDataTransferUpdates(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *FullNodeStruct) ClientRetrieveTryRestartInsufficientFunds(ctx context.Context, paymentChannel address.Address) error {
|
||||||
|
return c.Internal.ClientRetrieveTryRestartInsufficientFunds(ctx, paymentChannel)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) GasEstimateGasPremium(ctx context.Context, nblocksincl uint64, sender address.Address, gaslimit int64, tsk types.TipSetKey) (types.BigInt, error) {
|
func (c *FullNodeStruct) GasEstimateGasPremium(ctx context.Context, nblocksincl uint64, sender address.Address, gaslimit int64, tsk types.TipSetKey) (types.BigInt, error) {
|
||||||
return c.Internal.GasEstimateGasPremium(ctx, nblocksincl, sender, gaslimit, tsk)
|
return c.Internal.GasEstimateGasPremium(ctx, nblocksincl, sender, gaslimit, tsk)
|
||||||
}
|
}
|
||||||
@@ -560,7 +607,7 @@ func (c *FullNodeStruct) WalletSignMessage(ctx context.Context, k address.Addres
|
|||||||
return c.Internal.WalletSignMessage(ctx, k, msg)
|
return c.Internal.WalletSignMessage(ctx, k, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) WalletVerify(ctx context.Context, k address.Address, msg []byte, sig *crypto.Signature) bool {
|
func (c *FullNodeStruct) WalletVerify(ctx context.Context, k address.Address, msg []byte, sig *crypto.Signature) (bool, error) {
|
||||||
return c.Internal.WalletVerify(ctx, k, msg, sig)
|
return c.Internal.WalletVerify(ctx, k, msg, sig)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -616,6 +663,10 @@ func (c *FullNodeStruct) ChainReadObj(ctx context.Context, obj cid.Cid) ([]byte,
|
|||||||
return c.Internal.ChainReadObj(ctx, obj)
|
return c.Internal.ChainReadObj(ctx, obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *FullNodeStruct) ChainDeleteObj(ctx context.Context, obj cid.Cid) error {
|
||||||
|
return c.Internal.ChainDeleteObj(ctx, obj)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) ChainHasObj(ctx context.Context, o cid.Cid) (bool, error) {
|
func (c *FullNodeStruct) ChainHasObj(ctx context.Context, o cid.Cid) (bool, error) {
|
||||||
return c.Internal.ChainHasObj(ctx, o)
|
return c.Internal.ChainHasObj(ctx, o)
|
||||||
}
|
}
|
||||||
@@ -648,8 +699,8 @@ func (c *FullNodeStruct) ChainGetPath(ctx context.Context, from types.TipSetKey,
|
|||||||
return c.Internal.ChainGetPath(ctx, from, to)
|
return c.Internal.ChainGetPath(ctx, from, to)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) ChainExport(ctx context.Context, tsk types.TipSetKey) (<-chan []byte, error) {
|
func (c *FullNodeStruct) ChainExport(ctx context.Context, nroots abi.ChainEpoch, iom bool, tsk types.TipSetKey) (<-chan []byte, error) {
|
||||||
return c.Internal.ChainExport(ctx, tsk)
|
return c.Internal.ChainExport(ctx, nroots, iom, tsk)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) BeaconGetEntry(ctx context.Context, epoch abi.ChainEpoch) (*types.BeaconEntry, error) {
|
func (c *FullNodeStruct) BeaconGetEntry(ctx context.Context, epoch abi.ChainEpoch) (*types.BeaconEntry, error) {
|
||||||
@@ -668,10 +719,18 @@ func (c *FullNodeStruct) SyncIncomingBlocks(ctx context.Context) (<-chan *types.
|
|||||||
return c.Internal.SyncIncomingBlocks(ctx)
|
return c.Internal.SyncIncomingBlocks(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *FullNodeStruct) SyncCheckpoint(ctx context.Context, tsk types.TipSetKey) error {
|
||||||
|
return c.Internal.SyncCheckpoint(ctx, tsk)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) SyncMarkBad(ctx context.Context, bcid cid.Cid) error {
|
func (c *FullNodeStruct) SyncMarkBad(ctx context.Context, bcid cid.Cid) error {
|
||||||
return c.Internal.SyncMarkBad(ctx, bcid)
|
return c.Internal.SyncMarkBad(ctx, bcid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *FullNodeStruct) SyncUnmarkBad(ctx context.Context, bcid cid.Cid) error {
|
||||||
|
return c.Internal.SyncUnmarkBad(ctx, bcid)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) SyncCheckBad(ctx context.Context, bcid cid.Cid) (string, error) {
|
func (c *FullNodeStruct) SyncCheckBad(ctx context.Context, bcid cid.Cid) (string, error) {
|
||||||
return c.Internal.SyncCheckBad(ctx, bcid)
|
return c.Internal.SyncCheckBad(ctx, bcid)
|
||||||
}
|
}
|
||||||
@@ -680,15 +739,15 @@ func (c *FullNodeStruct) StateNetworkName(ctx context.Context) (dtypes.NetworkNa
|
|||||||
return c.Internal.StateNetworkName(ctx)
|
return c.Internal.StateNetworkName(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) StateMinerSectors(ctx context.Context, addr address.Address, filter *abi.BitField, filterOut bool, tsk types.TipSetKey) ([]*api.ChainSectorInfo, error) {
|
func (c *FullNodeStruct) StateMinerSectors(ctx context.Context, addr address.Address, sectorNos *bitfield.BitField, tsk types.TipSetKey) ([]*miner.SectorOnChainInfo, error) {
|
||||||
return c.Internal.StateMinerSectors(ctx, addr, filter, filterOut, tsk)
|
return c.Internal.StateMinerSectors(ctx, addr, sectorNos, tsk)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) StateMinerActiveSectors(ctx context.Context, addr address.Address, tsk types.TipSetKey) ([]*api.ChainSectorInfo, error) {
|
func (c *FullNodeStruct) StateMinerActiveSectors(ctx context.Context, addr address.Address, tsk types.TipSetKey) ([]*miner.SectorOnChainInfo, error) {
|
||||||
return c.Internal.StateMinerActiveSectors(ctx, addr, tsk)
|
return c.Internal.StateMinerActiveSectors(ctx, addr, tsk)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) StateMinerProvingDeadline(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*miner.DeadlineInfo, error) {
|
func (c *FullNodeStruct) StateMinerProvingDeadline(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*dline.Info, error) {
|
||||||
return c.Internal.StateMinerProvingDeadline(ctx, addr, tsk)
|
return c.Internal.StateMinerProvingDeadline(ctx, addr, tsk)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,19 +755,19 @@ func (c *FullNodeStruct) StateMinerPower(ctx context.Context, a address.Address,
|
|||||||
return c.Internal.StateMinerPower(ctx, a, tsk)
|
return c.Internal.StateMinerPower(ctx, a, tsk)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) StateMinerInfo(ctx context.Context, actor address.Address, tsk types.TipSetKey) (api.MinerInfo, error) {
|
func (c *FullNodeStruct) StateMinerInfo(ctx context.Context, actor address.Address, tsk types.TipSetKey) (miner.MinerInfo, error) {
|
||||||
return c.Internal.StateMinerInfo(ctx, actor, tsk)
|
return c.Internal.StateMinerInfo(ctx, actor, tsk)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) StateMinerDeadlines(ctx context.Context, m address.Address, tsk types.TipSetKey) ([]*miner.Deadline, error) {
|
func (c *FullNodeStruct) StateMinerDeadlines(ctx context.Context, actor address.Address, tsk types.TipSetKey) ([]api.Deadline, error) {
|
||||||
return c.Internal.StateMinerDeadlines(ctx, m, tsk)
|
return c.Internal.StateMinerDeadlines(ctx, actor, tsk)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) StateMinerPartitions(ctx context.Context, m address.Address, dlIdx uint64, tsk types.TipSetKey) ([]*miner.Partition, error) {
|
func (c *FullNodeStruct) StateMinerPartitions(ctx context.Context, m address.Address, dlIdx uint64, tsk types.TipSetKey) ([]api.Partition, error) {
|
||||||
return c.Internal.StateMinerPartitions(ctx, m, dlIdx, tsk)
|
return c.Internal.StateMinerPartitions(ctx, m, dlIdx, tsk)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) StateMinerFaults(ctx context.Context, actor address.Address, tsk types.TipSetKey) (abi.BitField, error) {
|
func (c *FullNodeStruct) StateMinerFaults(ctx context.Context, actor address.Address, tsk types.TipSetKey) (bitfield.BitField, error) {
|
||||||
return c.Internal.StateMinerFaults(ctx, actor, tsk)
|
return c.Internal.StateMinerFaults(ctx, actor, tsk)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -716,7 +775,7 @@ func (c *FullNodeStruct) StateAllMinerFaults(ctx context.Context, cutoff abi.Cha
|
|||||||
return c.Internal.StateAllMinerFaults(ctx, cutoff, endTsk)
|
return c.Internal.StateAllMinerFaults(ctx, cutoff, endTsk)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) StateMinerRecoveries(ctx context.Context, actor address.Address, tsk types.TipSetKey) (abi.BitField, error) {
|
func (c *FullNodeStruct) StateMinerRecoveries(ctx context.Context, actor address.Address, tsk types.TipSetKey) (bitfield.BitField, error) {
|
||||||
return c.Internal.StateMinerRecoveries(ctx, actor, tsk)
|
return c.Internal.StateMinerRecoveries(ctx, actor, tsk)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -740,11 +799,11 @@ func (c *FullNodeStruct) StateSectorGetInfo(ctx context.Context, maddr address.A
|
|||||||
return c.Internal.StateSectorGetInfo(ctx, maddr, n, tsk)
|
return c.Internal.StateSectorGetInfo(ctx, maddr, n, tsk)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) StateSectorExpiration(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk types.TipSetKey) (*api.SectorExpiration, error) {
|
func (c *FullNodeStruct) StateSectorExpiration(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk types.TipSetKey) (*miner.SectorExpiration, error) {
|
||||||
return c.Internal.StateSectorExpiration(ctx, maddr, n, tsk)
|
return c.Internal.StateSectorExpiration(ctx, maddr, n, tsk)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*api.SectorLocation, error) {
|
func (c *FullNodeStruct) StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*miner.SectorLocation, error) {
|
||||||
return c.Internal.StateSectorPartition(ctx, maddr, sectorNumber, tok)
|
return c.Internal.StateSectorPartition(ctx, maddr, sectorNumber, tok)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -764,6 +823,10 @@ func (c *FullNodeStruct) StateReadState(ctx context.Context, addr address.Addres
|
|||||||
return c.Internal.StateReadState(ctx, addr, tsk)
|
return c.Internal.StateReadState(ctx, addr, tsk)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *FullNodeStruct) StateMsgGasCost(ctx context.Context, msgc cid.Cid, tsk types.TipSetKey) (*api.MsgGasCost, error) {
|
||||||
|
return c.Internal.StateMsgGasCost(ctx, msgc, tsk)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) StateWaitMsg(ctx context.Context, msgc cid.Cid, confidence uint64) (*api.MsgLookup, error) {
|
func (c *FullNodeStruct) StateWaitMsg(ctx context.Context, msgc cid.Cid, confidence uint64) (*api.MsgLookup, error) {
|
||||||
return c.Internal.StateWaitMsg(ctx, msgc, confidence)
|
return c.Internal.StateWaitMsg(ctx, msgc, confidence)
|
||||||
}
|
}
|
||||||
@@ -820,7 +883,7 @@ func (c *FullNodeStruct) StateCompute(ctx context.Context, height abi.ChainEpoch
|
|||||||
return c.Internal.StateCompute(ctx, height, msgs, tsk)
|
return c.Internal.StateCompute(ctx, height, msgs, tsk)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) StateVerifiedClientStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*verifreg.DataCap, error) {
|
func (c *FullNodeStruct) StateVerifiedClientStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*abi.StoragePower, error) {
|
||||||
return c.Internal.StateVerifiedClientStatus(ctx, addr, tsk)
|
return c.Internal.StateVerifiedClientStatus(ctx, addr, tsk)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -832,10 +895,18 @@ func (c *FullNodeStruct) StateCirculatingSupply(ctx context.Context, tsk types.T
|
|||||||
return c.Internal.StateCirculatingSupply(ctx, tsk)
|
return c.Internal.StateCirculatingSupply(ctx, tsk)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *FullNodeStruct) StateNetworkVersion(ctx context.Context, tsk types.TipSetKey) (stnetwork.Version, error) {
|
||||||
|
return c.Internal.StateNetworkVersion(ctx, tsk)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) MsigGetAvailableBalance(ctx context.Context, a address.Address, tsk types.TipSetKey) (types.BigInt, error) {
|
func (c *FullNodeStruct) MsigGetAvailableBalance(ctx context.Context, a address.Address, tsk types.TipSetKey) (types.BigInt, error) {
|
||||||
return c.Internal.MsigGetAvailableBalance(ctx, a, tsk)
|
return c.Internal.MsigGetAvailableBalance(ctx, a, tsk)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *FullNodeStruct) MsigGetVested(ctx context.Context, a address.Address, sTsk types.TipSetKey, eTsk types.TipSetKey) (types.BigInt, error) {
|
||||||
|
return c.Internal.MsigGetVested(ctx, a, sTsk, eTsk)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) MsigCreate(ctx context.Context, req uint64, addrs []address.Address, duration abi.ChainEpoch, val types.BigInt, src address.Address, gp types.BigInt) (cid.Cid, error) {
|
func (c *FullNodeStruct) MsigCreate(ctx context.Context, req uint64, addrs []address.Address, duration abi.ChainEpoch, val types.BigInt, src address.Address, gp types.BigInt) (cid.Cid, error) {
|
||||||
return c.Internal.MsigCreate(ctx, req, addrs, duration, val, src, gp)
|
return c.Internal.MsigCreate(ctx, req, addrs, duration, val, src, gp)
|
||||||
}
|
}
|
||||||
@@ -852,6 +923,18 @@ func (c *FullNodeStruct) MsigCancel(ctx context.Context, msig address.Address, t
|
|||||||
return c.Internal.MsigCancel(ctx, msig, txID, to, amt, src, method, params)
|
return c.Internal.MsigCancel(ctx, msig, txID, to, amt, src, method, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *FullNodeStruct) MsigAddPropose(ctx context.Context, msig address.Address, src address.Address, newAdd address.Address, inc bool) (cid.Cid, error) {
|
||||||
|
return c.Internal.MsigAddPropose(ctx, msig, src, newAdd, inc)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *FullNodeStruct) MsigAddApprove(ctx context.Context, msig address.Address, src address.Address, txID uint64, proposer address.Address, newAdd address.Address, inc bool) (cid.Cid, error) {
|
||||||
|
return c.Internal.MsigAddApprove(ctx, msig, src, txID, proposer, newAdd, inc)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *FullNodeStruct) MsigAddCancel(ctx context.Context, msig address.Address, src address.Address, txID uint64, newAdd address.Address, inc bool) (cid.Cid, error) {
|
||||||
|
return c.Internal.MsigAddCancel(ctx, msig, src, txID, newAdd, inc)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) MsigSwapPropose(ctx context.Context, msig address.Address, src address.Address, oldAdd address.Address, newAdd address.Address) (cid.Cid, error) {
|
func (c *FullNodeStruct) MsigSwapPropose(ctx context.Context, msig address.Address, src address.Address, oldAdd address.Address, newAdd address.Address) (cid.Cid, error) {
|
||||||
return c.Internal.MsigSwapPropose(ctx, msig, src, oldAdd, newAdd)
|
return c.Internal.MsigSwapPropose(ctx, msig, src, oldAdd, newAdd)
|
||||||
}
|
}
|
||||||
@@ -876,6 +959,14 @@ func (c *FullNodeStruct) PaychGetWaitReady(ctx context.Context, sentinel cid.Cid
|
|||||||
return c.Internal.PaychGetWaitReady(ctx, sentinel)
|
return c.Internal.PaychGetWaitReady(ctx, sentinel)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *FullNodeStruct) PaychAvailableFunds(ctx context.Context, ch address.Address) (*api.ChannelAvailableFunds, error) {
|
||||||
|
return c.Internal.PaychAvailableFunds(ctx, ch)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *FullNodeStruct) PaychAvailableFundsByFromTo(ctx context.Context, from, to address.Address) (*api.ChannelAvailableFunds, error) {
|
||||||
|
return c.Internal.PaychAvailableFundsByFromTo(ctx, from, to)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) PaychList(ctx context.Context) ([]address.Address, error) {
|
func (c *FullNodeStruct) PaychList(ctx context.Context) ([]address.Address, error) {
|
||||||
return c.Internal.PaychList(ctx)
|
return c.Internal.PaychList(ctx)
|
||||||
}
|
}
|
||||||
@@ -896,7 +987,7 @@ func (c *FullNodeStruct) PaychVoucherAdd(ctx context.Context, addr address.Addre
|
|||||||
return c.Internal.PaychVoucherAdd(ctx, addr, sv, proof, minDelta)
|
return c.Internal.PaychVoucherAdd(ctx, addr, sv, proof, minDelta)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) PaychVoucherCreate(ctx context.Context, pch address.Address, amt types.BigInt, lane uint64) (*paych.SignedVoucher, error) {
|
func (c *FullNodeStruct) PaychVoucherCreate(ctx context.Context, pch address.Address, amt types.BigInt, lane uint64) (*api.VoucherCreateResult, error) {
|
||||||
return c.Internal.PaychVoucherCreate(ctx, pch, amt, lane)
|
return c.Internal.PaychVoucherCreate(ctx, pch, amt, lane)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -920,8 +1011,8 @@ func (c *FullNodeStruct) PaychNewPayment(ctx context.Context, from, to address.A
|
|||||||
return c.Internal.PaychNewPayment(ctx, from, to, vouchers)
|
return c.Internal.PaychNewPayment(ctx, from, to, vouchers)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) PaychVoucherSubmit(ctx context.Context, ch address.Address, sv *paych.SignedVoucher) (cid.Cid, error) {
|
func (c *FullNodeStruct) PaychVoucherSubmit(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, secret []byte, proof []byte) (cid.Cid, error) {
|
||||||
return c.Internal.PaychVoucherSubmit(ctx, ch, sv)
|
return c.Internal.PaychVoucherSubmit(ctx, ch, sv, secret, proof)
|
||||||
}
|
}
|
||||||
|
|
||||||
// StorageMinerStruct
|
// StorageMinerStruct
|
||||||
@@ -1056,7 +1147,7 @@ func (c *StorageMinerStruct) MarketImportDealData(ctx context.Context, propcid c
|
|||||||
return c.Internal.MarketImportDealData(ctx, propcid, path)
|
return c.Internal.MarketImportDealData(ctx, propcid, path)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *StorageMinerStruct) MarketListDeals(ctx context.Context) ([]storagemarket.StorageDeal, error) {
|
func (c *StorageMinerStruct) MarketListDeals(ctx context.Context) ([]api.MarketDeal, error) {
|
||||||
return c.Internal.MarketListDeals(ctx)
|
return c.Internal.MarketListDeals(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1064,8 +1155,8 @@ func (c *StorageMinerStruct) MarketListRetrievalDeals(ctx context.Context) ([]re
|
|||||||
return c.Internal.MarketListRetrievalDeals(ctx)
|
return c.Internal.MarketListRetrievalDeals(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *StorageMinerStruct) MarketGetDealUpdates(ctx context.Context, d cid.Cid) (<-chan storagemarket.MinerDeal, error) {
|
func (c *StorageMinerStruct) MarketGetDealUpdates(ctx context.Context) (<-chan storagemarket.MinerDeal, error) {
|
||||||
return c.Internal.MarketGetDealUpdates(ctx, d)
|
return c.Internal.MarketGetDealUpdates(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *StorageMinerStruct) MarketListIncompleteDeals(ctx context.Context) ([]storagemarket.MinerDeal, error) {
|
func (c *StorageMinerStruct) MarketListIncompleteDeals(ctx context.Context) ([]storagemarket.MinerDeal, error) {
|
||||||
@@ -1100,7 +1191,7 @@ func (c *StorageMinerStruct) DealsImportData(ctx context.Context, dealPropCid ci
|
|||||||
return c.Internal.DealsImportData(ctx, dealPropCid, file)
|
return c.Internal.DealsImportData(ctx, dealPropCid, file)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *StorageMinerStruct) DealsList(ctx context.Context) ([]storagemarket.StorageDeal, error) {
|
func (c *StorageMinerStruct) DealsList(ctx context.Context) ([]api.MarketDeal, error) {
|
||||||
return c.Internal.DealsList(ctx)
|
return c.Internal.DealsList(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1214,8 +1305,12 @@ func (w *WorkerStruct) Remove(ctx context.Context, sector abi.SectorID) error {
|
|||||||
return w.Internal.Remove(ctx, sector)
|
return w.Internal.Remove(ctx, sector)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *WorkerStruct) MoveStorage(ctx context.Context, sector abi.SectorID) error {
|
func (w *WorkerStruct) MoveStorage(ctx context.Context, sector abi.SectorID, types stores.SectorFileType) error {
|
||||||
return w.Internal.MoveStorage(ctx, sector)
|
return w.Internal.MoveStorage(ctx, sector, types)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *WorkerStruct) StorageAddLocal(ctx context.Context, path string) error {
|
||||||
|
return w.Internal.StorageAddLocal(ctx, path)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *WorkerStruct) UnsealPiece(ctx context.Context, id abi.SectorID, index storiface.UnpaddedByteIndex, size abi.UnpaddedPieceSize, randomness abi.SealRandomness, c cid.Cid) error {
|
func (w *WorkerStruct) UnsealPiece(ctx context.Context, id abi.SectorID, index storiface.UnpaddedByteIndex, size abi.UnpaddedPieceSize, randomness abi.SealRandomness, c cid.Cid) error {
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
abi "github.com/filecoin-project/specs-actors/actors/abi"
|
abi "github.com/filecoin-project/go-state-types/abi"
|
||||||
paych "github.com/filecoin-project/specs-actors/actors/builtin/paych"
|
paych "github.com/filecoin-project/specs-actors/actors/builtin/paych"
|
||||||
cbg "github.com/whyrusleeping/cbor-gen"
|
cbg "github.com/whyrusleeping/cbor-gen"
|
||||||
xerrors "golang.org/x/xerrors"
|
xerrors "golang.org/x/xerrors"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package client
|
package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
"path"
|
||||||
@@ -14,9 +15,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// NewCommonRPC creates a new http jsonrpc client.
|
// NewCommonRPC creates a new http jsonrpc client.
|
||||||
func NewCommonRPC(addr string, requestHeader http.Header) (api.Common, jsonrpc.ClientCloser, error) {
|
func NewCommonRPC(ctx context.Context, addr string, requestHeader http.Header) (api.Common, jsonrpc.ClientCloser, error) {
|
||||||
var res apistruct.CommonStruct
|
var res apistruct.CommonStruct
|
||||||
closer, err := jsonrpc.NewMergeClient(addr, "Filecoin",
|
closer, err := jsonrpc.NewMergeClient(ctx, addr, "Filecoin",
|
||||||
[]interface{}{
|
[]interface{}{
|
||||||
&res.Internal,
|
&res.Internal,
|
||||||
},
|
},
|
||||||
@@ -27,9 +28,9 @@ func NewCommonRPC(addr string, requestHeader http.Header) (api.Common, jsonrpc.C
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewFullNodeRPC creates a new http jsonrpc client.
|
// NewFullNodeRPC creates a new http jsonrpc client.
|
||||||
func NewFullNodeRPC(addr string, requestHeader http.Header) (api.FullNode, jsonrpc.ClientCloser, error) {
|
func NewFullNodeRPC(ctx context.Context, addr string, requestHeader http.Header) (api.FullNode, jsonrpc.ClientCloser, error) {
|
||||||
var res apistruct.FullNodeStruct
|
var res apistruct.FullNodeStruct
|
||||||
closer, err := jsonrpc.NewMergeClient(addr, "Filecoin",
|
closer, err := jsonrpc.NewMergeClient(ctx, addr, "Filecoin",
|
||||||
[]interface{}{
|
[]interface{}{
|
||||||
&res.CommonStruct.Internal,
|
&res.CommonStruct.Internal,
|
||||||
&res.Internal,
|
&res.Internal,
|
||||||
@@ -39,9 +40,9 @@ func NewFullNodeRPC(addr string, requestHeader http.Header) (api.FullNode, jsonr
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewStorageMinerRPC creates a new http jsonrpc client for miner
|
// NewStorageMinerRPC creates a new http jsonrpc client for miner
|
||||||
func NewStorageMinerRPC(addr string, requestHeader http.Header, opts ...jsonrpc.Option) (api.StorageMiner, jsonrpc.ClientCloser, error) {
|
func NewStorageMinerRPC(ctx context.Context, addr string, requestHeader http.Header, opts ...jsonrpc.Option) (api.StorageMiner, jsonrpc.ClientCloser, error) {
|
||||||
var res apistruct.StorageMinerStruct
|
var res apistruct.StorageMinerStruct
|
||||||
closer, err := jsonrpc.NewMergeClient(addr, "Filecoin",
|
closer, err := jsonrpc.NewMergeClient(ctx, addr, "Filecoin",
|
||||||
[]interface{}{
|
[]interface{}{
|
||||||
&res.CommonStruct.Internal,
|
&res.CommonStruct.Internal,
|
||||||
&res.Internal,
|
&res.Internal,
|
||||||
@@ -53,7 +54,7 @@ func NewStorageMinerRPC(addr string, requestHeader http.Header, opts ...jsonrpc.
|
|||||||
return &res, closer, err
|
return &res, closer, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWorkerRPC(addr string, requestHeader http.Header) (api.WorkerAPI, jsonrpc.ClientCloser, error) {
|
func NewWorkerRPC(ctx context.Context, addr string, requestHeader http.Header) (api.WorkerAPI, jsonrpc.ClientCloser, error) {
|
||||||
u, err := url.Parse(addr)
|
u, err := url.Parse(addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
@@ -69,7 +70,7 @@ func NewWorkerRPC(addr string, requestHeader http.Header) (api.WorkerAPI, jsonrp
|
|||||||
u.Path = path.Join(u.Path, "../streams/v0/push")
|
u.Path = path.Join(u.Path, "../streams/v0/push")
|
||||||
|
|
||||||
var res apistruct.WorkerStruct
|
var res apistruct.WorkerStruct
|
||||||
closer, err := jsonrpc.NewMergeClient(addr, "Filecoin",
|
closer, err := jsonrpc.NewMergeClient(ctx, addr, "Filecoin",
|
||||||
[]interface{}{
|
[]interface{}{
|
||||||
&res.Internal,
|
&res.Internal,
|
||||||
},
|
},
|
||||||
|
|||||||
+23
-4
@@ -14,8 +14,10 @@ import (
|
|||||||
|
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
"github.com/ipfs/go-filestore"
|
"github.com/ipfs/go-filestore"
|
||||||
|
metrics "github.com/libp2p/go-libp2p-core/metrics"
|
||||||
"github.com/libp2p/go-libp2p-core/network"
|
"github.com/libp2p/go-libp2p-core/network"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
|
protocol "github.com/libp2p/go-libp2p-core/protocol"
|
||||||
pubsub "github.com/libp2p/go-libp2p-pubsub"
|
pubsub "github.com/libp2p/go-libp2p-pubsub"
|
||||||
"github.com/multiformats/go-multiaddr"
|
"github.com/multiformats/go-multiaddr"
|
||||||
|
|
||||||
@@ -26,9 +28,9 @@ import (
|
|||||||
"github.com/filecoin-project/go-jsonrpc/auth"
|
"github.com/filecoin-project/go-jsonrpc/auth"
|
||||||
"github.com/filecoin-project/go-multistore"
|
"github.com/filecoin-project/go-multistore"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/crypto"
|
"github.com/filecoin-project/go-state-types/crypto"
|
||||||
"github.com/filecoin-project/specs-actors/actors/runtime/exitcode"
|
"github.com/filecoin-project/go-state-types/exitcode"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/api/apistruct"
|
"github.com/filecoin-project/lotus/api/apistruct"
|
||||||
@@ -103,7 +105,7 @@ func init() {
|
|||||||
addExample(network.Connected)
|
addExample(network.Connected)
|
||||||
addExample(dtypes.NetworkName("lotus"))
|
addExample(dtypes.NetworkName("lotus"))
|
||||||
addExample(api.SyncStateStage(1))
|
addExample(api.SyncStateStage(1))
|
||||||
addExample(build.APIVersion)
|
addExample(build.FullAPIVersion)
|
||||||
addExample(api.PCHInbound)
|
addExample(api.PCHInbound)
|
||||||
addExample(time.Minute)
|
addExample(time.Minute)
|
||||||
addExample(datatransfer.TransferID(3))
|
addExample(datatransfer.TransferID(3))
|
||||||
@@ -112,6 +114,7 @@ func init() {
|
|||||||
addExample(retrievalmarket.ClientEventDealAccepted)
|
addExample(retrievalmarket.ClientEventDealAccepted)
|
||||||
addExample(retrievalmarket.DealStatusNew)
|
addExample(retrievalmarket.DealStatusNew)
|
||||||
addExample(network.ReachabilityPublic)
|
addExample(network.ReachabilityPublic)
|
||||||
|
addExample(build.NewestNetworkVersion)
|
||||||
addExample(&types.ExecutionTrace{
|
addExample(&types.ExecutionTrace{
|
||||||
Msg: exampleValue(reflect.TypeOf(&types.Message{}), nil).(*types.Message),
|
Msg: exampleValue(reflect.TypeOf(&types.Message{}), nil).(*types.Message),
|
||||||
MsgRct: exampleValue(reflect.TypeOf(&types.MessageReceipt{}), nil).(*types.MessageReceipt),
|
MsgRct: exampleValue(reflect.TypeOf(&types.MessageReceipt{}), nil).(*types.MessageReceipt),
|
||||||
@@ -133,6 +136,22 @@ func init() {
|
|||||||
InvalidMessageDeliveries: 3,
|
InvalidMessageDeliveries: 3,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
addExample(map[string]metrics.Stats{
|
||||||
|
"12D3KooWSXmXLJmBR1M7i9RW9GQPNUhZSzXKzxDHWtAgNuJAbyEJ": {
|
||||||
|
RateIn: 100,
|
||||||
|
RateOut: 50,
|
||||||
|
TotalIn: 174000,
|
||||||
|
TotalOut: 12500,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
addExample(map[protocol.ID]metrics.Stats{
|
||||||
|
"/fil/hello/1.0.0": {
|
||||||
|
RateIn: 100,
|
||||||
|
RateOut: 50,
|
||||||
|
TotalIn: 174000,
|
||||||
|
TotalOut: 12500,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
maddr, err := multiaddr.NewMultiaddr("/ip4/52.36.61.156/tcp/1347/p2p/12D3KooWFETiESTf1v4PGUvtnxMAcEFMzLZbJGg4tjWfGEimYior")
|
maddr, err := multiaddr.NewMultiaddr("/ip4/52.36.61.156/tcp/1347/p2p/12D3KooWFETiESTf1v4PGUvtnxMAcEFMzLZbJGg4tjWfGEimYior")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/lotus/miner"
|
"github.com/filecoin-project/lotus/miner"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type BlockMiner struct {
|
type BlockMiner struct {
|
||||||
@@ -41,7 +41,7 @@ func (bm *BlockMiner) MineBlocks() {
|
|||||||
nulls := atomic.SwapInt64(&bm.nulls, 0)
|
nulls := atomic.SwapInt64(&bm.nulls, 0)
|
||||||
if err := bm.miner.MineOne(bm.ctx, miner.MineReq{
|
if err := bm.miner.MineOne(bm.ctx, miner.MineReq{
|
||||||
InjectNulls: abi.ChainEpoch(nulls),
|
InjectNulls: abi.ChainEpoch(nulls),
|
||||||
Done: func(bool, error) {},
|
Done: func(bool, abi.ChainEpoch, error) {},
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
bm.t.Error(err)
|
bm.t.Error(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/node/impl"
|
"github.com/filecoin-project/lotus/node/impl"
|
||||||
@@ -85,6 +85,7 @@ func TestCCUpgrade(t *testing.T, b APIBuilder, blocktime time.Duration) {
|
|||||||
{
|
{
|
||||||
exp, err := client.StateSectorExpiration(ctx, maddr, CC, types.EmptyTSK)
|
exp, err := client.StateSectorExpiration(ctx, maddr, CC, types.EmptyTSK)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, exp)
|
||||||
require.Greater(t, 50000, int(exp.OnTime))
|
require.Greater(t, 50000, int(exp.OnTime))
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|||||||
+16
-13
@@ -20,6 +20,7 @@ import (
|
|||||||
"github.com/ipld/go-car"
|
"github.com/ipld/go-car"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
sealing "github.com/filecoin-project/lotus/extern/storage-sealing"
|
sealing "github.com/filecoin-project/lotus/extern/storage-sealing"
|
||||||
@@ -35,7 +36,7 @@ import (
|
|||||||
|
|
||||||
var MineNext = miner.MineReq{
|
var MineNext = miner.MineReq{
|
||||||
InjectNulls: 0,
|
InjectNulls: 0,
|
||||||
Done: func(bool, error) {},
|
Done: func(bool, abi.ChainEpoch, error) {},
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -333,7 +334,7 @@ loop:
|
|||||||
func waitDealPublished(t *testing.T, ctx context.Context, miner TestStorageNode, deal *cid.Cid) {
|
func waitDealPublished(t *testing.T, ctx context.Context, miner TestStorageNode, deal *cid.Cid) {
|
||||||
subCtx, cancel := context.WithCancel(ctx)
|
subCtx, cancel := context.WithCancel(ctx)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
updates, err := miner.MarketGetDealUpdates(subCtx, *deal)
|
updates, err := miner.MarketGetDealUpdates(subCtx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -342,18 +343,20 @@ func waitDealPublished(t *testing.T, ctx context.Context, miner TestStorageNode,
|
|||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
t.Fatal("context timeout")
|
t.Fatal("context timeout")
|
||||||
case di := <-updates:
|
case di := <-updates:
|
||||||
switch di.State {
|
if deal.Equals(di.ProposalCid) {
|
||||||
case storagemarket.StorageDealProposalRejected:
|
switch di.State {
|
||||||
t.Fatal("deal rejected")
|
case storagemarket.StorageDealProposalRejected:
|
||||||
case storagemarket.StorageDealFailing:
|
t.Fatal("deal rejected")
|
||||||
t.Fatal("deal failed")
|
case storagemarket.StorageDealFailing:
|
||||||
case storagemarket.StorageDealError:
|
t.Fatal("deal failed")
|
||||||
t.Fatal("deal errored", di.Message)
|
case storagemarket.StorageDealError:
|
||||||
case storagemarket.StorageDealFinalizing, storagemarket.StorageDealSealing, storagemarket.StorageDealActive:
|
t.Fatal("deal errored", di.Message)
|
||||||
fmt.Println("COMPLETE", di)
|
case storagemarket.StorageDealFinalizing, storagemarket.StorageDealSealing, storagemarket.StorageDealActive:
|
||||||
return
|
fmt.Println("COMPLETE", di)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
fmt.Println("Deal state: ", storagemarket.DealStates[di.State])
|
||||||
}
|
}
|
||||||
fmt.Println("Deal state: ", storagemarket.DealStates[di.State])
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-10
@@ -12,7 +12,7 @@ import (
|
|||||||
|
|
||||||
logging "github.com/ipfs/go-log/v2"
|
logging "github.com/ipfs/go-log/v2"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
@@ -31,22 +31,20 @@ func (ts *testSuite) testMining(t *testing.T) {
|
|||||||
newHeads, err := api.ChainNotify(ctx)
|
newHeads, err := api.ChainNotify(ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
initHead := (<-newHeads)[0]
|
initHead := (<-newHeads)[0]
|
||||||
if initHead.Val.Height() != 2 {
|
baseHeight := initHead.Val.Height()
|
||||||
<-newHeads
|
|
||||||
}
|
|
||||||
|
|
||||||
h1, err := api.ChainHead(ctx)
|
h1, err := api.ChainHead(ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, abi.ChainEpoch(2), h1.Height())
|
require.Equal(t, int64(h1.Height()), int64(baseHeight))
|
||||||
|
|
||||||
err = sn[0].MineOne(ctx, MineNext)
|
MineUntilBlock(ctx, t, apis[0], sn[0], nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
<-newHeads
|
<-newHeads
|
||||||
|
|
||||||
h2, err := api.ChainHead(ctx)
|
h2, err := api.ChainHead(ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, abi.ChainEpoch(3), h2.Height())
|
require.Greater(t, int64(h2.Height()), int64(h1.Height()))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ts *testSuite) testMiningReal(t *testing.T) {
|
func (ts *testSuite) testMiningReal(t *testing.T) {
|
||||||
@@ -70,7 +68,7 @@ func (ts *testSuite) testMiningReal(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, abi.ChainEpoch(2), h1.Height())
|
require.Equal(t, abi.ChainEpoch(2), h1.Height())
|
||||||
|
|
||||||
err = sn[0].MineOne(ctx, MineNext)
|
MineUntilBlock(ctx, t, apis[0], sn[0], nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
<-newHeads
|
<-newHeads
|
||||||
@@ -79,7 +77,7 @@ func (ts *testSuite) testMiningReal(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, abi.ChainEpoch(3), h2.Height())
|
require.Equal(t, abi.ChainEpoch(3), h2.Height())
|
||||||
|
|
||||||
err = sn[0].MineOne(ctx, MineNext)
|
MineUntilBlock(ctx, t, apis[0], sn[0], nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
<-newHeads
|
<-newHeads
|
||||||
@@ -144,7 +142,7 @@ func TestDealMining(t *testing.T, b APIBuilder, blocktime time.Duration, carExpo
|
|||||||
complChan := minedTwo
|
complChan := minedTwo
|
||||||
for atomic.LoadInt32(&mine) != 0 {
|
for atomic.LoadInt32(&mine) != 0 {
|
||||||
wait := make(chan int)
|
wait := make(chan int)
|
||||||
mdone := func(mined bool, err error) {
|
mdone := func(mined bool, _ abi.ChainEpoch, err error) {
|
||||||
n := 0
|
n := 0
|
||||||
if mined {
|
if mined {
|
||||||
n = 1
|
n = 1
|
||||||
|
|||||||
+10
-4
@@ -10,8 +10,8 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
"github.com/filecoin-project/go-state-types/big"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/paych"
|
"github.com/filecoin-project/specs-actors/actors/builtin/paych"
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
|
|
||||||
@@ -96,18 +96,24 @@ func TestPaymentChannels(t *testing.T, b APIBuilder, blocktime time.Duration) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if vouch1.Voucher == nil {
|
||||||
|
t.Fatal(fmt.Errorf("Not enough funds to create voucher: missing %d", vouch1.Shortfall))
|
||||||
|
}
|
||||||
vouch2, err := paymentCreator.PaychVoucherCreate(ctx, channel, abi.NewTokenAmount(2000), lane)
|
vouch2, err := paymentCreator.PaychVoucherCreate(ctx, channel, abi.NewTokenAmount(2000), lane)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
delta1, err := paymentReceiver.PaychVoucherAdd(ctx, channel, vouch1, nil, abi.NewTokenAmount(1000))
|
if vouch2.Voucher == nil {
|
||||||
|
t.Fatal(fmt.Errorf("Not enough funds to create voucher: missing %d", vouch2.Shortfall))
|
||||||
|
}
|
||||||
|
delta1, err := paymentReceiver.PaychVoucherAdd(ctx, channel, vouch1.Voucher, nil, abi.NewTokenAmount(1000))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if !delta1.Equals(abi.NewTokenAmount(1000)) {
|
if !delta1.Equals(abi.NewTokenAmount(1000)) {
|
||||||
t.Fatal("voucher didn't have the right amount")
|
t.Fatal("voucher didn't have the right amount")
|
||||||
}
|
}
|
||||||
delta2, err := paymentReceiver.PaychVoucherAdd(ctx, channel, vouch2, nil, abi.NewTokenAmount(1000))
|
delta2, err := paymentReceiver.PaychVoucherAdd(ctx, channel, vouch2.Voucher, nil, abi.NewTokenAmount(1000))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ func TestApis(t *testing.T, b APIBuilder) {
|
|||||||
var OneMiner = []StorageMiner{{Full: 0, Preseal: PresealGenesis}}
|
var OneMiner = []StorageMiner{{Full: 0, Preseal: PresealGenesis}}
|
||||||
|
|
||||||
func (ts *testSuite) testVersion(t *testing.T) {
|
func (ts *testSuite) testVersion(t *testing.T) {
|
||||||
|
build.RunningNodeType = build.NodeFull
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
apis, _ := ts.makeNodes(t, 1, OneMiner)
|
apis, _ := ts.makeNodes(t, 1, OneMiner)
|
||||||
api := apis[0]
|
api := apis[0]
|
||||||
|
|||||||
+51
-1
@@ -3,11 +3,13 @@ package test
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
"github.com/filecoin-project/lotus/miner"
|
||||||
)
|
)
|
||||||
|
|
||||||
func SendFunds(ctx context.Context, t *testing.T, sender TestNode, addr address.Address, amount abi.TokenAmount) {
|
func SendFunds(ctx context.Context, t *testing.T, sender TestNode, addr address.Address, amount abi.TokenAmount) {
|
||||||
@@ -34,3 +36,51 @@ func SendFunds(ctx context.Context, t *testing.T, sender TestNode, addr address.
|
|||||||
t.Fatal("did not successfully send money")
|
t.Fatal("did not successfully send money")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func MineUntilBlock(ctx context.Context, t *testing.T, fn TestNode, sn TestStorageNode, cb func(abi.ChainEpoch)) {
|
||||||
|
for i := 0; i < 1000; i++ {
|
||||||
|
var success bool
|
||||||
|
var err error
|
||||||
|
var epoch abi.ChainEpoch
|
||||||
|
wait := make(chan struct{})
|
||||||
|
mineErr := sn.MineOne(ctx, miner.MineReq{
|
||||||
|
Done: func(win bool, ep abi.ChainEpoch, e error) {
|
||||||
|
success = win
|
||||||
|
err = e
|
||||||
|
epoch = ep
|
||||||
|
wait <- struct{}{}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if mineErr != nil {
|
||||||
|
t.Fatal(mineErr)
|
||||||
|
}
|
||||||
|
<-wait
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if success {
|
||||||
|
// Wait until it shows up on the given full nodes ChainHead
|
||||||
|
nloops := 50
|
||||||
|
for i := 0; i < nloops; i++ {
|
||||||
|
ts, err := fn.ChainHead(ctx)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if ts.Height() == epoch {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if i == nloops-1 {
|
||||||
|
t.Fatal("block never managed to sync to node")
|
||||||
|
}
|
||||||
|
time.Sleep(time.Millisecond * 10)
|
||||||
|
}
|
||||||
|
|
||||||
|
if cb != nil {
|
||||||
|
cb(epoch)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
t.Log("did not mine block, trying again", i)
|
||||||
|
}
|
||||||
|
t.Fatal("failed to mine 1000 times in a row...")
|
||||||
|
}
|
||||||
|
|||||||
+18
-11
@@ -12,10 +12,9 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/lotus/extern/sector-storage/mock"
|
"github.com/filecoin-project/lotus/extern/sector-storage/mock"
|
||||||
sealing "github.com/filecoin-project/lotus/extern/storage-sealing"
|
sealing "github.com/filecoin-project/lotus/extern/storage-sealing"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
|
||||||
miner2 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
@@ -53,7 +52,7 @@ func TestPledgeSector(t *testing.T, b APIBuilder, blocktime time.Duration, nSect
|
|||||||
defer close(done)
|
defer close(done)
|
||||||
for mine {
|
for mine {
|
||||||
build.Clock.Sleep(blocktime)
|
build.Clock.Sleep(blocktime)
|
||||||
if err := sn[0].MineOne(ctx, bminer.MineReq{Done: func(bool, error) {
|
if err := sn[0].MineOne(ctx, bminer.MineReq{Done: func(bool, abi.ChainEpoch, error) {
|
||||||
|
|
||||||
}}); err != nil {
|
}}); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
@@ -159,7 +158,7 @@ func TestWindowPost(t *testing.T, b APIBuilder, blocktime time.Duration, nSector
|
|||||||
head, err := client.ChainHead(ctx)
|
head, err := client.ChainHead(ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
if head.Height() > di.PeriodStart+(miner2.WPoStProvingPeriod)+2 {
|
if head.Height() > di.PeriodStart+(di.WPoStProvingPeriod)+2 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,13 +185,15 @@ func TestWindowPost(t *testing.T, b APIBuilder, blocktime time.Duration, nSector
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Greater(t, len(parts), 0)
|
require.Greater(t, len(parts), 0)
|
||||||
|
|
||||||
n, err := parts[0].Sectors.Count()
|
secs := parts[0].AllSectors
|
||||||
|
require.NoError(t, err)
|
||||||
|
n, err := secs.Count()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, uint64(2), n)
|
require.Equal(t, uint64(2), n)
|
||||||
|
|
||||||
// Drop the partition
|
// Drop the partition
|
||||||
err = parts[0].Sectors.ForEach(func(sid uint64) error {
|
err = secs.ForEach(func(sid uint64) error {
|
||||||
return miner.StorageMiner.(*impl.StorageMinerAPI).IStorageMgr.(*mock.SectorMgr).MarkFailed(abi.SectorID{
|
return miner.StorageMiner.(*impl.StorageMinerAPI).IStorageMgr.(*mock.SectorMgr).MarkCorrupted(abi.SectorID{
|
||||||
Miner: abi.ActorID(mid),
|
Miner: abi.ActorID(mid),
|
||||||
Number: abi.SectorNumber(sid),
|
Number: abi.SectorNumber(sid),
|
||||||
}, true)
|
}, true)
|
||||||
@@ -208,14 +209,20 @@ func TestWindowPost(t *testing.T, b APIBuilder, blocktime time.Duration, nSector
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Greater(t, len(parts), 0)
|
require.Greater(t, len(parts), 0)
|
||||||
|
|
||||||
n, err := parts[0].Sectors.Count()
|
secs := parts[0].AllSectors
|
||||||
|
require.NoError(t, err)
|
||||||
|
n, err := secs.Count()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, uint64(2), n)
|
require.Equal(t, uint64(2), n)
|
||||||
|
|
||||||
// Drop the sector
|
// Drop the sector
|
||||||
sn, err := parts[0].Sectors.First()
|
sn, err := secs.First()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
all, err := secs.All(2)
|
||||||
|
require.NoError(t, err)
|
||||||
|
fmt.Println("the sectors", all)
|
||||||
|
|
||||||
s = abi.SectorID{
|
s = abi.SectorID{
|
||||||
Miner: abi.ActorID(mid),
|
Miner: abi.ActorID(mid),
|
||||||
Number: abi.SectorNumber(sn),
|
Number: abi.SectorNumber(sn),
|
||||||
@@ -234,7 +241,7 @@ func TestWindowPost(t *testing.T, b APIBuilder, blocktime time.Duration, nSector
|
|||||||
head, err := client.ChainHead(ctx)
|
head, err := client.ChainHead(ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
if head.Height() > di.PeriodStart+(miner2.WPoStProvingPeriod)+2 {
|
if head.Height() > di.PeriodStart+(di.WPoStProvingPeriod)+2 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,7 +271,7 @@ func TestWindowPost(t *testing.T, b APIBuilder, blocktime time.Duration, nSector
|
|||||||
head, err := client.ChainHead(ctx)
|
head, err := client.ChainHead(ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
if head.Height() > di.PeriodStart+(miner2.WPoStProvingPeriod)+2 {
|
if head.Height() > di.PeriodStart+di.WPoStProvingPeriod+2 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-47
@@ -4,11 +4,9 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
|
||||||
datatransfer "github.com/filecoin-project/go-data-transfer"
|
datatransfer "github.com/filecoin-project/go-data-transfer"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
"github.com/filecoin-project/lotus/build"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
@@ -49,54 +47,13 @@ type PubsubScore struct {
|
|||||||
Score *pubsub.PeerScoreSnapshot
|
Score *pubsub.PeerScoreSnapshot
|
||||||
}
|
}
|
||||||
|
|
||||||
type MinerInfo struct {
|
|
||||||
Owner address.Address // Must be an ID-address.
|
|
||||||
Worker address.Address // Must be an ID-address.
|
|
||||||
NewWorker address.Address // Must be an ID-address.
|
|
||||||
ControlAddresses []address.Address // Must be an ID-addresses.
|
|
||||||
WorkerChangeEpoch abi.ChainEpoch
|
|
||||||
PeerId *peer.ID
|
|
||||||
Multiaddrs []abi.Multiaddrs
|
|
||||||
SealProofType abi.RegisteredSealProof
|
|
||||||
SectorSize abi.SectorSize
|
|
||||||
WindowPoStPartitionSectors uint64
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewApiMinerInfo(info *miner.MinerInfo) MinerInfo {
|
|
||||||
var pid *peer.ID
|
|
||||||
if peerID, err := peer.IDFromBytes(info.PeerId); err == nil {
|
|
||||||
pid = &peerID
|
|
||||||
}
|
|
||||||
|
|
||||||
mi := MinerInfo{
|
|
||||||
Owner: info.Owner,
|
|
||||||
Worker: info.Worker,
|
|
||||||
ControlAddresses: info.ControlAddresses,
|
|
||||||
|
|
||||||
NewWorker: address.Undef,
|
|
||||||
WorkerChangeEpoch: -1,
|
|
||||||
|
|
||||||
PeerId: pid,
|
|
||||||
Multiaddrs: info.Multiaddrs,
|
|
||||||
SealProofType: info.SealProofType,
|
|
||||||
SectorSize: info.SectorSize,
|
|
||||||
WindowPoStPartitionSectors: info.WindowPoStPartitionSectors,
|
|
||||||
}
|
|
||||||
|
|
||||||
if info.PendingWorkerKey != nil {
|
|
||||||
mi.NewWorker = info.PendingWorkerKey.NewWorker
|
|
||||||
mi.WorkerChangeEpoch = info.PendingWorkerKey.EffectiveAt
|
|
||||||
}
|
|
||||||
|
|
||||||
return mi
|
|
||||||
}
|
|
||||||
|
|
||||||
type MessageSendSpec struct {
|
type MessageSendSpec struct {
|
||||||
MaxFee abi.TokenAmount
|
MaxFee abi.TokenAmount
|
||||||
}
|
}
|
||||||
|
|
||||||
var DefaultMessageSendSpec = MessageSendSpec{
|
var DefaultMessageSendSpec = MessageSendSpec{
|
||||||
MaxFee: big.Zero(),
|
// MaxFee of 0.1FIL
|
||||||
|
MaxFee: abi.NewTokenAmount(int64(build.FilecoinPrecision) / 10),
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ms *MessageSendSpec) Get() MessageSendSpec {
|
func (ms *MessageSendSpec) Get() MessageSendSpec {
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/specs-actors/actors/crypto"
|
"github.com/filecoin-project/go-state-types/crypto"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SignFunc = func(context.Context, []byte) (*crypto.Signature, error)
|
type SignFunc = func(context.Context, []byte) (*crypto.Signature, error)
|
||||||
|
|||||||
+17
-6
@@ -1,15 +1,26 @@
|
|||||||
package build
|
package build
|
||||||
|
|
||||||
import "github.com/filecoin-project/lotus/node/modules/dtypes"
|
import (
|
||||||
|
"sort"
|
||||||
|
|
||||||
var DrandNetwork = DrandIncentinet
|
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||||
|
)
|
||||||
func DrandConfig() dtypes.DrandConfig {
|
|
||||||
return DrandConfigs[DrandNetwork]
|
|
||||||
}
|
|
||||||
|
|
||||||
type DrandEnum int
|
type DrandEnum int
|
||||||
|
|
||||||
|
func DrandConfigSchedule() dtypes.DrandSchedule {
|
||||||
|
out := dtypes.DrandSchedule{}
|
||||||
|
for start, config := range DrandSchedule {
|
||||||
|
out = append(out, dtypes.DrandPoint{Start: start, Config: DrandConfigs[config]})
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Slice(out, func(i, j int) bool {
|
||||||
|
return out[i].Start < out[j].Start
|
||||||
|
})
|
||||||
|
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DrandMainnet DrandEnum = iota + 1
|
DrandMainnet DrandEnum = iota + 1
|
||||||
DrandTestnet
|
DrandTestnet
|
||||||
|
|||||||
+17
-8
@@ -3,19 +3,28 @@
|
|||||||
package build
|
package build
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
"github.com/filecoin-project/go-state-types/big"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/power"
|
power0 "github.com/filecoin-project/specs-actors/actors/builtin/power"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
|
verifreg0 "github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const UpgradeBreezeHeight = -1
|
||||||
|
const BreezeGasTampingDuration = 0
|
||||||
|
|
||||||
|
const UpgradeSmokeHeight = -1
|
||||||
|
|
||||||
|
var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
|
||||||
|
0: DrandMainnet,
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
power.ConsensusMinerMinPower = big.NewInt(2048)
|
power0.ConsensusMinerMinPower = big.NewInt(2048)
|
||||||
miner.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{
|
miner0.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{
|
||||||
abi.RegisteredSealProof_StackedDrg2KiBV1: {},
|
abi.RegisteredSealProof_StackedDrg2KiBV1: {},
|
||||||
}
|
}
|
||||||
verifreg.MinVerifiedDealSize = big.NewInt(256)
|
verifreg0.MinVerifiedDealSize = big.NewInt(256)
|
||||||
|
|
||||||
BuildType |= Build2k
|
BuildType |= Build2k
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,15 +5,15 @@ import (
|
|||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/protocol"
|
"github.com/libp2p/go-libp2p-core/protocol"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||||
)
|
)
|
||||||
|
|
||||||
func DefaultSectorSize() abi.SectorSize {
|
func DefaultSectorSize() abi.SectorSize {
|
||||||
szs := make([]abi.SectorSize, 0, len(miner.SupportedProofTypes))
|
szs := make([]abi.SectorSize, 0, len(miner0.SupportedProofTypes))
|
||||||
for spt := range miner.SupportedProofTypes {
|
for spt := range miner0.SupportedProofTypes {
|
||||||
ss, err := spt.SectorSize()
|
ss, err := spt.SectorSize()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@@ -36,3 +36,11 @@ func MessagesTopic(netName dtypes.NetworkName) string { return "/fil/msgs/" + st
|
|||||||
func DhtProtocolName(netName dtypes.NetworkName) protocol.ID {
|
func DhtProtocolName(netName dtypes.NetworkName) protocol.ID {
|
||||||
return protocol.ID("/fil/kad/" + string(netName))
|
return protocol.ID("/fil/kad/" + string(netName))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func UseNewestNetwork() bool {
|
||||||
|
// TODO: Put these in a container we can iterate over
|
||||||
|
if UpgradeBreezeHeight <= 0 && UpgradeSmokeHeight <= 0 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,9 +5,11 @@ package build
|
|||||||
import (
|
import (
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/go-state-types/network"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
)
|
)
|
||||||
|
|
||||||
// /////
|
// /////
|
||||||
@@ -20,6 +22,8 @@ const UnixfsLinksPerLevel = 1024
|
|||||||
// Consensus / Network
|
// Consensus / Network
|
||||||
|
|
||||||
const AllowableClockDriftSecs = uint64(1)
|
const AllowableClockDriftSecs = uint64(1)
|
||||||
|
const NewestNetworkVersion = network.Version2
|
||||||
|
const ActorUpgradeNetworkVersion = network.Version3
|
||||||
|
|
||||||
// Epochs
|
// Epochs
|
||||||
const ForkLengthThreshold = Finality
|
const ForkLengthThreshold = Finality
|
||||||
@@ -28,7 +32,7 @@ const ForkLengthThreshold = Finality
|
|||||||
var BlocksPerEpoch = uint64(builtin.ExpectedLeadersPerEpoch)
|
var BlocksPerEpoch = uint64(builtin.ExpectedLeadersPerEpoch)
|
||||||
|
|
||||||
// Epochs
|
// Epochs
|
||||||
const Finality = miner.ChainFinality
|
const Finality = miner0.ChainFinality
|
||||||
const MessageConfidence = uint64(5)
|
const MessageConfidence = uint64(5)
|
||||||
|
|
||||||
// constants for Weight calculation
|
// constants for Weight calculation
|
||||||
|
|||||||
@@ -10,9 +10,10 @@ package build
|
|||||||
import (
|
import (
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
"github.com/filecoin-project/go-state-types/network"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -31,7 +32,7 @@ var (
|
|||||||
|
|
||||||
AllowableClockDriftSecs = uint64(1)
|
AllowableClockDriftSecs = uint64(1)
|
||||||
|
|
||||||
Finality = miner.ChainFinality
|
Finality = miner0.ChainFinality
|
||||||
ForkLengthThreshold = Finality
|
ForkLengthThreshold = Finality
|
||||||
|
|
||||||
SlashablePowerDelay = 20
|
SlashablePowerDelay = 20
|
||||||
@@ -69,4 +70,16 @@ var (
|
|||||||
|
|
||||||
PackingEfficiencyNum int64 = 4
|
PackingEfficiencyNum int64 = 4
|
||||||
PackingEfficiencyDenom int64 = 5
|
PackingEfficiencyDenom int64 = 5
|
||||||
|
|
||||||
|
UpgradeBreezeHeight abi.ChainEpoch = -1
|
||||||
|
BreezeGasTampingDuration abi.ChainEpoch = 0
|
||||||
|
|
||||||
|
UpgradeSmokeHeight abi.ChainEpoch = -1
|
||||||
|
|
||||||
|
DrandSchedule = map[abi.ChainEpoch]DrandEnum{
|
||||||
|
0: DrandMainnet,
|
||||||
|
}
|
||||||
|
|
||||||
|
NewestNetworkVersion = network.Version2
|
||||||
|
ActorUpgradeNetworkVersion = network.Version3
|
||||||
)
|
)
|
||||||
|
|||||||
+16
-6
@@ -5,16 +5,26 @@
|
|||||||
package build
|
package build
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
"github.com/filecoin-project/go-state-types/big"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/power"
|
power0 "github.com/filecoin-project/specs-actors/actors/builtin/power"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
|
||||||
|
0: DrandIncentinet,
|
||||||
|
UpgradeSmokeHeight: DrandMainnet,
|
||||||
|
}
|
||||||
|
|
||||||
|
const UpgradeBreezeHeight = 41280
|
||||||
|
const BreezeGasTampingDuration = 120
|
||||||
|
|
||||||
|
const UpgradeSmokeHeight = 51000
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
power.ConsensusMinerMinPower = big.NewInt(10 << 40)
|
power0.ConsensusMinerMinPower = big.NewInt(10 << 40)
|
||||||
miner.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{
|
miner0.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{
|
||||||
abi.RegisteredSealProof_StackedDrg32GiBV1: {},
|
abi.RegisteredSealProof_StackedDrg32GiBV1: {},
|
||||||
abi.RegisteredSealProof_StackedDrg64GiBV1: {},
|
abi.RegisteredSealProof_StackedDrg64GiBV1: {},
|
||||||
}
|
}
|
||||||
|
|||||||
+37
-4
@@ -1,6 +1,10 @@
|
|||||||
package build
|
package build
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"golang.org/x/xerrors"
|
||||||
|
)
|
||||||
|
|
||||||
var CurrentCommit string
|
var CurrentCommit string
|
||||||
var BuildType int
|
var BuildType int
|
||||||
@@ -25,7 +29,7 @@ func buildType() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// BuildVersion is the local build version, set by build system
|
// BuildVersion is the local build version, set by build system
|
||||||
const BuildVersion = "0.5.2"
|
const BuildVersion = "0.7.2"
|
||||||
|
|
||||||
func UserVersion() string {
|
func UserVersion() string {
|
||||||
return BuildVersion + buildType() + CurrentCommit
|
return BuildVersion + buildType() + CurrentCommit
|
||||||
@@ -52,8 +56,37 @@ func (ve Version) EqMajorMinor(v2 Version) bool {
|
|||||||
return ve&minorMask == v2&minorMask
|
return ve&minorMask == v2&minorMask
|
||||||
}
|
}
|
||||||
|
|
||||||
// APIVersion is a semver version of the rpc api exposed
|
type NodeType int
|
||||||
var APIVersion Version = newVer(0, 12, 0)
|
|
||||||
|
const (
|
||||||
|
NodeUnknown NodeType = iota
|
||||||
|
|
||||||
|
NodeFull
|
||||||
|
NodeMiner
|
||||||
|
NodeWorker
|
||||||
|
)
|
||||||
|
|
||||||
|
var RunningNodeType NodeType
|
||||||
|
|
||||||
|
func VersionForType(nodeType NodeType) (Version, error) {
|
||||||
|
switch nodeType {
|
||||||
|
case NodeFull:
|
||||||
|
return FullAPIVersion, nil
|
||||||
|
case NodeMiner:
|
||||||
|
return MinerAPIVersion, nil
|
||||||
|
case NodeWorker:
|
||||||
|
return WorkerAPIVersion, nil
|
||||||
|
default:
|
||||||
|
return Version(0), xerrors.Errorf("unknown node type %d", nodeType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// semver versions of the rpc api exposed
|
||||||
|
var (
|
||||||
|
FullAPIVersion = newVer(0, 16, 0)
|
||||||
|
MinerAPIVersion = newVer(0, 15, 0)
|
||||||
|
WorkerAPIVersion = newVer(0, 15, 0)
|
||||||
|
)
|
||||||
|
|
||||||
//nolint:varcheck,deadcode
|
//nolint:varcheck,deadcode
|
||||||
const (
|
const (
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package adt
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/ipfs/go-cid"
|
||||||
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
"github.com/filecoin-project/go-state-types/cbor"
|
||||||
|
"github.com/filecoin-project/go-state-types/network"
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||||
|
adt0 "github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Map interface {
|
||||||
|
Root() (cid.Cid, error)
|
||||||
|
|
||||||
|
Put(k abi.Keyer, v cbor.Marshaler) error
|
||||||
|
Get(k abi.Keyer, v cbor.Unmarshaler) (bool, error)
|
||||||
|
Delete(k abi.Keyer) error
|
||||||
|
|
||||||
|
ForEach(v cbor.Unmarshaler, fn func(key string) error) error
|
||||||
|
}
|
||||||
|
|
||||||
|
func AsMap(store Store, root cid.Cid, version builtin.Version) (Map, error) {
|
||||||
|
switch version {
|
||||||
|
case builtin.Version0:
|
||||||
|
return adt0.AsMap(store, root)
|
||||||
|
}
|
||||||
|
return nil, xerrors.Errorf("unknown network version: %d", version)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewMap(store Store, version builtin.Version) (Map, error) {
|
||||||
|
switch version {
|
||||||
|
case builtin.Version0:
|
||||||
|
return adt0.MakeEmptyMap(store), nil
|
||||||
|
}
|
||||||
|
return nil, xerrors.Errorf("unknown network version: %d", version)
|
||||||
|
}
|
||||||
|
|
||||||
|
type Array interface {
|
||||||
|
Root() (cid.Cid, error)
|
||||||
|
|
||||||
|
Set(idx uint64, v cbor.Marshaler) error
|
||||||
|
Get(idx uint64, v cbor.Unmarshaler) (bool, error)
|
||||||
|
Delete(idx uint64) error
|
||||||
|
Length() uint64
|
||||||
|
|
||||||
|
ForEach(v cbor.Unmarshaler, fn func(idx int64) error) error
|
||||||
|
}
|
||||||
|
|
||||||
|
func AsArray(store Store, root cid.Cid, version network.Version) (Array, error) {
|
||||||
|
switch builtin.VersionForNetwork(version) {
|
||||||
|
case builtin.Version0:
|
||||||
|
return adt0.AsArray(store, root)
|
||||||
|
}
|
||||||
|
return nil, xerrors.Errorf("unknown network version: %d", version)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArray(store Store, version builtin.Version) (Array, error) {
|
||||||
|
switch version {
|
||||||
|
case builtin.Version0:
|
||||||
|
return adt0.MakeEmptyArray(store), nil
|
||||||
|
}
|
||||||
|
return nil, xerrors.Errorf("unknown network version: %d", version)
|
||||||
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
package state
|
package adt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
typegen "github.com/whyrusleeping/cbor-gen"
|
typegen "github.com/whyrusleeping/cbor-gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -26,7 +26,8 @@ type AdtArrayDiff interface {
|
|||||||
// - All values that exist in curArr nnd not in prevArr are passed to adtArrayDiff.Add()
|
// - All values that exist in curArr nnd not in prevArr are passed to adtArrayDiff.Add()
|
||||||
// - All values that exist in preArr and in curArr are passed to AdtArrayDiff.Modify()
|
// - All values that exist in preArr and in curArr are passed to AdtArrayDiff.Modify()
|
||||||
// - It is the responsibility of AdtArrayDiff.Modify() to determine if the values it was passed have been modified.
|
// - It is the responsibility of AdtArrayDiff.Modify() to determine if the values it was passed have been modified.
|
||||||
func DiffAdtArray(preArr, curArr *adt.Array, out AdtArrayDiff) error {
|
func DiffAdtArray(preArr, curArr Array, out AdtArrayDiff) error {
|
||||||
|
notNew := make(map[int64]struct{}, curArr.Length())
|
||||||
prevVal := new(typegen.Deferred)
|
prevVal := new(typegen.Deferred)
|
||||||
if err := preArr.ForEach(prevVal, func(i int64) error {
|
if err := preArr.ForEach(prevVal, func(i int64) error {
|
||||||
curVal := new(typegen.Deferred)
|
curVal := new(typegen.Deferred)
|
||||||
@@ -47,14 +48,17 @@ func DiffAdtArray(preArr, curArr *adt.Array, out AdtArrayDiff) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
notNew[i] = struct{}{}
|
||||||
return curArr.Delete(uint64(i))
|
return nil
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
curVal := new(typegen.Deferred)
|
curVal := new(typegen.Deferred)
|
||||||
return curArr.ForEach(curVal, func(i int64) error {
|
return curArr.ForEach(curVal, func(i int64) error {
|
||||||
|
if _, ok := notNew[i]; ok {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return out.Add(uint64(i), curVal)
|
return out.Add(uint64(i), curVal)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -69,13 +73,14 @@ func DiffAdtArray(preArr, curArr *adt.Array, out AdtArrayDiff) error {
|
|||||||
// Modify should be called when a value is modified in the map
|
// Modify should be called when a value is modified in the map
|
||||||
// Remove should be called when a value is removed from the map
|
// Remove should be called when a value is removed from the map
|
||||||
type AdtMapDiff interface {
|
type AdtMapDiff interface {
|
||||||
AsKey(key string) (adt.Keyer, error)
|
AsKey(key string) (abi.Keyer, error)
|
||||||
Add(key string, val *typegen.Deferred) error
|
Add(key string, val *typegen.Deferred) error
|
||||||
Modify(key string, from, to *typegen.Deferred) error
|
Modify(key string, from, to *typegen.Deferred) error
|
||||||
Remove(key string, val *typegen.Deferred) error
|
Remove(key string, val *typegen.Deferred) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func DiffAdtMap(preMap, curMap *adt.Map, out AdtMapDiff) error {
|
func DiffAdtMap(preMap, curMap Map, out AdtMapDiff) error {
|
||||||
|
notNew := make(map[string]struct{})
|
||||||
prevVal := new(typegen.Deferred)
|
prevVal := new(typegen.Deferred)
|
||||||
if err := preMap.ForEach(prevVal, func(key string) error {
|
if err := preMap.ForEach(prevVal, func(key string) error {
|
||||||
curVal := new(typegen.Deferred)
|
curVal := new(typegen.Deferred)
|
||||||
@@ -101,14 +106,17 @@ func DiffAdtMap(preMap, curMap *adt.Map, out AdtMapDiff) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
notNew[key] = struct{}{}
|
||||||
return curMap.Delete(k)
|
return nil
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
curVal := new(typegen.Deferred)
|
curVal := new(typegen.Deferred)
|
||||||
return curMap.ForEach(curVal, func(key string) error {
|
return curMap.ForEach(curVal, func(key string) error {
|
||||||
|
if _, ok := notNew[key]; ok {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return out.Add(key, curVal)
|
return out.Add(key, curVal)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package state
|
package adt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
@@ -11,8 +11,9 @@ import (
|
|||||||
cbornode "github.com/ipfs/go-ipld-cbor"
|
cbornode "github.com/ipfs/go-ipld-cbor"
|
||||||
typegen "github.com/whyrusleeping/cbor-gen"
|
typegen "github.com/whyrusleeping/cbor-gen"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/runtime"
|
"github.com/filecoin-project/specs-actors/actors/runtime"
|
||||||
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
adt0 "github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||||
|
|
||||||
bstore "github.com/filecoin-project/lotus/lib/blockstore"
|
bstore "github.com/filecoin-project/lotus/lib/blockstore"
|
||||||
)
|
)
|
||||||
@@ -21,8 +22,8 @@ func TestDiffAdtArray(t *testing.T) {
|
|||||||
ctxstoreA := newContextStore()
|
ctxstoreA := newContextStore()
|
||||||
ctxstoreB := newContextStore()
|
ctxstoreB := newContextStore()
|
||||||
|
|
||||||
arrA := adt.MakeEmptyArray(ctxstoreA)
|
arrA := adt0.MakeEmptyArray(ctxstoreA)
|
||||||
arrB := adt.MakeEmptyArray(ctxstoreB)
|
arrB := adt0.MakeEmptyArray(ctxstoreB)
|
||||||
|
|
||||||
require.NoError(t, arrA.Set(0, runtime.CBORBytes([]byte{0}))) // delete
|
require.NoError(t, arrA.Set(0, runtime.CBORBytes([]byte{0}))) // delete
|
||||||
|
|
||||||
@@ -75,24 +76,24 @@ func TestDiffAdtMap(t *testing.T) {
|
|||||||
ctxstoreA := newContextStore()
|
ctxstoreA := newContextStore()
|
||||||
ctxstoreB := newContextStore()
|
ctxstoreB := newContextStore()
|
||||||
|
|
||||||
mapA := adt.MakeEmptyMap(ctxstoreA)
|
mapA := adt0.MakeEmptyMap(ctxstoreA)
|
||||||
mapB := adt.MakeEmptyMap(ctxstoreB)
|
mapB := adt0.MakeEmptyMap(ctxstoreB)
|
||||||
|
|
||||||
require.NoError(t, mapA.Put(adt.UIntKey(0), runtime.CBORBytes([]byte{0}))) // delete
|
require.NoError(t, mapA.Put(abi.UIntKey(0), runtime.CBORBytes([]byte{0}))) // delete
|
||||||
|
|
||||||
require.NoError(t, mapA.Put(adt.UIntKey(1), runtime.CBORBytes([]byte{0}))) // modify
|
require.NoError(t, mapA.Put(abi.UIntKey(1), runtime.CBORBytes([]byte{0}))) // modify
|
||||||
require.NoError(t, mapB.Put(adt.UIntKey(1), runtime.CBORBytes([]byte{1})))
|
require.NoError(t, mapB.Put(abi.UIntKey(1), runtime.CBORBytes([]byte{1})))
|
||||||
|
|
||||||
require.NoError(t, mapA.Put(adt.UIntKey(2), runtime.CBORBytes([]byte{1}))) // delete
|
require.NoError(t, mapA.Put(abi.UIntKey(2), runtime.CBORBytes([]byte{1}))) // delete
|
||||||
|
|
||||||
require.NoError(t, mapA.Put(adt.UIntKey(3), runtime.CBORBytes([]byte{0}))) // noop
|
require.NoError(t, mapA.Put(abi.UIntKey(3), runtime.CBORBytes([]byte{0}))) // noop
|
||||||
require.NoError(t, mapB.Put(adt.UIntKey(3), runtime.CBORBytes([]byte{0})))
|
require.NoError(t, mapB.Put(abi.UIntKey(3), runtime.CBORBytes([]byte{0})))
|
||||||
|
|
||||||
require.NoError(t, mapA.Put(adt.UIntKey(4), runtime.CBORBytes([]byte{0}))) // modify
|
require.NoError(t, mapA.Put(abi.UIntKey(4), runtime.CBORBytes([]byte{0}))) // modify
|
||||||
require.NoError(t, mapB.Put(adt.UIntKey(4), runtime.CBORBytes([]byte{6})))
|
require.NoError(t, mapB.Put(abi.UIntKey(4), runtime.CBORBytes([]byte{6})))
|
||||||
|
|
||||||
require.NoError(t, mapB.Put(adt.UIntKey(5), runtime.CBORBytes{8})) // add
|
require.NoError(t, mapB.Put(abi.UIntKey(5), runtime.CBORBytes{8})) // add
|
||||||
require.NoError(t, mapB.Put(adt.UIntKey(6), runtime.CBORBytes{9})) // add
|
require.NoError(t, mapB.Put(abi.UIntKey(6), runtime.CBORBytes{9})) // add
|
||||||
|
|
||||||
changes := new(TestDiffMap)
|
changes := new(TestDiffMap)
|
||||||
|
|
||||||
@@ -134,12 +135,12 @@ type TestDiffMap struct {
|
|||||||
|
|
||||||
var _ AdtMapDiff = &TestDiffMap{}
|
var _ AdtMapDiff = &TestDiffMap{}
|
||||||
|
|
||||||
func (t *TestDiffMap) AsKey(key string) (adt.Keyer, error) {
|
func (t *TestDiffMap) AsKey(key string) (abi.Keyer, error) {
|
||||||
k, err := adt.ParseUIntKey(key)
|
k, err := abi.ParseUIntKey(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return adt.UIntKey(k), nil
|
return abi.UIntKey(k), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TestDiffMap) Add(key string, val *typegen.Deferred) error {
|
func (t *TestDiffMap) Add(key string, val *typegen.Deferred) error {
|
||||||
@@ -148,7 +149,7 @@ func (t *TestDiffMap) Add(key string, val *typegen.Deferred) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
k, err := adt.ParseUIntKey(key)
|
k, err := abi.ParseUIntKey(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -172,7 +173,7 @@ func (t *TestDiffMap) Modify(key string, from, to *typegen.Deferred) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
k, err := adt.ParseUIntKey(key)
|
k, err := abi.ParseUIntKey(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -198,7 +199,7 @@ func (t *TestDiffMap) Remove(key string, val *typegen.Deferred) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
k, err := adt.ParseUIntKey(key)
|
k, err := abi.ParseUIntKey(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -291,12 +292,9 @@ func (t *TestDiffArray) Remove(key uint64, val *typegen.Deferred) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func newContextStore() *contextStore {
|
func newContextStore() Store {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
bs := bstore.NewTemporarySync()
|
bs := bstore.NewTemporarySync()
|
||||||
store := cbornode.NewCborStore(bs)
|
store := cbornode.NewCborStore(bs)
|
||||||
return &contextStore{
|
return WrapStore(ctx, store)
|
||||||
ctx: ctx,
|
|
||||||
cst: store,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package adt
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
adt "github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||||
|
cbor "github.com/ipfs/go-ipld-cbor"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Store interface {
|
||||||
|
Context() context.Context
|
||||||
|
cbor.IpldStore
|
||||||
|
}
|
||||||
|
|
||||||
|
func WrapStore(ctx context.Context, store cbor.IpldStore) Store {
|
||||||
|
return adt.WrapStore(ctx, store)
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@ package aerrors
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/runtime/exitcode"
|
"github.com/filecoin-project/go-state-types/exitcode"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package aerrors_test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-state-types/exitcode"
|
||||||
. "github.com/filecoin-project/lotus/chain/actors/aerrors"
|
. "github.com/filecoin-project/lotus/chain/actors/aerrors"
|
||||||
"github.com/filecoin-project/specs-actors/actors/runtime/exitcode"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/runtime/exitcode"
|
"github.com/filecoin-project/go-state-types/exitcode"
|
||||||
cbor "github.com/ipfs/go-ipld-cbor"
|
cbor "github.com/ipfs/go-ipld-cbor"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Actors
|
||||||
|
|
||||||
|
This package contains shims for abstracting over different actor versions.
|
||||||
|
|
||||||
|
## Design
|
||||||
|
|
||||||
|
Shims in this package follow a few common design principles.
|
||||||
|
|
||||||
|
### Structure Agnostic
|
||||||
|
|
||||||
|
Shims interfaces defined in this package should (ideally) not change even if the
|
||||||
|
structure of the underlying data changes. For example:
|
||||||
|
|
||||||
|
* All shims store an internal "store" object. That way, state can be moved into
|
||||||
|
a separate object without needing to add a store to the function signature.
|
||||||
|
* All functions must return an error, even if unused for now.
|
||||||
|
|
||||||
|
### Minimal
|
||||||
|
|
||||||
|
These interfaces should be expanded only as necessary to reduce maintenance burden.
|
||||||
|
|
||||||
|
### Queries, not field assessors.
|
||||||
|
|
||||||
|
When possible, functions should query the state instead of simply acting as
|
||||||
|
field assessors. These queries are more likely to remain stable across
|
||||||
|
specs-actor upgrades than specific state fields.
|
||||||
|
|
||||||
|
Note: there is a trade-off here. Avoid implementing _complicated_ query logic
|
||||||
|
inside these shims, as it will need to be replicated in every shim.
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package account
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/go-state-types/cbor"
|
||||||
|
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||||
|
switch act.Code {
|
||||||
|
case builtin0.AccountActorCodeID:
|
||||||
|
out := state0{store: store}
|
||||||
|
err := store.Get(store.Context(), act.Head, &out)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &out, nil
|
||||||
|
}
|
||||||
|
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||||
|
}
|
||||||
|
|
||||||
|
type State interface {
|
||||||
|
cbor.Marshaler
|
||||||
|
|
||||||
|
PubkeyAddress() (address.Address, error)
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package account
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/builtin/account"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ State = (*state0)(nil)
|
||||||
|
|
||||||
|
type state0 struct {
|
||||||
|
account.State
|
||||||
|
store adt.Store
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) PubkeyAddress() (address.Address, error) {
|
||||||
|
return s.Address, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package builtin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
|
proof0 "github.com/filecoin-project/specs-actors/actors/runtime/proof"
|
||||||
|
|
||||||
|
smoothing0 "github.com/filecoin-project/specs-actors/actors/util/smoothing"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-state-types/network"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Version int
|
||||||
|
|
||||||
|
const (
|
||||||
|
Version0 = iota
|
||||||
|
)
|
||||||
|
|
||||||
|
// Converts a network version into a specs-actors version.
|
||||||
|
func VersionForNetwork(version network.Version) Version {
|
||||||
|
switch version {
|
||||||
|
case network.Version0, network.Version1, network.Version2:
|
||||||
|
return Version0
|
||||||
|
default:
|
||||||
|
panic(fmt.Sprintf("unsupported network version %d", version))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Why does actors have 2 different versions of this?
|
||||||
|
type SectorInfo = proof0.SectorInfo
|
||||||
|
type PoStProof = proof0.PoStProof
|
||||||
|
type FilterEstimate = smoothing0.FilterEstimate
|
||||||
|
|
||||||
|
func FromV0FilterEstimate(v0 smoothing0.FilterEstimate) FilterEstimate {
|
||||||
|
return (FilterEstimate)(v0)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Doesn't change between actors v0 and v1
|
||||||
|
func QAPowerForWeight(size abi.SectorSize, duration abi.ChainEpoch, dealWeight, verifiedWeight abi.DealWeight) abi.StoragePower {
|
||||||
|
return miner0.QAPowerForWeight(size, duration, dealWeight, verifiedWeight)
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package init
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
"github.com/filecoin-project/go-state-types/cbor"
|
||||||
|
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Address = builtin0.InitActorAddr
|
||||||
|
|
||||||
|
func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||||
|
switch act.Code {
|
||||||
|
case builtin0.InitActorCodeID:
|
||||||
|
out := state0{store: store}
|
||||||
|
err := store.Get(store.Context(), act.Head, &out)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &out, nil
|
||||||
|
}
|
||||||
|
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||||
|
}
|
||||||
|
|
||||||
|
type State interface {
|
||||||
|
cbor.Marshaler
|
||||||
|
|
||||||
|
ResolveAddress(address address.Address) (address.Address, bool, error)
|
||||||
|
MapAddressToNewID(address address.Address) (address.Address, error)
|
||||||
|
NetworkName() (dtypes.NetworkName, error)
|
||||||
|
|
||||||
|
ForEachActor(func(id abi.ActorID, address address.Address) error) error
|
||||||
|
|
||||||
|
// Remove exists to support tooling that manipulates state for testing.
|
||||||
|
// It should not be used in production code, as init actor entries are
|
||||||
|
// immutable.
|
||||||
|
Remove(addrs ...address.Address) error
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package init
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
cbg "github.com/whyrusleeping/cbor-gen"
|
||||||
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
|
init_ "github.com/filecoin-project/specs-actors/actors/builtin/init"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
|
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||||
|
|
||||||
|
adt0 "github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ State = (*state0)(nil)
|
||||||
|
|
||||||
|
type state0 struct {
|
||||||
|
init_.State
|
||||||
|
store adt.Store
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) ResolveAddress(address address.Address) (address.Address, bool, error) {
|
||||||
|
return s.State.ResolveAddress(s.store, address)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) MapAddressToNewID(address address.Address) (address.Address, error) {
|
||||||
|
return s.State.MapAddressToNewID(s.store, address)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) ForEachActor(cb func(id abi.ActorID, address address.Address) error) error {
|
||||||
|
addrs, err := adt0.AsMap(s.store, s.State.AddressMap)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
var actorID cbg.CborInt
|
||||||
|
return addrs.ForEach(&actorID, func(key string) error {
|
||||||
|
addr, err := address.NewFromBytes([]byte(key))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cb(abi.ActorID(actorID), addr)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) NetworkName() (dtypes.NetworkName, error) {
|
||||||
|
return dtypes.NetworkName(s.State.NetworkName), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) Remove(addrs ...address.Address) (err error) {
|
||||||
|
m, err := adt0.AsMap(s.store, s.State.AddressMap)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, addr := range addrs {
|
||||||
|
if err = m.Delete(abi.AddrKey(addr)); err != nil {
|
||||||
|
return xerrors.Errorf("failed to delete entry for address: %s; err: %w", addr, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
amr, err := m.Root()
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("failed to get address map root: %w", err)
|
||||||
|
}
|
||||||
|
s.State.AddressMap = amr
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
package market
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
|
cbg "github.com/whyrusleeping/cbor-gen"
|
||||||
|
)
|
||||||
|
|
||||||
|
func DiffDealProposals(pre, cur DealProposals) (*DealProposalChanges, error) {
|
||||||
|
results := new(DealProposalChanges)
|
||||||
|
if err := adt.DiffAdtArray(pre.array(), cur.array(), &marketProposalsDiffer{results, pre, cur}); err != nil {
|
||||||
|
return nil, fmt.Errorf("diffing deal states: %w", err)
|
||||||
|
}
|
||||||
|
return results, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type marketProposalsDiffer struct {
|
||||||
|
Results *DealProposalChanges
|
||||||
|
pre, cur DealProposals
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *marketProposalsDiffer) Add(key uint64, val *cbg.Deferred) error {
|
||||||
|
dp, err := d.cur.decode(val)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
d.Results.Added = append(d.Results.Added, ProposalIDState{abi.DealID(key), *dp})
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *marketProposalsDiffer) Modify(key uint64, from, to *cbg.Deferred) error {
|
||||||
|
// short circuit, DealProposals are static
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *marketProposalsDiffer) Remove(key uint64, val *cbg.Deferred) error {
|
||||||
|
dp, err := d.pre.decode(val)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
d.Results.Removed = append(d.Results.Removed, ProposalIDState{abi.DealID(key), *dp})
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func DiffDealStates(pre, cur DealStates) (*DealStateChanges, error) {
|
||||||
|
results := new(DealStateChanges)
|
||||||
|
if err := adt.DiffAdtArray(pre.array(), cur.array(), &marketStatesDiffer{results, pre, cur}); err != nil {
|
||||||
|
return nil, fmt.Errorf("diffing deal states: %w", err)
|
||||||
|
}
|
||||||
|
return results, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type marketStatesDiffer struct {
|
||||||
|
Results *DealStateChanges
|
||||||
|
pre, cur DealStates
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *marketStatesDiffer) Add(key uint64, val *cbg.Deferred) error {
|
||||||
|
ds, err := d.cur.decode(val)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
d.Results.Added = append(d.Results.Added, DealIDState{abi.DealID(key), *ds})
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *marketStatesDiffer) Modify(key uint64, from, to *cbg.Deferred) error {
|
||||||
|
dsFrom, err := d.pre.decode(from)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
dsTo, err := d.cur.decode(to)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if *dsFrom != *dsTo {
|
||||||
|
d.Results.Modified = append(d.Results.Modified, DealStateChange{abi.DealID(key), dsFrom, dsTo})
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *marketStatesDiffer) Remove(key uint64, val *cbg.Deferred) error {
|
||||||
|
ds, err := d.pre.decode(val)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
d.Results.Removed = append(d.Results.Removed, DealIDState{abi.DealID(key), *ds})
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
package market
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
"github.com/filecoin-project/go-state-types/cbor"
|
||||||
|
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
|
market0 "github.com/filecoin-project/specs-actors/actors/builtin/market"
|
||||||
|
"github.com/ipfs/go-cid"
|
||||||
|
cbg "github.com/whyrusleeping/cbor-gen"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Address = builtin0.StorageMarketActorAddr
|
||||||
|
|
||||||
|
func Load(store adt.Store, act *types.Actor) (st State, err error) {
|
||||||
|
switch act.Code {
|
||||||
|
case builtin0.StorageMarketActorCodeID:
|
||||||
|
out := state0{store: store}
|
||||||
|
err := store.Get(store.Context(), act.Head, &out)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &out, nil
|
||||||
|
}
|
||||||
|
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||||
|
}
|
||||||
|
|
||||||
|
type State interface {
|
||||||
|
cbor.Marshaler
|
||||||
|
BalancesChanged(State) (bool, error)
|
||||||
|
EscrowTable() (BalanceTable, error)
|
||||||
|
LockedTable() (BalanceTable, error)
|
||||||
|
TotalLocked() (abi.TokenAmount, error)
|
||||||
|
StatesChanged(State) (bool, error)
|
||||||
|
States() (DealStates, error)
|
||||||
|
ProposalsChanged(State) (bool, error)
|
||||||
|
Proposals() (DealProposals, error)
|
||||||
|
VerifyDealsForActivation(
|
||||||
|
minerAddr address.Address, deals []abi.DealID, currEpoch, sectorExpiry abi.ChainEpoch,
|
||||||
|
) (weight, verifiedWeight abi.DealWeight, err error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type BalanceTable interface {
|
||||||
|
ForEach(cb func(address.Address, abi.TokenAmount) error) error
|
||||||
|
Get(key address.Address) (abi.TokenAmount, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type DealStates interface {
|
||||||
|
ForEach(cb func(id abi.DealID, ds DealState) error) error
|
||||||
|
Get(id abi.DealID) (*DealState, bool, error)
|
||||||
|
|
||||||
|
array() adt.Array
|
||||||
|
decode(*cbg.Deferred) (*DealState, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type DealProposals interface {
|
||||||
|
ForEach(cb func(id abi.DealID, dp DealProposal) error) error
|
||||||
|
Get(id abi.DealID) (*DealProposal, bool, error)
|
||||||
|
|
||||||
|
array() adt.Array
|
||||||
|
decode(*cbg.Deferred) (*DealProposal, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type PublishStorageDealsParams = market0.PublishStorageDealsParams
|
||||||
|
type PublishStorageDealsReturn = market0.PublishStorageDealsReturn
|
||||||
|
type VerifyDealsForActivationParams = market0.VerifyDealsForActivationParams
|
||||||
|
|
||||||
|
type ClientDealProposal = market0.ClientDealProposal
|
||||||
|
|
||||||
|
type DealState struct {
|
||||||
|
SectorStartEpoch abi.ChainEpoch // -1 if not yet included in proven sector
|
||||||
|
LastUpdatedEpoch abi.ChainEpoch // -1 if deal state never updated
|
||||||
|
SlashEpoch abi.ChainEpoch // -1 if deal never slashed
|
||||||
|
}
|
||||||
|
|
||||||
|
type DealProposal struct {
|
||||||
|
PieceCID cid.Cid
|
||||||
|
PieceSize abi.PaddedPieceSize
|
||||||
|
VerifiedDeal bool
|
||||||
|
Client address.Address
|
||||||
|
Provider address.Address
|
||||||
|
Label string
|
||||||
|
StartEpoch abi.ChainEpoch
|
||||||
|
EndEpoch abi.ChainEpoch
|
||||||
|
StoragePricePerEpoch abi.TokenAmount
|
||||||
|
ProviderCollateral abi.TokenAmount
|
||||||
|
ClientCollateral abi.TokenAmount
|
||||||
|
}
|
||||||
|
|
||||||
|
type DealStateChanges struct {
|
||||||
|
Added []DealIDState
|
||||||
|
Modified []DealStateChange
|
||||||
|
Removed []DealIDState
|
||||||
|
}
|
||||||
|
|
||||||
|
type DealIDState struct {
|
||||||
|
ID abi.DealID
|
||||||
|
Deal DealState
|
||||||
|
}
|
||||||
|
|
||||||
|
// DealStateChange is a change in deal state from -> to
|
||||||
|
type DealStateChange struct {
|
||||||
|
ID abi.DealID
|
||||||
|
From *DealState
|
||||||
|
To *DealState
|
||||||
|
}
|
||||||
|
|
||||||
|
type DealProposalChanges struct {
|
||||||
|
Added []ProposalIDState
|
||||||
|
Removed []ProposalIDState
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProposalIDState struct {
|
||||||
|
ID abi.DealID
|
||||||
|
Proposal DealProposal
|
||||||
|
}
|
||||||
|
|
||||||
|
func EmptyDealState() *DealState {
|
||||||
|
return &DealState{
|
||||||
|
SectorStartEpoch: -1,
|
||||||
|
SlashEpoch: -1,
|
||||||
|
LastUpdatedEpoch: -1,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,192 @@
|
|||||||
|
package market
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/builtin/market"
|
||||||
|
adt0 "github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||||
|
cbg "github.com/whyrusleeping/cbor-gen"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ State = (*state0)(nil)
|
||||||
|
|
||||||
|
type state0 struct {
|
||||||
|
market.State
|
||||||
|
store adt.Store
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) TotalLocked() (abi.TokenAmount, error) {
|
||||||
|
fml := types.BigAdd(s.TotalClientLockedCollateral, s.TotalProviderLockedCollateral)
|
||||||
|
fml = types.BigAdd(fml, s.TotalClientStorageFee)
|
||||||
|
return fml, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) BalancesChanged(otherState State) (bool, error) {
|
||||||
|
otherState0, ok := otherState.(*state0)
|
||||||
|
if !ok {
|
||||||
|
// there's no way to compare different versions of the state, so let's
|
||||||
|
// just say that means the state of balances has changed
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
return !s.State.EscrowTable.Equals(otherState0.State.EscrowTable) || !s.State.LockedTable.Equals(otherState0.State.LockedTable), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) StatesChanged(otherState State) (bool, error) {
|
||||||
|
otherState0, ok := otherState.(*state0)
|
||||||
|
if !ok {
|
||||||
|
// there's no way to compare different versions of the state, so let's
|
||||||
|
// just say that means the state of balances has changed
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
return !s.State.States.Equals(otherState0.State.States), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) States() (DealStates, error) {
|
||||||
|
stateArray, err := adt0.AsArray(s.store, s.State.States)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &dealStates0{stateArray}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) ProposalsChanged(otherState State) (bool, error) {
|
||||||
|
otherState0, ok := otherState.(*state0)
|
||||||
|
if !ok {
|
||||||
|
// there's no way to compare different versions of the state, so let's
|
||||||
|
// just say that means the state of balances has changed
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
return !s.State.Proposals.Equals(otherState0.State.Proposals), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) Proposals() (DealProposals, error) {
|
||||||
|
proposalArray, err := adt0.AsArray(s.store, s.State.Proposals)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &dealProposals0{proposalArray}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) EscrowTable() (BalanceTable, error) {
|
||||||
|
bt, err := adt0.AsBalanceTable(s.store, s.State.EscrowTable)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &balanceTable0{bt}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) LockedTable() (BalanceTable, error) {
|
||||||
|
bt, err := adt0.AsBalanceTable(s.store, s.State.LockedTable)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &balanceTable0{bt}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) VerifyDealsForActivation(
|
||||||
|
minerAddr address.Address, deals []abi.DealID, currEpoch, sectorExpiry abi.ChainEpoch,
|
||||||
|
) (weight, verifiedWeight abi.DealWeight, err error) {
|
||||||
|
return market.ValidateDealsForActivation(&s.State, s.store, deals, minerAddr, sectorExpiry, currEpoch)
|
||||||
|
}
|
||||||
|
|
||||||
|
type balanceTable0 struct {
|
||||||
|
*adt0.BalanceTable
|
||||||
|
}
|
||||||
|
|
||||||
|
func (bt *balanceTable0) ForEach(cb func(address.Address, abi.TokenAmount) error) error {
|
||||||
|
asMap := (*adt0.Map)(bt.BalanceTable)
|
||||||
|
var ta abi.TokenAmount
|
||||||
|
return asMap.ForEach(&ta, func(key string) error {
|
||||||
|
a, err := address.NewFromBytes([]byte(key))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cb(a, ta)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
type dealStates0 struct {
|
||||||
|
adt.Array
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *dealStates0) Get(dealID abi.DealID) (*DealState, bool, error) {
|
||||||
|
var deal0 market.DealState
|
||||||
|
found, err := s.Array.Get(uint64(dealID), &deal0)
|
||||||
|
if err != nil {
|
||||||
|
return nil, false, err
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
return nil, false, nil
|
||||||
|
}
|
||||||
|
deal := fromV0DealState(deal0)
|
||||||
|
return &deal, true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *dealStates0) ForEach(cb func(dealID abi.DealID, ds DealState) error) error {
|
||||||
|
var ds0 market.DealState
|
||||||
|
return s.Array.ForEach(&ds0, func(idx int64) error {
|
||||||
|
return cb(abi.DealID(idx), fromV0DealState(ds0))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *dealStates0) decode(val *cbg.Deferred) (*DealState, error) {
|
||||||
|
var ds0 market.DealState
|
||||||
|
if err := ds0.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
ds := fromV0DealState(ds0)
|
||||||
|
return &ds, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *dealStates0) array() adt.Array {
|
||||||
|
return s.Array
|
||||||
|
}
|
||||||
|
|
||||||
|
func fromV0DealState(v0 market.DealState) DealState {
|
||||||
|
return (DealState)(v0)
|
||||||
|
}
|
||||||
|
|
||||||
|
type dealProposals0 struct {
|
||||||
|
adt.Array
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *dealProposals0) Get(dealID abi.DealID) (*DealProposal, bool, error) {
|
||||||
|
var proposal0 market.DealProposal
|
||||||
|
found, err := s.Array.Get(uint64(dealID), &proposal0)
|
||||||
|
if err != nil {
|
||||||
|
return nil, false, err
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
return nil, false, nil
|
||||||
|
}
|
||||||
|
proposal := fromV0DealProposal(proposal0)
|
||||||
|
return &proposal, true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *dealProposals0) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error {
|
||||||
|
var dp0 market.DealProposal
|
||||||
|
return s.Array.ForEach(&dp0, func(idx int64) error {
|
||||||
|
return cb(abi.DealID(idx), fromV0DealProposal(dp0))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *dealProposals0) decode(val *cbg.Deferred) (*DealProposal, error) {
|
||||||
|
var dp0 market.DealProposal
|
||||||
|
if err := dp0.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
dp := fromV0DealProposal(dp0)
|
||||||
|
return &dp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *dealProposals0) array() adt.Array {
|
||||||
|
return s.Array
|
||||||
|
}
|
||||||
|
|
||||||
|
func fromV0DealProposal(v0 market.DealProposal) DealProposal {
|
||||||
|
return (DealProposal)(v0)
|
||||||
|
}
|
||||||
@@ -0,0 +1,313 @@
|
|||||||
|
// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT.
|
||||||
|
|
||||||
|
package miner
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
|
||||||
|
abi "github.com/filecoin-project/go-state-types/abi"
|
||||||
|
cbg "github.com/whyrusleeping/cbor-gen"
|
||||||
|
xerrors "golang.org/x/xerrors"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ = xerrors.Errorf
|
||||||
|
|
||||||
|
var lengthBufSectorOnChainInfo = []byte{139}
|
||||||
|
|
||||||
|
func (t *SectorOnChainInfo) MarshalCBOR(w io.Writer) error {
|
||||||
|
if t == nil {
|
||||||
|
_, err := w.Write(cbg.CborNull)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if _, err := w.Write(lengthBufSectorOnChainInfo); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
scratch := make([]byte, 9)
|
||||||
|
|
||||||
|
// t.SectorNumber (abi.SectorNumber) (uint64)
|
||||||
|
|
||||||
|
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.SectorNumber)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// t.SealProof (abi.RegisteredSealProof) (int64)
|
||||||
|
if t.SealProof >= 0 {
|
||||||
|
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.SealProof)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.SealProof-1)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// t.SealedCID (cid.Cid) (struct)
|
||||||
|
|
||||||
|
if err := cbg.WriteCidBuf(scratch, w, t.SealedCID); err != nil {
|
||||||
|
return xerrors.Errorf("failed to write cid field t.SealedCID: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// t.DealIDs ([]abi.DealID) (slice)
|
||||||
|
if len(t.DealIDs) > cbg.MaxLength {
|
||||||
|
return xerrors.Errorf("Slice value in field t.DealIDs was too long")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(t.DealIDs))); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, v := range t.DealIDs {
|
||||||
|
if err := cbg.CborWriteHeader(w, cbg.MajUnsignedInt, uint64(v)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// t.Activation (abi.ChainEpoch) (int64)
|
||||||
|
if t.Activation >= 0 {
|
||||||
|
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.Activation)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.Activation-1)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// t.Expiration (abi.ChainEpoch) (int64)
|
||||||
|
if t.Expiration >= 0 {
|
||||||
|
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.Expiration)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.Expiration-1)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// t.DealWeight (big.Int) (struct)
|
||||||
|
if err := t.DealWeight.MarshalCBOR(w); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// t.VerifiedDealWeight (big.Int) (struct)
|
||||||
|
if err := t.VerifiedDealWeight.MarshalCBOR(w); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// t.InitialPledge (big.Int) (struct)
|
||||||
|
if err := t.InitialPledge.MarshalCBOR(w); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// t.ExpectedDayReward (big.Int) (struct)
|
||||||
|
if err := t.ExpectedDayReward.MarshalCBOR(w); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// t.ExpectedStoragePledge (big.Int) (struct)
|
||||||
|
if err := t.ExpectedStoragePledge.MarshalCBOR(w); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *SectorOnChainInfo) UnmarshalCBOR(r io.Reader) error {
|
||||||
|
*t = SectorOnChainInfo{}
|
||||||
|
|
||||||
|
br := cbg.GetPeeker(r)
|
||||||
|
scratch := make([]byte, 8)
|
||||||
|
|
||||||
|
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if maj != cbg.MajArray {
|
||||||
|
return fmt.Errorf("cbor input should be of type array")
|
||||||
|
}
|
||||||
|
|
||||||
|
if extra != 11 {
|
||||||
|
return fmt.Errorf("cbor input had wrong number of fields")
|
||||||
|
}
|
||||||
|
|
||||||
|
// t.SectorNumber (abi.SectorNumber) (uint64)
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if maj != cbg.MajUnsignedInt {
|
||||||
|
return fmt.Errorf("wrong type for uint64 field")
|
||||||
|
}
|
||||||
|
t.SectorNumber = abi.SectorNumber(extra)
|
||||||
|
|
||||||
|
}
|
||||||
|
// t.SealProof (abi.RegisteredSealProof) (int64)
|
||||||
|
{
|
||||||
|
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
|
||||||
|
var extraI int64
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
switch maj {
|
||||||
|
case cbg.MajUnsignedInt:
|
||||||
|
extraI = int64(extra)
|
||||||
|
if extraI < 0 {
|
||||||
|
return fmt.Errorf("int64 positive overflow")
|
||||||
|
}
|
||||||
|
case cbg.MajNegativeInt:
|
||||||
|
extraI = int64(extra)
|
||||||
|
if extraI < 0 {
|
||||||
|
return fmt.Errorf("int64 negative oveflow")
|
||||||
|
}
|
||||||
|
extraI = -1 - extraI
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("wrong type for int64 field: %d", maj)
|
||||||
|
}
|
||||||
|
|
||||||
|
t.SealProof = abi.RegisteredSealProof(extraI)
|
||||||
|
}
|
||||||
|
// t.SealedCID (cid.Cid) (struct)
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
c, err := cbg.ReadCid(br)
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("failed to read cid field t.SealedCID: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
t.SealedCID = c
|
||||||
|
|
||||||
|
}
|
||||||
|
// t.DealIDs ([]abi.DealID) (slice)
|
||||||
|
|
||||||
|
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if extra > cbg.MaxLength {
|
||||||
|
return fmt.Errorf("t.DealIDs: array too large (%d)", extra)
|
||||||
|
}
|
||||||
|
|
||||||
|
if maj != cbg.MajArray {
|
||||||
|
return fmt.Errorf("expected cbor array")
|
||||||
|
}
|
||||||
|
|
||||||
|
if extra > 0 {
|
||||||
|
t.DealIDs = make([]abi.DealID, extra)
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := 0; i < int(extra); i++ {
|
||||||
|
|
||||||
|
maj, val, err := cbg.CborReadHeaderBuf(br, scratch)
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("failed to read uint64 for t.DealIDs slice: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if maj != cbg.MajUnsignedInt {
|
||||||
|
return xerrors.Errorf("value read for array t.DealIDs was not a uint, instead got %d", maj)
|
||||||
|
}
|
||||||
|
|
||||||
|
t.DealIDs[i] = abi.DealID(val)
|
||||||
|
}
|
||||||
|
|
||||||
|
// t.Activation (abi.ChainEpoch) (int64)
|
||||||
|
{
|
||||||
|
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
|
||||||
|
var extraI int64
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
switch maj {
|
||||||
|
case cbg.MajUnsignedInt:
|
||||||
|
extraI = int64(extra)
|
||||||
|
if extraI < 0 {
|
||||||
|
return fmt.Errorf("int64 positive overflow")
|
||||||
|
}
|
||||||
|
case cbg.MajNegativeInt:
|
||||||
|
extraI = int64(extra)
|
||||||
|
if extraI < 0 {
|
||||||
|
return fmt.Errorf("int64 negative oveflow")
|
||||||
|
}
|
||||||
|
extraI = -1 - extraI
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("wrong type for int64 field: %d", maj)
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Activation = abi.ChainEpoch(extraI)
|
||||||
|
}
|
||||||
|
// t.Expiration (abi.ChainEpoch) (int64)
|
||||||
|
{
|
||||||
|
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
|
||||||
|
var extraI int64
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
switch maj {
|
||||||
|
case cbg.MajUnsignedInt:
|
||||||
|
extraI = int64(extra)
|
||||||
|
if extraI < 0 {
|
||||||
|
return fmt.Errorf("int64 positive overflow")
|
||||||
|
}
|
||||||
|
case cbg.MajNegativeInt:
|
||||||
|
extraI = int64(extra)
|
||||||
|
if extraI < 0 {
|
||||||
|
return fmt.Errorf("int64 negative oveflow")
|
||||||
|
}
|
||||||
|
extraI = -1 - extraI
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("wrong type for int64 field: %d", maj)
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Expiration = abi.ChainEpoch(extraI)
|
||||||
|
}
|
||||||
|
// t.DealWeight (big.Int) (struct)
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
if err := t.DealWeight.UnmarshalCBOR(br); err != nil {
|
||||||
|
return xerrors.Errorf("unmarshaling t.DealWeight: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// t.VerifiedDealWeight (big.Int) (struct)
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
if err := t.VerifiedDealWeight.UnmarshalCBOR(br); err != nil {
|
||||||
|
return xerrors.Errorf("unmarshaling t.VerifiedDealWeight: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// t.InitialPledge (big.Int) (struct)
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
if err := t.InitialPledge.UnmarshalCBOR(br); err != nil {
|
||||||
|
return xerrors.Errorf("unmarshaling t.InitialPledge: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// t.ExpectedDayReward (big.Int) (struct)
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
if err := t.ExpectedDayReward.UnmarshalCBOR(br); err != nil {
|
||||||
|
return xerrors.Errorf("unmarshaling t.ExpectedDayReward: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// t.ExpectedStoragePledge (big.Int) (struct)
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
if err := t.ExpectedStoragePledge.UnmarshalCBOR(br); err != nil {
|
||||||
|
return xerrors.Errorf("unmarshaling t.ExpectedStoragePledge: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,127 @@
|
|||||||
|
package miner
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
|
cbg "github.com/whyrusleeping/cbor-gen"
|
||||||
|
)
|
||||||
|
|
||||||
|
func DiffPreCommits(pre, cur State) (*PreCommitChanges, error) {
|
||||||
|
results := new(PreCommitChanges)
|
||||||
|
|
||||||
|
prep, err := pre.precommits()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
curp, err := cur.precommits()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = adt.DiffAdtMap(prep, curp, &preCommitDiffer{results, pre, cur})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return results, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type preCommitDiffer struct {
|
||||||
|
Results *PreCommitChanges
|
||||||
|
pre, after State
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *preCommitDiffer) AsKey(key string) (abi.Keyer, error) {
|
||||||
|
sector, err := abi.ParseUIntKey(key)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return abi.UIntKey(sector), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *preCommitDiffer) Add(key string, val *cbg.Deferred) error {
|
||||||
|
sp, err := m.after.decodeSectorPreCommitOnChainInfo(val)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
m.Results.Added = append(m.Results.Added, sp)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *preCommitDiffer) Modify(key string, from, to *cbg.Deferred) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *preCommitDiffer) Remove(key string, val *cbg.Deferred) error {
|
||||||
|
sp, err := m.pre.decodeSectorPreCommitOnChainInfo(val)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
m.Results.Removed = append(m.Results.Removed, sp)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func DiffSectors(pre, cur State) (*SectorChanges, error) {
|
||||||
|
results := new(SectorChanges)
|
||||||
|
|
||||||
|
pres, err := pre.sectors()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
curs, err := cur.sectors()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = adt.DiffAdtArray(pres, curs, §orDiffer{results, pre, cur})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return results, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type sectorDiffer struct {
|
||||||
|
Results *SectorChanges
|
||||||
|
pre, after State
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *sectorDiffer) Add(key uint64, val *cbg.Deferred) error {
|
||||||
|
si, err := m.after.decodeSectorOnChainInfo(val)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
m.Results.Added = append(m.Results.Added, si)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *sectorDiffer) Modify(key uint64, from, to *cbg.Deferred) error {
|
||||||
|
siFrom, err := m.pre.decodeSectorOnChainInfo(from)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
siTo, err := m.after.decodeSectorOnChainInfo(to)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if siFrom.Expiration != siTo.Expiration {
|
||||||
|
m.Results.Extended = append(m.Results.Extended, SectorExtensions{
|
||||||
|
From: siFrom,
|
||||||
|
To: siTo,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *sectorDiffer) Remove(key uint64, val *cbg.Deferred) error {
|
||||||
|
si, err := m.pre.decodeSectorOnChainInfo(val)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
m.Results.Removed = append(m.Results.Removed, si)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,170 @@
|
|||||||
|
package miner
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/ipfs/go-cid"
|
||||||
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
|
cbg "github.com/whyrusleeping/cbor-gen"
|
||||||
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/go-bitfield"
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
"github.com/filecoin-project/go-state-types/cbor"
|
||||||
|
"github.com/filecoin-project/go-state-types/dline"
|
||||||
|
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
|
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Unchanged between v0 and v1 actors
|
||||||
|
var PreCommitChallengeDelay = miner0.PreCommitChallengeDelay
|
||||||
|
var WPoStProvingPeriod = miner0.WPoStProvingPeriod
|
||||||
|
|
||||||
|
const MinSectorExpiration = miner0.MinSectorExpiration
|
||||||
|
|
||||||
|
func Load(store adt.Store, act *types.Actor) (st State, err error) {
|
||||||
|
switch act.Code {
|
||||||
|
case builtin0.StorageMinerActorCodeID:
|
||||||
|
out := state0{store: store}
|
||||||
|
err := store.Get(store.Context(), act.Head, &out)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &out, nil
|
||||||
|
}
|
||||||
|
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||||
|
}
|
||||||
|
|
||||||
|
type State interface {
|
||||||
|
cbor.Marshaler
|
||||||
|
|
||||||
|
// Total available balance to spend.
|
||||||
|
AvailableBalance(abi.TokenAmount) (abi.TokenAmount, error)
|
||||||
|
// Funds that will vest by the given epoch.
|
||||||
|
VestedFunds(abi.ChainEpoch) (abi.TokenAmount, error)
|
||||||
|
// Funds locked for various reasons.
|
||||||
|
LockedFunds() (LockedFunds, error)
|
||||||
|
|
||||||
|
GetSector(abi.SectorNumber) (*SectorOnChainInfo, error)
|
||||||
|
FindSector(abi.SectorNumber) (*SectorLocation, error)
|
||||||
|
GetSectorExpiration(abi.SectorNumber) (*SectorExpiration, error)
|
||||||
|
GetPrecommittedSector(abi.SectorNumber) (*SectorPreCommitOnChainInfo, error)
|
||||||
|
LoadSectors(sectorNos *bitfield.BitField) ([]*SectorOnChainInfo, error)
|
||||||
|
NumLiveSectors() (uint64, error)
|
||||||
|
IsAllocated(abi.SectorNumber) (bool, error)
|
||||||
|
|
||||||
|
LoadDeadline(idx uint64) (Deadline, error)
|
||||||
|
ForEachDeadline(cb func(idx uint64, dl Deadline) error) error
|
||||||
|
NumDeadlines() (uint64, error)
|
||||||
|
DeadlinesChanged(State) (bool, error)
|
||||||
|
|
||||||
|
Info() (MinerInfo, error)
|
||||||
|
|
||||||
|
DeadlineInfo(epoch abi.ChainEpoch) (*dline.Info, error)
|
||||||
|
|
||||||
|
// Diff helpers. Used by Diff* functions internally.
|
||||||
|
sectors() (adt.Array, error)
|
||||||
|
decodeSectorOnChainInfo(*cbg.Deferred) (SectorOnChainInfo, error)
|
||||||
|
precommits() (adt.Map, error)
|
||||||
|
decodeSectorPreCommitOnChainInfo(*cbg.Deferred) (SectorPreCommitOnChainInfo, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type Deadline interface {
|
||||||
|
LoadPartition(idx uint64) (Partition, error)
|
||||||
|
ForEachPartition(cb func(idx uint64, part Partition) error) error
|
||||||
|
PostSubmissions() (bitfield.BitField, error)
|
||||||
|
|
||||||
|
PartitionsChanged(Deadline) (bool, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type Partition interface {
|
||||||
|
AllSectors() (bitfield.BitField, error)
|
||||||
|
FaultySectors() (bitfield.BitField, error)
|
||||||
|
RecoveringSectors() (bitfield.BitField, error)
|
||||||
|
LiveSectors() (bitfield.BitField, error)
|
||||||
|
ActiveSectors() (bitfield.BitField, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type SectorOnChainInfo struct {
|
||||||
|
SectorNumber abi.SectorNumber
|
||||||
|
SealProof abi.RegisteredSealProof
|
||||||
|
SealedCID cid.Cid
|
||||||
|
DealIDs []abi.DealID
|
||||||
|
Activation abi.ChainEpoch
|
||||||
|
Expiration abi.ChainEpoch
|
||||||
|
DealWeight abi.DealWeight
|
||||||
|
VerifiedDealWeight abi.DealWeight
|
||||||
|
InitialPledge abi.TokenAmount
|
||||||
|
ExpectedDayReward abi.TokenAmount
|
||||||
|
ExpectedStoragePledge abi.TokenAmount
|
||||||
|
}
|
||||||
|
|
||||||
|
type SectorPreCommitInfo = miner0.SectorPreCommitInfo
|
||||||
|
|
||||||
|
type SectorPreCommitOnChainInfo struct {
|
||||||
|
Info SectorPreCommitInfo
|
||||||
|
PreCommitDeposit abi.TokenAmount
|
||||||
|
PreCommitEpoch abi.ChainEpoch
|
||||||
|
DealWeight abi.DealWeight
|
||||||
|
VerifiedDealWeight abi.DealWeight
|
||||||
|
}
|
||||||
|
|
||||||
|
type PoStPartition = miner0.PoStPartition
|
||||||
|
type RecoveryDeclaration = miner0.RecoveryDeclaration
|
||||||
|
type FaultDeclaration = miner0.FaultDeclaration
|
||||||
|
|
||||||
|
// Params
|
||||||
|
type DeclareFaultsParams = miner0.DeclareFaultsParams
|
||||||
|
type DeclareFaultsRecoveredParams = miner0.DeclareFaultsRecoveredParams
|
||||||
|
type SubmitWindowedPoStParams = miner0.SubmitWindowedPoStParams
|
||||||
|
type ProveCommitSectorParams = miner0.ProveCommitSectorParams
|
||||||
|
|
||||||
|
type MinerInfo struct {
|
||||||
|
Owner address.Address // Must be an ID-address.
|
||||||
|
Worker address.Address // Must be an ID-address.
|
||||||
|
NewWorker address.Address // Must be an ID-address.
|
||||||
|
ControlAddresses []address.Address // Must be an ID-addresses.
|
||||||
|
WorkerChangeEpoch abi.ChainEpoch
|
||||||
|
PeerId *peer.ID
|
||||||
|
Multiaddrs []abi.Multiaddrs
|
||||||
|
SealProofType abi.RegisteredSealProof
|
||||||
|
SectorSize abi.SectorSize
|
||||||
|
WindowPoStPartitionSectors uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
type SectorExpiration struct {
|
||||||
|
OnTime abi.ChainEpoch
|
||||||
|
|
||||||
|
// non-zero if sector is faulty, epoch at which it will be permanently
|
||||||
|
// removed if it doesn't recover
|
||||||
|
Early abi.ChainEpoch
|
||||||
|
}
|
||||||
|
|
||||||
|
type SectorLocation struct {
|
||||||
|
Deadline uint64
|
||||||
|
Partition uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
type SectorChanges struct {
|
||||||
|
Added []SectorOnChainInfo
|
||||||
|
Extended []SectorExtensions
|
||||||
|
Removed []SectorOnChainInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
type SectorExtensions struct {
|
||||||
|
From SectorOnChainInfo
|
||||||
|
To SectorOnChainInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
type PreCommitChanges struct {
|
||||||
|
Added []SectorPreCommitOnChainInfo
|
||||||
|
Removed []SectorPreCommitOnChainInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
type LockedFunds struct {
|
||||||
|
VestingFunds abi.TokenAmount
|
||||||
|
InitialPledgeRequirement abi.TokenAmount
|
||||||
|
PreCommitDeposits abi.TokenAmount
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package miner
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-bitfield"
|
||||||
|
)
|
||||||
|
|
||||||
|
func AllPartSectors(mas State, sget func(Partition) (bitfield.BitField, error)) (bitfield.BitField, error) {
|
||||||
|
var parts []bitfield.BitField
|
||||||
|
|
||||||
|
err := mas.ForEachDeadline(func(dlidx uint64, dl Deadline) error {
|
||||||
|
return dl.ForEachPartition(func(partidx uint64, part Partition) error {
|
||||||
|
s, err := sget(part)
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("getting sector list (dl: %d, part %d): %w", dlidx, partidx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
parts = append(parts, s)
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return bitfield.BitField{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return bitfield.MultiMerge(parts...)
|
||||||
|
}
|
||||||
@@ -0,0 +1,374 @@
|
|||||||
|
package miner
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"errors"
|
||||||
|
|
||||||
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
|
cbg "github.com/whyrusleeping/cbor-gen"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/go-bitfield"
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
"github.com/filecoin-project/go-state-types/dline"
|
||||||
|
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
|
adt0 "github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ State = (*state0)(nil)
|
||||||
|
|
||||||
|
type state0 struct {
|
||||||
|
miner0.State
|
||||||
|
store adt.Store
|
||||||
|
}
|
||||||
|
|
||||||
|
type deadline0 struct {
|
||||||
|
miner0.Deadline
|
||||||
|
store adt.Store
|
||||||
|
}
|
||||||
|
|
||||||
|
type partition0 struct {
|
||||||
|
miner0.Partition
|
||||||
|
store adt.Store
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) AvailableBalance(bal abi.TokenAmount) (abi.TokenAmount, error) {
|
||||||
|
return s.GetAvailableBalance(bal), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) VestedFunds(epoch abi.ChainEpoch) (abi.TokenAmount, error) {
|
||||||
|
return s.CheckVestedFunds(s.store, epoch)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) LockedFunds() (LockedFunds, error) {
|
||||||
|
return LockedFunds{
|
||||||
|
VestingFunds: s.State.LockedFunds,
|
||||||
|
InitialPledgeRequirement: s.State.InitialPledgeRequirement,
|
||||||
|
PreCommitDeposits: s.State.PreCommitDeposits,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) InitialPledge() (abi.TokenAmount, error) {
|
||||||
|
return s.State.InitialPledgeRequirement, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) PreCommitDeposits() (abi.TokenAmount, error) {
|
||||||
|
return s.State.PreCommitDeposits, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) GetSector(num abi.SectorNumber) (*SectorOnChainInfo, error) {
|
||||||
|
info, ok, err := s.State.GetSector(s.store, num)
|
||||||
|
if !ok || err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
ret := fromV0SectorOnChainInfo(*info)
|
||||||
|
return &ret, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) FindSector(num abi.SectorNumber) (*SectorLocation, error) {
|
||||||
|
dlIdx, partIdx, err := s.State.FindSector(s.store, num)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &SectorLocation{
|
||||||
|
Deadline: dlIdx,
|
||||||
|
Partition: partIdx,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) NumLiveSectors() (uint64, error) {
|
||||||
|
dls, err := s.State.LoadDeadlines(s.store)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
var total uint64
|
||||||
|
if err := dls.ForEach(s.store, func(dlIdx uint64, dl *miner0.Deadline) error {
|
||||||
|
total += dl.LiveSectors
|
||||||
|
return nil
|
||||||
|
}); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return total, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetSectorExpiration returns the effective expiration of the given sector.
|
||||||
|
//
|
||||||
|
// If the sector isn't found or has already been terminated, this method returns
|
||||||
|
// nil and no error. If the sector does not expire early, the Early expiration
|
||||||
|
// field is 0.
|
||||||
|
func (s *state0) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, error) {
|
||||||
|
dls, err := s.State.LoadDeadlines(s.store)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
// NOTE: this can be optimized significantly.
|
||||||
|
// 1. If the sector is non-faulty, it will either expire on-time (can be
|
||||||
|
// learned from the sector info), or in the next quantized expiration
|
||||||
|
// epoch (i.e., the first element in the partition's expiration queue.
|
||||||
|
// 2. If it's faulty, it will expire early within the first 14 entries
|
||||||
|
// of the expiration queue.
|
||||||
|
stopErr := errors.New("stop")
|
||||||
|
out := SectorExpiration{}
|
||||||
|
err = dls.ForEach(s.store, func(dlIdx uint64, dl *miner0.Deadline) error {
|
||||||
|
partitions, err := dl.PartitionsArray(s.store)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
quant := s.State.QuantSpecForDeadline(dlIdx)
|
||||||
|
var part miner0.Partition
|
||||||
|
return partitions.ForEach(&part, func(partIdx int64) error {
|
||||||
|
if found, err := part.Sectors.IsSet(uint64(num)); err != nil {
|
||||||
|
return err
|
||||||
|
} else if !found {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if found, err := part.Terminated.IsSet(uint64(num)); err != nil {
|
||||||
|
return err
|
||||||
|
} else if found {
|
||||||
|
// already terminated
|
||||||
|
return stopErr
|
||||||
|
}
|
||||||
|
|
||||||
|
q, err := miner0.LoadExpirationQueue(s.store, part.ExpirationsEpochs, quant)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
var exp miner0.ExpirationSet
|
||||||
|
return q.ForEach(&exp, func(epoch int64) error {
|
||||||
|
if early, err := exp.EarlySectors.IsSet(uint64(num)); err != nil {
|
||||||
|
return err
|
||||||
|
} else if early {
|
||||||
|
out.Early = abi.ChainEpoch(epoch)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if onTime, err := exp.OnTimeSectors.IsSet(uint64(num)); err != nil {
|
||||||
|
return err
|
||||||
|
} else if onTime {
|
||||||
|
out.OnTime = abi.ChainEpoch(epoch)
|
||||||
|
return stopErr
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
if err == stopErr {
|
||||||
|
err = nil
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if out.Early == 0 && out.OnTime == 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return &out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) {
|
||||||
|
info, ok, err := s.State.GetPrecommittedSector(s.store, num)
|
||||||
|
if !ok || err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
ret := fromV0SectorPreCommitOnChainInfo(*info)
|
||||||
|
return &ret, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) LoadSectors(snos *bitfield.BitField) ([]*SectorOnChainInfo, error) {
|
||||||
|
sectors, err := miner0.LoadSectors(s.store, s.State.Sectors)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// If no sector numbers are specified, load all.
|
||||||
|
if snos == nil {
|
||||||
|
infos := make([]*SectorOnChainInfo, 0, sectors.Length())
|
||||||
|
var info0 miner0.SectorOnChainInfo
|
||||||
|
if err := sectors.ForEach(&info0, func(_ int64) error {
|
||||||
|
info := fromV0SectorOnChainInfo(info0)
|
||||||
|
infos = append(infos, &info)
|
||||||
|
return nil
|
||||||
|
}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return infos, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, load selected.
|
||||||
|
infos0, err := sectors.Load(*snos)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
infos := make([]*SectorOnChainInfo, len(infos0))
|
||||||
|
for i, info0 := range infos0 {
|
||||||
|
info := fromV0SectorOnChainInfo(*info0)
|
||||||
|
infos[i] = &info
|
||||||
|
}
|
||||||
|
return infos, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) IsAllocated(num abi.SectorNumber) (bool, error) {
|
||||||
|
var allocatedSectors bitfield.BitField
|
||||||
|
if err := s.store.Get(s.store.Context(), s.State.AllocatedSectors, &allocatedSectors); err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return allocatedSectors.IsSet(uint64(num))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) LoadDeadline(idx uint64) (Deadline, error) {
|
||||||
|
dls, err := s.State.LoadDeadlines(s.store)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
dl, err := dls.LoadDeadline(s.store, idx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &deadline0{*dl, s.store}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) ForEachDeadline(cb func(uint64, Deadline) error) error {
|
||||||
|
dls, err := s.State.LoadDeadlines(s.store)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return dls.ForEach(s.store, func(i uint64, dl *miner0.Deadline) error {
|
||||||
|
return cb(i, &deadline0{*dl, s.store})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) NumDeadlines() (uint64, error) {
|
||||||
|
return miner0.WPoStPeriodDeadlines, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) DeadlinesChanged(other State) (bool, error) {
|
||||||
|
other0, ok := other.(*state0)
|
||||||
|
if !ok {
|
||||||
|
// treat an upgrade as a change, always
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.State.Deadlines.Equals(other0.Deadlines), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) Info() (MinerInfo, error) {
|
||||||
|
info, err := s.State.GetInfo(s.store)
|
||||||
|
if err != nil {
|
||||||
|
return MinerInfo{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var pid *peer.ID
|
||||||
|
if peerID, err := peer.IDFromBytes(info.PeerId); err == nil {
|
||||||
|
pid = &peerID
|
||||||
|
}
|
||||||
|
|
||||||
|
mi := MinerInfo{
|
||||||
|
Owner: info.Owner,
|
||||||
|
Worker: info.Worker,
|
||||||
|
ControlAddresses: info.ControlAddresses,
|
||||||
|
|
||||||
|
NewWorker: address.Undef,
|
||||||
|
WorkerChangeEpoch: -1,
|
||||||
|
|
||||||
|
PeerId: pid,
|
||||||
|
Multiaddrs: info.Multiaddrs,
|
||||||
|
SealProofType: info.SealProofType,
|
||||||
|
SectorSize: info.SectorSize,
|
||||||
|
WindowPoStPartitionSectors: info.WindowPoStPartitionSectors,
|
||||||
|
}
|
||||||
|
|
||||||
|
if info.PendingWorkerKey != nil {
|
||||||
|
mi.NewWorker = info.PendingWorkerKey.NewWorker
|
||||||
|
mi.WorkerChangeEpoch = info.PendingWorkerKey.EffectiveAt
|
||||||
|
}
|
||||||
|
|
||||||
|
return mi, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) DeadlineInfo(epoch abi.ChainEpoch) (*dline.Info, error) {
|
||||||
|
return s.State.DeadlineInfo(epoch), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) sectors() (adt.Array, error) {
|
||||||
|
return adt0.AsArray(s.store, s.Sectors)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) decodeSectorOnChainInfo(val *cbg.Deferred) (SectorOnChainInfo, error) {
|
||||||
|
var si miner0.SectorOnChainInfo
|
||||||
|
err := si.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
||||||
|
if err != nil {
|
||||||
|
return SectorOnChainInfo{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return fromV0SectorOnChainInfo(si), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) precommits() (adt.Map, error) {
|
||||||
|
return adt0.AsMap(s.store, s.PreCommittedSectors)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) {
|
||||||
|
var sp miner0.SectorPreCommitOnChainInfo
|
||||||
|
err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
||||||
|
if err != nil {
|
||||||
|
return SectorPreCommitOnChainInfo{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return fromV0SectorPreCommitOnChainInfo(sp), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *deadline0) LoadPartition(idx uint64) (Partition, error) {
|
||||||
|
p, err := d.Deadline.LoadPartition(d.store, idx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &partition0{*p, d.store}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *deadline0) ForEachPartition(cb func(uint64, Partition) error) error {
|
||||||
|
ps, err := d.Deadline.PartitionsArray(d.store)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
var part miner0.Partition
|
||||||
|
return ps.ForEach(&part, func(i int64) error {
|
||||||
|
return cb(uint64(i), &partition0{part, d.store})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *deadline0) PartitionsChanged(other Deadline) (bool, error) {
|
||||||
|
other0, ok := other.(*deadline0)
|
||||||
|
if !ok {
|
||||||
|
// treat an upgrade as a change, always
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return d.Deadline.Partitions.Equals(other0.Deadline.Partitions), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *deadline0) PostSubmissions() (bitfield.BitField, error) {
|
||||||
|
return d.Deadline.PostSubmissions, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *partition0) AllSectors() (bitfield.BitField, error) {
|
||||||
|
return p.Partition.Sectors, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *partition0) FaultySectors() (bitfield.BitField, error) {
|
||||||
|
return p.Partition.Faults, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *partition0) RecoveringSectors() (bitfield.BitField, error) {
|
||||||
|
return p.Partition.Recoveries, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func fromV0SectorOnChainInfo(v0 miner0.SectorOnChainInfo) SectorOnChainInfo {
|
||||||
|
return (SectorOnChainInfo)(v0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func fromV0SectorPreCommitOnChainInfo(v0 miner0.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo {
|
||||||
|
return (SectorPreCommitOnChainInfo)(v0)
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package multisig
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
"github.com/filecoin-project/go-state-types/cbor"
|
||||||
|
|
||||||
|
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
|
msig0 "github.com/filecoin-project/specs-actors/actors/builtin/multisig"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||||
|
switch act.Code {
|
||||||
|
case builtin0.MultisigActorCodeID:
|
||||||
|
out := state0{store: store}
|
||||||
|
err := store.Get(store.Context(), act.Head, &out)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &out, nil
|
||||||
|
}
|
||||||
|
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||||
|
}
|
||||||
|
|
||||||
|
type State interface {
|
||||||
|
cbor.Marshaler
|
||||||
|
|
||||||
|
LockedBalance(epoch abi.ChainEpoch) (abi.TokenAmount, error)
|
||||||
|
StartEpoch() (abi.ChainEpoch, error)
|
||||||
|
UnlockDuration() (abi.ChainEpoch, error)
|
||||||
|
InitialBalance() (abi.TokenAmount, error)
|
||||||
|
Threshold() (uint64, error)
|
||||||
|
Signers() ([]address.Address, error)
|
||||||
|
|
||||||
|
ForEachPendingTxn(func(id int64, txn Transaction) error) error
|
||||||
|
}
|
||||||
|
|
||||||
|
type Transaction = msig0.Transaction
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package multisig
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/binary"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
|
msig0 "github.com/filecoin-project/specs-actors/actors/builtin/multisig"
|
||||||
|
adt0 "github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ State = (*state0)(nil)
|
||||||
|
|
||||||
|
type state0 struct {
|
||||||
|
msig0.State
|
||||||
|
store adt.Store
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) LockedBalance(currEpoch abi.ChainEpoch) (abi.TokenAmount, error) {
|
||||||
|
return s.State.AmountLocked(currEpoch - s.State.StartEpoch), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) StartEpoch() (abi.ChainEpoch, error) {
|
||||||
|
return s.State.StartEpoch, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) UnlockDuration() (abi.ChainEpoch, error) {
|
||||||
|
return s.State.UnlockDuration, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) InitialBalance() (abi.TokenAmount, error) {
|
||||||
|
return s.State.InitialBalance, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) Threshold() (uint64, error) {
|
||||||
|
return s.State.NumApprovalsThreshold, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) Signers() ([]address.Address, error) {
|
||||||
|
return s.State.Signers, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) ForEachPendingTxn(cb func(id int64, txn Transaction) error) error {
|
||||||
|
arr, err := adt0.AsMap(s.store, s.State.PendingTxns)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
var out msig0.Transaction
|
||||||
|
return arr.ForEach(&out, func(key string) error {
|
||||||
|
txid, n := binary.Varint([]byte(key))
|
||||||
|
if n <= 0 {
|
||||||
|
return xerrors.Errorf("invalid pending transaction key: %v", key)
|
||||||
|
}
|
||||||
|
return cb(txid, (Transaction)(out))
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
package mock
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
"github.com/filecoin-project/go-state-types/big"
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/builtin/paych"
|
||||||
|
)
|
||||||
|
|
||||||
|
type mockState struct {
|
||||||
|
from address.Address
|
||||||
|
to address.Address
|
||||||
|
settlingAt abi.ChainEpoch
|
||||||
|
toSend abi.TokenAmount
|
||||||
|
lanes map[uint64]paych.LaneState
|
||||||
|
}
|
||||||
|
|
||||||
|
type mockLaneState struct {
|
||||||
|
redeemed big.Int
|
||||||
|
nonce uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewMockPayChState constructs a state for a payment channel with the set fixed values
|
||||||
|
// that satisfies the paych.State interface.
|
||||||
|
func NewMockPayChState(from address.Address,
|
||||||
|
to address.Address,
|
||||||
|
settlingAt abi.ChainEpoch,
|
||||||
|
toSend abi.TokenAmount,
|
||||||
|
lanes map[uint64]paych.LaneState,
|
||||||
|
) paych.State {
|
||||||
|
return &mockState{from, to, settlingAt, toSend, lanes}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewMockLaneState constructs a state for a payment channel lane with the set fixed values
|
||||||
|
// that satisfies the paych.LaneState interface. Useful for populating lanes when
|
||||||
|
// calling NewMockPayChState
|
||||||
|
func NewMockLaneState(redeemed big.Int, nonce uint64) paych.LaneState {
|
||||||
|
return &mockLaneState{redeemed, nonce}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ms *mockState) MarshalCBOR(io.Writer) error {
|
||||||
|
panic("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Channel owner, who has funded the actor
|
||||||
|
func (ms *mockState) From() (address.Address, error) {
|
||||||
|
return ms.from, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recipient of payouts from channel
|
||||||
|
func (ms *mockState) To() (address.Address, error) {
|
||||||
|
return ms.to, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Height at which the channel can be `Collected`
|
||||||
|
func (ms *mockState) SettlingAt() (abi.ChainEpoch, error) {
|
||||||
|
return ms.settlingAt, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Amount successfully redeemed through the payment channel, paid out on `Collect()`
|
||||||
|
func (ms *mockState) ToSend() (abi.TokenAmount, error) {
|
||||||
|
return ms.toSend, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get total number of lanes
|
||||||
|
func (ms *mockState) LaneCount() (uint64, error) {
|
||||||
|
return uint64(len(ms.lanes)), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Iterate lane states
|
||||||
|
func (ms *mockState) ForEachLaneState(cb func(idx uint64, dl paych.LaneState) error) error {
|
||||||
|
var lastErr error
|
||||||
|
for lane, state := range ms.lanes {
|
||||||
|
if err := cb(lane, state); err != nil {
|
||||||
|
lastErr = err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lastErr
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mls *mockLaneState) Redeemed() (big.Int, error) {
|
||||||
|
return mls.redeemed, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mls *mockLaneState) Nonce() (uint64, error) {
|
||||||
|
return mls.nonce, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package paych
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
big "github.com/filecoin-project/go-state-types/big"
|
||||||
|
"github.com/filecoin-project/go-state-types/cbor"
|
||||||
|
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
|
paych0 "github.com/filecoin-project/specs-actors/actors/builtin/paych"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Load returns an abstract copy of payment channel state, irregardless of actor version
|
||||||
|
func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||||
|
switch act.Code {
|
||||||
|
case builtin0.PaymentChannelActorCodeID:
|
||||||
|
out := state0{store: store}
|
||||||
|
err := store.Get(store.Context(), act.Head, &out)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &out, nil
|
||||||
|
}
|
||||||
|
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||||
|
}
|
||||||
|
|
||||||
|
// State is an abstract version of payment channel state that works across
|
||||||
|
// versions
|
||||||
|
type State interface {
|
||||||
|
cbor.Marshaler
|
||||||
|
// Channel owner, who has funded the actor
|
||||||
|
From() (address.Address, error)
|
||||||
|
// Recipient of payouts from channel
|
||||||
|
To() (address.Address, error)
|
||||||
|
|
||||||
|
// Height at which the channel can be `Collected`
|
||||||
|
SettlingAt() (abi.ChainEpoch, error)
|
||||||
|
|
||||||
|
// Amount successfully redeemed through the payment channel, paid out on `Collect()`
|
||||||
|
ToSend() (abi.TokenAmount, error)
|
||||||
|
|
||||||
|
// Get total number of lanes
|
||||||
|
LaneCount() (uint64, error)
|
||||||
|
|
||||||
|
// Iterate lane states
|
||||||
|
ForEachLaneState(cb func(idx uint64, dl LaneState) error) error
|
||||||
|
}
|
||||||
|
|
||||||
|
// LaneState is an abstract copy of the state of a single lane
|
||||||
|
type LaneState interface {
|
||||||
|
Redeemed() (big.Int, error)
|
||||||
|
Nonce() (uint64, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type SignedVoucher = paych0.SignedVoucher
|
||||||
|
type ModVerifyParams = paych0.ModVerifyParams
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
package paych
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
big "github.com/filecoin-project/go-state-types/big"
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/builtin/paych"
|
||||||
|
adt0 "github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ State = (*state0)(nil)
|
||||||
|
|
||||||
|
type state0 struct {
|
||||||
|
paych.State
|
||||||
|
store adt.Store
|
||||||
|
lsAmt *adt0.Array
|
||||||
|
}
|
||||||
|
|
||||||
|
// Channel owner, who has funded the actor
|
||||||
|
func (s *state0) From() (address.Address, error) {
|
||||||
|
return s.State.From, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recipient of payouts from channel
|
||||||
|
func (s *state0) To() (address.Address, error) {
|
||||||
|
return s.State.To, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Height at which the channel can be `Collected`
|
||||||
|
func (s *state0) SettlingAt() (abi.ChainEpoch, error) {
|
||||||
|
return s.State.SettlingAt, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Amount successfully redeemed through the payment channel, paid out on `Collect()`
|
||||||
|
func (s *state0) ToSend() (abi.TokenAmount, error) {
|
||||||
|
return s.State.ToSend, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) getOrLoadLsAmt() (*adt0.Array, error) {
|
||||||
|
if s.lsAmt != nil {
|
||||||
|
return s.lsAmt, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the lane state from the chain
|
||||||
|
lsamt, err := adt0.AsArray(s.store, s.State.LaneStates)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
s.lsAmt = lsamt
|
||||||
|
return lsamt, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get total number of lanes
|
||||||
|
func (s *state0) LaneCount() (uint64, error) {
|
||||||
|
lsamt, err := s.getOrLoadLsAmt()
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return lsamt.Length(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Iterate lane states
|
||||||
|
func (s *state0) ForEachLaneState(cb func(idx uint64, dl LaneState) error) error {
|
||||||
|
// Get the lane state from the chain
|
||||||
|
lsamt, err := s.getOrLoadLsAmt()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Note: we use a map instead of an array to store laneStates because the
|
||||||
|
// client sets the lane ID (the index) and potentially they could use a
|
||||||
|
// very large index.
|
||||||
|
var ls paych.LaneState
|
||||||
|
return lsamt.ForEach(&ls, func(i int64) error {
|
||||||
|
return cb(uint64(i), &laneState0{ls})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
type laneState0 struct {
|
||||||
|
paych.LaneState
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ls *laneState0) Redeemed() (big.Int, error) {
|
||||||
|
return ls.LaneState.Redeemed, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ls *laneState0) Nonce() (uint64, error) {
|
||||||
|
return ls.LaneState.Nonce, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package power
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/filecoin-project/go-address"
|
||||||
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
"github.com/filecoin-project/go-state-types/cbor"
|
||||||
|
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||||
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Address = builtin0.StoragePowerActorAddr
|
||||||
|
|
||||||
|
func Load(store adt.Store, act *types.Actor) (st State, err error) {
|
||||||
|
switch act.Code {
|
||||||
|
case builtin0.StoragePowerActorCodeID:
|
||||||
|
out := state0{store: store}
|
||||||
|
err := store.Get(store.Context(), act.Head, &out)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &out, nil
|
||||||
|
}
|
||||||
|
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||||
|
}
|
||||||
|
|
||||||
|
type State interface {
|
||||||
|
cbor.Marshaler
|
||||||
|
|
||||||
|
TotalLocked() (abi.TokenAmount, error)
|
||||||
|
TotalPower() (Claim, error)
|
||||||
|
TotalCommitted() (Claim, error)
|
||||||
|
TotalPowerSmoothed() (builtin.FilterEstimate, error)
|
||||||
|
|
||||||
|
// MinerCounts returns the number of miners. Participating is the number
|
||||||
|
// with power above the minimum miner threshold.
|
||||||
|
MinerCounts() (participating, total uint64, err error)
|
||||||
|
MinerPower(address.Address) (Claim, bool, error)
|
||||||
|
MinerNominalPowerMeetsConsensusMinimum(address.Address) (bool, error)
|
||||||
|
ListAllMiners() ([]address.Address, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type Claim struct {
|
||||||
|
// Sum of raw byte power for a miner's sectors.
|
||||||
|
RawBytePower abi.StoragePower
|
||||||
|
|
||||||
|
// Sum of quality adjusted power for a miner's sectors.
|
||||||
|
QualityAdjPower abi.StoragePower
|
||||||
|
}
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
package power
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||||
|
power0 "github.com/filecoin-project/specs-actors/actors/builtin/power"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ State = (*state0)(nil)
|
||||||
|
|
||||||
|
type state0 struct {
|
||||||
|
power0.State
|
||||||
|
store adt.Store
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) TotalLocked() (abi.TokenAmount, error) {
|
||||||
|
return s.TotalPledgeCollateral, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) TotalPower() (Claim, error) {
|
||||||
|
return Claim{
|
||||||
|
RawBytePower: s.TotalRawBytePower,
|
||||||
|
QualityAdjPower: s.TotalQualityAdjPower,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Committed power to the network. Includes miners below the minimum threshold.
|
||||||
|
func (s *state0) TotalCommitted() (Claim, error) {
|
||||||
|
return Claim{
|
||||||
|
RawBytePower: s.TotalBytesCommitted,
|
||||||
|
QualityAdjPower: s.TotalQABytesCommitted,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) MinerPower(addr address.Address) (Claim, bool, error) {
|
||||||
|
claims, err := adt.AsMap(s.store, s.Claims)
|
||||||
|
if err != nil {
|
||||||
|
return Claim{}, false, err
|
||||||
|
}
|
||||||
|
var claim power0.Claim
|
||||||
|
ok, err := claims.Get(abi.AddrKey(addr), &claim)
|
||||||
|
if err != nil {
|
||||||
|
return Claim{}, false, err
|
||||||
|
}
|
||||||
|
return Claim{
|
||||||
|
RawBytePower: claim.RawBytePower,
|
||||||
|
QualityAdjPower: claim.QualityAdjPower,
|
||||||
|
}, ok, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) MinerNominalPowerMeetsConsensusMinimum(a address.Address) (bool, error) {
|
||||||
|
return s.State.MinerNominalPowerMeetsConsensusMinimum(s.store, a)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) TotalPowerSmoothed() (builtin.FilterEstimate, error) {
|
||||||
|
return builtin.FromV0FilterEstimate(*s.State.ThisEpochQAPowerSmoothed), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) MinerCounts() (uint64, uint64, error) {
|
||||||
|
return uint64(s.State.MinerAboveMinPowerCount), uint64(s.State.MinerCount), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) ListAllMiners() ([]address.Address, error) {
|
||||||
|
claims, err := adt.AsMap(s.store, s.Claims)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var miners []address.Address
|
||||||
|
err = claims.ForEach(nil, func(k string) error {
|
||||||
|
a, err := address.NewFromBytes([]byte(k))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
miners = append(miners, a)
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return miners, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package reward
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
reward0 "github.com/filecoin-project/specs-actors/actors/builtin/reward"
|
||||||
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-state-types/cbor"
|
||||||
|
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||||
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Address = builtin0.RewardActorAddr
|
||||||
|
|
||||||
|
func Load(store adt.Store, act *types.Actor) (st State, err error) {
|
||||||
|
switch act.Code {
|
||||||
|
case builtin0.RewardActorCodeID:
|
||||||
|
out := state0{store: store}
|
||||||
|
err := store.Get(store.Context(), act.Head, &out)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &out, nil
|
||||||
|
}
|
||||||
|
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||||
|
}
|
||||||
|
|
||||||
|
type State interface {
|
||||||
|
cbor.Marshaler
|
||||||
|
|
||||||
|
ThisEpochBaselinePower() (abi.StoragePower, error)
|
||||||
|
ThisEpochReward() (abi.StoragePower, error)
|
||||||
|
ThisEpochRewardSmoothed() (builtin.FilterEstimate, error)
|
||||||
|
|
||||||
|
EffectiveBaselinePower() (abi.StoragePower, error)
|
||||||
|
EffectiveNetworkTime() (abi.ChainEpoch, error)
|
||||||
|
|
||||||
|
TotalStoragePowerReward() (abi.TokenAmount, error)
|
||||||
|
|
||||||
|
CumsumBaseline() (abi.StoragePower, error)
|
||||||
|
CumsumRealized() (abi.StoragePower, error)
|
||||||
|
|
||||||
|
InitialPledgeForPower(abi.StoragePower, abi.TokenAmount, *builtin.FilterEstimate, abi.TokenAmount) (abi.TokenAmount, error)
|
||||||
|
PreCommitDepositForPower(builtin.FilterEstimate, abi.StoragePower) (abi.TokenAmount, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type AwardBlockRewardParams = reward0.AwardBlockRewardParams
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
package reward
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||||
|
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/builtin/reward"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/util/smoothing"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ State = (*state0)(nil)
|
||||||
|
|
||||||
|
type state0 struct {
|
||||||
|
reward.State
|
||||||
|
store adt.Store
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) ThisEpochReward() (abi.StoragePower, error) {
|
||||||
|
return s.State.ThisEpochReward, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) ThisEpochRewardSmoothed() (builtin.FilterEstimate, error) {
|
||||||
|
return builtin.FromV0FilterEstimate(*s.State.ThisEpochRewardSmoothed), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) ThisEpochBaselinePower() (abi.StoragePower, error) {
|
||||||
|
return s.State.ThisEpochBaselinePower, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) TotalStoragePowerReward() (abi.TokenAmount, error) {
|
||||||
|
return s.State.TotalMined, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) EffectiveBaselinePower() (abi.StoragePower, error) {
|
||||||
|
return s.State.EffectiveBaselinePower, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) EffectiveNetworkTime() (abi.ChainEpoch, error) {
|
||||||
|
return s.State.EffectiveNetworkTime, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) CumsumBaseline() (abi.StoragePower, error) {
|
||||||
|
return s.State.CumsumBaseline, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) CumsumRealized() (abi.StoragePower, error) {
|
||||||
|
return s.State.CumsumBaseline, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) InitialPledgeForPower(sectorWeight abi.StoragePower, networkTotalPledge abi.TokenAmount, networkQAPower *builtin.FilterEstimate, circSupply abi.TokenAmount) (abi.TokenAmount, error) {
|
||||||
|
return miner0.InitialPledgeForPower(
|
||||||
|
sectorWeight,
|
||||||
|
s.State.ThisEpochBaselinePower,
|
||||||
|
networkTotalPledge,
|
||||||
|
s.State.ThisEpochRewardSmoothed,
|
||||||
|
&smoothing.FilterEstimate{
|
||||||
|
PositionEstimate: networkQAPower.PositionEstimate,
|
||||||
|
VelocityEstimate: networkQAPower.VelocityEstimate,
|
||||||
|
},
|
||||||
|
circSupply), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate, sectorWeight abi.StoragePower) (abi.TokenAmount, error) {
|
||||||
|
return miner0.PreCommitDepositForPower(s.State.ThisEpochRewardSmoothed,
|
||||||
|
&smoothing.FilterEstimate{
|
||||||
|
PositionEstimate: networkQAPower.PositionEstimate,
|
||||||
|
VelocityEstimate: networkQAPower.VelocityEstimate,
|
||||||
|
},
|
||||||
|
sectorWeight), nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
package verifreg
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
"github.com/filecoin-project/go-state-types/big"
|
||||||
|
verifreg0 "github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
|
||||||
|
adt0 "github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||||
|
"github.com/ipfs/go-cid"
|
||||||
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ State = (*state0)(nil)
|
||||||
|
|
||||||
|
type state0 struct {
|
||||||
|
verifreg0.State
|
||||||
|
store adt.Store
|
||||||
|
}
|
||||||
|
|
||||||
|
func getDataCap(store adt.Store, root cid.Cid, addr address.Address) (bool, abi.StoragePower, error) {
|
||||||
|
if addr.Protocol() != address.ID {
|
||||||
|
return false, big.Zero(), xerrors.Errorf("can only look up ID addresses")
|
||||||
|
}
|
||||||
|
|
||||||
|
vh, err := adt0.AsMap(store, root)
|
||||||
|
if err != nil {
|
||||||
|
return false, big.Zero(), xerrors.Errorf("loading verifreg: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var dcap abi.StoragePower
|
||||||
|
if found, err := vh.Get(abi.AddrKey(addr), &dcap); err != nil {
|
||||||
|
return false, big.Zero(), xerrors.Errorf("looking up addr: %w", err)
|
||||||
|
} else if !found {
|
||||||
|
return false, big.Zero(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return true, dcap, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) VerifiedClientDataCap(addr address.Address) (bool, abi.StoragePower, error) {
|
||||||
|
return getDataCap(s.store, s.State.VerifiedClients, addr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) VerifierDataCap(addr address.Address) (bool, abi.StoragePower, error) {
|
||||||
|
return getDataCap(s.store, s.State.Verifiers, addr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func forEachCap(store adt.Store, root cid.Cid, cb func(addr address.Address, dcap abi.StoragePower) error) error {
|
||||||
|
vh, err := adt0.AsMap(store, root)
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("loading verified clients: %w", err)
|
||||||
|
}
|
||||||
|
var dcap abi.StoragePower
|
||||||
|
return vh.ForEach(&dcap, func(key string) error {
|
||||||
|
a, err := address.NewFromBytes([]byte(key))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cb(a, dcap)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) ForEachVerifier(cb func(addr address.Address, dcap abi.StoragePower) error) error {
|
||||||
|
return forEachCap(s.store, s.State.Verifiers, cb)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state0) ForEachClient(cb func(addr address.Address, dcap abi.StoragePower) error) error {
|
||||||
|
return forEachCap(s.store, s.State.VerifiedClients, cb)
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package verifreg
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-state-types/cbor"
|
||||||
|
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Address = builtin0.VerifiedRegistryActorAddr
|
||||||
|
|
||||||
|
func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||||
|
switch act.Code {
|
||||||
|
case builtin0.VerifiedRegistryActorCodeID:
|
||||||
|
out := state0{store: store}
|
||||||
|
err := store.Get(store.Context(), act.Head, &out)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &out, nil
|
||||||
|
}
|
||||||
|
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||||
|
}
|
||||||
|
|
||||||
|
type State interface {
|
||||||
|
cbor.Marshaler
|
||||||
|
|
||||||
|
VerifiedClientDataCap(address.Address) (bool, abi.StoragePower, error)
|
||||||
|
VerifierDataCap(address.Address) (bool, abi.StoragePower, error)
|
||||||
|
ForEachVerifier(func(addr address.Address, dcap abi.StoragePower) error) error
|
||||||
|
ForEachClient(func(addr address.Address, dcap abi.StoragePower) error) error
|
||||||
|
}
|
||||||
@@ -56,6 +56,10 @@ func (bts *BadBlockCache) Add(c cid.Cid, bbr BadBlockReason) {
|
|||||||
bts.badBlocks.Add(c, bbr)
|
bts.badBlocks.Add(c, bbr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (bts *BadBlockCache) Remove(c cid.Cid) {
|
||||||
|
bts.badBlocks.Remove(c)
|
||||||
|
}
|
||||||
|
|
||||||
func (bts *BadBlockCache) Has(c cid.Cid) (BadBlockReason, bool) {
|
func (bts *BadBlockCache) Has(c cid.Cid) (BadBlockReason, bool) {
|
||||||
rval, ok := bts.badBlocks.Get(c)
|
rval, ok := bts.badBlocks.Get(c)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|||||||
+72
-7
@@ -3,7 +3,7 @@ package beacon
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
logging "github.com/ipfs/go-log"
|
logging "github.com/ipfs/go-log"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
@@ -18,6 +18,23 @@ type Response struct {
|
|||||||
Err error
|
Err error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Schedule []BeaconPoint
|
||||||
|
|
||||||
|
func (bs Schedule) BeaconForEpoch(e abi.ChainEpoch) RandomBeacon {
|
||||||
|
for i := len(bs) - 1; i >= 0; i-- {
|
||||||
|
bp := bs[i]
|
||||||
|
if e >= bp.Start {
|
||||||
|
return bp.Beacon
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return bs[0].Beacon
|
||||||
|
}
|
||||||
|
|
||||||
|
type BeaconPoint struct {
|
||||||
|
Start abi.ChainEpoch
|
||||||
|
Beacon RandomBeacon
|
||||||
|
}
|
||||||
|
|
||||||
// RandomBeacon represents a system that provides randomness to Lotus.
|
// RandomBeacon represents a system that provides randomness to Lotus.
|
||||||
// Other components interrogate the RandomBeacon to acquire randomness that's
|
// Other components interrogate the RandomBeacon to acquire randomness that's
|
||||||
// valid for a specific chain epoch. Also to verify beacon entries that have
|
// valid for a specific chain epoch. Also to verify beacon entries that have
|
||||||
@@ -25,11 +42,30 @@ type Response struct {
|
|||||||
type RandomBeacon interface {
|
type RandomBeacon interface {
|
||||||
Entry(context.Context, uint64) <-chan Response
|
Entry(context.Context, uint64) <-chan Response
|
||||||
VerifyEntry(types.BeaconEntry, types.BeaconEntry) error
|
VerifyEntry(types.BeaconEntry, types.BeaconEntry) error
|
||||||
MaxBeaconRoundForEpoch(abi.ChainEpoch, types.BeaconEntry) uint64
|
MaxBeaconRoundForEpoch(abi.ChainEpoch) uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
func ValidateBlockValues(b RandomBeacon, h *types.BlockHeader, prevEntry types.BeaconEntry) error {
|
func ValidateBlockValues(bSchedule Schedule, h *types.BlockHeader, parentEpoch abi.ChainEpoch,
|
||||||
maxRound := b.MaxBeaconRoundForEpoch(h.Height, prevEntry)
|
prevEntry types.BeaconEntry) error {
|
||||||
|
{
|
||||||
|
parentBeacon := bSchedule.BeaconForEpoch(parentEpoch)
|
||||||
|
currBeacon := bSchedule.BeaconForEpoch(h.Height)
|
||||||
|
if parentBeacon != currBeacon {
|
||||||
|
if len(h.BeaconEntries) != 2 {
|
||||||
|
return xerrors.Errorf("expected two beacon entries at beacon fork, got %d", len(h.BeaconEntries))
|
||||||
|
}
|
||||||
|
err := currBeacon.VerifyEntry(h.BeaconEntries[1], h.BeaconEntries[0])
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("beacon at fork point invalid: (%v, %v): %w",
|
||||||
|
h.BeaconEntries[1], h.BeaconEntries[0], err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: fork logic
|
||||||
|
b := bSchedule.BeaconForEpoch(h.Height)
|
||||||
|
maxRound := b.MaxBeaconRoundForEpoch(h.Height)
|
||||||
if maxRound == prevEntry.Round {
|
if maxRound == prevEntry.Round {
|
||||||
if len(h.BeaconEntries) != 0 {
|
if len(h.BeaconEntries) != 0 {
|
||||||
return xerrors.Errorf("expected not to have any beacon entries in this block, got %d", len(h.BeaconEntries))
|
return xerrors.Errorf("expected not to have any beacon entries in this block, got %d", len(h.BeaconEntries))
|
||||||
@@ -37,6 +73,10 @@ func ValidateBlockValues(b RandomBeacon, h *types.BlockHeader, prevEntry types.B
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(h.BeaconEntries) == 0 {
|
||||||
|
return xerrors.Errorf("expected to have beacon entries in this block, but didn't find any")
|
||||||
|
}
|
||||||
|
|
||||||
last := h.BeaconEntries[len(h.BeaconEntries)-1]
|
last := h.BeaconEntries[len(h.BeaconEntries)-1]
|
||||||
if last.Round != maxRound {
|
if last.Round != maxRound {
|
||||||
return xerrors.Errorf("expected final beacon entry in block to be at round %d, got %d", maxRound, last.Round)
|
return xerrors.Errorf("expected final beacon entry in block to be at round %d, got %d", maxRound, last.Round)
|
||||||
@@ -52,10 +92,35 @@ func ValidateBlockValues(b RandomBeacon, h *types.BlockHeader, prevEntry types.B
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func BeaconEntriesForBlock(ctx context.Context, beacon RandomBeacon, round abi.ChainEpoch, prev types.BeaconEntry) ([]types.BeaconEntry, error) {
|
func BeaconEntriesForBlock(ctx context.Context, bSchedule Schedule, epoch abi.ChainEpoch, parentEpoch abi.ChainEpoch, prev types.BeaconEntry) ([]types.BeaconEntry, error) {
|
||||||
|
{
|
||||||
|
parentBeacon := bSchedule.BeaconForEpoch(parentEpoch)
|
||||||
|
currBeacon := bSchedule.BeaconForEpoch(epoch)
|
||||||
|
if parentBeacon != currBeacon {
|
||||||
|
// Fork logic
|
||||||
|
round := currBeacon.MaxBeaconRoundForEpoch(epoch)
|
||||||
|
out := make([]types.BeaconEntry, 2)
|
||||||
|
rch := currBeacon.Entry(ctx, round-1)
|
||||||
|
res := <-rch
|
||||||
|
if res.Err != nil {
|
||||||
|
return nil, xerrors.Errorf("getting entry %d returned error: %w", round-1, res.Err)
|
||||||
|
}
|
||||||
|
out[0] = res.Entry
|
||||||
|
rch = currBeacon.Entry(ctx, round)
|
||||||
|
res = <-rch
|
||||||
|
if res.Err != nil {
|
||||||
|
return nil, xerrors.Errorf("getting entry %d returned error: %w", round, res.Err)
|
||||||
|
}
|
||||||
|
out[1] = res.Entry
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
beacon := bSchedule.BeaconForEpoch(epoch)
|
||||||
|
|
||||||
start := build.Clock.Now()
|
start := build.Clock.Now()
|
||||||
|
|
||||||
maxRound := beacon.MaxBeaconRoundForEpoch(round, prev)
|
maxRound := beacon.MaxBeaconRoundForEpoch(epoch)
|
||||||
if maxRound == prev.Round {
|
if maxRound == prev.Round {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
@@ -78,7 +143,7 @@ func BeaconEntriesForBlock(ctx context.Context, beacon RandomBeacon, round abi.C
|
|||||||
out = append(out, resp.Entry)
|
out = append(out, resp.Entry)
|
||||||
cur = resp.Entry.Round - 1
|
cur = resp.Entry.Round - 1
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return nil, xerrors.Errorf("context timed out waiting on beacon entry to come back for round %d: %w", round, ctx.Err())
|
return nil, xerrors.Errorf("context timed out waiting on beacon entry to come back for epoch %d: %w", epoch, ctx.Err())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import (
|
|||||||
logging "github.com/ipfs/go-log"
|
logging "github.com/ipfs/go-log"
|
||||||
pubsub "github.com/libp2p/go-libp2p-pubsub"
|
pubsub "github.com/libp2p/go-libp2p-pubsub"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
"github.com/filecoin-project/lotus/chain/beacon"
|
"github.com/filecoin-project/lotus/chain/beacon"
|
||||||
@@ -187,7 +187,7 @@ func (db *DrandBeacon) VerifyEntry(curr types.BeaconEntry, prev types.BeaconEntr
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *DrandBeacon) MaxBeaconRoundForEpoch(filEpoch abi.ChainEpoch, prevEntry types.BeaconEntry) uint64 {
|
func (db *DrandBeacon) MaxBeaconRoundForEpoch(filEpoch abi.ChainEpoch) uint64 {
|
||||||
// TODO: sometimes the genesis time for filecoin is zero and this goes negative
|
// TODO: sometimes the genesis time for filecoin is zero and this goes negative
|
||||||
latestTs := ((uint64(filEpoch) * db.filRoundTime) + db.filGenTime) - db.filRoundTime
|
latestTs := ((uint64(filEpoch) * db.filRoundTime) + db.filGenTime) - db.filRoundTime
|
||||||
dround := (latestTs - db.drandGenTime) / uint64(db.interval.Seconds())
|
dround := (latestTs - db.drandGenTime) / uint64(db.interval.Seconds())
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestPrintGroupInfo(t *testing.T) {
|
func TestPrintGroupInfo(t *testing.T) {
|
||||||
server := build.DrandConfig().Servers[0]
|
server := build.DrandConfigs[build.DrandIncentinet].Servers[0]
|
||||||
c, err := hclient.New(server, nil, nil)
|
c, err := hclient.New(server, nil, nil)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
cg := c.(interface {
|
cg := c.(interface {
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import (
|
|||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
|
||||||
"github.com/minio/blake2b-simd"
|
"github.com/minio/blake2b-simd"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
)
|
)
|
||||||
@@ -53,11 +53,7 @@ func (mb *mockBeacon) VerifyEntry(from types.BeaconEntry, to types.BeaconEntry)
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mb *mockBeacon) IsEntryForEpoch(e types.BeaconEntry, epoch abi.ChainEpoch, nulls int) (bool, error) {
|
func (mb *mockBeacon) MaxBeaconRoundForEpoch(epoch abi.ChainEpoch) uint64 {
|
||||||
return int64(e.Round) <= int64(epoch) && int64(epoch)-int64(nulls) >= int64(e.Round), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (mb *mockBeacon) MaxBeaconRoundForEpoch(epoch abi.ChainEpoch, prevEntry types.BeaconEntry) uint64 {
|
|
||||||
return uint64(epoch)
|
return uint64(epoch)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
package chain
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||||
|
"github.com/ipfs/go-datastore"
|
||||||
|
"golang.org/x/xerrors"
|
||||||
|
)
|
||||||
|
|
||||||
|
var CheckpointKey = datastore.NewKey("/chain/checks")
|
||||||
|
|
||||||
|
func loadCheckpoint(ds dtypes.MetadataDS) (types.TipSetKey, error) {
|
||||||
|
haveChks, err := ds.Has(CheckpointKey)
|
||||||
|
if err != nil {
|
||||||
|
return types.EmptyTSK, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !haveChks {
|
||||||
|
return types.EmptyTSK, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
tskBytes, err := ds.Get(CheckpointKey)
|
||||||
|
if err != nil {
|
||||||
|
return types.EmptyTSK, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var tsk types.TipSetKey
|
||||||
|
err = json.Unmarshal(tskBytes, &tsk)
|
||||||
|
if err != nil {
|
||||||
|
return types.EmptyTSK, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return tsk, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (syncer *Syncer) SetCheckpoint(tsk types.TipSetKey) error {
|
||||||
|
if tsk == types.EmptyTSK {
|
||||||
|
return xerrors.Errorf("called with empty tsk")
|
||||||
|
}
|
||||||
|
|
||||||
|
syncer.checkptLk.Lock()
|
||||||
|
defer syncer.checkptLk.Unlock()
|
||||||
|
|
||||||
|
ts, err := syncer.ChainStore().LoadTipSet(tsk)
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("cannot find tipset: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
hts := syncer.ChainStore().GetHeaviestTipSet()
|
||||||
|
anc, err := syncer.ChainStore().IsAncestorOf(ts, hts)
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("cannot determine whether checkpoint tipset is in main-chain: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !hts.Equals(ts) && !anc {
|
||||||
|
return xerrors.Errorf("cannot mark tipset as checkpoint, since it isn't in the main-chain: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
tskBytes, err := json.Marshal(tsk)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = syncer.ds.Put(CheckpointKey, tskBytes)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
syncer.checkpt = tsk
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (syncer *Syncer) GetCheckpoint() types.TipSetKey {
|
||||||
|
syncer.checkptLk.Lock()
|
||||||
|
defer syncer.checkptLk.Unlock()
|
||||||
|
return syncer.checkpt
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
logging "github.com/ipfs/go-log/v2"
|
logging "github.com/ipfs/go-log/v2"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
@@ -35,6 +35,7 @@ type eventAPI interface {
|
|||||||
ChainNotify(context.Context) (<-chan []*api.HeadChange, error)
|
ChainNotify(context.Context) (<-chan []*api.HeadChange, error)
|
||||||
ChainGetBlockMessages(context.Context, cid.Cid) (*api.BlockMessages, error)
|
ChainGetBlockMessages(context.Context, cid.Cid) (*api.BlockMessages, error)
|
||||||
ChainGetTipSetByHeight(context.Context, abi.ChainEpoch, types.TipSetKey) (*types.TipSet, error)
|
ChainGetTipSetByHeight(context.Context, abi.ChainEpoch, types.TipSetKey) (*types.TipSet, error)
|
||||||
|
ChainHead(context.Context) (*types.TipSet, error)
|
||||||
StateGetReceipt(context.Context, cid.Cid, types.TipSetKey) (*types.MessageReceipt, error)
|
StateGetReceipt(context.Context, cid.Cid, types.TipSetKey) (*types.MessageReceipt, error)
|
||||||
ChainGetTipSet(context.Context, types.TipSetKey) (*types.TipSet, error)
|
ChainGetTipSet(context.Context, types.TipSetKey) (*types.TipSet, error)
|
||||||
|
|
||||||
@@ -57,7 +58,7 @@ type Events struct {
|
|||||||
func NewEvents(ctx context.Context, api eventAPI) *Events {
|
func NewEvents(ctx context.Context, api eventAPI) *Events {
|
||||||
gcConfidence := 2 * build.ForkLengthThreshold
|
gcConfidence := 2 * build.ForkLengthThreshold
|
||||||
|
|
||||||
tsc := newTSCache(gcConfidence, api.ChainGetTipSetByHeight)
|
tsc := newTSCache(gcConfidence, api)
|
||||||
|
|
||||||
e := &Events{
|
e := &Events{
|
||||||
api: api,
|
api: api,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
@@ -307,7 +307,10 @@ func (e *hcEvents) onHeadChanged(check CheckFunc, hnd EventHandler, rev RevertHa
|
|||||||
defer e.lk.Unlock()
|
defer e.lk.Unlock()
|
||||||
|
|
||||||
// Check if the event has already occurred
|
// Check if the event has already occurred
|
||||||
ts := e.tsc.best()
|
ts, err := e.tsc.best()
|
||||||
|
if err != nil {
|
||||||
|
return 0, xerrors.Errorf("error getting best tipset: %w", err)
|
||||||
|
}
|
||||||
done, more, err := check(ts)
|
done, more, err := check(ts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, xerrors.Errorf("called check error (h: %d): %w", ts.Height(), err)
|
return 0, xerrors.Errorf("called check error (h: %d): %w", ts.Height(), err)
|
||||||
|
|||||||
@@ -4,8 +4,9 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"go.opencensus.io/trace"
|
"go.opencensus.io/trace"
|
||||||
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
)
|
)
|
||||||
@@ -26,7 +27,6 @@ type heightEvents struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *heightEvents) headChangeAt(rev, app []*types.TipSet) error {
|
func (e *heightEvents) headChangeAt(rev, app []*types.TipSet) error {
|
||||||
|
|
||||||
ctx, span := trace.StartSpan(e.ctx, "events.HeightHeadChange")
|
ctx, span := trace.StartSpan(e.ctx, "events.HeightHeadChange")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
span.AddAttributes(trace.Int64Attribute("endHeight", int64(app[0].Height())))
|
span.AddAttributes(trace.Int64Attribute("endHeight", int64(app[0].Height())))
|
||||||
@@ -144,16 +144,19 @@ func (e *heightEvents) headChangeAt(rev, app []*types.TipSet) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ChainAt invokes the specified `HeightHandler` when the chain reaches the
|
// ChainAt invokes the specified `HeightHandler` when the chain reaches the
|
||||||
// specified height+confidence threshold. If the chain is rolled-back under the
|
// specified height+confidence threshold. If the chain is rolled-back under the
|
||||||
// specified height, `RevertHandler` will be called.
|
// specified height, `RevertHandler` will be called.
|
||||||
//
|
//
|
||||||
// ts passed to handlers is the tipset at the specified, or above, if lower tipsets were null
|
// ts passed to handlers is the tipset at the specified, or above, if lower tipsets were null
|
||||||
func (e *heightEvents) ChainAt(hnd HeightHandler, rev RevertHandler, confidence int, h abi.ChainEpoch) error {
|
func (e *heightEvents) ChainAt(hnd HeightHandler, rev RevertHandler, confidence int, h abi.ChainEpoch) error {
|
||||||
|
|
||||||
e.lk.Lock() // Tricky locking, check your locks if you modify this function!
|
e.lk.Lock() // Tricky locking, check your locks if you modify this function!
|
||||||
|
|
||||||
bestH := e.tsc.best().Height()
|
best, err := e.tsc.best()
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("error getting best tipset: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
bestH := best.Height()
|
||||||
if bestH >= h+abi.ChainEpoch(confidence) {
|
if bestH >= h+abi.ChainEpoch(confidence) {
|
||||||
ts, err := e.tsc.getNonNull(h)
|
ts, err := e.tsc.getNonNull(h)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -172,7 +175,11 @@ func (e *heightEvents) ChainAt(hnd HeightHandler, rev RevertHandler, confidence
|
|||||||
}
|
}
|
||||||
|
|
||||||
e.lk.Lock()
|
e.lk.Lock()
|
||||||
bestH = e.tsc.best().Height()
|
best, err = e.tsc.best()
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("error getting best tipset: %w", err)
|
||||||
|
}
|
||||||
|
bestH = best.Height()
|
||||||
}
|
}
|
||||||
|
|
||||||
defer e.lk.Unlock()
|
defer e.lk.Unlock()
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/crypto"
|
"github.com/filecoin-project/go-state-types/crypto"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
@@ -46,6 +46,10 @@ type fakeCS struct {
|
|||||||
sub func(rev, app []*types.TipSet)
|
sub func(rev, app []*types.TipSet)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (fcs *fakeCS) ChainHead(ctx context.Context) (*types.TipSet, error) {
|
||||||
|
panic("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
func (fcs *fakeCS) ChainGetTipSet(ctx context.Context, key types.TipSetKey) (*types.TipSet, error) {
|
func (fcs *fakeCS) ChainGetTipSet(ctx context.Context, key types.TipSetKey) (*types.TipSet, error) {
|
||||||
return fcs.tipsets[key], nil
|
return fcs.tipsets[key], nil
|
||||||
}
|
}
|
||||||
@@ -110,7 +114,11 @@ func (fcs *fakeCS) makeTs(t *testing.T, parents []cid.Cid, h abi.ChainEpoch, msg
|
|||||||
|
|
||||||
func (fcs *fakeCS) ChainNotify(context.Context) (<-chan []*api.HeadChange, error) {
|
func (fcs *fakeCS) ChainNotify(context.Context) (<-chan []*api.HeadChange, error) {
|
||||||
out := make(chan []*api.HeadChange, 1)
|
out := make(chan []*api.HeadChange, 1)
|
||||||
out <- []*api.HeadChange{{Type: store.HCCurrent, Val: fcs.tsc.best()}}
|
best, err := fcs.tsc.best()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
out <- []*api.HeadChange{{Type: store.HCCurrent, Val: best}}
|
||||||
|
|
||||||
fcs.sub = func(rev, app []*types.TipSet) {
|
fcs.sub = func(rev, app []*types.TipSet) {
|
||||||
notif := make([]*api.HeadChange, len(rev)+len(app))
|
notif := make([]*api.HeadChange, len(rev)+len(app))
|
||||||
@@ -174,7 +182,8 @@ func (fcs *fakeCS) advance(rev, app int, msgs map[int]cid.Cid, nulls ...int) { /
|
|||||||
|
|
||||||
var revs []*types.TipSet
|
var revs []*types.TipSet
|
||||||
for i := 0; i < rev; i++ {
|
for i := 0; i < rev; i++ {
|
||||||
ts := fcs.tsc.best()
|
ts, err := fcs.tsc.best()
|
||||||
|
require.NoError(fcs.t, err)
|
||||||
|
|
||||||
if _, ok := nullm[int(ts.Height())]; !ok {
|
if _, ok := nullm[int(ts.Height())]; !ok {
|
||||||
revs = append(revs, ts)
|
revs = append(revs, ts)
|
||||||
@@ -196,7 +205,9 @@ func (fcs *fakeCS) advance(rev, app int, msgs map[int]cid.Cid, nulls ...int) { /
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
ts := fcs.makeTs(fcs.t, fcs.tsc.best().Key().Cids(), fcs.h, mc)
|
best, err := fcs.tsc.best()
|
||||||
|
require.NoError(fcs.t, err)
|
||||||
|
ts := fcs.makeTs(fcs.t, best.Key().Cids(), fcs.h, mc)
|
||||||
require.NoError(fcs.t, fcs.tsc.add(ts))
|
require.NoError(fcs.t, fcs.tsc.add(ts))
|
||||||
|
|
||||||
if hasMsgs {
|
if hasMsgs {
|
||||||
|
|||||||
+172
-362
@@ -4,20 +4,19 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
"github.com/filecoin-project/go-state-types/big"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
|
||||||
init_ "github.com/filecoin-project/specs-actors/actors/builtin/init"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/market"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/paych"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
|
||||||
"github.com/ipfs/go-cid"
|
|
||||||
cbor "github.com/ipfs/go-ipld-cbor"
|
cbor "github.com/ipfs/go-ipld-cbor"
|
||||||
typegen "github.com/whyrusleeping/cbor-gen"
|
typegen "github.com/whyrusleeping/cbor-gen"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api/apibstore"
|
"github.com/filecoin-project/lotus/api/apibstore"
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
|
init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init"
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/builtin/market"
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/builtin/paych"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -49,7 +48,7 @@ func NewStatePredicates(api ChainAPI) *StatePredicates {
|
|||||||
// - err
|
// - err
|
||||||
type DiffTipSetKeyFunc func(ctx context.Context, oldState, newState types.TipSetKey) (changed bool, user UserData, err error)
|
type DiffTipSetKeyFunc func(ctx context.Context, oldState, newState types.TipSetKey) (changed bool, user UserData, err error)
|
||||||
|
|
||||||
type DiffActorStateFunc func(ctx context.Context, oldActorStateHead, newActorStateHead cid.Cid) (changed bool, user UserData, err error)
|
type DiffActorStateFunc func(ctx context.Context, oldActorState *types.Actor, newActorState *types.Actor) (changed bool, user UserData, err error)
|
||||||
|
|
||||||
// OnActorStateChanged calls diffStateFunc when the state changes for the given actor
|
// OnActorStateChanged calls diffStateFunc when the state changes for the given actor
|
||||||
func (sp *StatePredicates) OnActorStateChanged(addr address.Address, diffStateFunc DiffActorStateFunc) DiffTipSetKeyFunc {
|
func (sp *StatePredicates) OnActorStateChanged(addr address.Address, diffStateFunc DiffActorStateFunc) DiffTipSetKeyFunc {
|
||||||
@@ -66,30 +65,30 @@ func (sp *StatePredicates) OnActorStateChanged(addr address.Address, diffStateFu
|
|||||||
if oldActor.Head.Equals(newActor.Head) {
|
if oldActor.Head.Equals(newActor.Head) {
|
||||||
return false, nil, nil
|
return false, nil, nil
|
||||||
}
|
}
|
||||||
return diffStateFunc(ctx, oldActor.Head, newActor.Head)
|
return diffStateFunc(ctx, oldActor, newActor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type DiffStorageMarketStateFunc func(ctx context.Context, oldState *market.State, newState *market.State) (changed bool, user UserData, err error)
|
type DiffStorageMarketStateFunc func(ctx context.Context, oldState market.State, newState market.State) (changed bool, user UserData, err error)
|
||||||
|
|
||||||
// OnStorageMarketActorChanged calls diffStorageMarketState when the state changes for the market actor
|
// OnStorageMarketActorChanged calls diffStorageMarketState when the state changes for the market actor
|
||||||
func (sp *StatePredicates) OnStorageMarketActorChanged(diffStorageMarketState DiffStorageMarketStateFunc) DiffTipSetKeyFunc {
|
func (sp *StatePredicates) OnStorageMarketActorChanged(diffStorageMarketState DiffStorageMarketStateFunc) DiffTipSetKeyFunc {
|
||||||
return sp.OnActorStateChanged(builtin.StorageMarketActorAddr, func(ctx context.Context, oldActorStateHead, newActorStateHead cid.Cid) (changed bool, user UserData, err error) {
|
return sp.OnActorStateChanged(market.Address, func(ctx context.Context, oldActorState, newActorState *types.Actor) (changed bool, user UserData, err error) {
|
||||||
var oldState market.State
|
oldState, err := market.Load(adt.WrapStore(ctx, sp.cst), oldActorState)
|
||||||
if err := sp.cst.Get(ctx, oldActorStateHead, &oldState); err != nil {
|
if err != nil {
|
||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
var newState market.State
|
newState, err := market.Load(adt.WrapStore(ctx, sp.cst), newActorState)
|
||||||
if err := sp.cst.Get(ctx, newActorStateHead, &newState); err != nil {
|
if err != nil {
|
||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
return diffStorageMarketState(ctx, &oldState, &newState)
|
return diffStorageMarketState(ctx, oldState, newState)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
type BalanceTables struct {
|
type BalanceTables struct {
|
||||||
EscrowTable *adt.BalanceTable
|
EscrowTable market.BalanceTable
|
||||||
LockedTable *adt.BalanceTable
|
LockedTable market.BalanceTable
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiffBalanceTablesFunc compares two balance tables
|
// DiffBalanceTablesFunc compares two balance tables
|
||||||
@@ -97,32 +96,32 @@ type DiffBalanceTablesFunc func(ctx context.Context, oldBalanceTable, newBalance
|
|||||||
|
|
||||||
// OnBalanceChanged runs when the escrow table for available balances changes
|
// OnBalanceChanged runs when the escrow table for available balances changes
|
||||||
func (sp *StatePredicates) OnBalanceChanged(diffBalances DiffBalanceTablesFunc) DiffStorageMarketStateFunc {
|
func (sp *StatePredicates) OnBalanceChanged(diffBalances DiffBalanceTablesFunc) DiffStorageMarketStateFunc {
|
||||||
return func(ctx context.Context, oldState *market.State, newState *market.State) (changed bool, user UserData, err error) {
|
return func(ctx context.Context, oldState market.State, newState market.State) (changed bool, user UserData, err error) {
|
||||||
if oldState.EscrowTable.Equals(newState.EscrowTable) && oldState.LockedTable.Equals(newState.LockedTable) {
|
bc, err := oldState.BalancesChanged(newState)
|
||||||
|
if err != nil {
|
||||||
|
return false, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !bc {
|
||||||
return false, nil, nil
|
return false, nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
ctxStore := &contextStore{
|
oldEscrowRoot, err := oldState.EscrowTable()
|
||||||
ctx: ctx,
|
|
||||||
cst: sp.cst,
|
|
||||||
}
|
|
||||||
|
|
||||||
oldEscrowRoot, err := adt.AsBalanceTable(ctxStore, oldState.EscrowTable)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
oldLockedRoot, err := adt.AsBalanceTable(ctxStore, oldState.LockedTable)
|
oldLockedRoot, err := oldState.LockedTable()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
newEscrowRoot, err := adt.AsBalanceTable(ctxStore, newState.EscrowTable)
|
newEscrowRoot, err := newState.EscrowTable()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
newLockedRoot, err := adt.AsBalanceTable(ctxStore, newState.LockedTable)
|
newLockedRoot, err := newState.LockedTable()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
@@ -131,25 +130,27 @@ func (sp *StatePredicates) OnBalanceChanged(diffBalances DiffBalanceTablesFunc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type DiffAdtArraysFunc func(ctx context.Context, oldDealStateRoot, newDealStateRoot *adt.Array) (changed bool, user UserData, err error)
|
type DiffDealStatesFunc func(ctx context.Context, oldDealStateRoot, newDealStateRoot market.DealStates) (changed bool, user UserData, err error)
|
||||||
|
type DiffDealProposalsFunc func(ctx context.Context, oldDealStateRoot, newDealStateRoot market.DealProposals) (changed bool, user UserData, err error)
|
||||||
|
type DiffAdtArraysFunc func(ctx context.Context, oldDealStateRoot, newDealStateRoot adt.Array) (changed bool, user UserData, err error)
|
||||||
|
|
||||||
// OnDealStateChanged calls diffDealStates when the market deal state changes
|
// OnDealStateChanged calls diffDealStates when the market deal state changes
|
||||||
func (sp *StatePredicates) OnDealStateChanged(diffDealStates DiffAdtArraysFunc) DiffStorageMarketStateFunc {
|
func (sp *StatePredicates) OnDealStateChanged(diffDealStates DiffDealStatesFunc) DiffStorageMarketStateFunc {
|
||||||
return func(ctx context.Context, oldState *market.State, newState *market.State) (changed bool, user UserData, err error) {
|
return func(ctx context.Context, oldState market.State, newState market.State) (changed bool, user UserData, err error) {
|
||||||
if oldState.States.Equals(newState.States) {
|
sc, err := oldState.StatesChanged(newState)
|
||||||
return false, nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
ctxStore := &contextStore{
|
|
||||||
ctx: ctx,
|
|
||||||
cst: sp.cst,
|
|
||||||
}
|
|
||||||
|
|
||||||
oldRoot, err := adt.AsArray(ctxStore, oldState.States)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
newRoot, err := adt.AsArray(ctxStore, newState.States)
|
|
||||||
|
if !sc {
|
||||||
|
return false, nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
oldRoot, err := oldState.States()
|
||||||
|
if err != nil {
|
||||||
|
return false, nil, err
|
||||||
|
}
|
||||||
|
newRoot, err := newState.States()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
@@ -159,22 +160,22 @@ func (sp *StatePredicates) OnDealStateChanged(diffDealStates DiffAdtArraysFunc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// OnDealProposalChanged calls diffDealProps when the market proposal state changes
|
// OnDealProposalChanged calls diffDealProps when the market proposal state changes
|
||||||
func (sp *StatePredicates) OnDealProposalChanged(diffDealProps DiffAdtArraysFunc) DiffStorageMarketStateFunc {
|
func (sp *StatePredicates) OnDealProposalChanged(diffDealProps DiffDealProposalsFunc) DiffStorageMarketStateFunc {
|
||||||
return func(ctx context.Context, oldState *market.State, newState *market.State) (changed bool, user UserData, err error) {
|
return func(ctx context.Context, oldState market.State, newState market.State) (changed bool, user UserData, err error) {
|
||||||
if oldState.Proposals.Equals(newState.Proposals) {
|
pc, err := oldState.ProposalsChanged(newState)
|
||||||
return false, nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
ctxStore := &contextStore{
|
|
||||||
ctx: ctx,
|
|
||||||
cst: sp.cst,
|
|
||||||
}
|
|
||||||
|
|
||||||
oldRoot, err := adt.AsArray(ctxStore, oldState.Proposals)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
newRoot, err := adt.AsArray(ctxStore, newState.Proposals)
|
|
||||||
|
if !pc {
|
||||||
|
return false, nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
oldRoot, err := oldState.Proposals()
|
||||||
|
if err != nil {
|
||||||
|
return false, nil, err
|
||||||
|
}
|
||||||
|
newRoot, err := newState.Proposals()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
@@ -183,51 +184,14 @@ func (sp *StatePredicates) OnDealProposalChanged(diffDealProps DiffAdtArraysFunc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ AdtArrayDiff = &MarketDealProposalChanges{}
|
|
||||||
|
|
||||||
type MarketDealProposalChanges struct {
|
|
||||||
Added []ProposalIDState
|
|
||||||
Removed []ProposalIDState
|
|
||||||
}
|
|
||||||
|
|
||||||
type ProposalIDState struct {
|
|
||||||
ID abi.DealID
|
|
||||||
Proposal market.DealProposal
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *MarketDealProposalChanges) Add(key uint64, val *typegen.Deferred) error {
|
|
||||||
dp := new(market.DealProposal)
|
|
||||||
err := dp.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
m.Added = append(m.Added, ProposalIDState{abi.DealID(key), *dp})
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *MarketDealProposalChanges) Modify(key uint64, from, to *typegen.Deferred) error {
|
|
||||||
// short circuit, DealProposals are static
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *MarketDealProposalChanges) Remove(key uint64, val *typegen.Deferred) error {
|
|
||||||
dp := new(market.DealProposal)
|
|
||||||
err := dp.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
m.Removed = append(m.Removed, ProposalIDState{abi.DealID(key), *dp})
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// OnDealProposalAmtChanged detects changes in the deal proposal AMT for all deal proposals and returns a MarketProposalsChanges structure containing:
|
// OnDealProposalAmtChanged detects changes in the deal proposal AMT for all deal proposals and returns a MarketProposalsChanges structure containing:
|
||||||
// - Added Proposals
|
// - Added Proposals
|
||||||
// - Modified Proposals
|
// - Modified Proposals
|
||||||
// - Removed Proposals
|
// - Removed Proposals
|
||||||
func (sp *StatePredicates) OnDealProposalAmtChanged() DiffAdtArraysFunc {
|
func (sp *StatePredicates) OnDealProposalAmtChanged() DiffDealProposalsFunc {
|
||||||
return func(ctx context.Context, oldDealProps, newDealProps *adt.Array) (changed bool, user UserData, err error) {
|
return func(ctx context.Context, oldDealProps, newDealProps market.DealProposals) (changed bool, user UserData, err error) {
|
||||||
proposalChanges := new(MarketDealProposalChanges)
|
proposalChanges, err := market.DiffDealProposals(oldDealProps, newDealProps)
|
||||||
if err := DiffAdtArray(oldDealProps, newDealProps, proposalChanges); err != nil {
|
if err != nil {
|
||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,64 +203,14 @@ func (sp *StatePredicates) OnDealProposalAmtChanged() DiffAdtArraysFunc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ AdtArrayDiff = &MarketDealStateChanges{}
|
|
||||||
|
|
||||||
type MarketDealStateChanges struct {
|
|
||||||
Added []DealIDState
|
|
||||||
Modified []DealStateChange
|
|
||||||
Removed []DealIDState
|
|
||||||
}
|
|
||||||
|
|
||||||
type DealIDState struct {
|
|
||||||
ID abi.DealID
|
|
||||||
Deal market.DealState
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *MarketDealStateChanges) Add(key uint64, val *typegen.Deferred) error {
|
|
||||||
ds := new(market.DealState)
|
|
||||||
err := ds.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
m.Added = append(m.Added, DealIDState{abi.DealID(key), *ds})
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *MarketDealStateChanges) Modify(key uint64, from, to *typegen.Deferred) error {
|
|
||||||
dsFrom := new(market.DealState)
|
|
||||||
if err := dsFrom.UnmarshalCBOR(bytes.NewReader(from.Raw)); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
dsTo := new(market.DealState)
|
|
||||||
if err := dsTo.UnmarshalCBOR(bytes.NewReader(to.Raw)); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if *dsFrom != *dsTo {
|
|
||||||
m.Modified = append(m.Modified, DealStateChange{abi.DealID(key), dsFrom, dsTo})
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *MarketDealStateChanges) Remove(key uint64, val *typegen.Deferred) error {
|
|
||||||
ds := new(market.DealState)
|
|
||||||
err := ds.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
m.Removed = append(m.Removed, DealIDState{abi.DealID(key), *ds})
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// OnDealStateAmtChanged detects changes in the deal state AMT for all deal states and returns a MarketDealStateChanges structure containing:
|
// OnDealStateAmtChanged detects changes in the deal state AMT for all deal states and returns a MarketDealStateChanges structure containing:
|
||||||
// - Added Deals
|
// - Added Deals
|
||||||
// - Modified Deals
|
// - Modified Deals
|
||||||
// - Removed Deals
|
// - Removed Deals
|
||||||
func (sp *StatePredicates) OnDealStateAmtChanged() DiffAdtArraysFunc {
|
func (sp *StatePredicates) OnDealStateAmtChanged() DiffDealStatesFunc {
|
||||||
return func(ctx context.Context, oldDealStates, newDealStates *adt.Array) (changed bool, user UserData, err error) {
|
return func(ctx context.Context, oldDealStates, newDealStates market.DealStates) (changed bool, user UserData, err error) {
|
||||||
dealStateChanges := new(MarketDealStateChanges)
|
dealStateChanges, err := market.DiffDealStates(oldDealStates, newDealStates)
|
||||||
if err := DiffAdtArray(oldDealStates, newDealStates, dealStateChanges); err != nil {
|
if err != nil {
|
||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,42 +223,29 @@ func (sp *StatePredicates) OnDealStateAmtChanged() DiffAdtArraysFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ChangedDeals is a set of changes to deal state
|
// ChangedDeals is a set of changes to deal state
|
||||||
type ChangedDeals map[abi.DealID]DealStateChange
|
type ChangedDeals map[abi.DealID]market.DealStateChange
|
||||||
|
|
||||||
// DealStateChange is a change in deal state from -> to
|
|
||||||
type DealStateChange struct {
|
|
||||||
ID abi.DealID
|
|
||||||
From *market.DealState
|
|
||||||
To *market.DealState
|
|
||||||
}
|
|
||||||
|
|
||||||
// DealStateChangedForIDs detects changes in the deal state AMT for the given deal IDs
|
// DealStateChangedForIDs detects changes in the deal state AMT for the given deal IDs
|
||||||
func (sp *StatePredicates) DealStateChangedForIDs(dealIds []abi.DealID) DiffAdtArraysFunc {
|
func (sp *StatePredicates) DealStateChangedForIDs(dealIds []abi.DealID) DiffDealStatesFunc {
|
||||||
return func(ctx context.Context, oldDealStateArray, newDealStateArray *adt.Array) (changed bool, user UserData, err error) {
|
return func(ctx context.Context, oldDealStates, newDealStates market.DealStates) (changed bool, user UserData, err error) {
|
||||||
changedDeals := make(ChangedDeals)
|
changedDeals := make(ChangedDeals)
|
||||||
for _, dealID := range dealIds {
|
for _, dealID := range dealIds {
|
||||||
var oldDealPtr, newDealPtr *market.DealState
|
|
||||||
var oldDeal, newDeal market.DealState
|
|
||||||
|
|
||||||
// If the deal has been removed, we just set it to nil
|
// If the deal has been removed, we just set it to nil
|
||||||
found, err := oldDealStateArray.Get(uint64(dealID), &oldDeal)
|
oldDeal, oldFound, err := oldDealStates.Get(dealID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
if found {
|
|
||||||
oldDealPtr = &oldDeal
|
|
||||||
}
|
|
||||||
|
|
||||||
found, err = newDealStateArray.Get(uint64(dealID), &newDeal)
|
newDeal, newFound, err := newDealStates.Get(dealID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
if found {
|
|
||||||
newDealPtr = &newDeal
|
|
||||||
}
|
|
||||||
|
|
||||||
if oldDeal != newDeal {
|
existenceChanged := oldFound != newFound
|
||||||
changedDeals[dealID] = DealStateChange{dealID, oldDealPtr, newDealPtr}
|
valueChanged := (oldFound && newFound) && *oldDeal != *newDeal
|
||||||
|
if existenceChanged || valueChanged {
|
||||||
|
changedDeals[dealID] = market.DealStateChange{ID: dealID, From: oldDeal, To: newDeal}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(changedDeals) > 0 {
|
if len(changedDeals) > 0 {
|
||||||
@@ -405,124 +306,43 @@ func (sp *StatePredicates) AvailableBalanceChangedForAddresses(getAddrs func() [
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type DiffMinerActorStateFunc func(ctx context.Context, oldState *miner.State, newState *miner.State) (changed bool, user UserData, err error)
|
type DiffMinerActorStateFunc func(ctx context.Context, oldState miner.State, newState miner.State) (changed bool, user UserData, err error)
|
||||||
|
|
||||||
func (sp *StatePredicates) OnInitActorChange(diffInitActorState DiffInitActorStateFunc) DiffTipSetKeyFunc {
|
func (sp *StatePredicates) OnInitActorChange(diffInitActorState DiffInitActorStateFunc) DiffTipSetKeyFunc {
|
||||||
return sp.OnActorStateChanged(builtin.InitActorAddr, func(ctx context.Context, oldActorStateHead, newActorStateHead cid.Cid) (changed bool, user UserData, err error) {
|
return sp.OnActorStateChanged(init_.Address, func(ctx context.Context, oldActorState, newActorState *types.Actor) (changed bool, user UserData, err error) {
|
||||||
var oldState init_.State
|
oldState, err := init_.Load(adt.WrapStore(ctx, sp.cst), oldActorState)
|
||||||
if err := sp.cst.Get(ctx, oldActorStateHead, &oldState); err != nil {
|
if err != nil {
|
||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
var newState init_.State
|
newState, err := init_.Load(adt.WrapStore(ctx, sp.cst), newActorState)
|
||||||
if err := sp.cst.Get(ctx, newActorStateHead, &newState); err != nil {
|
if err != nil {
|
||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
return diffInitActorState(ctx, &oldState, &newState)
|
return diffInitActorState(ctx, oldState, newState)
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sp *StatePredicates) OnMinerActorChange(minerAddr address.Address, diffMinerActorState DiffMinerActorStateFunc) DiffTipSetKeyFunc {
|
func (sp *StatePredicates) OnMinerActorChange(minerAddr address.Address, diffMinerActorState DiffMinerActorStateFunc) DiffTipSetKeyFunc {
|
||||||
return sp.OnActorStateChanged(minerAddr, func(ctx context.Context, oldActorStateHead, newActorStateHead cid.Cid) (changed bool, user UserData, err error) {
|
return sp.OnActorStateChanged(minerAddr, func(ctx context.Context, oldActorState, newActorState *types.Actor) (changed bool, user UserData, err error) {
|
||||||
var oldState miner.State
|
oldState, err := miner.Load(adt.WrapStore(ctx, sp.cst), oldActorState)
|
||||||
if err := sp.cst.Get(ctx, oldActorStateHead, &oldState); err != nil {
|
if err != nil {
|
||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
var newState miner.State
|
newState, err := miner.Load(adt.WrapStore(ctx, sp.cst), newActorState)
|
||||||
if err := sp.cst.Get(ctx, newActorStateHead, &newState); err != nil {
|
if err != nil {
|
||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
return diffMinerActorState(ctx, &oldState, &newState)
|
return diffMinerActorState(ctx, oldState, newState)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
type MinerSectorChanges struct {
|
|
||||||
Added []miner.SectorOnChainInfo
|
|
||||||
Extended []SectorExtensions
|
|
||||||
Removed []miner.SectorOnChainInfo
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ AdtArrayDiff = &MinerSectorChanges{}
|
|
||||||
|
|
||||||
type SectorExtensions struct {
|
|
||||||
From miner.SectorOnChainInfo
|
|
||||||
To miner.SectorOnChainInfo
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *MinerSectorChanges) Add(key uint64, val *typegen.Deferred) error {
|
|
||||||
si := new(miner.SectorOnChainInfo)
|
|
||||||
err := si.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
m.Added = append(m.Added, *si)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *MinerSectorChanges) Modify(key uint64, from, to *typegen.Deferred) error {
|
|
||||||
siFrom := new(miner.SectorOnChainInfo)
|
|
||||||
err := siFrom.UnmarshalCBOR(bytes.NewReader(from.Raw))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
siTo := new(miner.SectorOnChainInfo)
|
|
||||||
err = siTo.UnmarshalCBOR(bytes.NewReader(to.Raw))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if siFrom.Expiration != siTo.Expiration {
|
|
||||||
m.Extended = append(m.Extended, SectorExtensions{
|
|
||||||
From: *siFrom,
|
|
||||||
To: *siTo,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *MinerSectorChanges) Remove(key uint64, val *typegen.Deferred) error {
|
|
||||||
si := new(miner.SectorOnChainInfo)
|
|
||||||
err := si.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
m.Removed = append(m.Removed, *si)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sp *StatePredicates) OnMinerSectorChange() DiffMinerActorStateFunc {
|
func (sp *StatePredicates) OnMinerSectorChange() DiffMinerActorStateFunc {
|
||||||
return func(ctx context.Context, oldState, newState *miner.State) (changed bool, user UserData, err error) {
|
return func(ctx context.Context, oldState, newState miner.State) (changed bool, user UserData, err error) {
|
||||||
ctxStore := &contextStore{
|
sectorChanges, err := miner.DiffSectors(oldState, newState)
|
||||||
ctx: ctx,
|
|
||||||
cst: sp.cst,
|
|
||||||
}
|
|
||||||
|
|
||||||
sectorChanges := &MinerSectorChanges{
|
|
||||||
Added: []miner.SectorOnChainInfo{},
|
|
||||||
Extended: []SectorExtensions{},
|
|
||||||
Removed: []miner.SectorOnChainInfo{},
|
|
||||||
}
|
|
||||||
|
|
||||||
// no sector changes
|
|
||||||
if oldState.Sectors.Equals(newState.Sectors) {
|
|
||||||
return false, nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
oldSectors, err := adt.AsArray(ctxStore, oldState.Sectors)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
newSectors, err := adt.AsArray(ctxStore, newState.Sectors)
|
|
||||||
if err != nil {
|
|
||||||
return false, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := DiffAdtArray(oldSectors, newSectors, sectorChanges); err != nil {
|
|
||||||
return false, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// nothing changed
|
// nothing changed
|
||||||
if len(sectorChanges.Added)+len(sectorChanges.Extended)+len(sectorChanges.Removed) == 0 {
|
if len(sectorChanges.Added)+len(sectorChanges.Extended)+len(sectorChanges.Removed) == 0 {
|
||||||
return false, nil, nil
|
return false, nil, nil
|
||||||
@@ -532,73 +352,13 @@ func (sp *StatePredicates) OnMinerSectorChange() DiffMinerActorStateFunc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type MinerPreCommitChanges struct {
|
|
||||||
Added []miner.SectorPreCommitOnChainInfo
|
|
||||||
Removed []miner.SectorPreCommitOnChainInfo
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *MinerPreCommitChanges) AsKey(key string) (adt.Keyer, error) {
|
|
||||||
sector, err := adt.ParseUIntKey(key)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return miner.SectorKey(abi.SectorNumber(sector)), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *MinerPreCommitChanges) Add(key string, val *typegen.Deferred) error {
|
|
||||||
sp := new(miner.SectorPreCommitOnChainInfo)
|
|
||||||
err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
m.Added = append(m.Added, *sp)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *MinerPreCommitChanges) Modify(key string, from, to *typegen.Deferred) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *MinerPreCommitChanges) Remove(key string, val *typegen.Deferred) error {
|
|
||||||
sp := new(miner.SectorPreCommitOnChainInfo)
|
|
||||||
err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
m.Removed = append(m.Removed, *sp)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sp *StatePredicates) OnMinerPreCommitChange() DiffMinerActorStateFunc {
|
func (sp *StatePredicates) OnMinerPreCommitChange() DiffMinerActorStateFunc {
|
||||||
return func(ctx context.Context, oldState, newState *miner.State) (changed bool, user UserData, err error) {
|
return func(ctx context.Context, oldState, newState miner.State) (changed bool, user UserData, err error) {
|
||||||
ctxStore := &contextStore{
|
precommitChanges, err := miner.DiffPreCommits(oldState, newState)
|
||||||
ctx: ctx,
|
|
||||||
cst: sp.cst,
|
|
||||||
}
|
|
||||||
|
|
||||||
precommitChanges := &MinerPreCommitChanges{
|
|
||||||
Added: []miner.SectorPreCommitOnChainInfo{},
|
|
||||||
Removed: []miner.SectorPreCommitOnChainInfo{},
|
|
||||||
}
|
|
||||||
|
|
||||||
if oldState.PreCommittedSectors.Equals(newState.PreCommittedSectors) {
|
|
||||||
return false, nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
oldPrecommits, err := adt.AsMap(ctxStore, oldState.PreCommittedSectors)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
newPrecommits, err := adt.AsMap(ctxStore, newState.PreCommittedSectors)
|
|
||||||
if err != nil {
|
|
||||||
return false, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := DiffAdtMap(oldPrecommits, newPrecommits, precommitChanges); err != nil {
|
|
||||||
return false, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(precommitChanges.Added)+len(precommitChanges.Removed) == 0 {
|
if len(precommitChanges.Added)+len(precommitChanges.Removed) == 0 {
|
||||||
return false, nil, nil
|
return false, nil, nil
|
||||||
}
|
}
|
||||||
@@ -608,20 +368,20 @@ func (sp *StatePredicates) OnMinerPreCommitChange() DiffMinerActorStateFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DiffPaymentChannelStateFunc is function that compares two states for the payment channel
|
// DiffPaymentChannelStateFunc is function that compares two states for the payment channel
|
||||||
type DiffPaymentChannelStateFunc func(ctx context.Context, oldState *paych.State, newState *paych.State) (changed bool, user UserData, err error)
|
type DiffPaymentChannelStateFunc func(ctx context.Context, oldState paych.State, newState paych.State) (changed bool, user UserData, err error)
|
||||||
|
|
||||||
// OnPaymentChannelActorChanged calls diffPaymentChannelState when the state changes for the the payment channel actor
|
// OnPaymentChannelActorChanged calls diffPaymentChannelState when the state changes for the the payment channel actor
|
||||||
func (sp *StatePredicates) OnPaymentChannelActorChanged(paychAddr address.Address, diffPaymentChannelState DiffPaymentChannelStateFunc) DiffTipSetKeyFunc {
|
func (sp *StatePredicates) OnPaymentChannelActorChanged(paychAddr address.Address, diffPaymentChannelState DiffPaymentChannelStateFunc) DiffTipSetKeyFunc {
|
||||||
return sp.OnActorStateChanged(paychAddr, func(ctx context.Context, oldActorStateHead, newActorStateHead cid.Cid) (changed bool, user UserData, err error) {
|
return sp.OnActorStateChanged(paychAddr, func(ctx context.Context, oldActorState, newActorState *types.Actor) (changed bool, user UserData, err error) {
|
||||||
var oldState paych.State
|
oldState, err := paych.Load(adt.WrapStore(ctx, sp.cst), oldActorState)
|
||||||
if err := sp.cst.Get(ctx, oldActorStateHead, &oldState); err != nil {
|
if err != nil {
|
||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
var newState paych.State
|
newState, err := paych.Load(adt.WrapStore(ctx, sp.cst), newActorState)
|
||||||
if err := sp.cst.Get(ctx, newActorStateHead, &newState); err != nil {
|
if err != nil {
|
||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
return diffPaymentChannelState(ctx, &oldState, &newState)
|
return diffPaymentChannelState(ctx, oldState, newState)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -633,13 +393,23 @@ type PayChToSendChange struct {
|
|||||||
|
|
||||||
// OnToSendAmountChanges monitors changes on the total amount to send from one party to the other on a payment channel
|
// OnToSendAmountChanges monitors changes on the total amount to send from one party to the other on a payment channel
|
||||||
func (sp *StatePredicates) OnToSendAmountChanges() DiffPaymentChannelStateFunc {
|
func (sp *StatePredicates) OnToSendAmountChanges() DiffPaymentChannelStateFunc {
|
||||||
return func(ctx context.Context, oldState *paych.State, newState *paych.State) (changed bool, user UserData, err error) {
|
return func(ctx context.Context, oldState paych.State, newState paych.State) (changed bool, user UserData, err error) {
|
||||||
if oldState.ToSend.Equals(newState.ToSend) {
|
ots, err := oldState.ToSend()
|
||||||
|
if err != nil {
|
||||||
|
return false, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
nts, err := newState.ToSend()
|
||||||
|
if err != nil {
|
||||||
|
return false, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if ots.Equals(nts) {
|
||||||
return false, nil, nil
|
return false, nil, nil
|
||||||
}
|
}
|
||||||
return true, &PayChToSendChange{
|
return true, &PayChToSendChange{
|
||||||
OldToSend: oldState.ToSend,
|
OldToSend: ots,
|
||||||
NewToSend: newState.ToSend,
|
NewToSend: nts,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -660,14 +430,14 @@ type AddressChange struct {
|
|||||||
To AddressPair
|
To AddressPair
|
||||||
}
|
}
|
||||||
|
|
||||||
type DiffInitActorStateFunc func(ctx context.Context, oldState *init_.State, newState *init_.State) (changed bool, user UserData, err error)
|
type DiffInitActorStateFunc func(ctx context.Context, oldState init_.State, newState init_.State) (changed bool, user UserData, err error)
|
||||||
|
|
||||||
func (i *InitActorAddressChanges) AsKey(key string) (adt.Keyer, error) {
|
func (i *InitActorAddressChanges) AsKey(key string) (abi.Keyer, error) {
|
||||||
addr, err := address.NewFromBytes([]byte(key))
|
addr, err := address.NewFromBytes([]byte(key))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return adt.AddrKey(addr), nil
|
return abi.AddrKey(addr), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *InitActorAddressChanges) Add(key string, val *typegen.Deferred) error {
|
func (i *InitActorAddressChanges) Add(key string, val *typegen.Deferred) error {
|
||||||
@@ -748,33 +518,73 @@ func (i *InitActorAddressChanges) Remove(key string, val *typegen.Deferred) erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (sp *StatePredicates) OnAddressMapChange() DiffInitActorStateFunc {
|
func (sp *StatePredicates) OnAddressMapChange() DiffInitActorStateFunc {
|
||||||
return func(ctx context.Context, oldState, newState *init_.State) (changed bool, user UserData, err error) {
|
return func(ctx context.Context, oldState, newState init_.State) (changed bool, user UserData, err error) {
|
||||||
ctxStore := &contextStore{
|
|
||||||
ctx: ctx,
|
|
||||||
cst: sp.cst,
|
|
||||||
}
|
|
||||||
|
|
||||||
addressChanges := &InitActorAddressChanges{
|
addressChanges := &InitActorAddressChanges{
|
||||||
Added: []AddressPair{},
|
Added: []AddressPair{},
|
||||||
Modified: []AddressChange{},
|
Modified: []AddressChange{},
|
||||||
Removed: []AddressPair{},
|
Removed: []AddressPair{},
|
||||||
}
|
}
|
||||||
|
|
||||||
if oldState.AddressMap.Equals(newState.AddressMap) {
|
err = oldState.ForEachActor(func(oldId abi.ActorID, oldAddress address.Address) error {
|
||||||
return false, nil, nil
|
oldIdAddress, err := address.NewIDAddress(uint64(oldId))
|
||||||
}
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
newIdAddress, found, err := newState.ResolveAddress(oldAddress)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !found {
|
||||||
|
addressChanges.Removed = append(addressChanges.Removed, AddressPair{
|
||||||
|
ID: oldIdAddress,
|
||||||
|
PK: oldAddress,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if oldIdAddress != newIdAddress {
|
||||||
|
addressChanges.Modified = append(addressChanges.Modified, AddressChange{
|
||||||
|
From: AddressPair{
|
||||||
|
ID: oldIdAddress,
|
||||||
|
PK: oldAddress,
|
||||||
|
},
|
||||||
|
To: AddressPair{
|
||||||
|
ID: newIdAddress,
|
||||||
|
PK: oldAddress,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
oldAddrs, err := adt.AsMap(ctxStore, oldState.AddressMap)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
newAddrs, err := adt.AsMap(ctxStore, newState.AddressMap)
|
err = newState.ForEachActor(func(newId abi.ActorID, newAddress address.Address) error {
|
||||||
if err != nil {
|
newIdAddress, err := address.NewIDAddress(uint64(newId))
|
||||||
return false, nil, err
|
if err != nil {
|
||||||
}
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if err := DiffAdtMap(oldAddrs, newAddrs, addressChanges); err != nil {
|
_, found, err := newState.ResolveAddress(newAddress)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !found {
|
||||||
|
addressChanges.Added = append(addressChanges.Added, AddressPair{
|
||||||
|
ID: newIdAddress,
|
||||||
|
PK: newAddress,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-bitfield"
|
"github.com/filecoin-project/go-bitfield"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@@ -13,11 +15,14 @@ import (
|
|||||||
cbornode "github.com/ipfs/go-ipld-cbor"
|
cbornode "github.com/ipfs/go-ipld-cbor"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
"github.com/filecoin-project/go-state-types/big"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/market"
|
"github.com/filecoin-project/go-state-types/crypto"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
"github.com/filecoin-project/lotus/chain/actors/builtin/market"
|
||||||
"github.com/filecoin-project/specs-actors/actors/crypto"
|
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
|
market0 "github.com/filecoin-project/specs-actors/actors/builtin/market"
|
||||||
|
|
||||||
|
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||||
tutils "github.com/filecoin-project/specs-actors/support/testing"
|
tutils "github.com/filecoin-project/specs-actors/support/testing"
|
||||||
|
|
||||||
@@ -69,22 +74,22 @@ func TestMarketPredicates(t *testing.T) {
|
|||||||
bs := bstore.NewTemporarySync()
|
bs := bstore.NewTemporarySync()
|
||||||
store := adt.WrapStore(ctx, cbornode.NewCborStore(bs))
|
store := adt.WrapStore(ctx, cbornode.NewCborStore(bs))
|
||||||
|
|
||||||
oldDeal1 := &market.DealState{
|
oldDeal1 := &market0.DealState{
|
||||||
SectorStartEpoch: 1,
|
SectorStartEpoch: 1,
|
||||||
LastUpdatedEpoch: 2,
|
LastUpdatedEpoch: 2,
|
||||||
SlashEpoch: 0,
|
SlashEpoch: 0,
|
||||||
}
|
}
|
||||||
oldDeal2 := &market.DealState{
|
oldDeal2 := &market0.DealState{
|
||||||
SectorStartEpoch: 4,
|
SectorStartEpoch: 4,
|
||||||
LastUpdatedEpoch: 5,
|
LastUpdatedEpoch: 5,
|
||||||
SlashEpoch: 0,
|
SlashEpoch: 0,
|
||||||
}
|
}
|
||||||
oldDeals := map[abi.DealID]*market.DealState{
|
oldDeals := map[abi.DealID]*market0.DealState{
|
||||||
abi.DealID(1): oldDeal1,
|
abi.DealID(1): oldDeal1,
|
||||||
abi.DealID(2): oldDeal2,
|
abi.DealID(2): oldDeal2,
|
||||||
}
|
}
|
||||||
|
|
||||||
oldProp1 := &market.DealProposal{
|
oldProp1 := &market0.DealProposal{
|
||||||
PieceCID: dummyCid,
|
PieceCID: dummyCid,
|
||||||
PieceSize: 0,
|
PieceSize: 0,
|
||||||
VerifiedDeal: false,
|
VerifiedDeal: false,
|
||||||
@@ -96,7 +101,7 @@ func TestMarketPredicates(t *testing.T) {
|
|||||||
ProviderCollateral: big.Zero(),
|
ProviderCollateral: big.Zero(),
|
||||||
ClientCollateral: big.Zero(),
|
ClientCollateral: big.Zero(),
|
||||||
}
|
}
|
||||||
oldProp2 := &market.DealProposal{
|
oldProp2 := &market0.DealProposal{
|
||||||
PieceCID: dummyCid,
|
PieceCID: dummyCid,
|
||||||
PieceSize: 0,
|
PieceSize: 0,
|
||||||
VerifiedDeal: false,
|
VerifiedDeal: false,
|
||||||
@@ -108,7 +113,7 @@ func TestMarketPredicates(t *testing.T) {
|
|||||||
ProviderCollateral: big.Zero(),
|
ProviderCollateral: big.Zero(),
|
||||||
ClientCollateral: big.Zero(),
|
ClientCollateral: big.Zero(),
|
||||||
}
|
}
|
||||||
oldProps := map[abi.DealID]*market.DealProposal{
|
oldProps := map[abi.DealID]*market0.DealProposal{
|
||||||
abi.DealID(1): oldProp1,
|
abi.DealID(1): oldProp1,
|
||||||
abi.DealID(2): oldProp2,
|
abi.DealID(2): oldProp2,
|
||||||
}
|
}
|
||||||
@@ -122,7 +127,7 @@ func TestMarketPredicates(t *testing.T) {
|
|||||||
|
|
||||||
oldStateC := createMarketState(ctx, t, store, oldDeals, oldProps, oldBalances)
|
oldStateC := createMarketState(ctx, t, store, oldDeals, oldProps, oldBalances)
|
||||||
|
|
||||||
newDeal1 := &market.DealState{
|
newDeal1 := &market0.DealState{
|
||||||
SectorStartEpoch: 1,
|
SectorStartEpoch: 1,
|
||||||
LastUpdatedEpoch: 3,
|
LastUpdatedEpoch: 3,
|
||||||
SlashEpoch: 0,
|
SlashEpoch: 0,
|
||||||
@@ -131,19 +136,19 @@ func TestMarketPredicates(t *testing.T) {
|
|||||||
// deal 2 removed
|
// deal 2 removed
|
||||||
|
|
||||||
// added
|
// added
|
||||||
newDeal3 := &market.DealState{
|
newDeal3 := &market0.DealState{
|
||||||
SectorStartEpoch: 1,
|
SectorStartEpoch: 1,
|
||||||
LastUpdatedEpoch: 2,
|
LastUpdatedEpoch: 2,
|
||||||
SlashEpoch: 3,
|
SlashEpoch: 3,
|
||||||
}
|
}
|
||||||
newDeals := map[abi.DealID]*market.DealState{
|
newDeals := map[abi.DealID]*market0.DealState{
|
||||||
abi.DealID(1): newDeal1,
|
abi.DealID(1): newDeal1,
|
||||||
// deal 2 was removed
|
// deal 2 was removed
|
||||||
abi.DealID(3): newDeal3,
|
abi.DealID(3): newDeal3,
|
||||||
}
|
}
|
||||||
|
|
||||||
// added
|
// added
|
||||||
newProp3 := &market.DealProposal{
|
newProp3 := &market0.DealProposal{
|
||||||
PieceCID: dummyCid,
|
PieceCID: dummyCid,
|
||||||
PieceSize: 0,
|
PieceSize: 0,
|
||||||
VerifiedDeal: false,
|
VerifiedDeal: false,
|
||||||
@@ -155,7 +160,7 @@ func TestMarketPredicates(t *testing.T) {
|
|||||||
ProviderCollateral: big.Zero(),
|
ProviderCollateral: big.Zero(),
|
||||||
ClientCollateral: big.Zero(),
|
ClientCollateral: big.Zero(),
|
||||||
}
|
}
|
||||||
newProps := map[abi.DealID]*market.DealProposal{
|
newProps := map[abi.DealID]*market0.DealProposal{
|
||||||
abi.DealID(1): oldProp1, // 1 was persisted
|
abi.DealID(1): oldProp1, // 1 was persisted
|
||||||
// prop 2 was removed
|
// prop 2 was removed
|
||||||
abi.DealID(3): newProp3, // new
|
abi.DealID(3): newProp3, // new
|
||||||
@@ -178,8 +183,8 @@ func TestMarketPredicates(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
api := newMockAPI(bs)
|
api := newMockAPI(bs)
|
||||||
api.setActor(oldState.Key(), &types.Actor{Head: oldStateC})
|
api.setActor(oldState.Key(), &types.Actor{Code: builtin0.StorageMarketActorCodeID, Head: oldStateC})
|
||||||
api.setActor(newState.Key(), &types.Actor{Head: newStateC})
|
api.setActor(newState.Key(), &types.Actor{Code: builtin0.StorageMarketActorCodeID, Head: newStateC})
|
||||||
|
|
||||||
t.Run("deal ID predicate", func(t *testing.T) {
|
t.Run("deal ID predicate", func(t *testing.T) {
|
||||||
preds := NewStatePredicates(api)
|
preds := NewStatePredicates(api)
|
||||||
@@ -221,7 +226,7 @@ func TestMarketPredicates(t *testing.T) {
|
|||||||
// Test that OnActorStateChanged does not call the callback if the state has not changed
|
// Test that OnActorStateChanged does not call the callback if the state has not changed
|
||||||
mockAddr, err := address.NewFromString("t01")
|
mockAddr, err := address.NewFromString("t01")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
actorDiffFn := preds.OnActorStateChanged(mockAddr, func(context.Context, cid.Cid, cid.Cid) (bool, UserData, error) {
|
actorDiffFn := preds.OnActorStateChanged(mockAddr, func(context.Context, *types.Actor, *types.Actor) (bool, UserData, error) {
|
||||||
t.Fatal("No state change so this should not be called")
|
t.Fatal("No state change so this should not be called")
|
||||||
return false, nil, nil
|
return false, nil, nil
|
||||||
})
|
})
|
||||||
@@ -230,11 +235,18 @@ func TestMarketPredicates(t *testing.T) {
|
|||||||
require.False(t, changed)
|
require.False(t, changed)
|
||||||
|
|
||||||
// Test that OnDealStateChanged does not call the callback if the state has not changed
|
// Test that OnDealStateChanged does not call the callback if the state has not changed
|
||||||
diffDealStateFn := preds.OnDealStateChanged(func(context.Context, *adt.Array, *adt.Array) (bool, UserData, error) {
|
diffDealStateFn := preds.OnDealStateChanged(func(context.Context, market.DealStates, market.DealStates) (bool, UserData, error) {
|
||||||
t.Fatal("No state change so this should not be called")
|
t.Fatal("No state change so this should not be called")
|
||||||
return false, nil, nil
|
return false, nil, nil
|
||||||
})
|
})
|
||||||
marketState := createEmptyMarketState(t, store)
|
marketState0 := createEmptyMarketState(t, store)
|
||||||
|
marketCid, err := store.Put(ctx, marketState0)
|
||||||
|
require.NoError(t, err)
|
||||||
|
marketState, err := market.Load(store, &types.Actor{
|
||||||
|
Code: builtin0.StorageMarketActorCodeID,
|
||||||
|
Head: marketCid,
|
||||||
|
})
|
||||||
|
require.NoError(t, err)
|
||||||
changed, _, err = diffDealStateFn(ctx, marketState, marketState)
|
changed, _, err = diffDealStateFn(ctx, marketState, marketState)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.False(t, changed)
|
require.False(t, changed)
|
||||||
@@ -252,18 +264,18 @@ func TestMarketPredicates(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.True(t, changed)
|
require.True(t, changed)
|
||||||
|
|
||||||
changedDeals, ok := valArr.(*MarketDealStateChanges)
|
changedDeals, ok := valArr.(*market.DealStateChanges)
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
require.Len(t, changedDeals.Added, 1)
|
require.Len(t, changedDeals.Added, 1)
|
||||||
require.Equal(t, abi.DealID(3), changedDeals.Added[0].ID)
|
require.Equal(t, abi.DealID(3), changedDeals.Added[0].ID)
|
||||||
require.Equal(t, *newDeal3, changedDeals.Added[0].Deal)
|
require.True(t, dealEquality(*newDeal3, changedDeals.Added[0].Deal))
|
||||||
|
|
||||||
require.Len(t, changedDeals.Removed, 1)
|
require.Len(t, changedDeals.Removed, 1)
|
||||||
|
|
||||||
require.Len(t, changedDeals.Modified, 1)
|
require.Len(t, changedDeals.Modified, 1)
|
||||||
require.Equal(t, abi.DealID(1), changedDeals.Modified[0].ID)
|
require.Equal(t, abi.DealID(1), changedDeals.Modified[0].ID)
|
||||||
require.Equal(t, newDeal1, changedDeals.Modified[0].To)
|
require.True(t, dealEquality(*newDeal1, *changedDeals.Modified[0].To))
|
||||||
require.Equal(t, oldDeal1, changedDeals.Modified[0].From)
|
require.True(t, dealEquality(*oldDeal1, *changedDeals.Modified[0].From))
|
||||||
|
|
||||||
require.Equal(t, abi.DealID(2), changedDeals.Removed[0].ID)
|
require.Equal(t, abi.DealID(2), changedDeals.Removed[0].ID)
|
||||||
})
|
})
|
||||||
@@ -279,17 +291,15 @@ func TestMarketPredicates(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.True(t, changed)
|
require.True(t, changed)
|
||||||
|
|
||||||
changedProps, ok := valArr.(*MarketDealProposalChanges)
|
changedProps, ok := valArr.(*market.DealProposalChanges)
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
require.Len(t, changedProps.Added, 1)
|
require.Len(t, changedProps.Added, 1)
|
||||||
require.Equal(t, abi.DealID(3), changedProps.Added[0].ID)
|
require.Equal(t, abi.DealID(3), changedProps.Added[0].ID)
|
||||||
require.Equal(t, *newProp3, changedProps.Added[0].Proposal)
|
|
||||||
|
|
||||||
// proposals cannot be modified -- no modified testing
|
// proposals cannot be modified -- no modified testing
|
||||||
|
|
||||||
require.Len(t, changedProps.Removed, 1)
|
require.Len(t, changedProps.Removed, 1)
|
||||||
require.Equal(t, abi.DealID(2), changedProps.Removed[0].ID)
|
require.Equal(t, abi.DealID(2), changedProps.Removed[0].ID)
|
||||||
require.Equal(t, *oldProp2, changedProps.Removed[0].Proposal)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("balances predicate", func(t *testing.T) {
|
t.Run("balances predicate", func(t *testing.T) {
|
||||||
@@ -342,7 +352,14 @@ func TestMarketPredicates(t *testing.T) {
|
|||||||
t.Fatal("No state change so this should not be called")
|
t.Fatal("No state change so this should not be called")
|
||||||
return false, nil, nil
|
return false, nil, nil
|
||||||
})
|
})
|
||||||
marketState := createEmptyMarketState(t, store)
|
marketState0 := createEmptyMarketState(t, store)
|
||||||
|
marketCid, err := store.Put(ctx, marketState0)
|
||||||
|
require.NoError(t, err)
|
||||||
|
marketState, err := market.Load(store, &types.Actor{
|
||||||
|
Code: builtin0.StorageMarketActorCodeID,
|
||||||
|
Head: marketCid,
|
||||||
|
})
|
||||||
|
require.NoError(t, err)
|
||||||
changed, _, err = diffDealBalancesFn(ctx, marketState, marketState)
|
changed, _, err = diffDealBalancesFn(ctx, marketState, marketState)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.False(t, changed)
|
require.False(t, changed)
|
||||||
@@ -362,12 +379,12 @@ func TestMinerSectorChange(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
owner, worker := nextIDAddrF(), nextIDAddrF()
|
owner, worker := nextIDAddrF(), nextIDAddrF()
|
||||||
si0 := newSectorOnChainInfo(0, tutils.MakeCID("0", &miner.SealedCIDPrefix), big.NewInt(0), abi.ChainEpoch(0), abi.ChainEpoch(10))
|
si0 := newSectorOnChainInfo(0, tutils.MakeCID("0", &miner0.SealedCIDPrefix), big.NewInt(0), abi.ChainEpoch(0), abi.ChainEpoch(10))
|
||||||
si1 := newSectorOnChainInfo(1, tutils.MakeCID("1", &miner.SealedCIDPrefix), big.NewInt(1), abi.ChainEpoch(1), abi.ChainEpoch(11))
|
si1 := newSectorOnChainInfo(1, tutils.MakeCID("1", &miner0.SealedCIDPrefix), big.NewInt(1), abi.ChainEpoch(1), abi.ChainEpoch(11))
|
||||||
si2 := newSectorOnChainInfo(2, tutils.MakeCID("2", &miner.SealedCIDPrefix), big.NewInt(2), abi.ChainEpoch(2), abi.ChainEpoch(11))
|
si2 := newSectorOnChainInfo(2, tutils.MakeCID("2", &miner0.SealedCIDPrefix), big.NewInt(2), abi.ChainEpoch(2), abi.ChainEpoch(11))
|
||||||
oldMinerC := createMinerState(ctx, t, store, owner, worker, []miner.SectorOnChainInfo{si0, si1, si2})
|
oldMinerC := createMinerState(ctx, t, store, owner, worker, []miner.SectorOnChainInfo{si0, si1, si2})
|
||||||
|
|
||||||
si3 := newSectorOnChainInfo(3, tutils.MakeCID("3", &miner.SealedCIDPrefix), big.NewInt(3), abi.ChainEpoch(3), abi.ChainEpoch(12))
|
si3 := newSectorOnChainInfo(3, tutils.MakeCID("3", &miner0.SealedCIDPrefix), big.NewInt(3), abi.ChainEpoch(3), abi.ChainEpoch(12))
|
||||||
// 0 delete
|
// 0 delete
|
||||||
// 1 extend
|
// 1 extend
|
||||||
// 2 same
|
// 2 same
|
||||||
@@ -383,8 +400,8 @@ func TestMinerSectorChange(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
api := newMockAPI(bs)
|
api := newMockAPI(bs)
|
||||||
api.setActor(oldState.Key(), &types.Actor{Head: oldMinerC})
|
api.setActor(oldState.Key(), &types.Actor{Head: oldMinerC, Code: builtin0.StorageMinerActorCodeID})
|
||||||
api.setActor(newState.Key(), &types.Actor{Head: newMinerC})
|
api.setActor(newState.Key(), &types.Actor{Head: newMinerC, Code: builtin0.StorageMinerActorCodeID})
|
||||||
|
|
||||||
preds := NewStatePredicates(api)
|
preds := NewStatePredicates(api)
|
||||||
|
|
||||||
@@ -394,7 +411,7 @@ func TestMinerSectorChange(t *testing.T) {
|
|||||||
require.True(t, change)
|
require.True(t, change)
|
||||||
require.NotNil(t, val)
|
require.NotNil(t, val)
|
||||||
|
|
||||||
sectorChanges, ok := val.(*MinerSectorChanges)
|
sectorChanges, ok := val.(*miner.SectorChanges)
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
|
|
||||||
require.Equal(t, len(sectorChanges.Added), 1)
|
require.Equal(t, len(sectorChanges.Added), 1)
|
||||||
@@ -418,7 +435,7 @@ func TestMinerSectorChange(t *testing.T) {
|
|||||||
require.True(t, change)
|
require.True(t, change)
|
||||||
require.NotNil(t, val)
|
require.NotNil(t, val)
|
||||||
|
|
||||||
sectorChanges, ok = val.(*MinerSectorChanges)
|
sectorChanges, ok = val.(*miner.SectorChanges)
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
|
|
||||||
require.Equal(t, 1, len(sectorChanges.Added))
|
require.Equal(t, 1, len(sectorChanges.Added))
|
||||||
@@ -450,7 +467,7 @@ type balance struct {
|
|||||||
locked abi.TokenAmount
|
locked abi.TokenAmount
|
||||||
}
|
}
|
||||||
|
|
||||||
func createMarketState(ctx context.Context, t *testing.T, store adt.Store, deals map[abi.DealID]*market.DealState, props map[abi.DealID]*market.DealProposal, balances map[address.Address]balance) cid.Cid {
|
func createMarketState(ctx context.Context, t *testing.T, store adt.Store, deals map[abi.DealID]*market0.DealState, props map[abi.DealID]*market0.DealProposal, balances map[address.Address]balance) cid.Cid {
|
||||||
dealRootCid := createDealAMT(ctx, t, store, deals)
|
dealRootCid := createDealAMT(ctx, t, store, deals)
|
||||||
propRootCid := createProposalAMT(ctx, t, store, props)
|
propRootCid := createProposalAMT(ctx, t, store, props)
|
||||||
balancesCids := createBalanceTable(ctx, t, store, balances)
|
balancesCids := createBalanceTable(ctx, t, store, balances)
|
||||||
@@ -465,15 +482,15 @@ func createMarketState(ctx context.Context, t *testing.T, store adt.Store, deals
|
|||||||
return stateC
|
return stateC
|
||||||
}
|
}
|
||||||
|
|
||||||
func createEmptyMarketState(t *testing.T, store adt.Store) *market.State {
|
func createEmptyMarketState(t *testing.T, store adt.Store) *market0.State {
|
||||||
emptyArrayCid, err := adt.MakeEmptyArray(store).Root()
|
emptyArrayCid, err := adt.MakeEmptyArray(store).Root()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
emptyMap, err := adt.MakeEmptyMap(store).Root()
|
emptyMap, err := adt.MakeEmptyMap(store).Root()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
return market.ConstructState(emptyArrayCid, emptyMap, emptyMap)
|
return market0.ConstructState(emptyArrayCid, emptyMap, emptyMap)
|
||||||
}
|
}
|
||||||
|
|
||||||
func createDealAMT(ctx context.Context, t *testing.T, store adt.Store, deals map[abi.DealID]*market.DealState) cid.Cid {
|
func createDealAMT(ctx context.Context, t *testing.T, store adt.Store, deals map[abi.DealID]*market0.DealState) cid.Cid {
|
||||||
root := adt.MakeEmptyArray(store)
|
root := adt.MakeEmptyArray(store)
|
||||||
for dealID, dealState := range deals {
|
for dealID, dealState := range deals {
|
||||||
err := root.Set(uint64(dealID), dealState)
|
err := root.Set(uint64(dealID), dealState)
|
||||||
@@ -484,7 +501,7 @@ func createDealAMT(ctx context.Context, t *testing.T, store adt.Store, deals map
|
|||||||
return rootCid
|
return rootCid
|
||||||
}
|
}
|
||||||
|
|
||||||
func createProposalAMT(ctx context.Context, t *testing.T, store adt.Store, props map[abi.DealID]*market.DealProposal) cid.Cid {
|
func createProposalAMT(ctx context.Context, t *testing.T, store adt.Store, props map[abi.DealID]*market0.DealProposal) cid.Cid {
|
||||||
root := adt.MakeEmptyArray(store)
|
root := adt.MakeEmptyArray(store)
|
||||||
for dealID, prop := range props {
|
for dealID, prop := range props {
|
||||||
err := root.Set(uint64(dealID), prop)
|
err := root.Set(uint64(dealID), prop)
|
||||||
@@ -532,20 +549,20 @@ func createMinerState(ctx context.Context, t *testing.T, store adt.Store, owner,
|
|||||||
return stateC
|
return stateC
|
||||||
}
|
}
|
||||||
|
|
||||||
func createEmptyMinerState(ctx context.Context, t *testing.T, store adt.Store, owner, worker address.Address) *miner.State {
|
func createEmptyMinerState(ctx context.Context, t *testing.T, store adt.Store, owner, worker address.Address) *miner0.State {
|
||||||
emptyArrayCid, err := adt.MakeEmptyArray(store).Root()
|
emptyArrayCid, err := adt.MakeEmptyArray(store).Root()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
emptyMap, err := adt.MakeEmptyMap(store).Root()
|
emptyMap, err := adt.MakeEmptyMap(store).Root()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
emptyDeadline, err := store.Put(store.Context(), miner.ConstructDeadline(emptyArrayCid))
|
emptyDeadline, err := store.Put(store.Context(), miner0.ConstructDeadline(emptyArrayCid))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
emptyVestingFunds := miner.ConstructVestingFunds()
|
emptyVestingFunds := miner0.ConstructVestingFunds()
|
||||||
emptyVestingFundsCid, err := store.Put(store.Context(), emptyVestingFunds)
|
emptyVestingFundsCid, err := store.Put(store.Context(), emptyVestingFunds)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
emptyDeadlines := miner.ConstructDeadlines(emptyDeadline)
|
emptyDeadlines := miner0.ConstructDeadlines(emptyDeadline)
|
||||||
emptyDeadlinesCid, err := store.Put(store.Context(), emptyDeadlines)
|
emptyDeadlinesCid, err := store.Put(store.Context(), emptyDeadlines)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@@ -555,7 +572,7 @@ func createEmptyMinerState(ctx context.Context, t *testing.T, store adt.Store, o
|
|||||||
emptyBitfieldCid, err := store.Put(store.Context(), emptyBitfield)
|
emptyBitfieldCid, err := store.Put(store.Context(), emptyBitfield)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
state, err := miner.ConstructState(minerInfo, 123, emptyBitfieldCid, emptyArrayCid, emptyMap, emptyDeadlinesCid, emptyVestingFundsCid)
|
state, err := miner0.ConstructState(minerInfo, 123, emptyBitfieldCid, emptyArrayCid, emptyMap, emptyDeadlinesCid, emptyVestingFundsCid)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
return state
|
return state
|
||||||
|
|
||||||
@@ -607,3 +624,9 @@ func newSectorPreCommitInfo(sectorNo abi.SectorNumber, sealed cid.Cid, expiratio
|
|||||||
Expiration: expiration,
|
Expiration: expiration,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func dealEquality(expected market0.DealState, actual market.DealState) bool {
|
||||||
|
return expected.LastUpdatedEpoch == actual.LastUpdatedEpoch &&
|
||||||
|
expected.SectorStartEpoch == actual.SectorStartEpoch &&
|
||||||
|
expected.SlashEpoch == actual.SlashEpoch
|
||||||
|
}
|
||||||
|
|||||||
+15
-8
@@ -3,13 +3,16 @@ package events
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
type tsByHFunc func(context.Context, abi.ChainEpoch, types.TipSetKey) (*types.TipSet, error)
|
type tsCacheAPI interface {
|
||||||
|
ChainGetTipSetByHeight(context.Context, abi.ChainEpoch, types.TipSetKey) (*types.TipSet, error)
|
||||||
|
ChainHead(context.Context) (*types.TipSet, error)
|
||||||
|
}
|
||||||
|
|
||||||
// tipSetCache implements a simple ring-buffer cache to keep track of recent
|
// tipSetCache implements a simple ring-buffer cache to keep track of recent
|
||||||
// tipsets
|
// tipsets
|
||||||
@@ -18,10 +21,10 @@ type tipSetCache struct {
|
|||||||
start int
|
start int
|
||||||
len int
|
len int
|
||||||
|
|
||||||
storage tsByHFunc
|
storage tsCacheAPI
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTSCache(cap abi.ChainEpoch, storage tsByHFunc) *tipSetCache {
|
func newTSCache(cap abi.ChainEpoch, storage tsCacheAPI) *tipSetCache {
|
||||||
return &tipSetCache{
|
return &tipSetCache{
|
||||||
cache: make([]*types.TipSet, cap),
|
cache: make([]*types.TipSet, cap),
|
||||||
start: 0,
|
start: 0,
|
||||||
@@ -94,7 +97,7 @@ func (tsc *tipSetCache) getNonNull(height abi.ChainEpoch) (*types.TipSet, error)
|
|||||||
func (tsc *tipSetCache) get(height abi.ChainEpoch) (*types.TipSet, error) {
|
func (tsc *tipSetCache) get(height abi.ChainEpoch) (*types.TipSet, error) {
|
||||||
if tsc.len == 0 {
|
if tsc.len == 0 {
|
||||||
log.Warnf("tipSetCache.get: cache is empty, requesting from storage (h=%d)", height)
|
log.Warnf("tipSetCache.get: cache is empty, requesting from storage (h=%d)", height)
|
||||||
return tsc.storage(context.TODO(), height, types.EmptyTSK)
|
return tsc.storage.ChainGetTipSetByHeight(context.TODO(), height, types.EmptyTSK)
|
||||||
}
|
}
|
||||||
|
|
||||||
headH := tsc.cache[tsc.start].Height()
|
headH := tsc.cache[tsc.start].Height()
|
||||||
@@ -114,14 +117,18 @@ func (tsc *tipSetCache) get(height abi.ChainEpoch) (*types.TipSet, error) {
|
|||||||
|
|
||||||
if height < tail.Height() {
|
if height < tail.Height() {
|
||||||
log.Warnf("tipSetCache.get: requested tipset not in cache, requesting from storage (h=%d; tail=%d)", height, tail.Height())
|
log.Warnf("tipSetCache.get: requested tipset not in cache, requesting from storage (h=%d; tail=%d)", height, tail.Height())
|
||||||
return tsc.storage(context.TODO(), height, tail.Key())
|
return tsc.storage.ChainGetTipSetByHeight(context.TODO(), height, tail.Key())
|
||||||
}
|
}
|
||||||
|
|
||||||
return tsc.cache[normalModulo(tsc.start-int(headH-height), clen)], nil
|
return tsc.cache[normalModulo(tsc.start-int(headH-height), clen)], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tsc *tipSetCache) best() *types.TipSet {
|
func (tsc *tipSetCache) best() (*types.TipSet, error) {
|
||||||
return tsc.cache[tsc.start]
|
best := tsc.cache[tsc.start]
|
||||||
|
if best == nil {
|
||||||
|
return tsc.storage.ChainHead(context.TODO())
|
||||||
|
}
|
||||||
|
return best, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func normalModulo(n, m int) int {
|
func normalModulo(n, m int) int {
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/crypto"
|
"github.com/filecoin-project/go-state-types/crypto"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
@@ -13,10 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestTsCache(t *testing.T) {
|
func TestTsCache(t *testing.T) {
|
||||||
tsc := newTSCache(50, func(context.Context, abi.ChainEpoch, types.TipSetKey) (*types.TipSet, error) {
|
tsc := newTSCache(50, &tsCacheAPIFailOnStorageCall{t: t})
|
||||||
t.Fatal("storage call")
|
|
||||||
return &types.TipSet{}, nil
|
|
||||||
})
|
|
||||||
|
|
||||||
h := abi.ChainEpoch(75)
|
h := abi.ChainEpoch(75)
|
||||||
|
|
||||||
@@ -43,7 +40,12 @@ func TestTsCache(t *testing.T) {
|
|||||||
|
|
||||||
for i := 0; i < 9000; i++ {
|
for i := 0; i < 9000; i++ {
|
||||||
if i%90 > 60 {
|
if i%90 > 60 {
|
||||||
if err := tsc.revert(tsc.best()); err != nil {
|
best, err := tsc.best()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err, "; i:", i)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := tsc.revert(best); err != nil {
|
||||||
t.Fatal(err, "; i:", i)
|
t.Fatal(err, "; i:", i)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -55,11 +57,21 @@ func TestTsCache(t *testing.T) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type tsCacheAPIFailOnStorageCall struct {
|
||||||
|
t *testing.T
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tc *tsCacheAPIFailOnStorageCall) ChainGetTipSetByHeight(ctx context.Context, epoch abi.ChainEpoch, key types.TipSetKey) (*types.TipSet, error) {
|
||||||
|
tc.t.Fatal("storage call")
|
||||||
|
return &types.TipSet{}, nil
|
||||||
|
}
|
||||||
|
func (tc *tsCacheAPIFailOnStorageCall) ChainHead(ctx context.Context) (*types.TipSet, error) {
|
||||||
|
tc.t.Fatal("storage call")
|
||||||
|
return &types.TipSet{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
func TestTsCacheNulls(t *testing.T) {
|
func TestTsCacheNulls(t *testing.T) {
|
||||||
tsc := newTSCache(50, func(context.Context, abi.ChainEpoch, types.TipSetKey) (*types.TipSet, error) {
|
tsc := newTSCache(50, &tsCacheAPIFailOnStorageCall{t: t})
|
||||||
t.Fatal("storage call")
|
|
||||||
return &types.TipSet{}, nil
|
|
||||||
})
|
|
||||||
|
|
||||||
h := abi.ChainEpoch(75)
|
h := abi.ChainEpoch(75)
|
||||||
|
|
||||||
@@ -91,7 +103,9 @@ func TestTsCacheNulls(t *testing.T) {
|
|||||||
add()
|
add()
|
||||||
add()
|
add()
|
||||||
|
|
||||||
require.Equal(t, h-1, tsc.best().Height())
|
best, err := tsc.best()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, h-1, best.Height())
|
||||||
|
|
||||||
ts, err := tsc.get(h - 1)
|
ts, err := tsc.get(h - 1)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -109,9 +123,17 @@ func TestTsCacheNulls(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, h-8, ts.Height())
|
require.Equal(t, h-8, ts.Height())
|
||||||
|
|
||||||
require.NoError(t, tsc.revert(tsc.best()))
|
best, err = tsc.best()
|
||||||
require.NoError(t, tsc.revert(tsc.best()))
|
require.NoError(t, err)
|
||||||
require.Equal(t, h-8, tsc.best().Height())
|
require.NoError(t, tsc.revert(best))
|
||||||
|
|
||||||
|
best, err = tsc.best()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NoError(t, tsc.revert(best))
|
||||||
|
|
||||||
|
best, err = tsc.best()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, h-8, best.Height())
|
||||||
|
|
||||||
h += 50
|
h += 50
|
||||||
add()
|
add()
|
||||||
@@ -120,3 +142,27 @@ func TestTsCacheNulls(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, h-1, ts.Height())
|
require.Equal(t, h-1, ts.Height())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type tsCacheAPIStorageCallCounter struct {
|
||||||
|
t *testing.T
|
||||||
|
chainGetTipSetByHeight int
|
||||||
|
chainHead int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tc *tsCacheAPIStorageCallCounter) ChainGetTipSetByHeight(ctx context.Context, epoch abi.ChainEpoch, key types.TipSetKey) (*types.TipSet, error) {
|
||||||
|
tc.chainGetTipSetByHeight++
|
||||||
|
return &types.TipSet{}, nil
|
||||||
|
}
|
||||||
|
func (tc *tsCacheAPIStorageCallCounter) ChainHead(ctx context.Context) (*types.TipSet, error) {
|
||||||
|
tc.chainHead++
|
||||||
|
return &types.TipSet{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTsCacheEmpty(t *testing.T) {
|
||||||
|
// Calling best on an empty cache should just call out to the chain API
|
||||||
|
callCounter := &tsCacheAPIStorageCallCounter{t: t}
|
||||||
|
tsc := newTSCache(50, callCounter)
|
||||||
|
_, err := tsc.best()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, 1, callCounter.chainHead)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT.
|
// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT.
|
||||||
|
|
||||||
package blocksync
|
package exchange
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -146,7 +146,7 @@ func (t *Response) MarshalCBOR(w io.Writer) error {
|
|||||||
|
|
||||||
scratch := make([]byte, 9)
|
scratch := make([]byte, 9)
|
||||||
|
|
||||||
// t.Status (blocksync.status) (uint64)
|
// t.Status (exchange.status) (uint64)
|
||||||
|
|
||||||
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.Status)); err != nil {
|
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.Status)); err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -164,7 +164,7 @@ func (t *Response) MarshalCBOR(w io.Writer) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// t.Chain ([]*blocksync.BSTipSet) (slice)
|
// t.Chain ([]*exchange.BSTipSet) (slice)
|
||||||
if len(t.Chain) > cbg.MaxLength {
|
if len(t.Chain) > cbg.MaxLength {
|
||||||
return xerrors.Errorf("Slice value in field t.Chain was too long")
|
return xerrors.Errorf("Slice value in field t.Chain was too long")
|
||||||
}
|
}
|
||||||
@@ -198,7 +198,7 @@ func (t *Response) UnmarshalCBOR(r io.Reader) error {
|
|||||||
return fmt.Errorf("cbor input had wrong number of fields")
|
return fmt.Errorf("cbor input had wrong number of fields")
|
||||||
}
|
}
|
||||||
|
|
||||||
// t.Status (blocksync.status) (uint64)
|
// t.Status (exchange.status) (uint64)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -222,7 +222,7 @@ func (t *Response) UnmarshalCBOR(r io.Reader) error {
|
|||||||
|
|
||||||
t.ErrorMessage = string(sval)
|
t.ErrorMessage = string(sval)
|
||||||
}
|
}
|
||||||
// t.Chain ([]*blocksync.BSTipSet) (slice)
|
// t.Chain ([]*exchange.BSTipSet) (slice)
|
||||||
|
|
||||||
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
|
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -567,7 +567,7 @@ func (t *BSTipSet) MarshalCBOR(w io.Writer) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// t.Messages (blocksync.CompactedMessages) (struct)
|
// t.Messages (exchange.CompactedMessages) (struct)
|
||||||
if err := t.Messages.MarshalCBOR(w); err != nil {
|
if err := t.Messages.MarshalCBOR(w); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -621,7 +621,7 @@ func (t *BSTipSet) UnmarshalCBOR(r io.Reader) error {
|
|||||||
t.Blocks[i] = &v
|
t.Blocks[i] = &v
|
||||||
}
|
}
|
||||||
|
|
||||||
// t.Messages (blocksync.CompactedMessages) (struct)
|
// t.Messages (exchange.CompactedMessages) (struct)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package blocksync
|
package exchange
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
@@ -7,13 +7,17 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
host "github.com/libp2p/go-libp2p-core/host"
|
"github.com/libp2p/go-libp2p-core/helpers"
|
||||||
inet "github.com/libp2p/go-libp2p-core/network"
|
"github.com/libp2p/go-libp2p-core/host"
|
||||||
|
"github.com/libp2p/go-libp2p-core/network"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
|
|
||||||
"go.opencensus.io/trace"
|
"go.opencensus.io/trace"
|
||||||
|
"go.uber.org/fx"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
cborutil "github.com/filecoin-project/go-cbor-util"
|
cborutil "github.com/filecoin-project/go-cbor-util"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
"github.com/filecoin-project/lotus/chain/store"
|
"github.com/filecoin-project/lotus/chain/store"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
@@ -21,11 +25,9 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/lib/peermgr"
|
"github.com/filecoin-project/lotus/lib/peermgr"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Protocol client.
|
// client implements exchange.Client, using the libp2p ChainExchange protocol
|
||||||
// FIXME: Rename to just `Client`. Not done at the moment to avoid
|
// as the fetching mechanism.
|
||||||
// disrupting too much of the consumer code, should be done along
|
type client struct {
|
||||||
// https://github.com/filecoin-project/lotus/issues/2612.
|
|
||||||
type BlockSync struct {
|
|
||||||
// Connection manager used to contact the server.
|
// Connection manager used to contact the server.
|
||||||
// FIXME: We should have a reduced interface here, initialized
|
// FIXME: We should have a reduced interface here, initialized
|
||||||
// just with our protocol ID, we shouldn't be able to open *any*
|
// just with our protocol ID, we shouldn't be able to open *any*
|
||||||
@@ -35,13 +37,14 @@ type BlockSync struct {
|
|||||||
peerTracker *bsPeerTracker
|
peerTracker *bsPeerTracker
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewClient(
|
var _ Client = (*client)(nil)
|
||||||
host host.Host,
|
|
||||||
pmgr peermgr.MaybePeerMgr,
|
// NewClient creates a new libp2p-based exchange.Client that uses the libp2p
|
||||||
) *BlockSync {
|
// ChainExhange protocol as the fetching mechanism.
|
||||||
return &BlockSync{
|
func NewClient(lc fx.Lifecycle, host host.Host, pmgr peermgr.MaybePeerMgr) Client {
|
||||||
|
return &client{
|
||||||
host: host,
|
host: host,
|
||||||
peerTracker: newPeerTracker(pmgr.Mgr),
|
peerTracker: newPeerTracker(lc, host, pmgr.Mgr),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,10 +65,14 @@ func NewClient(
|
|||||||
// request options without disrupting external calls. In the future the
|
// request options without disrupting external calls. In the future the
|
||||||
// consumers should be forced to use a more standardized service and
|
// consumers should be forced to use a more standardized service and
|
||||||
// adhere to a single API derived from this function.
|
// adhere to a single API derived from this function.
|
||||||
func (client *BlockSync) doRequest(
|
func (c *client) doRequest(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *Request,
|
req *Request,
|
||||||
singlePeer *peer.ID,
|
singlePeer *peer.ID,
|
||||||
|
// In the `GetChainMessages` case, we won't request the headers but we still
|
||||||
|
// need them to check the integrity of the `CompactedMessages` in the response
|
||||||
|
// so the tipset blocks need to be provided by the caller.
|
||||||
|
tipsets []*types.TipSet,
|
||||||
) (*validatedResponse, error) {
|
) (*validatedResponse, error) {
|
||||||
// Validate request.
|
// Validate request.
|
||||||
if req.Length == 0 {
|
if req.Length == 0 {
|
||||||
@@ -86,7 +93,7 @@ func (client *BlockSync) doRequest(
|
|||||||
if singlePeer != nil {
|
if singlePeer != nil {
|
||||||
peers = []peer.ID{*singlePeer}
|
peers = []peer.ID{*singlePeer}
|
||||||
} else {
|
} else {
|
||||||
peers = client.getShuffledPeers()
|
peers = c.getShuffledPeers()
|
||||||
if len(peers) == 0 {
|
if len(peers) == 0 {
|
||||||
return nil, xerrors.Errorf("no peers available")
|
return nil, xerrors.Errorf("no peers available")
|
||||||
}
|
}
|
||||||
@@ -107,9 +114,9 @@ func (client *BlockSync) doRequest(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Send request, read response.
|
// Send request, read response.
|
||||||
res, err := client.sendRequestToPeer(ctx, peer, req)
|
res, err := c.sendRequestToPeer(ctx, peer, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !xerrors.Is(err, inet.ErrNoConn) {
|
if !xerrors.Is(err, network.ErrNoConn) {
|
||||||
log.Warnf("could not connect to peer %s: %s",
|
log.Warnf("could not connect to peer %s: %s",
|
||||||
peer.String(), err)
|
peer.String(), err)
|
||||||
}
|
}
|
||||||
@@ -117,15 +124,15 @@ func (client *BlockSync) doRequest(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Process and validate response.
|
// Process and validate response.
|
||||||
validRes, err := client.processResponse(req, res)
|
validRes, err := c.processResponse(req, res, tipsets)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnf("processing peer %s response failed: %s",
|
log.Warnf("processing peer %s response failed: %s",
|
||||||
peer.String(), err)
|
peer.String(), err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
client.peerTracker.logGlobalSuccess(build.Clock.Since(globalTime))
|
c.peerTracker.logGlobalSuccess(build.Clock.Since(globalTime))
|
||||||
client.host.ConnManager().TagPeer(peer, "bsync", SUCCESS_PEER_TAG_VALUE)
|
c.host.ConnManager().TagPeer(peer, "bsync", SuccessPeerTagValue)
|
||||||
return validRes, nil
|
return validRes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,11 +151,8 @@ func (client *BlockSync) doRequest(
|
|||||||
// We are conflating in the single error returned both status and validation
|
// We are conflating in the single error returned both status and validation
|
||||||
// errors. Peer penalization should happen here then, before returning, so
|
// errors. Peer penalization should happen here then, before returning, so
|
||||||
// we can apply the correct penalties depending on the cause of the error.
|
// we can apply the correct penalties depending on the cause of the error.
|
||||||
func (client *BlockSync) processResponse(
|
// FIXME: Add the `peer` as argument once we implement penalties.
|
||||||
req *Request,
|
func (c *client) processResponse(req *Request, res *Response, tipsets []*types.TipSet) (*validatedResponse, error) {
|
||||||
res *Response,
|
|
||||||
// FIXME: Add the `peer` as argument once we implement penalties.
|
|
||||||
) (*validatedResponse, error) {
|
|
||||||
err := res.statusToError()
|
err := res.statusToError()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("status error: %s", err)
|
return nil, xerrors.Errorf("status error: %s", err)
|
||||||
@@ -180,6 +184,16 @@ func (client *BlockSync) processResponse(
|
|||||||
// Check for valid block sets and extract them into `TipSet`s.
|
// Check for valid block sets and extract them into `TipSet`s.
|
||||||
validRes.tipsets = make([]*types.TipSet, resLength)
|
validRes.tipsets = make([]*types.TipSet, resLength)
|
||||||
for i := 0; i < resLength; i++ {
|
for i := 0; i < resLength; i++ {
|
||||||
|
if res.Chain[i] == nil {
|
||||||
|
return nil, xerrors.Errorf("response with nil tipset in pos %d", i)
|
||||||
|
}
|
||||||
|
for blockIdx, block := range res.Chain[i].Blocks {
|
||||||
|
if block == nil {
|
||||||
|
return nil, xerrors.Errorf("tipset with nil block in pos %d", blockIdx)
|
||||||
|
// FIXME: Maybe we should move this check to `NewTipSet`.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
validRes.tipsets[i], err = types.NewTipSet(res.Chain[i].Blocks)
|
validRes.tipsets[i], err = types.NewTipSet(res.Chain[i].Blocks)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("invalid tipset blocks at height (head - %d): %w", i, err)
|
return nil, xerrors.Errorf("invalid tipset blocks at height (head - %d): %w", i, err)
|
||||||
@@ -214,31 +228,28 @@ func (client *BlockSync) processResponse(
|
|||||||
// If the headers were also returned check that the compression
|
// If the headers were also returned check that the compression
|
||||||
// indexes are valid before `toFullTipSets()` is called by the
|
// indexes are valid before `toFullTipSets()` is called by the
|
||||||
// consumer.
|
// consumer.
|
||||||
for tipsetIdx := 0; tipsetIdx < resLength; tipsetIdx++ {
|
err := c.validateCompressedIndices(res.Chain)
|
||||||
msgs := res.Chain[tipsetIdx].Messages
|
if err != nil {
|
||||||
blocksNum := len(res.Chain[tipsetIdx].Blocks)
|
return nil, err
|
||||||
if len(msgs.BlsIncludes) != blocksNum {
|
}
|
||||||
return nil, xerrors.Errorf("BlsIncludes (%d) does not match number of blocks (%d)",
|
} else {
|
||||||
len(msgs.BlsIncludes), blocksNum)
|
// If we didn't request the headers they should have been provided
|
||||||
}
|
// by the caller.
|
||||||
if len(msgs.SecpkIncludes) != blocksNum {
|
if len(tipsets) < len(res.Chain) {
|
||||||
return nil, xerrors.Errorf("SecpkIncludes (%d) does not match number of blocks (%d)",
|
return nil, xerrors.Errorf("not enought tipsets provided for message response validation, needed %d, have %d", len(res.Chain), len(tipsets))
|
||||||
len(msgs.SecpkIncludes), blocksNum)
|
}
|
||||||
}
|
chain := make([]*BSTipSet, 0, resLength)
|
||||||
for blockIdx := 0; blockIdx < blocksNum; blockIdx++ {
|
for i, resChain := range res.Chain {
|
||||||
for _, mi := range msgs.BlsIncludes[blockIdx] {
|
next := &BSTipSet{
|
||||||
if int(mi) >= len(msgs.Bls) {
|
Blocks: tipsets[i].Blocks(),
|
||||||
return nil, xerrors.Errorf("index in BlsIncludes (%d) exceeds number of messages (%d)",
|
Messages: resChain.Messages,
|
||||||
mi, len(msgs.Bls))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for _, mi := range msgs.SecpkIncludes[blockIdx] {
|
|
||||||
if int(mi) >= len(msgs.Secpk) {
|
|
||||||
return nil, xerrors.Errorf("index in SecpkIncludes (%d) exceeds number of messages (%d)",
|
|
||||||
mi, len(msgs.Secpk))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
chain = append(chain, next)
|
||||||
|
}
|
||||||
|
|
||||||
|
err := c.validateCompressedIndices(chain)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -246,16 +257,44 @@ func (client *BlockSync) processResponse(
|
|||||||
return validRes, nil
|
return validRes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetBlocks fetches count blocks from the network, from the provided tipset
|
func (c *client) validateCompressedIndices(chain []*BSTipSet) error {
|
||||||
// *backwards*, returning as many tipsets as count.
|
resLength := len(chain)
|
||||||
//
|
for tipsetIdx := 0; tipsetIdx < resLength; tipsetIdx++ {
|
||||||
// {hint/usage}: This is used by the Syncer during normal chain syncing and when
|
msgs := chain[tipsetIdx].Messages
|
||||||
// resolving forks.
|
blocksNum := len(chain[tipsetIdx].Blocks)
|
||||||
func (client *BlockSync) GetBlocks(
|
|
||||||
ctx context.Context,
|
if len(msgs.BlsIncludes) != blocksNum {
|
||||||
tsk types.TipSetKey,
|
return xerrors.Errorf("BlsIncludes (%d) does not match number of blocks (%d)",
|
||||||
count int,
|
len(msgs.BlsIncludes), blocksNum)
|
||||||
) ([]*types.TipSet, error) {
|
}
|
||||||
|
|
||||||
|
if len(msgs.SecpkIncludes) != blocksNum {
|
||||||
|
return xerrors.Errorf("SecpkIncludes (%d) does not match number of blocks (%d)",
|
||||||
|
len(msgs.SecpkIncludes), blocksNum)
|
||||||
|
}
|
||||||
|
|
||||||
|
for blockIdx := 0; blockIdx < blocksNum; blockIdx++ {
|
||||||
|
for _, mi := range msgs.BlsIncludes[blockIdx] {
|
||||||
|
if int(mi) >= len(msgs.Bls) {
|
||||||
|
return xerrors.Errorf("index in BlsIncludes (%d) exceeds number of messages (%d)",
|
||||||
|
mi, len(msgs.Bls))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, mi := range msgs.SecpkIncludes[blockIdx] {
|
||||||
|
if int(mi) >= len(msgs.Secpk) {
|
||||||
|
return xerrors.Errorf("index in SecpkIncludes (%d) exceeds number of messages (%d)",
|
||||||
|
mi, len(msgs.Secpk))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetBlocks implements Client.GetBlocks(). Refer to the godocs there.
|
||||||
|
func (c *client) GetBlocks(ctx context.Context, tsk types.TipSetKey, count int) ([]*types.TipSet, error) {
|
||||||
ctx, span := trace.StartSpan(ctx, "bsync.GetBlocks")
|
ctx, span := trace.StartSpan(ctx, "bsync.GetBlocks")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
if span.IsRecordingEvents() {
|
if span.IsRecordingEvents() {
|
||||||
@@ -271,7 +310,7 @@ func (client *BlockSync) GetBlocks(
|
|||||||
Options: Headers,
|
Options: Headers,
|
||||||
}
|
}
|
||||||
|
|
||||||
validRes, err := client.doRequest(ctx, req, nil)
|
validRes, err := c.doRequest(ctx, req, nil, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -279,11 +318,8 @@ func (client *BlockSync) GetBlocks(
|
|||||||
return validRes.tipsets, nil
|
return validRes.tipsets, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *BlockSync) GetFullTipSet(
|
// GetFullTipSet implements Client.GetFullTipSet(). Refer to the godocs there.
|
||||||
ctx context.Context,
|
func (c *client) GetFullTipSet(ctx context.Context, peer peer.ID, tsk types.TipSetKey) (*store.FullTipSet, error) {
|
||||||
peer peer.ID,
|
|
||||||
tsk types.TipSetKey,
|
|
||||||
) (*store.FullTipSet, error) {
|
|
||||||
// TODO: round robin through these peers on error
|
// TODO: round robin through these peers on error
|
||||||
|
|
||||||
req := &Request{
|
req := &Request{
|
||||||
@@ -292,7 +328,7 @@ func (client *BlockSync) GetFullTipSet(
|
|||||||
Options: Headers | Messages,
|
Options: Headers | Messages,
|
||||||
}
|
}
|
||||||
|
|
||||||
validRes, err := client.doRequest(ctx, req, &peer)
|
validRes, err := c.doRequest(ctx, req, &peer, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -302,12 +338,18 @@ func (client *BlockSync) GetFullTipSet(
|
|||||||
// *one* tipset here, so it's safe to index directly.
|
// *one* tipset here, so it's safe to index directly.
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *BlockSync) GetChainMessages(
|
// GetChainMessages implements Client.GetChainMessages(). Refer to the godocs there.
|
||||||
ctx context.Context,
|
func (c *client) GetChainMessages(ctx context.Context, tipsets []*types.TipSet) ([]*CompactedMessages, error) {
|
||||||
head *types.TipSet,
|
head := tipsets[0]
|
||||||
length uint64,
|
length := uint64(len(tipsets))
|
||||||
) ([]*CompactedMessages, error) {
|
|
||||||
ctx, span := trace.StartSpan(ctx, "GetChainMessages")
|
ctx, span := trace.StartSpan(ctx, "GetChainMessages")
|
||||||
|
if span.IsRecordingEvents() {
|
||||||
|
span.AddAttributes(
|
||||||
|
trace.StringAttribute("tipset", fmt.Sprint(head.Cids())),
|
||||||
|
trace.Int64Attribute("count", int64(length)),
|
||||||
|
)
|
||||||
|
}
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
req := &Request{
|
req := &Request{
|
||||||
@@ -316,7 +358,7 @@ func (client *BlockSync) GetChainMessages(
|
|||||||
Options: Messages,
|
Options: Messages,
|
||||||
}
|
}
|
||||||
|
|
||||||
validRes, err := client.doRequest(ctx, req, nil)
|
validRes, err := c.doRequest(ctx, req, nil, tipsets)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -327,11 +369,7 @@ func (client *BlockSync) GetChainMessages(
|
|||||||
// Send a request to a peer. Write request in the stream and read the
|
// Send a request to a peer. Write request in the stream and read the
|
||||||
// response back. We do not do any processing of the request/response
|
// response back. We do not do any processing of the request/response
|
||||||
// here.
|
// here.
|
||||||
func (client *BlockSync) sendRequestToPeer(
|
func (c *client) sendRequestToPeer(ctx context.Context, peer peer.ID, req *Request) (_ *Response, err error) {
|
||||||
ctx context.Context,
|
|
||||||
peer peer.ID,
|
|
||||||
req *Request,
|
|
||||||
) (_ *Response, err error) {
|
|
||||||
// Trace code.
|
// Trace code.
|
||||||
ctx, span := trace.StartSpan(ctx, "sendRequestToPeer")
|
ctx, span := trace.StartSpan(ctx, "sendRequestToPeer")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
@@ -352,34 +390,39 @@ func (client *BlockSync) sendRequestToPeer(
|
|||||||
}()
|
}()
|
||||||
// -- TRACE --
|
// -- TRACE --
|
||||||
|
|
||||||
supported, err := client.host.Peerstore().SupportsProtocols(peer, BlockSyncProtocolID)
|
supported, err := c.host.Peerstore().SupportsProtocols(peer, BlockSyncProtocolID, ChainExchangeProtocolID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
c.RemovePeer(peer)
|
||||||
return nil, xerrors.Errorf("failed to get protocols for peer: %w", err)
|
return nil, xerrors.Errorf("failed to get protocols for peer: %w", err)
|
||||||
}
|
}
|
||||||
if len(supported) == 0 || supported[0] != BlockSyncProtocolID {
|
if len(supported) == 0 || (supported[0] != BlockSyncProtocolID && supported[0] != ChainExchangeProtocolID) {
|
||||||
return nil, xerrors.Errorf("peer %s does not support protocol %s",
|
return nil, xerrors.Errorf("peer %s does not support protocols %s",
|
||||||
peer, BlockSyncProtocolID)
|
peer, []string{BlockSyncProtocolID, ChainExchangeProtocolID})
|
||||||
// FIXME: `ProtoBook` should support a *single* protocol check that returns
|
|
||||||
// a bool instead of a list.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
connectionStart := build.Clock.Now()
|
connectionStart := build.Clock.Now()
|
||||||
|
|
||||||
// Open stream to peer.
|
// Open stream to peer.
|
||||||
stream, err := client.host.NewStream(
|
stream, err := c.host.NewStream(
|
||||||
inet.WithNoDial(ctx, "should already have connection"),
|
network.WithNoDial(ctx, "should already have connection"),
|
||||||
peer,
|
peer,
|
||||||
BlockSyncProtocolID)
|
ChainExchangeProtocolID, BlockSyncProtocolID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
client.RemovePeer(peer)
|
c.RemovePeer(peer)
|
||||||
return nil, xerrors.Errorf("failed to open stream to peer: %w", err)
|
return nil, xerrors.Errorf("failed to open stream to peer: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
// Note: this will become just stream.Close once we've completed the go-libp2p migration to
|
||||||
|
// go-libp2p-core 0.7.0
|
||||||
|
go helpers.FullClose(stream) //nolint:errcheck
|
||||||
|
}()
|
||||||
|
|
||||||
// Write request.
|
// Write request.
|
||||||
_ = stream.SetWriteDeadline(time.Now().Add(WRITE_REQ_DEADLINE))
|
_ = stream.SetWriteDeadline(time.Now().Add(WriteReqDeadline))
|
||||||
if err := cborutil.WriteCborRPC(stream, req); err != nil {
|
if err := cborutil.WriteCborRPC(stream, req); err != nil {
|
||||||
_ = stream.SetWriteDeadline(time.Time{})
|
_ = stream.SetWriteDeadline(time.Time{})
|
||||||
client.peerTracker.logFailure(peer, build.Clock.Since(connectionStart))
|
c.peerTracker.logFailure(peer, build.Clock.Since(connectionStart), req.Length)
|
||||||
// FIXME: Should we also remove peer here?
|
// FIXME: Should we also remove peer here?
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -389,11 +432,11 @@ func (client *BlockSync) sendRequestToPeer(
|
|||||||
// Read response.
|
// Read response.
|
||||||
var res Response
|
var res Response
|
||||||
err = cborutil.ReadCborRPC(
|
err = cborutil.ReadCborRPC(
|
||||||
bufio.NewReader(incrt.New(stream, READ_RES_MIN_SPEED, READ_RES_DEADLINE)),
|
bufio.NewReader(incrt.New(stream, ReadResMinSpeed, ReadResDeadline)),
|
||||||
&res)
|
&res)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
client.peerTracker.logFailure(peer, build.Clock.Since(connectionStart))
|
c.peerTracker.logFailure(peer, build.Clock.Since(connectionStart), req.Length)
|
||||||
return nil, xerrors.Errorf("failed to read blocksync response: %w", err)
|
return nil, xerrors.Errorf("failed to read chainxchg response: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Move all this together at the top using a defer as done elsewhere.
|
// FIXME: Move all this together at the top using a defer as done elsewhere.
|
||||||
@@ -406,32 +449,34 @@ func (client *BlockSync) sendRequestToPeer(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
client.peerTracker.logSuccess(peer, build.Clock.Since(connectionStart))
|
c.peerTracker.logSuccess(peer, build.Clock.Since(connectionStart), uint64(len(res.Chain)))
|
||||||
// FIXME: We should really log a success only after we validate the response.
|
// FIXME: We should really log a success only after we validate the response.
|
||||||
// It might be a bit hard to do.
|
// It might be a bit hard to do.
|
||||||
return &res, nil
|
return &res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *BlockSync) AddPeer(p peer.ID) {
|
// AddPeer implements Client.AddPeer(). Refer to the godocs there.
|
||||||
client.peerTracker.addPeer(p)
|
func (c *client) AddPeer(p peer.ID) {
|
||||||
|
c.peerTracker.addPeer(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *BlockSync) RemovePeer(p peer.ID) {
|
// RemovePeer implements Client.RemovePeer(). Refer to the godocs there.
|
||||||
client.peerTracker.removePeer(p)
|
func (c *client) RemovePeer(p peer.ID) {
|
||||||
|
c.peerTracker.removePeer(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
// getShuffledPeers returns a preference-sorted set of peers (by latency
|
// getShuffledPeers returns a preference-sorted set of peers (by latency
|
||||||
// and failure counting), shuffling the first few peers so we don't always
|
// and failure counting), shuffling the first few peers so we don't always
|
||||||
// pick the same peer.
|
// pick the same peer.
|
||||||
// FIXME: Consider merging with `shufflePrefix()s`.
|
// FIXME: Consider merging with `shufflePrefix()s`.
|
||||||
func (client *BlockSync) getShuffledPeers() []peer.ID {
|
func (c *client) getShuffledPeers() []peer.ID {
|
||||||
peers := client.peerTracker.prefSortedPeers()
|
peers := c.peerTracker.prefSortedPeers()
|
||||||
shufflePrefix(peers)
|
shufflePrefix(peers)
|
||||||
return peers
|
return peers
|
||||||
}
|
}
|
||||||
|
|
||||||
func shufflePrefix(peers []peer.ID) {
|
func shufflePrefix(peers []peer.ID) {
|
||||||
prefix := SHUFFLE_PEERS_PREFIX
|
prefix := ShufflePeersPrefix
|
||||||
if len(peers) < prefix {
|
if len(peers) < prefix {
|
||||||
prefix = len(peers)
|
prefix = len(peers)
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
// Package exchange contains the ChainExchange server and client components.
|
||||||
|
//
|
||||||
|
// ChainExchange is the basic chain synchronization protocol of Filecoin.
|
||||||
|
// ChainExchange is an RPC-oriented protocol, with a single operation to
|
||||||
|
// request blocks for now.
|
||||||
|
//
|
||||||
|
// A request contains a start anchor block (referred to with a CID), and a
|
||||||
|
// amount of blocks requested beyond the anchor (including the anchor itself).
|
||||||
|
//
|
||||||
|
// A client can also pass options, encoded as a 64-bit bitfield. Lotus supports
|
||||||
|
// two options at the moment:
|
||||||
|
//
|
||||||
|
// - include block contents
|
||||||
|
// - include block messages
|
||||||
|
//
|
||||||
|
// The response will include a status code, an optional message, and the
|
||||||
|
// response payload in case of success. The payload is a slice of serialized
|
||||||
|
// tipsets.
|
||||||
|
package exchange
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package exchange
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/libp2p/go-libp2p-core/network"
|
||||||
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/store"
|
||||||
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Server is the responder side of the ChainExchange protocol. It accepts
|
||||||
|
// requests from clients and services them by returning the requested
|
||||||
|
// chain data.
|
||||||
|
type Server interface {
|
||||||
|
// HandleStream is the protocol handler to be registered on a libp2p
|
||||||
|
// protocol router.
|
||||||
|
//
|
||||||
|
// In the current version of the protocol, streams are single-use. The
|
||||||
|
// server will read a single Request, and will respond with a single
|
||||||
|
// Response. It will dispose of the stream straight after.
|
||||||
|
HandleStream(stream network.Stream)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Client is the requesting side of the ChainExchange protocol. It acts as
|
||||||
|
// a proxy for other components to request chain data from peers. It is chiefly
|
||||||
|
// used by the Syncer.
|
||||||
|
type Client interface {
|
||||||
|
// GetBlocks fetches block headers from the network, from the provided
|
||||||
|
// tipset *backwards*, returning as many tipsets as the count parameter,
|
||||||
|
// or less.
|
||||||
|
GetBlocks(ctx context.Context, tsk types.TipSetKey, count int) ([]*types.TipSet, error)
|
||||||
|
|
||||||
|
// GetChainMessages fetches messages from the network, starting from the first provided tipset
|
||||||
|
// and returning messages from as many tipsets as requested or less.
|
||||||
|
GetChainMessages(ctx context.Context, tipsets []*types.TipSet) ([]*CompactedMessages, error)
|
||||||
|
|
||||||
|
// GetFullTipSet fetches a full tipset from a given peer. If successful,
|
||||||
|
// the fetched object contains block headers and all messages in full form.
|
||||||
|
GetFullTipSet(ctx context.Context, peer peer.ID, tsk types.TipSetKey) (*store.FullTipSet, error)
|
||||||
|
|
||||||
|
// AddPeer adds a peer to the pool of peers that the Client requests
|
||||||
|
// data from.
|
||||||
|
AddPeer(peer peer.ID)
|
||||||
|
|
||||||
|
// RemovePeer removes a peer from the pool of peers that the Client
|
||||||
|
// requests data from.
|
||||||
|
RemovePeer(peer peer.ID)
|
||||||
|
}
|
||||||
@@ -1,13 +1,16 @@
|
|||||||
package blocksync
|
package exchange
|
||||||
|
|
||||||
// FIXME: This needs to be reviewed.
|
// FIXME: This needs to be reviewed.
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"sort"
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
host "github.com/libp2p/go-libp2p-core/host"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
|
"go.uber.org/fx"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
"github.com/filecoin-project/lotus/lib/peermgr"
|
"github.com/filecoin-project/lotus/lib/peermgr"
|
||||||
@@ -29,11 +32,30 @@ type bsPeerTracker struct {
|
|||||||
pmgr *peermgr.PeerMgr
|
pmgr *peermgr.PeerMgr
|
||||||
}
|
}
|
||||||
|
|
||||||
func newPeerTracker(pmgr *peermgr.PeerMgr) *bsPeerTracker {
|
func newPeerTracker(lc fx.Lifecycle, h host.Host, pmgr *peermgr.PeerMgr) *bsPeerTracker {
|
||||||
return &bsPeerTracker{
|
bsPt := &bsPeerTracker{
|
||||||
peers: make(map[peer.ID]*peerStats),
|
peers: make(map[peer.ID]*peerStats),
|
||||||
pmgr: pmgr,
|
pmgr: pmgr,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub, err := h.EventBus().Subscribe(new(peermgr.NewFilPeer))
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
for newPeer := range sub.Out() {
|
||||||
|
bsPt.addPeer(newPeer.(peermgr.NewFilPeer).Id)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
lc.Append(fx.Hook{
|
||||||
|
OnStop: func(ctx context.Context) error {
|
||||||
|
return sub.Close()
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
return bsPt
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bpt *bsPeerTracker) addPeer(p peer.ID) {
|
func (bpt *bsPeerTracker) addPeer(p peer.ID) {
|
||||||
@@ -72,16 +94,7 @@ func (bpt *bsPeerTracker) prefSortedPeers() []peer.ID {
|
|||||||
var costI, costJ float64
|
var costI, costJ float64
|
||||||
|
|
||||||
getPeerInitLat := func(p peer.ID) float64 {
|
getPeerInitLat := func(p peer.ID) float64 {
|
||||||
var res float64
|
return float64(bpt.avgGlobalTime) * newPeerMul
|
||||||
if bpt.pmgr != nil {
|
|
||||||
if lat, ok := bpt.pmgr.GetPeerLatency(p); ok {
|
|
||||||
res = float64(lat)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if res == 0 {
|
|
||||||
res = float64(bpt.avgGlobalTime)
|
|
||||||
}
|
|
||||||
return res * newPeerMul
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if pi.successes+pi.failures > 0 {
|
if pi.successes+pi.failures > 0 {
|
||||||
@@ -107,8 +120,8 @@ func (bpt *bsPeerTracker) prefSortedPeers() []peer.ID {
|
|||||||
const (
|
const (
|
||||||
// xInvAlpha = (N+1)/2
|
// xInvAlpha = (N+1)/2
|
||||||
|
|
||||||
localInvAlpha = 5 // 86% of the value is the last 9
|
localInvAlpha = 10 // 86% of the value is the last 19
|
||||||
globalInvAlpha = 20 // 86% of the value is the last 39
|
globalInvAlpha = 25 // 86% of the value is the last 49
|
||||||
)
|
)
|
||||||
|
|
||||||
func (bpt *bsPeerTracker) logGlobalSuccess(dur time.Duration) {
|
func (bpt *bsPeerTracker) logGlobalSuccess(dur time.Duration) {
|
||||||
@@ -133,7 +146,7 @@ func logTime(pi *peerStats, dur time.Duration) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bpt *bsPeerTracker) logSuccess(p peer.ID, dur time.Duration) {
|
func (bpt *bsPeerTracker) logSuccess(p peer.ID, dur time.Duration, reqSize uint64) {
|
||||||
bpt.lk.Lock()
|
bpt.lk.Lock()
|
||||||
defer bpt.lk.Unlock()
|
defer bpt.lk.Unlock()
|
||||||
|
|
||||||
@@ -145,10 +158,13 @@ func (bpt *bsPeerTracker) logSuccess(p peer.ID, dur time.Duration) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pi.successes++
|
pi.successes++
|
||||||
logTime(pi, dur)
|
if reqSize == 0 {
|
||||||
|
reqSize = 1
|
||||||
|
}
|
||||||
|
logTime(pi, dur/time.Duration(reqSize))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bpt *bsPeerTracker) logFailure(p peer.ID, dur time.Duration) {
|
func (bpt *bsPeerTracker) logFailure(p peer.ID, dur time.Duration, reqSize uint64) {
|
||||||
bpt.lk.Lock()
|
bpt.lk.Lock()
|
||||||
defer bpt.lk.Unlock()
|
defer bpt.lk.Unlock()
|
||||||
|
|
||||||
@@ -160,7 +176,10 @@ func (bpt *bsPeerTracker) logFailure(p peer.ID, dur time.Duration) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pi.failures++
|
pi.failures++
|
||||||
logTime(pi, dur)
|
if reqSize == 0 {
|
||||||
|
reqSize = 1
|
||||||
|
}
|
||||||
|
logTime(pi, dur/time.Duration(reqSize))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bpt *bsPeerTracker) removePeer(p peer.ID) {
|
func (bpt *bsPeerTracker) removePeer(p peer.ID) {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package blocksync
|
package exchange
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
@@ -13,9 +13,17 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
var log = logging.Logger("blocksync")
|
var log = logging.Logger("chainxchg")
|
||||||
|
|
||||||
const BlockSyncProtocolID = "/fil/sync/blk/0.0.1"
|
const (
|
||||||
|
// BlockSyncProtocolID is the protocol ID of the former blocksync protocol.
|
||||||
|
// Deprecated.
|
||||||
|
BlockSyncProtocolID = "/fil/sync/blk/0.0.1"
|
||||||
|
|
||||||
|
// ChainExchangeProtocolID is the protocol ID of the chain exchange
|
||||||
|
// protocol.
|
||||||
|
ChainExchangeProtocolID = "/fil/chain/xchg/0.0.1"
|
||||||
|
)
|
||||||
|
|
||||||
// FIXME: Bumped from original 800 to this to accommodate `syncFork()`
|
// FIXME: Bumped from original 800 to this to accommodate `syncFork()`
|
||||||
// use of `GetBlocks()`. It seems the expectation of that API is to
|
// use of `GetBlocks()`. It seems the expectation of that API is to
|
||||||
@@ -25,14 +33,16 @@ const BlockSyncProtocolID = "/fil/sync/blk/0.0.1"
|
|||||||
// qualifier to avoid "const initializer [...] is not a constant" error.)
|
// qualifier to avoid "const initializer [...] is not a constant" error.)
|
||||||
var MaxRequestLength = uint64(build.ForkLengthThreshold)
|
var MaxRequestLength = uint64(build.ForkLengthThreshold)
|
||||||
|
|
||||||
// Extracted constants from the code.
|
const (
|
||||||
// FIXME: Should be reviewed and confirmed.
|
// Extracted constants from the code.
|
||||||
const SUCCESS_PEER_TAG_VALUE = 25
|
// FIXME: Should be reviewed and confirmed.
|
||||||
const WRITE_REQ_DEADLINE = 5 * time.Second
|
SuccessPeerTagValue = 25
|
||||||
const READ_RES_DEADLINE = WRITE_REQ_DEADLINE
|
WriteReqDeadline = 5 * time.Second
|
||||||
const READ_RES_MIN_SPEED = 50 << 10
|
ReadResDeadline = WriteReqDeadline
|
||||||
const SHUFFLE_PEERS_PREFIX = 5
|
ReadResMinSpeed = 50 << 10
|
||||||
const WRITE_RES_DEADLINE = 60 * time.Second
|
ShufflePeersPrefix = 16
|
||||||
|
WriteResDeadline = 60 * time.Second
|
||||||
|
)
|
||||||
|
|
||||||
// FIXME: Rename. Make private.
|
// FIXME: Rename. Make private.
|
||||||
type Request struct {
|
type Request struct {
|
||||||
@@ -117,7 +127,7 @@ func (res *Response) statusToError() error {
|
|||||||
case NotFound:
|
case NotFound:
|
||||||
return xerrors.Errorf("not found")
|
return xerrors.Errorf("not found")
|
||||||
case GoAway:
|
case GoAway:
|
||||||
return xerrors.Errorf("not handling 'go away' blocksync responses yet")
|
return xerrors.Errorf("not handling 'go away' chainxchg responses yet")
|
||||||
case InternalError:
|
case InternalError:
|
||||||
return xerrors.Errorf("block sync peer errored: %s", res.ErrorMessage)
|
return xerrors.Errorf("block sync peer errored: %s", res.ErrorMessage)
|
||||||
case BadRequest:
|
case BadRequest:
|
||||||
@@ -129,6 +139,8 @@ func (res *Response) statusToError() error {
|
|||||||
|
|
||||||
// FIXME: Rename.
|
// FIXME: Rename.
|
||||||
type BSTipSet struct {
|
type BSTipSet struct {
|
||||||
|
// List of blocks belonging to a single tipset to which the
|
||||||
|
// `CompactedMessages` are linked.
|
||||||
Blocks []*types.BlockHeader
|
Blocks []*types.BlockHeader
|
||||||
Messages *CompactedMessages
|
Messages *CompactedMessages
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package blocksync
|
package exchange
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
@@ -15,44 +15,34 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
|
"github.com/libp2p/go-libp2p-core/helpers"
|
||||||
inet "github.com/libp2p/go-libp2p-core/network"
|
inet "github.com/libp2p/go-libp2p-core/network"
|
||||||
)
|
)
|
||||||
|
|
||||||
// BlockSyncService is the component that services BlockSync requests from
|
// server implements exchange.Server. It services requests for the
|
||||||
// peers.
|
// libp2p ChainExchange protocol.
|
||||||
//
|
type server struct {
|
||||||
// BlockSync is the basic chain synchronization protocol of Filecoin. BlockSync
|
|
||||||
// is an RPC-oriented protocol, with a single operation to request blocks.
|
|
||||||
//
|
|
||||||
// A request contains a start anchor block (referred to with a CID), and a
|
|
||||||
// amount of blocks requested beyond the anchor (including the anchor itself).
|
|
||||||
//
|
|
||||||
// A client can also pass options, encoded as a 64-bit bitfield. Lotus supports
|
|
||||||
// two options at the moment:
|
|
||||||
//
|
|
||||||
// - include block contents
|
|
||||||
// - include block messages
|
|
||||||
//
|
|
||||||
// The response will include a status code, an optional message, and the
|
|
||||||
// response payload in case of success. The payload is a slice of serialized
|
|
||||||
// tipsets.
|
|
||||||
// FIXME: Rename to just `Server` (will be done later, see note on `BlockSync`).
|
|
||||||
type BlockSyncService struct {
|
|
||||||
cs *store.ChainStore
|
cs *store.ChainStore
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBlockSyncService(cs *store.ChainStore) *BlockSyncService {
|
var _ Server = (*server)(nil)
|
||||||
return &BlockSyncService{
|
|
||||||
|
// NewServer creates a new libp2p-based exchange.Server. It services requests
|
||||||
|
// for the libp2p ChainExchange protocol.
|
||||||
|
func NewServer(cs *store.ChainStore) Server {
|
||||||
|
return &server{
|
||||||
cs: cs,
|
cs: cs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Entry point of the service, handles `Request`s.
|
// HandleStream implements Server.HandleStream. Refer to the godocs there.
|
||||||
func (server *BlockSyncService) HandleStream(stream inet.Stream) {
|
func (s *server) HandleStream(stream inet.Stream) {
|
||||||
ctx, span := trace.StartSpan(context.Background(), "blocksync.HandleStream")
|
ctx, span := trace.StartSpan(context.Background(), "chainxchg.HandleStream")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
defer stream.Close() //nolint:errcheck
|
// Note: this will become just stream.Close once we've completed the go-libp2p migration to
|
||||||
|
// go-libp2p-core 0.7.0
|
||||||
|
defer helpers.FullClose(stream) //nolint:errcheck
|
||||||
|
|
||||||
var req Request
|
var req Request
|
||||||
if err := cborutil.ReadCborRPC(bufio.NewReader(stream), &req); err != nil {
|
if err := cborutil.ReadCborRPC(bufio.NewReader(stream), &req); err != nil {
|
||||||
@@ -62,13 +52,13 @@ func (server *BlockSyncService) HandleStream(stream inet.Stream) {
|
|||||||
log.Infow("block sync request",
|
log.Infow("block sync request",
|
||||||
"start", req.Head, "len", req.Length)
|
"start", req.Head, "len", req.Length)
|
||||||
|
|
||||||
resp, err := server.processRequest(ctx, &req)
|
resp, err := s.processRequest(ctx, &req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn("failed to process request: ", err)
|
log.Warn("failed to process request: ", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = stream.SetDeadline(time.Now().Add(WRITE_RES_DEADLINE))
|
_ = stream.SetDeadline(time.Now().Add(WriteResDeadline))
|
||||||
if err := cborutil.WriteCborRPC(stream, resp); err != nil {
|
if err := cborutil.WriteCborRPC(stream, resp); err != nil {
|
||||||
_ = stream.SetDeadline(time.Time{})
|
_ = stream.SetDeadline(time.Time{})
|
||||||
log.Warnw("failed to write back response for handle stream",
|
log.Warnw("failed to write back response for handle stream",
|
||||||
@@ -80,10 +70,7 @@ func (server *BlockSyncService) HandleStream(stream inet.Stream) {
|
|||||||
|
|
||||||
// Validate and service the request. We return either a protocol
|
// Validate and service the request. We return either a protocol
|
||||||
// response or an internal error.
|
// response or an internal error.
|
||||||
func (server *BlockSyncService) processRequest(
|
func (s *server) processRequest(ctx context.Context, req *Request) (*Response, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *Request,
|
|
||||||
) (*Response, error) {
|
|
||||||
validReq, errResponse := validateRequest(ctx, req)
|
validReq, errResponse := validateRequest(ctx, req)
|
||||||
if errResponse != nil {
|
if errResponse != nil {
|
||||||
// The request did not pass validation, return the response
|
// The request did not pass validation, return the response
|
||||||
@@ -91,17 +78,14 @@ func (server *BlockSyncService) processRequest(
|
|||||||
return errResponse, nil
|
return errResponse, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return server.serviceRequest(ctx, validReq)
|
return s.serviceRequest(ctx, validReq)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate request. We either return a `validatedRequest`, or an error
|
// Validate request. We either return a `validatedRequest`, or an error
|
||||||
// `Response` indicating why we can't process it. We do not return any
|
// `Response` indicating why we can't process it. We do not return any
|
||||||
// internal errors here, we just signal protocol ones.
|
// internal errors here, we just signal protocol ones.
|
||||||
func validateRequest(
|
func validateRequest(ctx context.Context, req *Request) (*validatedRequest, *Response) {
|
||||||
ctx context.Context,
|
_, span := trace.StartSpan(ctx, "chainxchg.ValidateRequest")
|
||||||
req *Request,
|
|
||||||
) (*validatedRequest, *Response) {
|
|
||||||
_, span := trace.StartSpan(ctx, "blocksync.ValidateRequest")
|
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
validReq := validatedRequest{}
|
validReq := validatedRequest{}
|
||||||
@@ -147,14 +131,11 @@ func validateRequest(
|
|||||||
return &validReq, nil
|
return &validReq, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (server *BlockSyncService) serviceRequest(
|
func (s *server) serviceRequest(ctx context.Context, req *validatedRequest) (*Response, error) {
|
||||||
ctx context.Context,
|
_, span := trace.StartSpan(ctx, "chainxchg.ServiceRequest")
|
||||||
req *validatedRequest,
|
|
||||||
) (*Response, error) {
|
|
||||||
_, span := trace.StartSpan(ctx, "blocksync.ServiceRequest")
|
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
chain, err := collectChainSegment(server.cs, req)
|
chain, err := collectChainSegment(s.cs, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn("block sync request: collectChainSegment failed: ", err)
|
log.Warn("block sync request: collectChainSegment failed: ", err)
|
||||||
return &Response{
|
return &Response{
|
||||||
@@ -174,10 +155,7 @@ func (server *BlockSyncService) serviceRequest(
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func collectChainSegment(
|
func collectChainSegment(cs *store.ChainStore, req *validatedRequest) ([]*BSTipSet, error) {
|
||||||
cs *store.ChainStore,
|
|
||||||
req *validatedRequest,
|
|
||||||
) ([]*BSTipSet, error) {
|
|
||||||
var bstips []*BSTipSet
|
var bstips []*BSTipSet
|
||||||
|
|
||||||
cur := req.head
|
cur := req.head
|
||||||
@@ -221,37 +199,36 @@ func collectChainSegment(
|
|||||||
func gatherMessages(cs *store.ChainStore, ts *types.TipSet) ([]*types.Message, [][]uint64, []*types.SignedMessage, [][]uint64, error) {
|
func gatherMessages(cs *store.ChainStore, ts *types.TipSet) ([]*types.Message, [][]uint64, []*types.SignedMessage, [][]uint64, error) {
|
||||||
blsmsgmap := make(map[cid.Cid]uint64)
|
blsmsgmap := make(map[cid.Cid]uint64)
|
||||||
secpkmsgmap := make(map[cid.Cid]uint64)
|
secpkmsgmap := make(map[cid.Cid]uint64)
|
||||||
var secpkmsgs []*types.SignedMessage
|
|
||||||
var blsmsgs []*types.Message
|
|
||||||
var secpkincl, blsincl [][]uint64
|
var secpkincl, blsincl [][]uint64
|
||||||
|
|
||||||
|
var blscids, secpkcids []cid.Cid
|
||||||
for _, block := range ts.Blocks() {
|
for _, block := range ts.Blocks() {
|
||||||
bmsgs, smsgs, err := cs.MessagesForBlock(block)
|
bc, sc, err := cs.ReadMsgMetaCids(block.Messages)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: DRY. Use `chain.Message` interface.
|
// FIXME: DRY. Use `chain.Message` interface.
|
||||||
bmi := make([]uint64, 0, len(bmsgs))
|
bmi := make([]uint64, 0, len(bc))
|
||||||
for _, m := range bmsgs {
|
for _, m := range bc {
|
||||||
i, ok := blsmsgmap[m.Cid()]
|
i, ok := blsmsgmap[m]
|
||||||
if !ok {
|
if !ok {
|
||||||
i = uint64(len(blsmsgs))
|
i = uint64(len(blscids))
|
||||||
blsmsgs = append(blsmsgs, m)
|
blscids = append(blscids, m)
|
||||||
blsmsgmap[m.Cid()] = i
|
blsmsgmap[m] = i
|
||||||
}
|
}
|
||||||
|
|
||||||
bmi = append(bmi, i)
|
bmi = append(bmi, i)
|
||||||
}
|
}
|
||||||
blsincl = append(blsincl, bmi)
|
blsincl = append(blsincl, bmi)
|
||||||
|
|
||||||
smi := make([]uint64, 0, len(smsgs))
|
smi := make([]uint64, 0, len(sc))
|
||||||
for _, m := range smsgs {
|
for _, m := range sc {
|
||||||
i, ok := secpkmsgmap[m.Cid()]
|
i, ok := secpkmsgmap[m]
|
||||||
if !ok {
|
if !ok {
|
||||||
i = uint64(len(secpkmsgs))
|
i = uint64(len(secpkcids))
|
||||||
secpkmsgs = append(secpkmsgs, m)
|
secpkcids = append(secpkcids, m)
|
||||||
secpkmsgmap[m.Cid()] = i
|
secpkmsgmap[m] = i
|
||||||
}
|
}
|
||||||
|
|
||||||
smi = append(smi, i)
|
smi = append(smi, i)
|
||||||
@@ -259,5 +236,15 @@ func gatherMessages(cs *store.ChainStore, ts *types.TipSet) ([]*types.Message, [
|
|||||||
secpkincl = append(secpkincl, smi)
|
secpkincl = append(secpkincl, smi)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
blsmsgs, err := cs.LoadMessagesFromCids(blscids)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
secpkmsgs, err := cs.LoadSignedMessagesFromCids(secpkcids)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return blsmsgs, blsincl, secpkmsgs, secpkincl, nil
|
return blsmsgs, blsincl, secpkmsgs, secpkincl, nil
|
||||||
}
|
}
|
||||||
+25
-20
@@ -8,11 +8,13 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/runtime/proof"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
"github.com/filecoin-project/go-state-types/big"
|
||||||
saminer "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
"github.com/filecoin-project/go-state-types/crypto"
|
||||||
"github.com/filecoin-project/specs-actors/actors/crypto"
|
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
block "github.com/ipfs/go-block-format"
|
block "github.com/ipfs/go-block-format"
|
||||||
"github.com/ipfs/go-blockservice"
|
"github.com/ipfs/go-blockservice"
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
@@ -46,7 +48,7 @@ const msgsPerBlock = 20
|
|||||||
//nolint:deadcode,varcheck
|
//nolint:deadcode,varcheck
|
||||||
var log = logging.Logger("gen")
|
var log = logging.Logger("gen")
|
||||||
|
|
||||||
var ValidWpostForTesting = []abi.PoStProof{{
|
var ValidWpostForTesting = []proof.PoStProof{{
|
||||||
ProofBytes: []byte("valid proof"),
|
ProofBytes: []byte("valid proof"),
|
||||||
}}
|
}}
|
||||||
|
|
||||||
@@ -57,7 +59,7 @@ type ChainGen struct {
|
|||||||
|
|
||||||
cs *store.ChainStore
|
cs *store.ChainStore
|
||||||
|
|
||||||
beacon beacon.RandomBeacon
|
beacon beacon.Schedule
|
||||||
|
|
||||||
sm *stmgr.StateManager
|
sm *stmgr.StateManager
|
||||||
|
|
||||||
@@ -119,7 +121,7 @@ var DefaultRemainderAccountActor = genesis.Actor{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewGeneratorWithSectors(numSectors int) (*ChainGen, error) {
|
func NewGeneratorWithSectors(numSectors int) (*ChainGen, error) {
|
||||||
saminer.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{
|
miner0.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{
|
||||||
abi.RegisteredSealProof_StackedDrg2KiBV1: {},
|
abi.RegisteredSealProof_StackedDrg2KiBV1: {},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,7 +252,7 @@ func NewGeneratorWithSectors(numSectors int) (*ChainGen, error) {
|
|||||||
|
|
||||||
miners := []address.Address{maddr1, maddr2}
|
miners := []address.Address{maddr1, maddr2}
|
||||||
|
|
||||||
beac := beacon.NewMockBeacon(time.Second)
|
beac := beacon.Schedule{{Start: 0, Beacon: beacon.NewMockBeacon(time.Second)}}
|
||||||
//beac, err := drand.NewDrandBeacon(tpl.Timestamp, build.BlockDelaySecs)
|
//beac, err := drand.NewDrandBeacon(tpl.Timestamp, build.BlockDelaySecs)
|
||||||
//if err != nil {
|
//if err != nil {
|
||||||
//return nil, xerrors.Errorf("creating drand beacon: %w", err)
|
//return nil, xerrors.Errorf("creating drand beacon: %w", err)
|
||||||
@@ -336,7 +338,7 @@ func (cg *ChainGen) nextBlockProof(ctx context.Context, pts *types.TipSet, m add
|
|||||||
|
|
||||||
prev := mbi.PrevBeaconEntry
|
prev := mbi.PrevBeaconEntry
|
||||||
|
|
||||||
entries, err := beacon.BeaconEntriesForBlock(ctx, cg.beacon, round, prev)
|
entries, err := beacon.BeaconEntriesForBlock(ctx, cg.beacon, round, pts.Height(), prev)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, xerrors.Errorf("get beacon entries for block: %w", err)
|
return nil, nil, nil, xerrors.Errorf("get beacon entries for block: %w", err)
|
||||||
}
|
}
|
||||||
@@ -356,7 +358,7 @@ func (cg *ChainGen) nextBlockProof(ctx context.Context, pts *types.TipSet, m add
|
|||||||
return nil, nil, nil, xerrors.Errorf("failed to cbor marshal address: %w", err)
|
return nil, nil, nil, xerrors.Errorf("failed to cbor marshal address: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(entries) == 0 {
|
if round > build.UpgradeSmokeHeight {
|
||||||
buf.Write(pts.MinTicket().VRFProof)
|
buf.Write(pts.MinTicket().VRFProof)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -457,7 +459,7 @@ func (cg *ChainGen) NextTipSetFromMinersWithMessages(base *types.TipSet, miners
|
|||||||
|
|
||||||
func (cg *ChainGen) makeBlock(parents *types.TipSet, m address.Address, vrfticket *types.Ticket,
|
func (cg *ChainGen) makeBlock(parents *types.TipSet, m address.Address, vrfticket *types.Ticket,
|
||||||
eticket *types.ElectionProof, bvals []types.BeaconEntry, height abi.ChainEpoch,
|
eticket *types.ElectionProof, bvals []types.BeaconEntry, height abi.ChainEpoch,
|
||||||
wpost []abi.PoStProof, msgs []*types.SignedMessage) (*types.FullBlock, error) {
|
wpost []proof.PoStProof, msgs []*types.SignedMessage) (*types.FullBlock, error) {
|
||||||
|
|
||||||
var ts uint64
|
var ts uint64
|
||||||
if cg.Timestamper != nil {
|
if cg.Timestamper != nil {
|
||||||
@@ -487,13 +489,16 @@ func (cg *ChainGen) makeBlock(parents *types.TipSet, m address.Address, vrfticke
|
|||||||
// ResyncBankerNonce is used for dealing with messages made when
|
// ResyncBankerNonce is used for dealing with messages made when
|
||||||
// simulating forks
|
// simulating forks
|
||||||
func (cg *ChainGen) ResyncBankerNonce(ts *types.TipSet) error {
|
func (cg *ChainGen) ResyncBankerNonce(ts *types.TipSet) error {
|
||||||
var act types.Actor
|
st, err := cg.sm.ParentState(ts)
|
||||||
err := cg.sm.WithParentState(ts, cg.sm.WithActor(cg.banker, stmgr.GetActor(&act)))
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
act, err := st.GetActor(cg.banker)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
cg.bankerNonce = act.Nonce
|
cg.bankerNonce = act.Nonce
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -557,7 +562,7 @@ type mca struct {
|
|||||||
w *wallet.Wallet
|
w *wallet.Wallet
|
||||||
sm *stmgr.StateManager
|
sm *stmgr.StateManager
|
||||||
pv ffiwrapper.Verifier
|
pv ffiwrapper.Verifier
|
||||||
bcn beacon.RandomBeacon
|
bcn beacon.Schedule
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mca mca) ChainGetRandomnessFromTickets(ctx context.Context, tsk types.TipSetKey, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error) {
|
func (mca mca) ChainGetRandomnessFromTickets(ctx context.Context, tsk types.TipSetKey, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error) {
|
||||||
@@ -588,7 +593,7 @@ func (mca mca) WalletSign(ctx context.Context, a address.Address, v []byte) (*cr
|
|||||||
|
|
||||||
type WinningPoStProver interface {
|
type WinningPoStProver interface {
|
||||||
GenerateCandidates(context.Context, abi.PoStRandomness, uint64) ([]uint64, error)
|
GenerateCandidates(context.Context, abi.PoStRandomness, uint64) ([]uint64, error)
|
||||||
ComputeProof(context.Context, []abi.SectorInfo, abi.PoStRandomness) ([]abi.PoStProof, error)
|
ComputeProof(context.Context, []proof.SectorInfo, abi.PoStRandomness) ([]proof.PoStProof, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type wppProvider struct{}
|
type wppProvider struct{}
|
||||||
@@ -597,7 +602,7 @@ func (wpp *wppProvider) GenerateCandidates(ctx context.Context, _ abi.PoStRandom
|
|||||||
return []uint64{0}, nil
|
return []uint64{0}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wpp *wppProvider) ComputeProof(context.Context, []abi.SectorInfo, abi.PoStRandomness) ([]abi.PoStProof, error) {
|
func (wpp *wppProvider) ComputeProof(context.Context, []proof.SectorInfo, abi.PoStRandomness) ([]proof.PoStProof, error) {
|
||||||
return ValidWpostForTesting, nil
|
return ValidWpostForTesting, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -664,15 +669,15 @@ type genFakeVerifier struct{}
|
|||||||
|
|
||||||
var _ ffiwrapper.Verifier = (*genFakeVerifier)(nil)
|
var _ ffiwrapper.Verifier = (*genFakeVerifier)(nil)
|
||||||
|
|
||||||
func (m genFakeVerifier) VerifySeal(svi abi.SealVerifyInfo) (bool, error) {
|
func (m genFakeVerifier) VerifySeal(svi proof.SealVerifyInfo) (bool, error) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m genFakeVerifier) VerifyWinningPoSt(ctx context.Context, info abi.WinningPoStVerifyInfo) (bool, error) {
|
func (m genFakeVerifier) VerifyWinningPoSt(ctx context.Context, info proof.WinningPoStVerifyInfo) (bool, error) {
|
||||||
panic("not supported")
|
panic("not supported")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m genFakeVerifier) VerifyWindowPoSt(ctx context.Context, info abi.WindowPoStVerifyInfo) (bool, error) {
|
func (m genFakeVerifier) VerifyWindowPoSt(ctx context.Context, info proof.WindowPoStVerifyInfo) (bool, error) {
|
||||||
panic("not supported")
|
panic("not supported")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,22 +3,22 @@ package gen
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
"github.com/filecoin-project/go-state-types/big"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/power"
|
power0 "github.com/filecoin-project/specs-actors/actors/builtin/power"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
|
verifreg0 "github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
|
||||||
|
|
||||||
_ "github.com/filecoin-project/lotus/lib/sigs/bls"
|
_ "github.com/filecoin-project/lotus/lib/sigs/bls"
|
||||||
_ "github.com/filecoin-project/lotus/lib/sigs/secp"
|
_ "github.com/filecoin-project/lotus/lib/sigs/secp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
miner.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{
|
miner0.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{
|
||||||
abi.RegisteredSealProof_StackedDrg2KiBV1: {},
|
abi.RegisteredSealProof_StackedDrg2KiBV1: {},
|
||||||
}
|
}
|
||||||
power.ConsensusMinerMinPower = big.NewInt(2048)
|
power0.ConsensusMinerMinPower = big.NewInt(2048)
|
||||||
verifreg.MinVerifiedDealSize = big.NewInt(256)
|
verifreg0.MinVerifiedDealSize = big.NewInt(256)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testGeneration(t testing.TB, n int, msgs int, sectors int) {
|
func testGeneration(t testing.TB, n int, msgs int, sectors int) {
|
||||||
|
|||||||
@@ -14,16 +14,17 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
"github.com/filecoin-project/go-state-types/big"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
"github.com/filecoin-project/go-state-types/crypto"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/account"
|
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/multisig"
|
account0 "github.com/filecoin-project/specs-actors/actors/builtin/account"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
|
multisig0 "github.com/filecoin-project/specs-actors/actors/builtin/multisig"
|
||||||
"github.com/filecoin-project/specs-actors/actors/crypto"
|
verifreg0 "github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
|
||||||
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
adt0 "github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||||
"github.com/filecoin-project/lotus/chain/state"
|
"github.com/filecoin-project/lotus/chain/state"
|
||||||
"github.com/filecoin-project/lotus/chain/store"
|
"github.com/filecoin-project/lotus/chain/store"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
@@ -114,7 +115,7 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge
|
|||||||
return nil, nil, xerrors.Errorf("putting empty object: %w", err)
|
return nil, nil, xerrors.Errorf("putting empty object: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
state, err := state.NewStateTree(cst)
|
state, err := state.NewStateTree(cst, builtin.Version0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, xerrors.Errorf("making new state tree: %w", err)
|
return nil, nil, xerrors.Errorf("making new state tree: %w", err)
|
||||||
}
|
}
|
||||||
@@ -125,7 +126,7 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, xerrors.Errorf("setup init actor: %w", err)
|
return nil, nil, xerrors.Errorf("setup init actor: %w", err)
|
||||||
}
|
}
|
||||||
if err := state.SetActor(builtin.SystemActorAddr, sysact); err != nil {
|
if err := state.SetActor(builtin0.SystemActorAddr, sysact); err != nil {
|
||||||
return nil, nil, xerrors.Errorf("set init actor: %w", err)
|
return nil, nil, xerrors.Errorf("set init actor: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,7 +136,7 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, xerrors.Errorf("setup init actor: %w", err)
|
return nil, nil, xerrors.Errorf("setup init actor: %w", err)
|
||||||
}
|
}
|
||||||
if err := state.SetActor(builtin.InitActorAddr, initact); err != nil {
|
if err := state.SetActor(builtin0.InitActorAddr, initact); err != nil {
|
||||||
return nil, nil, xerrors.Errorf("set init actor: %w", err)
|
return nil, nil, xerrors.Errorf("set init actor: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,7 +147,7 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge
|
|||||||
return nil, nil, xerrors.Errorf("setup init actor: %w", err)
|
return nil, nil, xerrors.Errorf("setup init actor: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = state.SetActor(builtin.RewardActorAddr, rewact)
|
err = state.SetActor(builtin0.RewardActorAddr, rewact)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, xerrors.Errorf("set network account actor: %w", err)
|
return nil, nil, xerrors.Errorf("set network account actor: %w", err)
|
||||||
}
|
}
|
||||||
@@ -156,7 +157,7 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, xerrors.Errorf("setup cron actor: %w", err)
|
return nil, nil, xerrors.Errorf("setup cron actor: %w", err)
|
||||||
}
|
}
|
||||||
if err := state.SetActor(builtin.CronActorAddr, cronact); err != nil {
|
if err := state.SetActor(builtin0.CronActorAddr, cronact); err != nil {
|
||||||
return nil, nil, xerrors.Errorf("set cron actor: %w", err)
|
return nil, nil, xerrors.Errorf("set cron actor: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,7 +166,7 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, xerrors.Errorf("setup storage market actor: %w", err)
|
return nil, nil, xerrors.Errorf("setup storage market actor: %w", err)
|
||||||
}
|
}
|
||||||
if err := state.SetActor(builtin.StoragePowerActorAddr, spact); err != nil {
|
if err := state.SetActor(builtin0.StoragePowerActorAddr, spact); err != nil {
|
||||||
return nil, nil, xerrors.Errorf("set storage market actor: %w", err)
|
return nil, nil, xerrors.Errorf("set storage market actor: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,7 +175,7 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, xerrors.Errorf("setup storage market actor: %w", err)
|
return nil, nil, xerrors.Errorf("setup storage market actor: %w", err)
|
||||||
}
|
}
|
||||||
if err := state.SetActor(builtin.StorageMarketActorAddr, marketact); err != nil {
|
if err := state.SetActor(builtin0.StorageMarketActorAddr, marketact); err != nil {
|
||||||
return nil, nil, xerrors.Errorf("set market actor: %w", err)
|
return nil, nil, xerrors.Errorf("set market actor: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,20 +184,20 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, xerrors.Errorf("setup storage market actor: %w", err)
|
return nil, nil, xerrors.Errorf("setup storage market actor: %w", err)
|
||||||
}
|
}
|
||||||
if err := state.SetActor(builtin.VerifiedRegistryActorAddr, verifact); err != nil {
|
if err := state.SetActor(builtin0.VerifiedRegistryActorAddr, verifact); err != nil {
|
||||||
return nil, nil, xerrors.Errorf("set market actor: %w", err)
|
return nil, nil, xerrors.Errorf("set market actor: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
burntRoot, err := cst.Put(ctx, &account.State{
|
burntRoot, err := cst.Put(ctx, &account0.State{
|
||||||
Address: builtin.BurntFundsActorAddr,
|
Address: builtin0.BurntFundsActorAddr,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, xerrors.Errorf("failed to setup burnt funds actor state: %w", err)
|
return nil, nil, xerrors.Errorf("failed to setup burnt funds actor state: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup burnt-funds
|
// Setup burnt-funds
|
||||||
err = state.SetActor(builtin.BurntFundsActorAddr, &types.Actor{
|
err = state.SetActor(builtin0.BurntFundsActorAddr, &types.Actor{
|
||||||
Code: builtin.AccountActorCodeID,
|
Code: builtin0.AccountActorCodeID,
|
||||||
Balance: types.NewInt(0),
|
Balance: types.NewInt(0),
|
||||||
Head: burntRoot,
|
Head: burntRoot,
|
||||||
})
|
})
|
||||||
@@ -261,13 +262,13 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge
|
|||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
verifierState, err := cst.Put(ctx, &account.State{Address: verifierAd})
|
verifierState, err := cst.Put(ctx, &account0.State{Address: verifierAd})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = state.SetActor(verifierId, &types.Actor{
|
err = state.SetActor(verifierId, &types.Actor{
|
||||||
Code: builtin.AccountActorCodeID,
|
Code: builtin0.AccountActorCodeID,
|
||||||
Balance: types.NewInt(0),
|
Balance: types.NewInt(0),
|
||||||
Head: verifierState,
|
Head: verifierState,
|
||||||
})
|
})
|
||||||
@@ -314,7 +315,7 @@ func createAccountActor(ctx context.Context, cst cbor.IpldStore, state *state.St
|
|||||||
if err := json.Unmarshal(info.Meta, &ainfo); err != nil {
|
if err := json.Unmarshal(info.Meta, &ainfo); err != nil {
|
||||||
return xerrors.Errorf("unmarshaling account meta: %w", err)
|
return xerrors.Errorf("unmarshaling account meta: %w", err)
|
||||||
}
|
}
|
||||||
st, err := cst.Put(ctx, &account.State{Address: ainfo.Owner})
|
st, err := cst.Put(ctx, &account0.State{Address: ainfo.Owner})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -325,7 +326,7 @@ func createAccountActor(ctx context.Context, cst cbor.IpldStore, state *state.St
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = state.SetActor(ida, &types.Actor{
|
err = state.SetActor(ida, &types.Actor{
|
||||||
Code: builtin.AccountActorCodeID,
|
Code: builtin0.AccountActorCodeID,
|
||||||
Balance: info.Balance,
|
Balance: info.Balance,
|
||||||
Head: st,
|
Head: st,
|
||||||
})
|
})
|
||||||
@@ -343,7 +344,7 @@ func createMultisigAccount(ctx context.Context, bs bstore.Blockstore, cst cbor.I
|
|||||||
if err := json.Unmarshal(info.Meta, &ainfo); err != nil {
|
if err := json.Unmarshal(info.Meta, &ainfo); err != nil {
|
||||||
return xerrors.Errorf("unmarshaling account meta: %w", err)
|
return xerrors.Errorf("unmarshaling account meta: %w", err)
|
||||||
}
|
}
|
||||||
pending, err := adt.MakeEmptyMap(adt.WrapStore(ctx, cst)).Root()
|
pending, err := adt0.MakeEmptyMap(adt0.WrapStore(ctx, cst)).Root()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("failed to create empty map: %v", err)
|
return xerrors.Errorf("failed to create empty map: %v", err)
|
||||||
}
|
}
|
||||||
@@ -363,12 +364,12 @@ func createMultisigAccount(ctx context.Context, bs bstore.Blockstore, cst cbor.I
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
st, err := cst.Put(ctx, &account.State{Address: e})
|
st, err := cst.Put(ctx, &account0.State{Address: e})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = state.SetActor(idAddress, &types.Actor{
|
err = state.SetActor(idAddress, &types.Actor{
|
||||||
Code: builtin.AccountActorCodeID,
|
Code: builtin0.AccountActorCodeID,
|
||||||
Balance: types.NewInt(0),
|
Balance: types.NewInt(0),
|
||||||
Head: st,
|
Head: st,
|
||||||
})
|
})
|
||||||
@@ -378,7 +379,7 @@ func createMultisigAccount(ctx context.Context, bs bstore.Blockstore, cst cbor.I
|
|||||||
signers = append(signers, idAddress)
|
signers = append(signers, idAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
st, err := cst.Put(ctx, &multisig.State{
|
st, err := cst.Put(ctx, &multisig0.State{
|
||||||
Signers: signers,
|
Signers: signers,
|
||||||
NumApprovalsThreshold: uint64(ainfo.Threshold),
|
NumApprovalsThreshold: uint64(ainfo.Threshold),
|
||||||
StartEpoch: abi.ChainEpoch(ainfo.VestingStart),
|
StartEpoch: abi.ChainEpoch(ainfo.VestingStart),
|
||||||
@@ -390,7 +391,7 @@ func createMultisigAccount(ctx context.Context, bs bstore.Blockstore, cst cbor.I
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = state.SetActor(ida, &types.Actor{
|
err = state.SetActor(ida, &types.Actor{
|
||||||
Code: builtin.MultisigActorCodeID,
|
Code: builtin0.MultisigActorCodeID,
|
||||||
Balance: info.Balance,
|
Balance: info.Balance,
|
||||||
Head: st,
|
Head: st,
|
||||||
})
|
})
|
||||||
@@ -411,9 +412,10 @@ func VerifyPreSealedData(ctx context.Context, cs *store.ChainStore, stateroot ci
|
|||||||
Bstore: cs.Blockstore(),
|
Bstore: cs.Blockstore(),
|
||||||
Syscalls: mkFakedSigSyscalls(cs.VMSys()),
|
Syscalls: mkFakedSigSyscalls(cs.VMSys()),
|
||||||
CircSupplyCalc: nil,
|
CircSupplyCalc: nil,
|
||||||
|
NtwkVersion: genesisNetworkVersion,
|
||||||
BaseFee: types.NewInt(0),
|
BaseFee: types.NewInt(0),
|
||||||
}
|
}
|
||||||
vm, err := vm.NewVM(&vmopt)
|
vm, err := vm.NewVM(ctx, &vmopt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cid.Undef, xerrors.Errorf("failed to create NewVM: %w", err)
|
return cid.Undef, xerrors.Errorf("failed to create NewVM: %w", err)
|
||||||
}
|
}
|
||||||
@@ -440,7 +442,7 @@ func VerifyPreSealedData(ctx context.Context, cs *store.ChainStore, stateroot ci
|
|||||||
return cid.Undef, err
|
return cid.Undef, err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = doExecValue(ctx, vm, builtin.VerifiedRegistryActorAddr, verifregRoot, types.NewInt(0), builtin.MethodsVerifiedRegistry.AddVerifier, mustEnc(&verifreg.AddVerifierParams{
|
_, err = doExecValue(ctx, vm, builtin0.VerifiedRegistryActorAddr, verifregRoot, types.NewInt(0), builtin0.MethodsVerifiedRegistry.AddVerifier, mustEnc(&verifreg0.AddVerifierParams{
|
||||||
|
|
||||||
Address: verifier,
|
Address: verifier,
|
||||||
Allowance: abi.NewStoragePower(int64(sum)), // eh, close enough
|
Allowance: abi.NewStoragePower(int64(sum)), // eh, close enough
|
||||||
@@ -451,7 +453,7 @@ func VerifyPreSealedData(ctx context.Context, cs *store.ChainStore, stateroot ci
|
|||||||
}
|
}
|
||||||
|
|
||||||
for c, amt := range verifNeeds {
|
for c, amt := range verifNeeds {
|
||||||
_, err := doExecValue(ctx, vm, builtin.VerifiedRegistryActorAddr, verifier, types.NewInt(0), builtin.MethodsVerifiedRegistry.AddVerifiedClient, mustEnc(&verifreg.AddVerifiedClientParams{
|
_, err := doExecValue(ctx, vm, builtin0.VerifiedRegistryActorAddr, verifier, types.NewInt(0), builtin0.MethodsVerifiedRegistry.AddVerifiedClient, mustEnc(&verifreg0.AddVerifiedClientParams{
|
||||||
Address: c,
|
Address: c,
|
||||||
Allowance: abi.NewStoragePower(int64(amt)),
|
Allowance: abi.NewStoragePower(int64(amt)),
|
||||||
}))
|
}))
|
||||||
@@ -493,8 +495,8 @@ func MakeGenesisBlock(ctx context.Context, bs bstore.Blockstore, sys vm.SyscallB
|
|||||||
return nil, xerrors.Errorf("setup miners failed: %w", err)
|
return nil, xerrors.Errorf("setup miners failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
store := adt.WrapStore(ctx, cbor.NewCborStore(bs))
|
store := adt0.WrapStore(ctx, cbor.NewCborStore(bs))
|
||||||
emptyroot, err := adt.MakeEmptyArray(store).Root()
|
emptyroot, err := adt0.MakeEmptyArray(store).Root()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("amt build failed: %w", err)
|
return nil, xerrors.Errorf("amt build failed: %w", err)
|
||||||
}
|
}
|
||||||
@@ -542,7 +544,7 @@ func MakeGenesisBlock(ctx context.Context, bs bstore.Blockstore, sys vm.SyscallB
|
|||||||
}
|
}
|
||||||
|
|
||||||
b := &types.BlockHeader{
|
b := &types.BlockHeader{
|
||||||
Miner: builtin.SystemActorAddr,
|
Miner: builtin0.SystemActorAddr,
|
||||||
Ticket: genesisticket,
|
Ticket: genesisticket,
|
||||||
Parents: []cid.Cid{filecoinGenesisCid},
|
Parents: []cid.Cid{filecoinGenesisCid},
|
||||||
Height: 0,
|
Height: 0,
|
||||||
|
|||||||
+46
-38
@@ -6,7 +6,13 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/state"
|
market0 "github.com/filecoin-project/specs-actors/actors/builtin/market"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/builtin/power"
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/builtin/reward"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/builtin/market"
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
||||||
|
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
cbor "github.com/ipfs/go-ipld-cbor"
|
cbor "github.com/ipfs/go-ipld-cbor"
|
||||||
@@ -14,17 +20,17 @@ import (
|
|||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
"github.com/filecoin-project/go-state-types/big"
|
||||||
|
"github.com/filecoin-project/go-state-types/crypto"
|
||||||
"github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper"
|
"github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/market"
|
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
power0 "github.com/filecoin-project/specs-actors/actors/builtin/power"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/power"
|
reward0 "github.com/filecoin-project/specs-actors/actors/builtin/reward"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/reward"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/crypto"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/runtime"
|
"github.com/filecoin-project/specs-actors/actors/runtime"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/state"
|
||||||
"github.com/filecoin-project/lotus/chain/store"
|
"github.com/filecoin-project/lotus/chain/store"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/chain/vm"
|
"github.com/filecoin-project/lotus/chain/vm"
|
||||||
@@ -68,10 +74,11 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
|
|||||||
Bstore: cs.Blockstore(),
|
Bstore: cs.Blockstore(),
|
||||||
Syscalls: mkFakedSigSyscalls(cs.VMSys()),
|
Syscalls: mkFakedSigSyscalls(cs.VMSys()),
|
||||||
CircSupplyCalc: csc,
|
CircSupplyCalc: csc,
|
||||||
|
NtwkVersion: genesisNetworkVersion,
|
||||||
BaseFee: types.NewInt(0),
|
BaseFee: types.NewInt(0),
|
||||||
}
|
}
|
||||||
|
|
||||||
vm, err := vm.NewVM(vmopt)
|
vm, err := vm.NewVM(ctx, vmopt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cid.Undef, xerrors.Errorf("failed to create NewVM: %w", err)
|
return cid.Undef, xerrors.Errorf("failed to create NewVM: %w", err)
|
||||||
}
|
}
|
||||||
@@ -99,7 +106,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
constructorParams := &power.CreateMinerParams{
|
constructorParams := &power0.CreateMinerParams{
|
||||||
Owner: m.Worker,
|
Owner: m.Worker,
|
||||||
Worker: m.Worker,
|
Worker: m.Worker,
|
||||||
Peer: []byte(m.PeerId),
|
Peer: []byte(m.PeerId),
|
||||||
@@ -107,12 +114,12 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
|
|||||||
}
|
}
|
||||||
|
|
||||||
params := mustEnc(constructorParams)
|
params := mustEnc(constructorParams)
|
||||||
rval, err := doExecValue(ctx, vm, builtin.StoragePowerActorAddr, m.Owner, m.PowerBalance, builtin.MethodsPower.CreateMiner, params)
|
rval, err := doExecValue(ctx, vm, power.Address, m.Owner, m.PowerBalance, builtin.MethodsPower.CreateMiner, params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cid.Undef, xerrors.Errorf("failed to create genesis miner: %w", err)
|
return cid.Undef, xerrors.Errorf("failed to create genesis miner: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var ma power.CreateMinerReturn
|
var ma power0.CreateMinerReturn
|
||||||
if err := ma.UnmarshalCBOR(bytes.NewReader(rval)); err != nil {
|
if err := ma.UnmarshalCBOR(bytes.NewReader(rval)); err != nil {
|
||||||
return cid.Undef, xerrors.Errorf("unmarshaling CreateMinerReturn: %w", err)
|
return cid.Undef, xerrors.Errorf("unmarshaling CreateMinerReturn: %w", err)
|
||||||
}
|
}
|
||||||
@@ -123,9 +130,10 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
|
|||||||
}
|
}
|
||||||
minerInfos[i].maddr = ma.IDAddress
|
minerInfos[i].maddr = ma.IDAddress
|
||||||
|
|
||||||
err = vm.MutateState(ctx, minerInfos[i].maddr, func(cst cbor.IpldStore, st *miner.State) error {
|
// TODO: ActorUpgrade
|
||||||
maxPeriods := miner.MaxSectorExpirationExtension / miner.WPoStProvingPeriod
|
err = vm.MutateState(ctx, minerInfos[i].maddr, func(cst cbor.IpldStore, st *miner0.State) error {
|
||||||
minerInfos[i].presealExp = (maxPeriods-1)*miner.WPoStProvingPeriod + st.ProvingPeriodStart - 1
|
maxPeriods := miner0.MaxSectorExpirationExtension / miner0.WPoStProvingPeriod
|
||||||
|
minerInfos[i].presealExp = (maxPeriods-1)*miner0.WPoStProvingPeriod + st.ProvingPeriodStart - 1
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
@@ -138,7 +146,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
|
|||||||
|
|
||||||
if m.MarketBalance.GreaterThan(big.Zero()) {
|
if m.MarketBalance.GreaterThan(big.Zero()) {
|
||||||
params := mustEnc(&minerInfos[i].maddr)
|
params := mustEnc(&minerInfos[i].maddr)
|
||||||
_, err := doExecValue(ctx, vm, builtin.StorageMarketActorAddr, m.Worker, m.MarketBalance, builtin.MethodsMarket.AddBalance, params)
|
_, err := doExecValue(ctx, vm, market.Address, m.Worker, m.MarketBalance, builtin.MethodsMarket.AddBalance, params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cid.Undef, xerrors.Errorf("failed to create genesis miner (add balance): %w", err)
|
return cid.Undef, xerrors.Errorf("failed to create genesis miner (add balance): %w", err)
|
||||||
}
|
}
|
||||||
@@ -150,7 +158,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
|
|||||||
publish := func(params *market.PublishStorageDealsParams) error {
|
publish := func(params *market.PublishStorageDealsParams) error {
|
||||||
fmt.Printf("publishing %d storage deals on miner %s with worker %s\n", len(params.Deals), params.Deals[0].Proposal.Provider, m.Worker)
|
fmt.Printf("publishing %d storage deals on miner %s with worker %s\n", len(params.Deals), params.Deals[0].Proposal.Provider, m.Worker)
|
||||||
|
|
||||||
ret, err := doExecValue(ctx, vm, builtin.StorageMarketActorAddr, m.Worker, big.Zero(), builtin.MethodsMarket.PublishStorageDeals, mustEnc(params))
|
ret, err := doExecValue(ctx, vm, market.Address, m.Worker, big.Zero(), builtin.MethodsMarket.PublishStorageDeals, mustEnc(params))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("failed to create genesis miner (publish deals): %w", err)
|
return xerrors.Errorf("failed to create genesis miner (publish deals): %w", err)
|
||||||
}
|
}
|
||||||
@@ -201,13 +209,13 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
|
|||||||
return cid.Undef, xerrors.Errorf("getting deal weight: %w", err)
|
return cid.Undef, xerrors.Errorf("getting deal weight: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
sectorWeight := miner.QAPowerForWeight(m.SectorSize, minerInfos[i].presealExp, dweight.DealWeight, dweight.VerifiedDealWeight)
|
sectorWeight := miner0.QAPowerForWeight(m.SectorSize, minerInfos[i].presealExp, dweight.DealWeight, dweight.VerifiedDealWeight)
|
||||||
|
|
||||||
qaPow = types.BigAdd(qaPow, sectorWeight)
|
qaPow = types.BigAdd(qaPow, sectorWeight)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = vm.MutateState(ctx, builtin.StoragePowerActorAddr, func(cst cbor.IpldStore, st *power.State) error {
|
err = vm.MutateState(ctx, power.Address, func(cst cbor.IpldStore, st *power0.State) error {
|
||||||
st.TotalQualityAdjPower = qaPow
|
st.TotalQualityAdjPower = qaPow
|
||||||
st.TotalRawBytePower = rawPow
|
st.TotalRawBytePower = rawPow
|
||||||
|
|
||||||
@@ -219,8 +227,8 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
|
|||||||
return cid.Undef, xerrors.Errorf("mutating state: %w", err)
|
return cid.Undef, xerrors.Errorf("mutating state: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = vm.MutateState(ctx, builtin.RewardActorAddr, func(sct cbor.IpldStore, st *reward.State) error {
|
err = vm.MutateState(ctx, reward.Address, func(sct cbor.IpldStore, st *reward0.State) error {
|
||||||
*st = *reward.ConstructState(qaPow)
|
*st = *reward0.ConstructState(qaPow)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -246,10 +254,10 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
|
|||||||
return cid.Undef, xerrors.Errorf("getting deal weight: %w", err)
|
return cid.Undef, xerrors.Errorf("getting deal weight: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
sectorWeight := miner.QAPowerForWeight(m.SectorSize, minerInfos[i].presealExp, dweight.DealWeight, dweight.VerifiedDealWeight)
|
sectorWeight := miner0.QAPowerForWeight(m.SectorSize, minerInfos[i].presealExp, dweight.DealWeight, dweight.VerifiedDealWeight)
|
||||||
|
|
||||||
// we've added fake power for this sector above, remove it now
|
// we've added fake power for this sector above, remove it now
|
||||||
err = vm.MutateState(ctx, builtin.StoragePowerActorAddr, func(cst cbor.IpldStore, st *power.State) error {
|
err = vm.MutateState(ctx, power.Address, func(cst cbor.IpldStore, st *power0.State) error {
|
||||||
st.TotalQualityAdjPower = types.BigSub(st.TotalQualityAdjPower, sectorWeight) //nolint:scopelint
|
st.TotalQualityAdjPower = types.BigSub(st.TotalQualityAdjPower, sectorWeight) //nolint:scopelint
|
||||||
st.TotalRawBytePower = types.BigSub(st.TotalRawBytePower, types.NewInt(uint64(m.SectorSize)))
|
st.TotalRawBytePower = types.BigSub(st.TotalRawBytePower, types.NewInt(uint64(m.SectorSize)))
|
||||||
return nil
|
return nil
|
||||||
@@ -268,9 +276,9 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
|
|||||||
return cid.Undef, xerrors.Errorf("getting current total power: %w", err)
|
return cid.Undef, xerrors.Errorf("getting current total power: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
pcd := miner.PreCommitDepositForPower(epochReward.ThisEpochRewardSmoothed, tpow.QualityAdjPowerSmoothed, sectorWeight)
|
pcd := miner0.PreCommitDepositForPower(epochReward.ThisEpochRewardSmoothed, tpow.QualityAdjPowerSmoothed, sectorWeight)
|
||||||
|
|
||||||
pledge := miner.InitialPledgeForPower(
|
pledge := miner0.InitialPledgeForPower(
|
||||||
sectorWeight,
|
sectorWeight,
|
||||||
epochReward.ThisEpochBaselinePower,
|
epochReward.ThisEpochBaselinePower,
|
||||||
tpow.PledgeCollateral,
|
tpow.PledgeCollateral,
|
||||||
@@ -292,7 +300,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
|
|||||||
Sectors: []abi.SectorNumber{preseal.SectorID},
|
Sectors: []abi.SectorNumber{preseal.SectorID},
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = doExecValue(ctx, vm, minerInfos[i].maddr, builtin.StoragePowerActorAddr, big.Zero(), builtin.MethodsMiner.ConfirmSectorProofsValid, mustEnc(confirmParams))
|
_, err = doExecValue(ctx, vm, minerInfos[i].maddr, power.Address, big.Zero(), builtin.MethodsMiner.ConfirmSectorProofsValid, mustEnc(confirmParams))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cid.Undef, xerrors.Errorf("failed to confirm presealed sectors: %w", err)
|
return cid.Undef, xerrors.Errorf("failed to confirm presealed sectors: %w", err)
|
||||||
}
|
}
|
||||||
@@ -301,7 +309,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sanity-check total network power
|
// Sanity-check total network power
|
||||||
err = vm.MutateState(ctx, builtin.StoragePowerActorAddr, func(cst cbor.IpldStore, st *power.State) error {
|
err = vm.MutateState(ctx, power.Address, func(cst cbor.IpldStore, st *power0.State) error {
|
||||||
if !st.TotalRawBytePower.Equals(rawPow) {
|
if !st.TotalRawBytePower.Equals(rawPow) {
|
||||||
return xerrors.Errorf("st.TotalRawBytePower doesn't match previously calculated rawPow")
|
return xerrors.Errorf("st.TotalRawBytePower doesn't match previously calculated rawPow")
|
||||||
}
|
}
|
||||||
@@ -340,12 +348,12 @@ func (fr *fakeRand) GetBeaconRandomness(ctx context.Context, personalization cry
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func currentTotalPower(ctx context.Context, vm *vm.VM, maddr address.Address) (*power.CurrentTotalPowerReturn, error) {
|
func currentTotalPower(ctx context.Context, vm *vm.VM, maddr address.Address) (*power0.CurrentTotalPowerReturn, error) {
|
||||||
pwret, err := doExecValue(ctx, vm, builtin.StoragePowerActorAddr, maddr, big.Zero(), builtin.MethodsPower.CurrentTotalPower, nil)
|
pwret, err := doExecValue(ctx, vm, power.Address, maddr, big.Zero(), builtin.MethodsPower.CurrentTotalPower, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var pwr power.CurrentTotalPowerReturn
|
var pwr power0.CurrentTotalPowerReturn
|
||||||
if err := pwr.UnmarshalCBOR(bytes.NewReader(pwret)); err != nil {
|
if err := pwr.UnmarshalCBOR(bytes.NewReader(pwret)); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -353,38 +361,38 @@ func currentTotalPower(ctx context.Context, vm *vm.VM, maddr address.Address) (*
|
|||||||
return &pwr, nil
|
return &pwr, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func dealWeight(ctx context.Context, vm *vm.VM, maddr address.Address, dealIDs []abi.DealID, sectorStart, sectorExpiry abi.ChainEpoch) (market.VerifyDealsForActivationReturn, error) {
|
func dealWeight(ctx context.Context, vm *vm.VM, maddr address.Address, dealIDs []abi.DealID, sectorStart, sectorExpiry abi.ChainEpoch) (market0.VerifyDealsForActivationReturn, error) {
|
||||||
params := &market.VerifyDealsForActivationParams{
|
params := &market.VerifyDealsForActivationParams{
|
||||||
DealIDs: dealIDs,
|
DealIDs: dealIDs,
|
||||||
SectorStart: sectorStart,
|
SectorStart: sectorStart,
|
||||||
SectorExpiry: sectorExpiry,
|
SectorExpiry: sectorExpiry,
|
||||||
}
|
}
|
||||||
|
|
||||||
var dealWeights market.VerifyDealsForActivationReturn
|
var dealWeights market0.VerifyDealsForActivationReturn
|
||||||
ret, err := doExecValue(ctx, vm,
|
ret, err := doExecValue(ctx, vm,
|
||||||
builtin.StorageMarketActorAddr,
|
market.Address,
|
||||||
maddr,
|
maddr,
|
||||||
abi.NewTokenAmount(0),
|
abi.NewTokenAmount(0),
|
||||||
builtin.MethodsMarket.VerifyDealsForActivation,
|
builtin.MethodsMarket.VerifyDealsForActivation,
|
||||||
mustEnc(params),
|
mustEnc(params),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return market.VerifyDealsForActivationReturn{}, err
|
return market0.VerifyDealsForActivationReturn{}, err
|
||||||
}
|
}
|
||||||
if err := dealWeights.UnmarshalCBOR(bytes.NewReader(ret)); err != nil {
|
if err := dealWeights.UnmarshalCBOR(bytes.NewReader(ret)); err != nil {
|
||||||
return market.VerifyDealsForActivationReturn{}, err
|
return market0.VerifyDealsForActivationReturn{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return dealWeights, nil
|
return dealWeights, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func currentEpochBlockReward(ctx context.Context, vm *vm.VM, maddr address.Address) (*reward.ThisEpochRewardReturn, error) {
|
func currentEpochBlockReward(ctx context.Context, vm *vm.VM, maddr address.Address) (*reward0.ThisEpochRewardReturn, error) {
|
||||||
rwret, err := doExecValue(ctx, vm, builtin.RewardActorAddr, maddr, big.Zero(), builtin.MethodsReward.ThisEpochReward, nil)
|
rwret, err := doExecValue(ctx, vm, reward.Address, maddr, big.Zero(), builtin.MethodsReward.ThisEpochReward, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var epochReward reward.ThisEpochRewardReturn
|
var epochReward reward0.ThisEpochRewardReturn
|
||||||
if err := epochReward.UnmarshalCBOR(bytes.NewReader(rwret)); err != nil {
|
if err := epochReward.UnmarshalCBOR(bytes.NewReader(rwret)); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||||
@@ -50,7 +51,7 @@ func SetupInitActor(bs bstore.Blockstore, netname string, initialActors []genesi
|
|||||||
fmt.Printf("init set %s t0%d\n", e, counter)
|
fmt.Printf("init set %s t0%d\n", e, counter)
|
||||||
|
|
||||||
value := cbg.CborInt(counter)
|
value := cbg.CborInt(counter)
|
||||||
if err := amap.Put(adt.AddrKey(e), &value); err != nil {
|
if err := amap.Put(abi.AddrKey(e), &value); err != nil {
|
||||||
return 0, nil, nil, err
|
return 0, nil, nil, err
|
||||||
}
|
}
|
||||||
counter = counter + 1
|
counter = counter + 1
|
||||||
@@ -77,7 +78,7 @@ func SetupInitActor(bs bstore.Blockstore, netname string, initialActors []genesi
|
|||||||
fmt.Printf("init set %s t0%d\n", ainfo.Owner, counter)
|
fmt.Printf("init set %s t0%d\n", ainfo.Owner, counter)
|
||||||
|
|
||||||
value := cbg.CborInt(counter)
|
value := cbg.CborInt(counter)
|
||||||
if err := amap.Put(adt.AddrKey(ainfo.Owner), &value); err != nil {
|
if err := amap.Put(abi.AddrKey(ainfo.Owner), &value); err != nil {
|
||||||
return 0, nil, nil, err
|
return 0, nil, nil, err
|
||||||
}
|
}
|
||||||
counter = counter + 1
|
counter = counter + 1
|
||||||
@@ -95,7 +96,7 @@ func SetupInitActor(bs bstore.Blockstore, netname string, initialActors []genesi
|
|||||||
return 0, nil, nil, xerrors.Errorf("unmarshaling account meta: %w", err)
|
return 0, nil, nil, xerrors.Errorf("unmarshaling account meta: %w", err)
|
||||||
}
|
}
|
||||||
value := cbg.CborInt(80)
|
value := cbg.CborInt(80)
|
||||||
if err := amap.Put(adt.AddrKey(ainfo.Owner), &value); err != nil {
|
if err := amap.Put(abi.AddrKey(ainfo.Owner), &value); err != nil {
|
||||||
return 0, nil, nil, err
|
return 0, nil, nil, err
|
||||||
}
|
}
|
||||||
} else if rootVerifier.Type == genesis.TMultisig {
|
} else if rootVerifier.Type == genesis.TMultisig {
|
||||||
@@ -110,7 +111,7 @@ func SetupInitActor(bs bstore.Blockstore, netname string, initialActors []genesi
|
|||||||
fmt.Printf("init set %s t0%d\n", e, counter)
|
fmt.Printf("init set %s t0%d\n", e, counter)
|
||||||
|
|
||||||
value := cbg.CborInt(counter)
|
value := cbg.CborInt(counter)
|
||||||
if err := amap.Put(adt.AddrKey(e), &value); err != nil {
|
if err := amap.Put(abi.AddrKey(e), &value); err != nil {
|
||||||
return 0, nil, nil, err
|
return 0, nil, nil, err
|
||||||
}
|
}
|
||||||
counter = counter + 1
|
counter = counter + 1
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ package genesis
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
"github.com/filecoin-project/go-state-types/big"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/reward"
|
reward0 "github.com/filecoin-project/specs-actors/actors/builtin/reward"
|
||||||
cbor "github.com/ipfs/go-ipld-cbor"
|
cbor "github.com/ipfs/go-ipld-cbor"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
@@ -17,7 +17,7 @@ import (
|
|||||||
func SetupRewardActor(bs bstore.Blockstore, qaPower big.Int) (*types.Actor, error) {
|
func SetupRewardActor(bs bstore.Blockstore, qaPower big.Int) (*types.Actor, error) {
|
||||||
cst := cbor.NewCborStore(bs)
|
cst := cbor.NewCborStore(bs)
|
||||||
|
|
||||||
st := reward.ConstructState(qaPower)
|
st := reward0.ConstructState(qaPower)
|
||||||
|
|
||||||
hcid, err := cst.Put(context.TODO(), st)
|
hcid, err := cst.Put(context.TODO(), st)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/power"
|
power0 "github.com/filecoin-project/specs-actors/actors/builtin/power"
|
||||||
cbor "github.com/ipfs/go-ipld-cbor"
|
cbor "github.com/ipfs/go-ipld-cbor"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
@@ -30,7 +30,7 @@ func SetupStoragePowerActor(bs bstore.Blockstore) (*types.Actor, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
sms := power.ConstructState(emptyMap, emptyMultiMap)
|
sms := power0.ConstructState(emptyMap, emptyMultiMap)
|
||||||
|
|
||||||
stcid, err := store.Put(store.Context(), sms)
|
stcid, err := store.Put(store.Context(), sms)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
cbor "github.com/ipfs/go-ipld-cbor"
|
cbor "github.com/ipfs/go-ipld-cbor"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
|
verifreg0 "github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
|
||||||
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
@@ -34,7 +34,7 @@ func SetupVerifiedRegistryActor(bs bstore.Blockstore) (*types.Actor, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
sms := verifreg.ConstructState(h, RootVerifierID)
|
sms := verifreg0.ConstructState(h, RootVerifierID)
|
||||||
|
|
||||||
stcid, err := store.Put(store.Context(), sms)
|
stcid, err := store.Put(store.Context(), sms)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -3,8 +3,11 @@ package genesis
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-state-types/network"
|
||||||
|
"github.com/filecoin-project/lotus/build"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
cbg "github.com/whyrusleeping/cbor-gen"
|
cbg "github.com/whyrusleeping/cbor-gen"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
@@ -46,3 +49,14 @@ func doExecValue(ctx context.Context, vm *vm.VM, to, from address.Address, value
|
|||||||
|
|
||||||
return ret.Return, nil
|
return ret.Return, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var GenesisNetworkVersion = func() network.Version { // TODO: Get from build/
|
||||||
|
if build.UseNewestNetwork() { // TODO: Get from build/
|
||||||
|
return build.NewestNetworkVersion // TODO: Get from build/
|
||||||
|
} // TODO: Get from build/
|
||||||
|
return network.Version1 // TODO: Get from build/
|
||||||
|
}() // TODO: Get from build/
|
||||||
|
|
||||||
|
func genesisNetworkVersion(context.Context, abi.ChainEpoch) network.Version { // TODO: Get from build/
|
||||||
|
return GenesisNetworkVersion // TODO: Get from build/
|
||||||
|
} // TODO: Get from build/
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ package gen
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/crypto"
|
"github.com/filecoin-project/go-state-types/crypto"
|
||||||
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||||
cid "github.com/ipfs/go-cid"
|
cid "github.com/ipfs/go-cid"
|
||||||
cbor "github.com/ipfs/go-ipld-cbor"
|
cbor "github.com/ipfs/go-ipld-cbor"
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import (
|
|||||||
ds "github.com/ipfs/go-datastore"
|
ds "github.com/ipfs/go-datastore"
|
||||||
"github.com/ipfs/go-datastore/namespace"
|
"github.com/ipfs/go-datastore/namespace"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type SlashFilter struct {
|
type SlashFilter struct {
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
"github.com/filecoin-project/go-state-types/big"
|
||||||
"go.uber.org/fx"
|
"go.uber.org/fx"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
@@ -15,6 +15,7 @@ import (
|
|||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/chain/actors"
|
"github.com/filecoin-project/lotus/chain/actors"
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/builtin/market"
|
||||||
"github.com/filecoin-project/lotus/chain/events"
|
"github.com/filecoin-project/lotus/chain/events"
|
||||||
"github.com/filecoin-project/lotus/chain/events/state"
|
"github.com/filecoin-project/lotus/chain/events/state"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
@@ -151,7 +152,7 @@ func (fm *FundMgr) EnsureAvailable(ctx context.Context, addr, wallet address.Add
|
|||||||
}
|
}
|
||||||
|
|
||||||
smsg, err := fm.api.MpoolPushMessage(ctx, &types.Message{
|
smsg, err := fm.api.MpoolPushMessage(ctx, &types.Message{
|
||||||
To: builtin.StorageMarketActorAddr,
|
To: market.Address,
|
||||||
From: wallet,
|
From: wallet,
|
||||||
Value: toAdd,
|
Value: toAdd,
|
||||||
Method: builtin.MethodsMarket.AddBalance,
|
Method: builtin.MethodsMarket.AddBalance,
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user