From 43c62f4406298b892fa7a8ca87dfe1f89de162ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Wed, 26 May 2021 12:33:08 +0200 Subject: [PATCH] Revert "Allow starting networks from arbitrary actor versions" --- build/openrpc/full.json.gz | Bin 23305 -> 23308 bytes build/params_2k.go | 20 +- build/params_shared_vals.go | 2 +- chain/actors/adt/temp | 0 chain/actors/aerrors/temp | 0 chain/actors/agen/main.go | 72 ++-- chain/actors/agen/temp | 0 chain/actors/builtin/account/account.go | 41 --- .../actors/builtin/account/actor.go.template | 23 -- .../actors/builtin/account/state.go.template | 10 - chain/actors/builtin/account/temp | 0 chain/actors/builtin/account/v0.go | 10 - chain/actors/builtin/account/v2.go | 10 - chain/actors/builtin/account/v3.go | 10 - chain/actors/builtin/account/v4.go | 10 - chain/actors/builtin/builtin.go.template | 94 ++--- chain/actors/builtin/cron/actor.go.template | 34 +- chain/actors/builtin/cron/cron.go | 54 --- chain/actors/builtin/cron/state.go.template | 35 -- chain/actors/builtin/cron/temp | 0 chain/actors/builtin/cron/v0.go | 35 -- chain/actors/builtin/cron/v2.go | 35 -- chain/actors/builtin/cron/v3.go | 35 -- chain/actors/builtin/cron/v4.go | 35 -- chain/actors/builtin/init/actor.go.template | 31 +- chain/actors/builtin/init/diff.go | 4 +- chain/actors/builtin/init/init.go | 49 +-- chain/actors/builtin/init/state.go.template | 38 +- chain/actors/builtin/init/temp | 0 chain/actors/builtin/init/v0.go | 31 +- chain/actors/builtin/init/v2.go | 31 +- chain/actors/builtin/init/v3.go | 31 +- chain/actors/builtin/init/v4.go | 31 +- chain/actors/builtin/market/actor.go.template | 80 ++--- chain/actors/builtin/market/market.go | 42 +-- chain/actors/builtin/market/state.go.template | 29 -- chain/actors/builtin/market/temp | 0 chain/actors/builtin/market/v0.go | 22 -- chain/actors/builtin/market/v2.go | 22 -- chain/actors/builtin/market/v3.go | 17 - chain/actors/builtin/market/v4.go | 17 - chain/actors/builtin/miner/actor.go.template | 86 ++--- chain/actors/builtin/miner/miner.go | 46 --- chain/actors/builtin/miner/state.go.template | 101 ++---- chain/actors/builtin/miner/temp | 0 chain/actors/builtin/miner/v0.go | 21 -- chain/actors/builtin/miner/v2.go | 51 --- chain/actors/builtin/miner/v3.go | 51 --- chain/actors/builtin/miner/v4.go | 51 --- .../actors/builtin/multisig/actor.go.template | 24 +- .../builtin/multisig/message.go.template | 36 +- chain/actors/builtin/multisig/multisig.go | 40 --- .../actors/builtin/multisig/state.go.template | 30 -- chain/actors/builtin/multisig/temp | 0 chain/actors/builtin/multisig/v0.go | 23 -- chain/actors/builtin/multisig/v2.go | 23 -- chain/actors/builtin/multisig/v3.go | 23 -- chain/actors/builtin/multisig/v4.go | 23 -- chain/actors/builtin/paych/actor.go.template | 23 -- .../actors/builtin/paych/message.go.template | 28 +- chain/actors/builtin/paych/mock/mock.go | 4 - chain/actors/builtin/paych/mock/temp | 0 chain/actors/builtin/paych/paych.go | 41 --- chain/actors/builtin/paych/state.go.template | 10 - chain/actors/builtin/paych/temp | 0 chain/actors/builtin/paych/v0.go | 10 - chain/actors/builtin/paych/v2.go | 10 - chain/actors/builtin/paych/v3.go | 10 - chain/actors/builtin/paych/v4.go | 10 - chain/actors/builtin/power/actor.go.template | 31 +- chain/actors/builtin/power/power.go | 47 --- chain/actors/builtin/power/state.go.template | 60 +--- chain/actors/builtin/power/temp | 0 chain/actors/builtin/power/v0.go | 42 --- chain/actors/builtin/power/v2.go | 42 --- chain/actors/builtin/power/v3.go | 37 -- chain/actors/builtin/power/v4.go | 37 -- chain/actors/builtin/reward/actor.go.template | 23 -- chain/actors/builtin/reward/reward.go | 41 --- chain/actors/builtin/reward/state.go.template | 10 - chain/actors/builtin/reward/temp | 0 chain/actors/builtin/reward/v0.go | 10 - chain/actors/builtin/reward/v2.go | 10 - chain/actors/builtin/reward/v3.go | 10 - chain/actors/builtin/reward/v4.go | 10 - chain/actors/builtin/system/actor.go.template | 41 --- chain/actors/builtin/system/state.go.template | 35 -- chain/actors/builtin/system/system.go | 63 ---- chain/actors/builtin/system/temp | 0 chain/actors/builtin/system/v0.go | 35 -- chain/actors/builtin/system/v2.go | 35 -- chain/actors/builtin/system/v3.go | 35 -- chain/actors/builtin/system/v4.go | 35 -- chain/actors/builtin/temp | 0 .../actors/builtin/verifreg/actor.go.template | 24 -- .../actors/builtin/verifreg/state.go.template | 26 +- chain/actors/builtin/verifreg/temp | 0 chain/actors/builtin/verifreg/v0.go | 17 - chain/actors/builtin/verifreg/v2.go | 17 - chain/actors/builtin/verifreg/v3.go | 17 - chain/actors/builtin/verifreg/v4.go | 17 - chain/actors/builtin/verifreg/verifreg.go | 41 --- chain/actors/policy/policy.go.template | 164 ++++----- chain/actors/policy/temp | 0 chain/actors/temp | 0 chain/actors/version.go | 4 - chain/gen/gen.go | 3 - chain/gen/genesis/f00_system.go | 21 +- chain/gen/genesis/f01_init.go | 40 +-- chain/gen/genesis/f02_reward.go | 29 +- chain/gen/genesis/f03_cron.go | 32 +- chain/gen/genesis/f04_power.go | 31 +- chain/gen/genesis/f05_market.go | 26 +- chain/gen/genesis/f06_vreg.go | 25 +- chain/gen/genesis/genesis.go | 242 ++++++------- chain/gen/genesis/miners.go | 325 ++++-------------- chain/gen/genesis/util.go | 29 ++ chain/state/statetree.go | 17 +- chain/state/statetree_test.go | 48 +-- chain/vm/vm.go | 35 +- cmd/lotus-seed/genesis.go | 51 --- cmd/lotus-seed/main.go | 7 +- documentation/en/api-v0-methods.md | 2 +- documentation/en/api-v1-unstable-methods.md | 2 +- genesis/types.go | 7 +- node/test/builder.go | 4 - 126 files changed, 643 insertions(+), 3164 deletions(-) delete mode 100644 chain/actors/adt/temp delete mode 100644 chain/actors/aerrors/temp delete mode 100644 chain/actors/agen/temp delete mode 100644 chain/actors/builtin/account/temp delete mode 100644 chain/actors/builtin/cron/state.go.template delete mode 100644 chain/actors/builtin/cron/temp delete mode 100644 chain/actors/builtin/cron/v0.go delete mode 100644 chain/actors/builtin/cron/v2.go delete mode 100644 chain/actors/builtin/cron/v3.go delete mode 100644 chain/actors/builtin/cron/v4.go delete mode 100644 chain/actors/builtin/init/temp delete mode 100644 chain/actors/builtin/market/temp delete mode 100644 chain/actors/builtin/miner/temp delete mode 100644 chain/actors/builtin/multisig/temp delete mode 100644 chain/actors/builtin/paych/mock/temp delete mode 100644 chain/actors/builtin/paych/temp delete mode 100644 chain/actors/builtin/power/temp delete mode 100644 chain/actors/builtin/reward/temp delete mode 100644 chain/actors/builtin/system/actor.go.template delete mode 100644 chain/actors/builtin/system/state.go.template delete mode 100644 chain/actors/builtin/system/system.go delete mode 100644 chain/actors/builtin/system/temp delete mode 100644 chain/actors/builtin/system/v0.go delete mode 100644 chain/actors/builtin/system/v2.go delete mode 100644 chain/actors/builtin/system/v3.go delete mode 100644 chain/actors/builtin/system/v4.go delete mode 100644 chain/actors/builtin/temp delete mode 100644 chain/actors/builtin/verifreg/temp delete mode 100644 chain/actors/policy/temp delete mode 100644 chain/actors/temp diff --git a/build/openrpc/full.json.gz b/build/openrpc/full.json.gz index 394f1998be7c464c835d2474d93a843971cb659d..4d9fb5284d1c6ed52d84f50d11610f338e15b4bf 100644 GIT binary patch delta 4870 zcmV+h6Z!0kwgHT`0k958f5t{<9rcP*h*wS4qf@}X&STVxIHc7V^uOCP`Hh4fL(6w- zp~*~(&xFoNuHs?YyA+XSnWrk}I^xyBM=sm1Wqm>6osE7n$w^^y?lB*hc(20bC~KQ# zFCA0se0gU0Eyb1QRBC!{9``-7jh!Ytl)54@?MkF&T}$MqD6~iXf3*YROUisiub6kL z4uBK~pZ5ChKf2>J+f9#04zAtKN<=BX-D+nNRe^DfKbKs2UXyPy~J zXo#@+jV@s-nSQ7<6#9K-m%_SlPxfJYm4${Zraod6d1Fjy|ANXMCLqSlN7p1sE~Oz% z^^72nr`mhUpv$DKe{0O?FG9Cx21Hryh-6J1%5xYI$*fE{!coB3CHN=~^{~k>8B*E} z8e#r2f-oXp(iEdF)%dewa_9pv^9??Fi3pV~sk|;6jQ5xPH1JVw;nzO#(E%~vPMJUx zEWEKQE*~pqXg*Iq^KcMAgsxR$bioi%9!DmB4BTK(1XI)1e_t_hbr(MOA#ej;EWp>( zK1H9to}FvI4c$V;xClq^SBwMMS(^Jn?vn%JuU*h@M2xjgoN&|9fQj+U805sVh>Qru zK{}ubp2{Tw93jjvD33i4I3LDAFii)VPIMn#kBK){mE?+{fLsE?$Y=2&fR{W3>Z^UZ zSH10UZl%One^w;JAw-gT9vmIYrJqV6`~&7X@hexm;euwxI2lna0ZShZVquyI0>s1^ zBE3!^AmVxfW%tiGiz5$y^??gQl_sozK`B$|^EJxpBM{!&b0;O;GSFy5XNDrr7keuC zZLuwRWF)Bo4)TOz#32~I)MW;8Q+TEg17Ib=Od?Xu7#ARjjK4E-zpK2`8jpU!{FqFLP&a=+VE!K9 z0EgMjf0GC%B%YWDpA?tu?QZmYCx#gG{!N4R|D5fQJ^J5c_}72^mjt<0cZUaq(1+1g zv_-Z(#^G9wr+oD4=JF=|Ye+Y*hu+^ildH|~gk6g3fq!#}Z??IDfuH#3)KiP|?uH1B zK-c@dQ^m@v2k-&&uPQ3^+ke!L1IASYpELztf8IKz9jWQr#~j`R?CWvKCtt20ddCIP z3G#C<^i46KSUC`6kIqRl`KK_9Y0|Qa9-+TNN8Wg+*b`y&Ji;2tyDeeACEiI~S5CBk z7$?@Eo%QrTy@AF!8fCHA&*FiELFRYM2HRdZkK35A%s?svcb9j}Jq#j0mA0|hiz87M ze}Sr|y^-DE^evBjVKF?nyRKgsJOocGEi}Pf+Fo83DeLz>np+uNqKbV?Z*Jr3lVGzw*j-BECsgG@GP(V z&elwYFC88f3xjI46P<~`f1m^rkaeDFek>Q<=Ds=C-MM8~pUX04sV!%fww<1nNfvPZ=T1C7xoj$$r5O10;xalSQ0HX5Vb_;%Cnz(Id(Ka~5?BH6l3RA6c=_Pdv zRU2`Dp zX@aoiST-ZDTqzs)Rm@peNK@B79bJnYZmqJfJu;55x!!aGyE>aWA5(wqqpu$^}(K`o>Nd;kb(9Dvz71%saAnXqf4)+#!YG1}MM67lD!=EL3Nisiw|y*74lKsG1*5|OACf3 zRRXv%Q?YA^?6^?%I4ok~Rn;se_{IVw4`)}MG)qao=7Od!8zewP@uo=KTA>U9711=g z!jv{7@F0MsxeJ=L^duE7jt#cZgU=q0vJSkWgvIKw-_pXbD0SRy@^MQj!YPah7t!>T zF|#oje;|-EjkO5tK1(%QP{VSk^YHjQVrWK_VDO|oN_zT*qlhsTYt!N6`-t*hBK@n* z8dj7-Y&AJEm~9^|0XaqYj+vqkXen|y$>F3GCW8(qEr$wjHyP-^VIn$5^e~m{=w24P zV-v-MikCqtiK))-V@kaPiOlw~-(F(MRh}a;Jx9;<^3D~5ifuM1hI0iq zf4Jm`4AXp25&=(eB$+>!LXn@OOfn$|`-zfBr%;Ljb4Hh^!*LjD#qzY624?3reQcp* zDWq(8WchD1Zg1{3J!6jkv(wE@( z(F8C}6Szq_!RRjn!4*XE{9Gb@ji+cBf3XQ7!Z}>shX(a?9F%<#&BGjVO+|npc;M%9 zr_LlirQRnTb>`cq?p(G#_atTwH6KG$uHpnf47liS>0Ob2)1Xf{iw6@T_9cJse@3aY`gQQ+g~rUP%qKpwfGNdBo1sdsEb=f#13=bU1nlcO zTq>DRKE>lX@hwtnkq^?=*Em^ z2uU|Mwb1BKnaPK?3@nj9a1UYnOH81}pfeWHao`!l={EQoYGngaJD_6T-i&9Ma_gJX zMN-?XdIf`PH~0z$+@*o8Ar4Z&@WeSlhU4z;NLC%P9HOu}G(`;9e~p|M8n6g)C5!G) z1$0ezIG?arrbsOUo+rIsyGq4QO?bSy`L@Ag_mxg?bh#GU)E5c$POpB)fg|&)L zZEtO@H&~tYdM&oGf0kl-$~V=l&`C?8nAX{!DmU0bh2tPTP8^W6AqwFUCeG&MY)+5n zz;D#uE1XjAcXI;HRkWH;r@q*P{Vn4GV}XrLs?>fnJt!8>?d0n*C{O&t?FW;{UIvn>E(rZ#W1*?Bf7auf4^%e^A@<7VvZQ%vdGJ=!lAW z=XSP>`XgH?S+FY)%rj$9E?n(RLTx3s=P_VE4bnAUD*s-&8@p9!C%-l|L@0gfuAG*R zS&hL{@6AIP;y4g>;SKCgTd|R9SB;ioH)rj>Kqort;10x)UEfg@1BV%XW>L zLT{6IHzAAK%PaZH_Q=OLWc&tGo2dFTeazeNx?q78hY`8L0?;L>JIA>*umCN7@F$?S z3UyvH*=rl8nR63eI^Zhix0-e-r&YN^wDVlZH@2t|f49ao@ksdCs~Yu$J{})&SIG4d z+lDx@R7T{Rop-7~VqT+qD9SP9X`g8)^OugpPNU3!G+BV}>B@8bE)45c;lQ<^4D-n=Y ztMw1xe}8m3@utD1vo4FEfN;T8M4X(y0T$waRXecs6{UHqDlvZ-N|EYEKk?}JZso(2 z+lx6qr5z+5_V#?;sC@Vg*By7~XSi;*ApHi@b7gky#-4Qh^LW!|xHj(pTwe#M7QnLf zm>Se^GLmCkyP$hlm;@@6q?F;*$am2o;C;lwe+xHX?Obl;{(Px&)kYWeEDjY@9I^<} zcmfgeaFA5rKri#PH_=P9e|#npWVS_?Y`8L$ZAYag&s(OQ*0GW$oz*vunv}CtE!^?Q zW(_P;VOVH&-g(Umn=8l_1|#)973{B^>-BpOW(!)fcY_*5Pb#s1Lp4m4se*gJc(dJ;)!|iNyT#R?dn^*Y6+@BMOJ2* z9g{IjEPuU!+GaRYU)}ZwQtrDuR5kNw8Hq8S(6&7#b8pj+S!~O6@p#hp9*y2~ZNJ3q zzt+`~&3=14rok{-pqq84ceYT=;I2>LIQM%Q$g#Ylet*;?w=|9hIU3ZF2IX%M=J)=} z0`tcjN_V?1g|Y^%$<>0zTtR1Ase|l#dAjPk%YU8B)1l4ONbg2v-U~QUbL&{CCVGw! z9`m)wC`Q*11TW16BQx%$q4hft=jxQww|LU(lEs?M2oV{!Pk)%N++IDW(*2Y)Ev=k` z(ysF1hgK{xIk2T7p0ZbD@`f`dFJ2kGvF#8&=_AO s*C!yKiU-o_X#*Q`YdEE!^D0{wxmDR`fBf_R0ssL2{{xC7k>8sH07~LgPyhe` delta 4808 zcmV;(5;yIPwgHK@0k958e@6HFt}99*UNu>dP67Kmk5MP$kXB#N|8CFZHxhOXE#Iw$ zCNnKQ6FMikiic(IQbd+zo~oSdh*t|Axop3d^#z4@Hu}jVCxywm$9!1gy$X|~tZkOP zbWE-D<(c8P6jz#4sp++O-1p2jcAD%^>Waj)E0LCUEs>j|&>r#Ee-4N*Df1D%V&17b z0G6cLbY?}DWmy!de|VNa3^>Ol=p)Q|JRx+1h(Onvr>aP8YZ?U1yDWzT(U@-Sf?m+0 zA;RW2x`e4@`k~HH==YUf3hTZ-*@x*>781d^15&^-e2<5z(=`-U;D&I2gH0kWdcpG z@W!gRe5{zE`8@f|!$ANMx>kwN1w%l29GUzvaDzP&OifpRf5pJnUHIIGzzuk@0AEl0 z6n*-7cCP(4bPE;ZA{@bAF%D#BY3>KPPY#H`c0s=pG1fY9!c9v9CdM;kkQ2)yG9nZQ z>3}A9DwhOsgfPFLJoY@`d>9A8G#zL<(S3A1Cf-<8k}HM+atR0{pT&a!Uh)vAulD6$ z^|r&gl@eoFe~}D_5J~EJaC9h_ekz6V518x3uUzeh3z`+538zpALvZ~sw04j5Mre9{znd6O_U6@Nr0$j`md zH^qQr2lki5)y9HkKq|sm-7re=$HjT@~+l- z{xutGT`l36-8NUojauxdjB!~m?^o+I7YQ5eH1Sm*n6bNz2$l|2Re!}C^lGJ@%)zJ* z$0nJnwx=M)hV8VQMJU(0+Z6S+&h1fwE!#)G)F88My&N80JT#gk#*P>-lNcLGyX7f< z+(i7*nNynF%Fh5t-dK{AP8OB4dIzJ5@*>9rvZkC!RWOD=3b)aKu|Nf><)dT9F5}S3 z+>#$j-gR6y*#|BF_T_j8S&nmJI7%72Z4b@>ab6^Mxw9VDW5 z@}M-{wOcc&Okytb29@%Z)Y?bg4;%#S+C*^k|HzCCva+HEYp861(Yr_4 zCuSPBpsHzx6uohV8fU0+h8kz6S;pm5rRDT z%F58SYzvFwxqsbt{kq^Gcv@+p3EtB7^0G)-zxUDH%IFeR>|=VPW4>U~SP4{Q?ou%BBtd6o-v6WkhU{kmanDt~Su$6{qdF6MuW-5H? z@Ss>2RI8onOaulch=8o~RP$rG;5PTox$e#_yZT&~F@H;KIjgko^qfqx0Hp756imA@ zWmDBE;-%^I>4k@Q({#a2FX0CemG`z=@C(z#Z8M9u!69Y`*NRn`YK2QLsZ+3u6)`V; z#u_>`b!i*~h|tVWIEkJnn<05GXRX#t-H2s@wH(u$;Hh#U9st6g7e`otY*)p(mW}g1 ziaAuXa(^Tk8i7bFUQo#1DK6-Eoa1p%h{rVrtym~z#n0-bFZrA>OHTnalk6oQ`66Mp z<@_)CXa&mKuqup!dNC8aK|QMoL{WG?6J4UW-s=)8%7yQ!ZNi1`Snco~4;eVVZMye7 zn`>wR=$JNg+u-q-d2RI!`LVUaj%h_SB-H0=T7QvW(@fmjXjMdyPde$E17S}SgeAwa z8G+?W*}$)2&bmUHy7uYlTI6tRm3{4zag5FNrW@GR*%Z5TjeJA5z&R>YKz36<%nr33 zBgt1Ts3OugcDe}1RUB7&++1bek+nMoFz`9I!MorxmJ~UaC=!z#8p-KCYk7}xRYxa^n6UX zq@?ndaur4qge(%;VN>}%$5fCBAR@;x#D5+j!F0enjy&csF|~9 z0VK^`(5$5=sc>;@u!SCc_HdMS;1wk-R)77L7Jfyk<7ShOTS5^|VMMryrl*XVjky4U zoN25@Soc|~*@7CDJDrEe=Mh6Qntud?C*@Jn(=QxFjHy_g4kzD7l=l+pUv<{7q7-7Q z$(g}y`)CQsDY|#e6m>vLk;6$2C#^6UbU0}_RB*e=K>rOB(K(`rsa!|*ve+G)C?-_w zY%e#AN7j9dAReYt=MWxiCLpW52z`l&d^PVtS6A>E)d(1{K?EPz>h^YH-OB8K(K5 zBm$n`NHTvcg(5#mnPfr`_J0#4kxro$0p^S@Plw|$)QaV4F%8VlZTi?k$x=w!@W}E9 zZ@#KC%qPbzWQ3M8+*p$cRo&XWq|>R*BN0iP7DPf7RRn=2B!WxA;H59Y@1qG|nkI0Q zbb`@e1cEDw{qFk%x#gmbvM4-M+)I4Jufnuj^!nu-8H@PEM13bV=o-|Z{)XO=xy*SePPi>zy%5OCt>TDxEma25|HMC?oc-i=aa_3Plt3yqmonNNIV0aJ>NHba$MS%2hViUxpU$(sd3T)jdV zQMeAK$csQ3IUAfDFgo-I1(1WI04(b7+bfup2oqG++_pN*3Lp3h0{ba6VzL zOp#gyJbzDmyLOd|otp4?bMtM3#qKMe;OKHM2)ddF@(olf4d)8nGcD9h+xdbhjH3}K zlYo(_J?xF4k0$t1?s+0m$T%m1K*c{$szbrFr!Yrh1XqN`JeU?u{|jpspW5EqT5qsA z>GfJ{V=cw3dccwoPRhVYeN*mBTSsl$=RG9&4J&jyH_}+ z-tXoFoU3RxolbqR3Hw{d1I7Xyn^dX&W_nO8p4-XSV^E&>h1(A%fi2;h79bWO%7kcSh?owi~l)vg*X!*0|x+;q%}g)5_MWWtrN3n#ZDuT=|+dvUmM5lh;&TQxd@ zWT^w_;7ydTY|R=PrMa0F=WzmE5c%pK9e;_@>`djG+jS>CcnbgIq?YX(HHF?L?`}dC zwU<}&mFf zH#_fCf5f~-^-z>!$kRU4PUbHihn+^5|7fxR-_w=n_+1(T+EpG&`2P)_c zMk#+ybkJT9`|3@OA)2e6sxn6^v5bjmvg`xo7>Wx9c#mYDQ73Uscvm7It5)kDzW?ZS z;!T51XI&OS0pWtHh&VZY11!Y5P?8Lm6-&d+e&Y(e@BrsvA+*o{5u_UG}Y&v0$r|GB;nP%VIE=`l5^<76bq zwst}Ht}qEyC`l>9sgduZLBRWngBNbT+PU1w{rOVms*Nt_SsW^+IAjr`@qYv&;^82v zzJXrmYj2{LX#e<3BFJouEZJ~nCfklmOP;q(JFR0SOFFA>8Z{|rsam+>kb&!s6*gCpD-1^Je=63iDaq&(6RWJ;W^_8lFndcXz02=Fc(`V>+R2drIcsrXRD|mg(a0r0YEzz3JM1iP?Xxt0kNL_ION# zVX{Cs>rU@%p_aj2pTKeM_cD-Uc}4yHs7Y>V91U_bs3Q%^-yqEI{gnmgk2RF;c3lc( z4O)|{1&g_Y&a_eo+4b^t)pM6SnWuk4o2ilBjmo?iaH8hcu~JR+93MR9YmZTkt|16s znhQo|+)G32cOK5wDWz}mq}3&hHJcG4GHjpzFkiX7dQPSLDQQ|-IR~X(=TrPNo;p_cI_ja&nKd8C$b4>J)UuasPryME2USOR0i_QzuRZPRX(6GzDlk^J{2Snq}9^~ iHs;oFN" } } func IsBuiltinActor(c cid.Cid) bool { - {{range .versions}} - if builtin{{.}}.IsBuiltinActor(c) { - return true - } - {{end}} - return false + {{range .versions}} + if builtin{{.}}.IsBuiltinActor(c) { + return true + } + {{end}} + return false } func IsAccountActor(c cid.Cid) bool { - {{range .versions}} - if c == builtin{{.}}.AccountActorCodeID { - return true - } - {{end}} - return false + {{range .versions}} + if c == builtin{{.}}.AccountActorCodeID { + return true + } + {{end}} + return false } func IsStorageMinerActor(c cid.Cid) bool { - {{range .versions}} - if c == builtin{{.}}.StorageMinerActorCodeID { - return true - } - {{end}} - return false + {{range .versions}} + if c == builtin{{.}}.StorageMinerActorCodeID { + return true + } + {{end}} + return false } func IsMultisigActor(c cid.Cid) bool { - {{range .versions}} - if c == builtin{{.}}.MultisigActorCodeID { - return true - } - {{end}} - return false + {{range .versions}} + if c == builtin{{.}}.MultisigActorCodeID { + return true + } + {{end}} + return false } func IsPaymentChannelActor(c cid.Cid) bool { - {{range .versions}} - if c == builtin{{.}}.PaymentChannelActorCodeID { - return true - } - {{end}} - return false + {{range .versions}} + if c == builtin{{.}}.PaymentChannelActorCodeID { + return true + } + {{end}} + return false } func makeAddress(addr string) address.Address { diff --git a/chain/actors/builtin/cron/actor.go.template b/chain/actors/builtin/cron/actor.go.template index d7380855632..6b7449617fe 100644 --- a/chain/actors/builtin/cron/actor.go.template +++ b/chain/actors/builtin/cron/actor.go.template @@ -1,42 +1,10 @@ package cron import ( - "github.com/filecoin-project/lotus/chain/actors" - "github.com/filecoin-project/lotus/chain/actors/adt" - "golang.org/x/xerrors" - "github.com/ipfs/go-cid" -{{range .versions}} - builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" -{{end}} + builtin{{.latestVersion}} "github.com/filecoin-project/specs-actors{{import .latestVersion}}actors/builtin" ) -func MakeState(store adt.Store, av actors.Version) (State, error) { - switch av { -{{range .versions}} - case actors.Version{{.}}: - return make{{.}}(store) -{{end}} -} - return nil, xerrors.Errorf("unknown actor version %d", av) -} - -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { -{{range .versions}} - case actors.Version{{.}}: - return builtin{{.}}.CronActorCodeID, nil -{{end}} - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - var ( Address = builtin{{.latestVersion}}.CronActorAddr Methods = builtin{{.latestVersion}}.MethodsCron ) - - -type State interface { - GetState() interface{} -} diff --git a/chain/actors/builtin/cron/cron.go b/chain/actors/builtin/cron/cron.go index 62fa413a84b..52a9fab0708 100644 --- a/chain/actors/builtin/cron/cron.go +++ b/chain/actors/builtin/cron/cron.go @@ -1,64 +1,10 @@ package cron import ( - "github.com/filecoin-project/lotus/chain/actors" - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/ipfs/go-cid" - "golang.org/x/xerrors" - - builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" - - builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" - - builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin" - builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" ) -func MakeState(store adt.Store, av actors.Version) (State, error) { - switch av { - - case actors.Version0: - return make0(store) - - case actors.Version2: - return make2(store) - - case actors.Version3: - return make3(store) - - case actors.Version4: - return make4(store) - - } - return nil, xerrors.Errorf("unknown actor version %d", av) -} - -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { - - case actors.Version0: - return builtin0.CronActorCodeID, nil - - case actors.Version2: - return builtin2.CronActorCodeID, nil - - case actors.Version3: - return builtin3.CronActorCodeID, nil - - case actors.Version4: - return builtin4.CronActorCodeID, nil - - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - var ( Address = builtin4.CronActorAddr Methods = builtin4.MethodsCron ) - -type State interface { - GetState() interface{} -} diff --git a/chain/actors/builtin/cron/state.go.template b/chain/actors/builtin/cron/state.go.template deleted file mode 100644 index 99a06d7f806..00000000000 --- a/chain/actors/builtin/cron/state.go.template +++ /dev/null @@ -1,35 +0,0 @@ -package cron - -import ( - "github.com/ipfs/go-cid" - - "github.com/filecoin-project/lotus/chain/actors/adt" - - cron{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/cron" -) - -var _ State = (*state{{.v}})(nil) - -func load{{.v}}(store adt.Store, root cid.Cid) (State, error) { - out := state{{.v}}{store: store} - err := store.Get(store.Context(), root, &out) - if err != nil { - return nil, err - } - return &out, nil -} - -func make{{.v}}(store adt.Store) (State, error) { - out := state{{.v}}{store: store} - out.State = *cron{{.v}}.ConstructState(cron{{.v}}.BuiltInEntries()) - return &out, nil -} - -type state{{.v}} struct { - cron{{.v}}.State - store adt.Store -} - -func (s *state{{.v}}) GetState() interface{} { - return &s.State -} \ No newline at end of file diff --git a/chain/actors/builtin/cron/temp b/chain/actors/builtin/cron/temp deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/chain/actors/builtin/cron/v0.go b/chain/actors/builtin/cron/v0.go deleted file mode 100644 index 6147b858c10..00000000000 --- a/chain/actors/builtin/cron/v0.go +++ /dev/null @@ -1,35 +0,0 @@ -package cron - -import ( - "github.com/ipfs/go-cid" - - "github.com/filecoin-project/lotus/chain/actors/adt" - - cron0 "github.com/filecoin-project/specs-actors/actors/builtin/cron" -) - -var _ State = (*state0)(nil) - -func load0(store adt.Store, root cid.Cid) (State, error) { - out := state0{store: store} - err := store.Get(store.Context(), root, &out) - if err != nil { - return nil, err - } - return &out, nil -} - -func make0(store adt.Store) (State, error) { - out := state0{store: store} - out.State = *cron0.ConstructState(cron0.BuiltInEntries()) - return &out, nil -} - -type state0 struct { - cron0.State - store adt.Store -} - -func (s *state0) GetState() interface{} { - return &s.State -} diff --git a/chain/actors/builtin/cron/v2.go b/chain/actors/builtin/cron/v2.go deleted file mode 100644 index 51ca179d9ce..00000000000 --- a/chain/actors/builtin/cron/v2.go +++ /dev/null @@ -1,35 +0,0 @@ -package cron - -import ( - "github.com/ipfs/go-cid" - - "github.com/filecoin-project/lotus/chain/actors/adt" - - cron2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/cron" -) - -var _ State = (*state2)(nil) - -func load2(store adt.Store, root cid.Cid) (State, error) { - out := state2{store: store} - err := store.Get(store.Context(), root, &out) - if err != nil { - return nil, err - } - return &out, nil -} - -func make2(store adt.Store) (State, error) { - out := state2{store: store} - out.State = *cron2.ConstructState(cron2.BuiltInEntries()) - return &out, nil -} - -type state2 struct { - cron2.State - store adt.Store -} - -func (s *state2) GetState() interface{} { - return &s.State -} diff --git a/chain/actors/builtin/cron/v3.go b/chain/actors/builtin/cron/v3.go deleted file mode 100644 index ff74d511de5..00000000000 --- a/chain/actors/builtin/cron/v3.go +++ /dev/null @@ -1,35 +0,0 @@ -package cron - -import ( - "github.com/ipfs/go-cid" - - "github.com/filecoin-project/lotus/chain/actors/adt" - - cron3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/cron" -) - -var _ State = (*state3)(nil) - -func load3(store adt.Store, root cid.Cid) (State, error) { - out := state3{store: store} - err := store.Get(store.Context(), root, &out) - if err != nil { - return nil, err - } - return &out, nil -} - -func make3(store adt.Store) (State, error) { - out := state3{store: store} - out.State = *cron3.ConstructState(cron3.BuiltInEntries()) - return &out, nil -} - -type state3 struct { - cron3.State - store adt.Store -} - -func (s *state3) GetState() interface{} { - return &s.State -} diff --git a/chain/actors/builtin/cron/v4.go b/chain/actors/builtin/cron/v4.go deleted file mode 100644 index 1cff8cc2813..00000000000 --- a/chain/actors/builtin/cron/v4.go +++ /dev/null @@ -1,35 +0,0 @@ -package cron - -import ( - "github.com/ipfs/go-cid" - - "github.com/filecoin-project/lotus/chain/actors/adt" - - cron4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/cron" -) - -var _ State = (*state4)(nil) - -func load4(store adt.Store, root cid.Cid) (State, error) { - out := state4{store: store} - err := store.Get(store.Context(), root, &out) - if err != nil { - return nil, err - } - return &out, nil -} - -func make4(store adt.Store) (State, error) { - out := state4{store: store} - out.State = *cron4.ConstructState(cron4.BuiltInEntries()) - return &out, nil -} - -type state4 struct { - cron4.State - store adt.Store -} - -func (s *state4) GetState() interface{} { - return &s.State -} diff --git a/chain/actors/builtin/init/actor.go.template b/chain/actors/builtin/init/actor.go.template index f825eb9fa45..5b700cec863 100644 --- a/chain/actors/builtin/init/actor.go.template +++ b/chain/actors/builtin/init/actor.go.template @@ -1,7 +1,6 @@ package init import ( - "github.com/filecoin-project/lotus/chain/actors" "golang.org/x/xerrors" "github.com/filecoin-project/go-address" @@ -40,27 +39,6 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version, networkName string) (State, error) { - switch av { -{{range .versions}} - case actors.Version{{.}}: - return make{{.}}(store, networkName) -{{end}} -} - return nil, xerrors.Errorf("unknown actor version %d", av) -} - -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { -{{range .versions}} - case actors.Version{{.}}: - return builtin{{.}}.InitActorCodeID, nil -{{end}} - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - type State interface { cbor.Marshaler @@ -78,12 +56,5 @@ type State interface { // Sets the network's name. This should only be used on upgrade/fork. SetNetworkName(name string) error - // Sets the next ID for the init actor. This should only be used for testing. - SetNextID(id abi.ActorID) error - - // Sets the address map for the init actor. This should only be used for testing. - SetAddressMap(mcid cid.Cid) error - - AddressMap() (adt.Map, error) - GetState() interface{} + addressMap() (adt.Map, error) } diff --git a/chain/actors/builtin/init/diff.go b/chain/actors/builtin/init/diff.go index 5eb8f3c75b6..593171322f7 100644 --- a/chain/actors/builtin/init/diff.go +++ b/chain/actors/builtin/init/diff.go @@ -11,12 +11,12 @@ import ( ) func DiffAddressMap(pre, cur State) (*AddressMapChanges, error) { - prem, err := pre.AddressMap() + prem, err := pre.addressMap() if err != nil { return nil, err } - curm, err := cur.AddressMap() + curm, err := cur.addressMap() if err != nil { return nil, err } diff --git a/chain/actors/builtin/init/init.go b/chain/actors/builtin/init/init.go index 2091252ce78..730d21fd83f 100644 --- a/chain/actors/builtin/init/init.go +++ b/chain/actors/builtin/init/init.go @@ -1,7 +1,6 @@ package init import ( - "github.com/filecoin-project/lotus/chain/actors" "golang.org/x/xerrors" "github.com/filecoin-project/go-address" @@ -66,45 +65,6 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version, networkName string) (State, error) { - switch av { - - case actors.Version0: - return make0(store, networkName) - - case actors.Version2: - return make2(store, networkName) - - case actors.Version3: - return make3(store, networkName) - - case actors.Version4: - return make4(store, networkName) - - } - return nil, xerrors.Errorf("unknown actor version %d", av) -} - -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { - - case actors.Version0: - return builtin0.InitActorCodeID, nil - - case actors.Version2: - return builtin2.InitActorCodeID, nil - - case actors.Version3: - return builtin3.InitActorCodeID, nil - - case actors.Version4: - return builtin4.InitActorCodeID, nil - - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - type State interface { cbor.Marshaler @@ -122,12 +82,5 @@ type State interface { // Sets the network's name. This should only be used on upgrade/fork. SetNetworkName(name string) error - // Sets the next ID for the init actor. This should only be used for testing. - SetNextID(id abi.ActorID) error - - // Sets the address map for the init actor. This should only be used for testing. - SetAddressMap(mcid cid.Cid) error - - AddressMap() (adt.Map, error) - GetState() interface{} + addressMap() (adt.Map, error) } diff --git a/chain/actors/builtin/init/state.go.template b/chain/actors/builtin/init/state.go.template index 482ad4df526..95f052bdaaf 100644 --- a/chain/actors/builtin/init/state.go.template +++ b/chain/actors/builtin/init/state.go.template @@ -29,26 +29,6 @@ func load{{.v}}(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make{{.v}}(store adt.Store, networkName string) (State, error) { - out := state{{.v}}{store: store} - {{if (le .v 2)}} - mr, err := adt{{.v}}.MakeEmptyMap(store).Root() - if err != nil { - return nil, err - } - - out.State = *init{{.v}}.ConstructState(mr, networkName) - {{else}} - s, err := init{{.v}}.ConstructState(store, networkName) - if err != nil { - return nil, err - } - - out.State = *s - {{end}} - return &out, nil -} - type state{{.v}} struct { init{{.v}}.State store adt.Store @@ -86,11 +66,6 @@ func (s *state{{.v}}) SetNetworkName(name string) error { return nil } -func (s *state{{.v}}) SetNextID(id abi.ActorID) error { - s.State.NextID = id - return nil -} - func (s *state{{.v}}) Remove(addrs ...address.Address) (err error) { m, err := adt{{.v}}.AsMap(s.store, s.State.AddressMap{{if (ge .v 3)}}, builtin{{.v}}.DefaultHamtBitwidth{{end}}) if err != nil { @@ -109,15 +84,6 @@ func (s *state{{.v}}) Remove(addrs ...address.Address) (err error) { return nil } -func (s *state{{.v}}) SetAddressMap(mcid cid.Cid) error { - s.State.AddressMap = mcid - return nil -} - -func (s *state{{.v}}) AddressMap() (adt.Map, error) { - return adt{{.v}}.AsMap(s.store, s.State.AddressMap{{if (ge .v 3)}}, builtin{{.v}}.DefaultHamtBitwidth{{end}}) +func (s *state{{.v}}) addressMap() (adt.Map, error) { + return adt{{.v}}.AsMap(s.store, s.AddressMap{{if (ge .v 3)}}, builtin{{.v}}.DefaultHamtBitwidth{{end}}) } - -func (s *state{{.v}}) GetState() interface{} { - return &s.State -} \ No newline at end of file diff --git a/chain/actors/builtin/init/temp b/chain/actors/builtin/init/temp deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/chain/actors/builtin/init/v0.go b/chain/actors/builtin/init/v0.go index ddd2dab94f2..c019705b1e2 100644 --- a/chain/actors/builtin/init/v0.go +++ b/chain/actors/builtin/init/v0.go @@ -25,19 +25,6 @@ func load0(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make0(store adt.Store, networkName string) (State, error) { - out := state0{store: store} - - mr, err := adt0.MakeEmptyMap(store).Root() - if err != nil { - return nil, err - } - - out.State = *init0.ConstructState(mr, networkName) - - return &out, nil -} - type state0 struct { init0.State store adt.Store @@ -75,11 +62,6 @@ func (s *state0) SetNetworkName(name string) error { return nil } -func (s *state0) SetNextID(id abi.ActorID) error { - s.State.NextID = id - return nil -} - func (s *state0) Remove(addrs ...address.Address) (err error) { m, err := adt0.AsMap(s.store, s.State.AddressMap) if err != nil { @@ -98,15 +80,6 @@ func (s *state0) Remove(addrs ...address.Address) (err error) { return nil } -func (s *state0) SetAddressMap(mcid cid.Cid) error { - s.State.AddressMap = mcid - return nil -} - -func (s *state0) AddressMap() (adt.Map, error) { - return adt0.AsMap(s.store, s.State.AddressMap) -} - -func (s *state0) GetState() interface{} { - return &s.State +func (s *state0) addressMap() (adt.Map, error) { + return adt0.AsMap(s.store, s.AddressMap) } diff --git a/chain/actors/builtin/init/v2.go b/chain/actors/builtin/init/v2.go index 72e2d56a522..420243be496 100644 --- a/chain/actors/builtin/init/v2.go +++ b/chain/actors/builtin/init/v2.go @@ -25,19 +25,6 @@ func load2(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make2(store adt.Store, networkName string) (State, error) { - out := state2{store: store} - - mr, err := adt2.MakeEmptyMap(store).Root() - if err != nil { - return nil, err - } - - out.State = *init2.ConstructState(mr, networkName) - - return &out, nil -} - type state2 struct { init2.State store adt.Store @@ -75,11 +62,6 @@ func (s *state2) SetNetworkName(name string) error { return nil } -func (s *state2) SetNextID(id abi.ActorID) error { - s.State.NextID = id - return nil -} - func (s *state2) Remove(addrs ...address.Address) (err error) { m, err := adt2.AsMap(s.store, s.State.AddressMap) if err != nil { @@ -98,15 +80,6 @@ func (s *state2) Remove(addrs ...address.Address) (err error) { return nil } -func (s *state2) SetAddressMap(mcid cid.Cid) error { - s.State.AddressMap = mcid - return nil -} - -func (s *state2) AddressMap() (adt.Map, error) { - return adt2.AsMap(s.store, s.State.AddressMap) -} - -func (s *state2) GetState() interface{} { - return &s.State +func (s *state2) addressMap() (adt.Map, error) { + return adt2.AsMap(s.store, s.AddressMap) } diff --git a/chain/actors/builtin/init/v3.go b/chain/actors/builtin/init/v3.go index 4609c94a372..eaa54dfd4a3 100644 --- a/chain/actors/builtin/init/v3.go +++ b/chain/actors/builtin/init/v3.go @@ -27,19 +27,6 @@ func load3(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make3(store adt.Store, networkName string) (State, error) { - out := state3{store: store} - - s, err := init3.ConstructState(store, networkName) - if err != nil { - return nil, err - } - - out.State = *s - - return &out, nil -} - type state3 struct { init3.State store adt.Store @@ -77,11 +64,6 @@ func (s *state3) SetNetworkName(name string) error { return nil } -func (s *state3) SetNextID(id abi.ActorID) error { - s.State.NextID = id - return nil -} - func (s *state3) Remove(addrs ...address.Address) (err error) { m, err := adt3.AsMap(s.store, s.State.AddressMap, builtin3.DefaultHamtBitwidth) if err != nil { @@ -100,15 +82,6 @@ func (s *state3) Remove(addrs ...address.Address) (err error) { return nil } -func (s *state3) SetAddressMap(mcid cid.Cid) error { - s.State.AddressMap = mcid - return nil -} - -func (s *state3) AddressMap() (adt.Map, error) { - return adt3.AsMap(s.store, s.State.AddressMap, builtin3.DefaultHamtBitwidth) -} - -func (s *state3) GetState() interface{} { - return &s.State +func (s *state3) addressMap() (adt.Map, error) { + return adt3.AsMap(s.store, s.AddressMap, builtin3.DefaultHamtBitwidth) } diff --git a/chain/actors/builtin/init/v4.go b/chain/actors/builtin/init/v4.go index dc56d1f196c..38749eed55b 100644 --- a/chain/actors/builtin/init/v4.go +++ b/chain/actors/builtin/init/v4.go @@ -27,19 +27,6 @@ func load4(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make4(store adt.Store, networkName string) (State, error) { - out := state4{store: store} - - s, err := init4.ConstructState(store, networkName) - if err != nil { - return nil, err - } - - out.State = *s - - return &out, nil -} - type state4 struct { init4.State store adt.Store @@ -77,11 +64,6 @@ func (s *state4) SetNetworkName(name string) error { return nil } -func (s *state4) SetNextID(id abi.ActorID) error { - s.State.NextID = id - return nil -} - func (s *state4) Remove(addrs ...address.Address) (err error) { m, err := adt4.AsMap(s.store, s.State.AddressMap, builtin4.DefaultHamtBitwidth) if err != nil { @@ -100,15 +82,6 @@ func (s *state4) Remove(addrs ...address.Address) (err error) { return nil } -func (s *state4) SetAddressMap(mcid cid.Cid) error { - s.State.AddressMap = mcid - return nil -} - -func (s *state4) AddressMap() (adt.Map, error) { - return adt4.AsMap(s.store, s.State.AddressMap, builtin4.DefaultHamtBitwidth) -} - -func (s *state4) GetState() interface{} { - return &s.State +func (s *state4) addressMap() (adt.Map, error) { + return adt4.AsMap(s.store, s.AddressMap, builtin4.DefaultHamtBitwidth) } diff --git a/chain/actors/builtin/market/actor.go.template b/chain/actors/builtin/market/actor.go.template index 5b67695e12b..39cfe1be7f0 100644 --- a/chain/actors/builtin/market/actor.go.template +++ b/chain/actors/builtin/market/actor.go.template @@ -16,7 +16,6 @@ import ( {{end}} "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/types" ) @@ -43,27 +42,6 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version) (State, error) { - switch av { -{{range .versions}} - case actors.Version{{.}}: - return make{{.}}(store) -{{end}} -} - return nil, xerrors.Errorf("unknown actor version %d", av) -} - -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { -{{range .versions}} - case actors.Version{{.}}: - return builtin{{.}}.StorageMarketActorCodeID, nil -{{end}} - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - type State interface { cbor.Marshaler BalancesChanged(State) (bool, error) @@ -78,7 +56,6 @@ type State interface { minerAddr address.Address, deals []abi.DealID, currEpoch, sectorExpiry abi.ChainEpoch, ) (weight, verifiedWeight abi.DealWeight, err error) NextID() (abi.DealID, error) - GetState() interface{} } type BalanceTable interface { @@ -104,6 +81,7 @@ type DealProposals interface { type PublishStorageDealsParams = market0.PublishStorageDealsParams type PublishStorageDealsReturn = market0.PublishStorageDealsReturn +type VerifyDealsForActivationParams = market0.VerifyDealsForActivationParams type WithdrawBalanceParams = market0.WithdrawBalanceParams type ClientDealProposal = market0.ClientDealProposal @@ -111,71 +89,71 @@ 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 + 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 + 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 + ProviderCollateral abi.TokenAmount + ClientCollateral abi.TokenAmount } type DealStateChanges struct { - Added []DealIDState + Added []DealIDState Modified []DealStateChange - Removed []DealIDState + Removed []DealIDState } type DealIDState struct { - ID abi.DealID + ID abi.DealID Deal DealState } // DealStateChange is a change in deal state from -> to type DealStateChange struct { - ID abi.DealID + ID abi.DealID From *DealState - To *DealState + To *DealState } type DealProposalChanges struct { - Added []ProposalIDState + Added []ProposalIDState Removed []ProposalIDState } type ProposalIDState struct { - ID abi.DealID + ID abi.DealID Proposal DealProposal } func EmptyDealState() *DealState { return &DealState{ SectorStartEpoch: -1, - SlashEpoch: -1, + SlashEpoch: -1, LastUpdatedEpoch: -1, } } // returns the earned fees and pending fees for a given deal func (deal DealProposal) GetDealFees(height abi.ChainEpoch) (abi.TokenAmount, abi.TokenAmount) { - tf := big.Mul(deal.StoragePricePerEpoch, big.NewInt(int64(deal.EndEpoch-deal.StartEpoch))) + tf := big.Mul(deal.StoragePricePerEpoch, big.NewInt(int64(deal.EndEpoch-deal.StartEpoch))) - ef := big.Mul(deal.StoragePricePerEpoch, big.NewInt(int64(height-deal.StartEpoch))) - if ef.LessThan(big.Zero()) { - ef = big.Zero() - } + ef := big.Mul(deal.StoragePricePerEpoch, big.NewInt(int64(height-deal.StartEpoch))) + if ef.LessThan(big.Zero()) { + ef = big.Zero() + } - if ef.GreaterThan(tf) { - ef = tf - } + if ef.GreaterThan(tf) { + ef = tf + } - return ef, big.Sub(tf, ef) + return ef, big.Sub(tf, ef) } diff --git a/chain/actors/builtin/market/market.go b/chain/actors/builtin/market/market.go index ffc8266587b..adf7ce33db0 100644 --- a/chain/actors/builtin/market/market.go +++ b/chain/actors/builtin/market/market.go @@ -20,7 +20,6 @@ import ( builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" - "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/types" @@ -69,45 +68,6 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version) (State, error) { - switch av { - - case actors.Version0: - return make0(store) - - case actors.Version2: - return make2(store) - - case actors.Version3: - return make3(store) - - case actors.Version4: - return make4(store) - - } - return nil, xerrors.Errorf("unknown actor version %d", av) -} - -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { - - case actors.Version0: - return builtin0.StorageMarketActorCodeID, nil - - case actors.Version2: - return builtin2.StorageMarketActorCodeID, nil - - case actors.Version3: - return builtin3.StorageMarketActorCodeID, nil - - case actors.Version4: - return builtin4.StorageMarketActorCodeID, nil - - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - type State interface { cbor.Marshaler BalancesChanged(State) (bool, error) @@ -122,7 +82,6 @@ type State interface { minerAddr address.Address, deals []abi.DealID, currEpoch, sectorExpiry abi.ChainEpoch, ) (weight, verifiedWeight abi.DealWeight, err error) NextID() (abi.DealID, error) - GetState() interface{} } type BalanceTable interface { @@ -148,6 +107,7 @@ type DealProposals interface { type PublishStorageDealsParams = market0.PublishStorageDealsParams type PublishStorageDealsReturn = market0.PublishStorageDealsReturn +type VerifyDealsForActivationParams = market0.VerifyDealsForActivationParams type WithdrawBalanceParams = market0.WithdrawBalanceParams type ClientDealProposal = market0.ClientDealProposal diff --git a/chain/actors/builtin/market/state.go.template b/chain/actors/builtin/market/state.go.template index 965c8d41f59..a55743ce553 100644 --- a/chain/actors/builtin/market/state.go.template +++ b/chain/actors/builtin/market/state.go.template @@ -26,31 +26,6 @@ func load{{.v}}(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make{{.v}}(store adt.Store) (State, error) { - out := state{{.v}}{store: store} - {{if (le .v 2)}} - ea, err := adt{{.v}}.MakeEmptyArray(store).Root() - if err != nil { - return nil, err - } - - em, err := adt{{.v}}.MakeEmptyMap(store).Root() - if err != nil { - return nil, err - } - - out.State = *market{{.v}}.ConstructState(ea, em, em) - {{else}} - s, err := market{{.v}}.ConstructState(store) - if err != nil { - return nil, err - } - - out.State = *s - {{end}} - return &out, nil -} - type state{{.v}} struct { market{{.v}}.State store adt.Store @@ -232,7 +207,3 @@ func (s *dealProposals{{.v}}) array() adt.Array { func fromV{{.v}}DealProposal(v{{.v}} market{{.v}}.DealProposal) DealProposal { return (DealProposal)(v{{.v}}) } - -func (s *state{{.v}}) GetState() interface{} { - return &s.State -} \ No newline at end of file diff --git a/chain/actors/builtin/market/temp b/chain/actors/builtin/market/temp deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/chain/actors/builtin/market/v0.go b/chain/actors/builtin/market/v0.go index b3093b54b0f..175c0a2ea9c 100644 --- a/chain/actors/builtin/market/v0.go +++ b/chain/actors/builtin/market/v0.go @@ -26,24 +26,6 @@ func load0(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make0(store adt.Store) (State, error) { - out := state0{store: store} - - ea, err := adt0.MakeEmptyArray(store).Root() - if err != nil { - return nil, err - } - - em, err := adt0.MakeEmptyMap(store).Root() - if err != nil { - return nil, err - } - - out.State = *market0.ConstructState(ea, em, em) - - return &out, nil -} - type state0 struct { market0.State store adt.Store @@ -225,7 +207,3 @@ func (s *dealProposals0) array() adt.Array { func fromV0DealProposal(v0 market0.DealProposal) DealProposal { return (DealProposal)(v0) } - -func (s *state0) GetState() interface{} { - return &s.State -} diff --git a/chain/actors/builtin/market/v2.go b/chain/actors/builtin/market/v2.go index fdedcce8547..dafae8feb95 100644 --- a/chain/actors/builtin/market/v2.go +++ b/chain/actors/builtin/market/v2.go @@ -26,24 +26,6 @@ func load2(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make2(store adt.Store) (State, error) { - out := state2{store: store} - - ea, err := adt2.MakeEmptyArray(store).Root() - if err != nil { - return nil, err - } - - em, err := adt2.MakeEmptyMap(store).Root() - if err != nil { - return nil, err - } - - out.State = *market2.ConstructState(ea, em, em) - - return &out, nil -} - type state2 struct { market2.State store adt.Store @@ -225,7 +207,3 @@ func (s *dealProposals2) array() adt.Array { func fromV2DealProposal(v2 market2.DealProposal) DealProposal { return (DealProposal)(v2) } - -func (s *state2) GetState() interface{} { - return &s.State -} diff --git a/chain/actors/builtin/market/v3.go b/chain/actors/builtin/market/v3.go index 53d26644380..dec8d6e2513 100644 --- a/chain/actors/builtin/market/v3.go +++ b/chain/actors/builtin/market/v3.go @@ -26,19 +26,6 @@ func load3(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make3(store adt.Store) (State, error) { - out := state3{store: store} - - s, err := market3.ConstructState(store) - if err != nil { - return nil, err - } - - out.State = *s - - return &out, nil -} - type state3 struct { market3.State store adt.Store @@ -220,7 +207,3 @@ func (s *dealProposals3) array() adt.Array { func fromV3DealProposal(v3 market3.DealProposal) DealProposal { return (DealProposal)(v3) } - -func (s *state3) GetState() interface{} { - return &s.State -} diff --git a/chain/actors/builtin/market/v4.go b/chain/actors/builtin/market/v4.go index 30aa2692057..22514395c00 100644 --- a/chain/actors/builtin/market/v4.go +++ b/chain/actors/builtin/market/v4.go @@ -26,19 +26,6 @@ func load4(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make4(store adt.Store) (State, error) { - out := state4{store: store} - - s, err := market4.ConstructState(store) - if err != nil { - return nil, err - } - - out.State = *s - - return &out, nil -} - type state4 struct { market4.State store adt.Store @@ -220,7 +207,3 @@ func (s *dealProposals4) array() adt.Array { func fromV4DealProposal(v4 market4.DealProposal) DealProposal { return (DealProposal)(v4) } - -func (s *state4) GetState() interface{} { - return &s.State -} diff --git a/chain/actors/builtin/miner/actor.go.template b/chain/actors/builtin/miner/actor.go.template index c7755ef71fc..4b3d8db5e6f 100644 --- a/chain/actors/builtin/miner/actor.go.template +++ b/chain/actors/builtin/miner/actor.go.template @@ -3,7 +3,6 @@ package miner import ( "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/network" - "github.com/filecoin-project/lotus/chain/actors" "github.com/ipfs/go-cid" "github.com/libp2p/go-libp2p-core/peer" cbg "github.com/whyrusleeping/cbor-gen" @@ -61,27 +60,6 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version) (State, error) { - switch av { -{{range .versions}} - case actors.Version{{.}}: - return make{{.}}(store) -{{end}} -} - return nil, xerrors.Errorf("unknown actor version %d", av) -} - -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { -{{range .versions}} - case actors.Version{{.}}: - return builtin{{.}}.StorageMinerActorCodeID, nil -{{end}} - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - type State interface { cbor.Marshaler @@ -101,11 +79,6 @@ type State interface { NumLiveSectors() (uint64, error) IsAllocated(abi.SectorNumber) (bool, error) - // Note that ProvingPeriodStart is deprecated and will be renamed / removed in a future version of actors - GetProvingPeriodStart() (abi.ChainEpoch, error) - // Testing only - EraseAllUnproven() error - LoadDeadline(idx uint64) (Deadline, error) ForEachDeadline(cb func(idx uint64, dl Deadline) error) error NumDeadlines() (uint64, error) @@ -122,7 +95,6 @@ type State interface { decodeSectorOnChainInfo(*cbg.Deferred) (SectorOnChainInfo, error) precommits() (adt.Map, error) decodeSectorPreCommitOnChainInfo(*cbg.Deferred) (SectorPreCommitOnChainInfo, error) - GetState() interface{} } type Deadline interface { @@ -143,26 +115,26 @@ type Partition interface { } 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 + 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 + Info SectorPreCommitInfo PreCommitDeposit abi.TokenAmount - PreCommitEpoch abi.ChainEpoch - DealWeight abi.DealWeight + PreCommitEpoch abi.ChainEpoch + DealWeight abi.DealWeight VerifiedDealWeight abi.DealWeight } @@ -231,17 +203,17 @@ func WinningPoStProofTypeFromWindowPoStProofType(nver network.Version, proof abi } 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 - WindowPoStProofType abi.RegisteredPoStProof - SectorSize abi.SectorSize + 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 + WindowPoStProofType abi.RegisteredPoStProof + SectorSize abi.SectorSize WindowPoStPartitionSectors uint64 - ConsensusFaultElapsed abi.ChainEpoch + ConsensusFaultElapsed abi.ChainEpoch } func (mi MinerInfo) IsController(addr address.Address) bool { @@ -272,25 +244,25 @@ type SectorLocation struct { } type SectorChanges struct { - Added []SectorOnChainInfo + Added []SectorOnChainInfo Extended []SectorExtensions - Removed []SectorOnChainInfo + Removed []SectorOnChainInfo } type SectorExtensions struct { From SectorOnChainInfo - To SectorOnChainInfo + To SectorOnChainInfo } type PreCommitChanges struct { - Added []SectorPreCommitOnChainInfo + Added []SectorPreCommitOnChainInfo Removed []SectorPreCommitOnChainInfo } type LockedFunds struct { - VestingFunds abi.TokenAmount + VestingFunds abi.TokenAmount InitialPledgeRequirement abi.TokenAmount - PreCommitDeposits abi.TokenAmount + PreCommitDeposits abi.TokenAmount } func (lf LockedFunds) TotalLockedFunds() abi.TokenAmount { diff --git a/chain/actors/builtin/miner/miner.go b/chain/actors/builtin/miner/miner.go index d9b872e3f92..a426e063b9c 100644 --- a/chain/actors/builtin/miner/miner.go +++ b/chain/actors/builtin/miner/miner.go @@ -3,7 +3,6 @@ package miner import ( "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/network" - "github.com/filecoin-project/lotus/chain/actors" "github.com/ipfs/go-cid" "github.com/libp2p/go-libp2p-core/peer" cbg "github.com/whyrusleeping/cbor-gen" @@ -87,45 +86,6 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version) (State, error) { - switch av { - - case actors.Version0: - return make0(store) - - case actors.Version2: - return make2(store) - - case actors.Version3: - return make3(store) - - case actors.Version4: - return make4(store) - - } - return nil, xerrors.Errorf("unknown actor version %d", av) -} - -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { - - case actors.Version0: - return builtin0.StorageMinerActorCodeID, nil - - case actors.Version2: - return builtin2.StorageMinerActorCodeID, nil - - case actors.Version3: - return builtin3.StorageMinerActorCodeID, nil - - case actors.Version4: - return builtin4.StorageMinerActorCodeID, nil - - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - type State interface { cbor.Marshaler @@ -145,11 +105,6 @@ type State interface { NumLiveSectors() (uint64, error) IsAllocated(abi.SectorNumber) (bool, error) - // Note that ProvingPeriodStart is deprecated and will be renamed / removed in a future version of actors - GetProvingPeriodStart() (abi.ChainEpoch, error) - // Testing only - EraseAllUnproven() error - LoadDeadline(idx uint64) (Deadline, error) ForEachDeadline(cb func(idx uint64, dl Deadline) error) error NumDeadlines() (uint64, error) @@ -166,7 +121,6 @@ type State interface { decodeSectorOnChainInfo(*cbg.Deferred) (SectorOnChainInfo, error) precommits() (adt.Map, error) decodeSectorPreCommitOnChainInfo(*cbg.Deferred) (SectorPreCommitOnChainInfo, error) - GetState() interface{} } type Deadline interface { diff --git a/chain/actors/builtin/miner/state.go.template b/chain/actors/builtin/miner/state.go.template index 270510a8c5b..0769eea1003 100644 --- a/chain/actors/builtin/miner/state.go.template +++ b/chain/actors/builtin/miner/state.go.template @@ -35,12 +35,6 @@ func load{{.v}}(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make{{.v}}(store adt.Store) (State, error) { - out := state{{.v}}{store: store} - out.State = miner{{.v}}.State{} - return &out, nil -} - type state{{.v}} struct { miner{{.v}}.State store adt.Store @@ -74,9 +68,9 @@ func (s *state{{.v}}) VestedFunds(epoch abi.ChainEpoch) (abi.TokenAmount, error) func (s *state{{.v}}) LockedFunds() (LockedFunds, error) { return LockedFunds{ - VestingFunds: s.State.LockedFunds, + VestingFunds: s.State.LockedFunds, InitialPledgeRequirement: s.State.InitialPledge{{if (le .v 1)}}Requirement{{end}}, - PreCommitDeposits: s.State.PreCommitDeposits, + PreCommitDeposits: s.State.PreCommitDeposits, }, nil } @@ -251,10 +245,6 @@ func (s *state{{.v}}) IsAllocated(num abi.SectorNumber) (bool, error) { return allocatedSectors.IsSet(uint64(num)) } -func (s *state{{.v}}) GetProvingPeriodStart() (abi.ChainEpoch, error) { - return s.State.ProvingPeriodStart, nil -} - func (s *state{{.v}}) LoadDeadline(idx uint64) (Deadline, error) { dls, err := s.State.LoadDeadlines(s.store) if err != nil { @@ -317,19 +307,19 @@ func (s *state{{.v}}) Info() (MinerInfo, error) { } {{end}} mi := MinerInfo{ - Owner: info.Owner, - Worker: info.Worker, + Owner: info.Owner, + Worker: info.Worker, ControlAddresses: info.ControlAddresses, - NewWorker: address.Undef, + NewWorker: address.Undef, WorkerChangeEpoch: -1, - PeerId: pid, - Multiaddrs: info.Multiaddrs, - WindowPoStProofType: {{if (ge .v 3)}}info.WindowPoStProofType{{else}}wpp{{end}}, - SectorSize: info.SectorSize, + PeerId: pid, + Multiaddrs: info.Multiaddrs, + WindowPoStProofType: {{if (ge .v 3)}}info.WindowPoStProofType{{else}}wpp{{end}}, + SectorSize: info.SectorSize, WindowPoStPartitionSectors: info.WindowPoStPartitionSectors, - ConsensusFaultElapsed: {{if (ge .v 2)}}info.ConsensusFaultElapsed{{else}}-1{{end}}, + ConsensusFaultElapsed: {{if (ge .v 2)}}info.ConsensusFaultElapsed{{else}}-1{{end}}, } if info.PendingWorkerKey != nil { @@ -376,45 +366,6 @@ func (s *state{{.v}}) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (Secto return fromV{{.v}}SectorPreCommitOnChainInfo(sp), nil } -func (s *state{{.v}}) EraseAllUnproven() error { - {{if (ge .v 2)}} - dls, err := s.State.LoadDeadlines(s.store) - if err != nil { - return err - } - - err = dls.ForEach(s.store, func(dindx uint64, dl *miner{{.v}}.Deadline) error { - ps, err := dl.PartitionsArray(s.store) - if err != nil { - return err - } - - var part miner{{.v}}.Partition - err = ps.ForEach(&part, func(pindx int64) error { - _ = part.ActivateUnproven() - err = ps.Set(uint64(pindx), &part) - return nil - }) - - if err != nil { - return err - } - - dl.Partitions, err = ps.Root() - if err != nil { - return err - } - - return dls.UpdateDeadline(s.store, dindx, dl) - }) - - return s.State.SaveDeadlines(s.store, dls) - {{else}} - // field doesn't exist until v2 - {{end}} - return nil -} - func (d *deadline{{.v}}) LoadPartition(idx uint64) (Partition, error) { p, err := d.Deadline.LoadPartition(d.store, idx) if err != nil { @@ -477,16 +428,16 @@ func (p *partition{{.v}}) RecoveringSectors() (bitfield.BitField, error) { func fromV{{.v}}SectorOnChainInfo(v{{.v}} miner{{.v}}.SectorOnChainInfo) SectorOnChainInfo { {{if (ge .v 2)}} return SectorOnChainInfo{ - SectorNumber: v{{.v}}.SectorNumber, - SealProof: v{{.v}}.SealProof, - SealedCID: v{{.v}}.SealedCID, - DealIDs: v{{.v}}.DealIDs, - Activation: v{{.v}}.Activation, - Expiration: v{{.v}}.Expiration, - DealWeight: v{{.v}}.DealWeight, - VerifiedDealWeight: v{{.v}}.VerifiedDealWeight, - InitialPledge: v{{.v}}.InitialPledge, - ExpectedDayReward: v{{.v}}.ExpectedDayReward, + SectorNumber: v{{.v}}.SectorNumber, + SealProof: v{{.v}}.SealProof, + SealedCID: v{{.v}}.SealedCID, + DealIDs: v{{.v}}.DealIDs, + Activation: v{{.v}}.Activation, + Expiration: v{{.v}}.Expiration, + DealWeight: v{{.v}}.DealWeight, + VerifiedDealWeight: v{{.v}}.VerifiedDealWeight, + InitialPledge: v{{.v}}.InitialPledge, + ExpectedDayReward: v{{.v}}.ExpectedDayReward, ExpectedStoragePledge: v{{.v}}.ExpectedStoragePledge, } {{else}} @@ -497,17 +448,13 @@ func fromV{{.v}}SectorOnChainInfo(v{{.v}} miner{{.v}}.SectorOnChainInfo) SectorO func fromV{{.v}}SectorPreCommitOnChainInfo(v{{.v}} miner{{.v}}.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo { {{if (ge .v 2)}} return SectorPreCommitOnChainInfo{ - Info: (SectorPreCommitInfo)(v{{.v}}.Info), - PreCommitDeposit: v{{.v}}.PreCommitDeposit, - PreCommitEpoch: v{{.v}}.PreCommitEpoch, - DealWeight: v{{.v}}.DealWeight, + Info: (SectorPreCommitInfo)(v{{.v}}.Info), + PreCommitDeposit: v{{.v}}.PreCommitDeposit, + PreCommitEpoch: v{{.v}}.PreCommitEpoch, + DealWeight: v{{.v}}.DealWeight, VerifiedDealWeight: v{{.v}}.VerifiedDealWeight, } {{else}} return (SectorPreCommitOnChainInfo)(v0) {{end}} } - -func (s *state{{.v}}) GetState() interface{} { - return &s.State -} \ No newline at end of file diff --git a/chain/actors/builtin/miner/temp b/chain/actors/builtin/miner/temp deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/chain/actors/builtin/miner/v0.go b/chain/actors/builtin/miner/v0.go index 344be199360..2dc8ae23e75 100644 --- a/chain/actors/builtin/miner/v0.go +++ b/chain/actors/builtin/miner/v0.go @@ -32,12 +32,6 @@ func load0(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make0(store adt.Store) (State, error) { - out := state0{store: store} - out.State = miner0.State{} - return &out, nil -} - type state0 struct { miner0.State store adt.Store @@ -248,10 +242,6 @@ func (s *state0) IsAllocated(num abi.SectorNumber) (bool, error) { return allocatedSectors.IsSet(uint64(num)) } -func (s *state0) GetProvingPeriodStart() (abi.ChainEpoch, error) { - return s.State.ProvingPeriodStart, nil -} - func (s *state0) LoadDeadline(idx uint64) (Deadline, error) { dls, err := s.State.LoadDeadlines(s.store) if err != nil { @@ -373,13 +363,6 @@ func (s *state0) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreC return fromV0SectorPreCommitOnChainInfo(sp), nil } -func (s *state0) EraseAllUnproven() error { - - // field doesn't exist until v2 - - return nil -} - func (d *deadline0) LoadPartition(idx uint64) (Partition, error) { p, err := d.Deadline.LoadPartition(d.store, idx) if err != nil { @@ -443,7 +426,3 @@ func fromV0SectorPreCommitOnChainInfo(v0 miner0.SectorPreCommitOnChainInfo) Sect return (SectorPreCommitOnChainInfo)(v0) } - -func (s *state0) GetState() interface{} { - return &s.State -} diff --git a/chain/actors/builtin/miner/v2.go b/chain/actors/builtin/miner/v2.go index 3e76d0b6977..7564dd8b8ea 100644 --- a/chain/actors/builtin/miner/v2.go +++ b/chain/actors/builtin/miner/v2.go @@ -30,12 +30,6 @@ func load2(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make2(store adt.Store) (State, error) { - out := state2{store: store} - out.State = miner2.State{} - return &out, nil -} - type state2 struct { miner2.State store adt.Store @@ -246,10 +240,6 @@ func (s *state2) IsAllocated(num abi.SectorNumber) (bool, error) { return allocatedSectors.IsSet(uint64(num)) } -func (s *state2) GetProvingPeriodStart() (abi.ChainEpoch, error) { - return s.State.ProvingPeriodStart, nil -} - func (s *state2) LoadDeadline(idx uint64) (Deadline, error) { dls, err := s.State.LoadDeadlines(s.store) if err != nil { @@ -371,43 +361,6 @@ func (s *state2) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreC return fromV2SectorPreCommitOnChainInfo(sp), nil } -func (s *state2) EraseAllUnproven() error { - - dls, err := s.State.LoadDeadlines(s.store) - if err != nil { - return err - } - - err = dls.ForEach(s.store, func(dindx uint64, dl *miner2.Deadline) error { - ps, err := dl.PartitionsArray(s.store) - if err != nil { - return err - } - - var part miner2.Partition - err = ps.ForEach(&part, func(pindx int64) error { - _ = part.ActivateUnproven() - err = ps.Set(uint64(pindx), &part) - return nil - }) - - if err != nil { - return err - } - - dl.Partitions, err = ps.Root() - if err != nil { - return err - } - - return dls.UpdateDeadline(s.store, dindx, dl) - }) - - return s.State.SaveDeadlines(s.store, dls) - - return nil -} - func (d *deadline2) LoadPartition(idx uint64) (Partition, error) { p, err := d.Deadline.LoadPartition(d.store, idx) if err != nil { @@ -489,7 +442,3 @@ func fromV2SectorPreCommitOnChainInfo(v2 miner2.SectorPreCommitOnChainInfo) Sect } } - -func (s *state2) GetState() interface{} { - return &s.State -} diff --git a/chain/actors/builtin/miner/v3.go b/chain/actors/builtin/miner/v3.go index 72986233d2e..72a080f73c2 100644 --- a/chain/actors/builtin/miner/v3.go +++ b/chain/actors/builtin/miner/v3.go @@ -32,12 +32,6 @@ func load3(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make3(store adt.Store) (State, error) { - out := state3{store: store} - out.State = miner3.State{} - return &out, nil -} - type state3 struct { miner3.State store adt.Store @@ -248,10 +242,6 @@ func (s *state3) IsAllocated(num abi.SectorNumber) (bool, error) { return allocatedSectors.IsSet(uint64(num)) } -func (s *state3) GetProvingPeriodStart() (abi.ChainEpoch, error) { - return s.State.ProvingPeriodStart, nil -} - func (s *state3) LoadDeadline(idx uint64) (Deadline, error) { dls, err := s.State.LoadDeadlines(s.store) if err != nil { @@ -368,43 +358,6 @@ func (s *state3) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreC return fromV3SectorPreCommitOnChainInfo(sp), nil } -func (s *state3) EraseAllUnproven() error { - - dls, err := s.State.LoadDeadlines(s.store) - if err != nil { - return err - } - - err = dls.ForEach(s.store, func(dindx uint64, dl *miner3.Deadline) error { - ps, err := dl.PartitionsArray(s.store) - if err != nil { - return err - } - - var part miner3.Partition - err = ps.ForEach(&part, func(pindx int64) error { - _ = part.ActivateUnproven() - err = ps.Set(uint64(pindx), &part) - return nil - }) - - if err != nil { - return err - } - - dl.Partitions, err = ps.Root() - if err != nil { - return err - } - - return dls.UpdateDeadline(s.store, dindx, dl) - }) - - return s.State.SaveDeadlines(s.store, dls) - - return nil -} - func (d *deadline3) LoadPartition(idx uint64) (Partition, error) { p, err := d.Deadline.LoadPartition(d.store, idx) if err != nil { @@ -490,7 +443,3 @@ func fromV3SectorPreCommitOnChainInfo(v3 miner3.SectorPreCommitOnChainInfo) Sect } } - -func (s *state3) GetState() interface{} { - return &s.State -} diff --git a/chain/actors/builtin/miner/v4.go b/chain/actors/builtin/miner/v4.go index 96ed21f0450..698bdf2f53f 100644 --- a/chain/actors/builtin/miner/v4.go +++ b/chain/actors/builtin/miner/v4.go @@ -32,12 +32,6 @@ func load4(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make4(store adt.Store) (State, error) { - out := state4{store: store} - out.State = miner4.State{} - return &out, nil -} - type state4 struct { miner4.State store adt.Store @@ -248,10 +242,6 @@ func (s *state4) IsAllocated(num abi.SectorNumber) (bool, error) { return allocatedSectors.IsSet(uint64(num)) } -func (s *state4) GetProvingPeriodStart() (abi.ChainEpoch, error) { - return s.State.ProvingPeriodStart, nil -} - func (s *state4) LoadDeadline(idx uint64) (Deadline, error) { dls, err := s.State.LoadDeadlines(s.store) if err != nil { @@ -368,43 +358,6 @@ func (s *state4) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreC return fromV4SectorPreCommitOnChainInfo(sp), nil } -func (s *state4) EraseAllUnproven() error { - - dls, err := s.State.LoadDeadlines(s.store) - if err != nil { - return err - } - - err = dls.ForEach(s.store, func(dindx uint64, dl *miner4.Deadline) error { - ps, err := dl.PartitionsArray(s.store) - if err != nil { - return err - } - - var part miner4.Partition - err = ps.ForEach(&part, func(pindx int64) error { - _ = part.ActivateUnproven() - err = ps.Set(uint64(pindx), &part) - return nil - }) - - if err != nil { - return err - } - - dl.Partitions, err = ps.Root() - if err != nil { - return err - } - - return dls.UpdateDeadline(s.store, dindx, dl) - }) - - return s.State.SaveDeadlines(s.store, dls) - - return nil -} - func (d *deadline4) LoadPartition(idx uint64) (Partition, error) { p, err := d.Deadline.LoadPartition(d.store, idx) if err != nil { @@ -490,7 +443,3 @@ func fromV4SectorPreCommitOnChainInfo(v4 miner4.SectorPreCommitOnChainInfo) Sect } } - -func (s *state4) GetState() interface{} { - return &s.State -} diff --git a/chain/actors/builtin/multisig/actor.go.template b/chain/actors/builtin/multisig/actor.go.template index 3af270c60f6..19d99dcb729 100644 --- a/chain/actors/builtin/multisig/actor.go.template +++ b/chain/actors/builtin/multisig/actor.go.template @@ -40,27 +40,6 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) { - switch av { -{{range .versions}} - case actors.Version{{.}}: - return make{{.}}(store, signers, threshold, startEpoch, unlockDuration, initialBalance) -{{end}} -} - return nil, xerrors.Errorf("unknown actor version %d", av) -} - -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { -{{range .versions}} - case actors.Version{{.}}: - return builtin{{.}}.MultisigActorCodeID, nil -{{end}} - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - type State interface { cbor.Marshaler @@ -76,7 +55,6 @@ type State interface { transactions() (adt.Map, error) decodeTransaction(val *cbg.Deferred) (Transaction, error) - GetState() interface{} } type Transaction = msig{{.latestVersion}}.Transaction @@ -88,7 +66,7 @@ func Message(version actors.Version, from address.Address) MessageBuilder { {{range .versions}} case actors.Version{{.}}: return message{{.}}{{"{"}}{{if (ge . 2)}}message0{from}{{else}}from{{end}}} -{{end}} default: +{{end}} default: panic(fmt.Sprintf("unsupported actors version: %d", version)) } } diff --git a/chain/actors/builtin/multisig/message.go.template b/chain/actors/builtin/multisig/message.go.template index 917e6944baa..6bff8983ab0 100644 --- a/chain/actors/builtin/multisig/message.go.template +++ b/chain/actors/builtin/multisig/message.go.template @@ -43,10 +43,10 @@ func (m message{{.v}}) Create( {{end}} // Set up constructor parameters for multisig msigParams := &multisig{{.v}}.ConstructorParams{ - Signers: signers, + Signers: signers, NumApprovalsThreshold: threshold, - UnlockDuration: unlockDuration,{{if (ge .v 2)}} - StartEpoch: unlockStart,{{end}} + UnlockDuration: unlockDuration,{{if (ge .v 2)}} + StartEpoch: unlockStart,{{end}} } enc, actErr := actors.SerializeParams(msigParams) @@ -56,7 +56,7 @@ func (m message{{.v}}) Create( // new actors are created by invoking 'exec' on the init actor with the constructor params execParams := &init{{.v}}.ExecParams{ - CodeCID: builtin{{.v}}.MultisigActorCodeID, + CodeCID: builtin{{.v}}.MultisigActorCodeID, ConstructorParams: enc, } @@ -66,11 +66,11 @@ func (m message{{.v}}) Create( } return &types.Message{ - To: init_.Address, - From: m.from, + To: init_.Address, + From: m.from, Method: builtin{{.v}}.MethodsInit.Exec, Params: enc, - Value: initialAmount, + Value: initialAmount, }, nil } @@ -96,8 +96,8 @@ func (m message0) Propose(msig, to address.Address, amt abi.TokenAmount, } enc, actErr := actors.SerializeParams(&multisig0.ProposeParams{ - To: to, - Value: amt, + To: to, + Value: amt, Method: method, Params: params, }) @@ -106,9 +106,9 @@ func (m message0) Propose(msig, to address.Address, amt abi.TokenAmount, } return &types.Message{ - To: msig, - From: m.from, - Value: abi.NewTokenAmount(0), + To: msig, + From: m.from, + Value: abi.NewTokenAmount(0), Method: builtin0.MethodsMultisig.Propose, Params: enc, }, nil @@ -121,9 +121,9 @@ func (m message0) Approve(msig address.Address, txID uint64, hashData *ProposalH } return &types.Message{ - To: msig, - From: m.from, - Value: types.NewInt(0), + To: msig, + From: m.from, + Value: types.NewInt(0), Method: builtin0.MethodsMultisig.Approve, Params: enc, }, nil @@ -136,9 +136,9 @@ func (m message0) Cancel(msig address.Address, txID uint64, hashData *ProposalHa } return &types.Message{ - To: msig, - From: m.from, - Value: types.NewInt(0), + To: msig, + From: m.from, + Value: types.NewInt(0), Method: builtin0.MethodsMultisig.Cancel, Params: enc, }, nil diff --git a/chain/actors/builtin/multisig/multisig.go b/chain/actors/builtin/multisig/multisig.go index fd773f39804..d8f6fabae20 100644 --- a/chain/actors/builtin/multisig/multisig.go +++ b/chain/actors/builtin/multisig/multisig.go @@ -66,45 +66,6 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) { - switch av { - - case actors.Version0: - return make0(store, signers, threshold, startEpoch, unlockDuration, initialBalance) - - case actors.Version2: - return make2(store, signers, threshold, startEpoch, unlockDuration, initialBalance) - - case actors.Version3: - return make3(store, signers, threshold, startEpoch, unlockDuration, initialBalance) - - case actors.Version4: - return make4(store, signers, threshold, startEpoch, unlockDuration, initialBalance) - - } - return nil, xerrors.Errorf("unknown actor version %d", av) -} - -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { - - case actors.Version0: - return builtin0.MultisigActorCodeID, nil - - case actors.Version2: - return builtin2.MultisigActorCodeID, nil - - case actors.Version3: - return builtin3.MultisigActorCodeID, nil - - case actors.Version4: - return builtin4.MultisigActorCodeID, nil - - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - type State interface { cbor.Marshaler @@ -120,7 +81,6 @@ type State interface { transactions() (adt.Map, error) decodeTransaction(val *cbg.Deferred) (Transaction, error) - GetState() interface{} } type Transaction = msig4.Transaction diff --git a/chain/actors/builtin/multisig/state.go.template b/chain/actors/builtin/multisig/state.go.template index 067415533d9..2316aadba0c 100644 --- a/chain/actors/builtin/multisig/state.go.template +++ b/chain/actors/builtin/multisig/state.go.template @@ -31,32 +31,6 @@ func load{{.v}}(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make{{.v}}(store adt.Store, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) { - out := state{{.v}}{store: store} - out.State = msig{{.v}}.State{} - out.State.Signers = signers - out.State.NumApprovalsThreshold = threshold - out.State.StartEpoch = startEpoch - out.State.UnlockDuration = unlockDuration - out.State.InitialBalance = initialBalance - {{if (le .v 2)}} - em, err := adt{{.v}}.MakeEmptyMap(store).Root() - if err != nil { - return nil, err - } - - out.State.PendingTxns = em - {{else}} - em, err := adt{{.v}}.StoreEmptyMap(store, builtin{{.v}}.DefaultHamtBitwidth) - if err != nil { - return nil, err - } - - out.State.PendingTxns = em - {{end}} - return &out, nil -} - type state{{.v}} struct { msig{{.v}}.State store adt.Store @@ -121,7 +95,3 @@ func (s *state{{.v}}) decodeTransaction(val *cbg.Deferred) (Transaction, error) } return tx, nil } - -func (s *state{{.v}}) GetState() interface{} { - return &s.State -} \ No newline at end of file diff --git a/chain/actors/builtin/multisig/temp b/chain/actors/builtin/multisig/temp deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/chain/actors/builtin/multisig/v0.go b/chain/actors/builtin/multisig/v0.go index 973ac920904..20c1557b007 100644 --- a/chain/actors/builtin/multisig/v0.go +++ b/chain/actors/builtin/multisig/v0.go @@ -28,25 +28,6 @@ func load0(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make0(store adt.Store, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) { - out := state0{store: store} - out.State = msig0.State{} - out.State.Signers = signers - out.State.NumApprovalsThreshold = threshold - out.State.StartEpoch = startEpoch - out.State.UnlockDuration = unlockDuration - out.State.InitialBalance = initialBalance - - em, err := adt0.MakeEmptyMap(store).Root() - if err != nil { - return nil, err - } - - out.State.PendingTxns = em - - return &out, nil -} - type state0 struct { msig0.State store adt.Store @@ -111,7 +92,3 @@ func (s *state0) decodeTransaction(val *cbg.Deferred) (Transaction, error) { } return tx, nil } - -func (s *state0) GetState() interface{} { - return &s.State -} diff --git a/chain/actors/builtin/multisig/v2.go b/chain/actors/builtin/multisig/v2.go index 5b830e69530..ef317f903e2 100644 --- a/chain/actors/builtin/multisig/v2.go +++ b/chain/actors/builtin/multisig/v2.go @@ -28,25 +28,6 @@ func load2(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make2(store adt.Store, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) { - out := state2{store: store} - out.State = msig2.State{} - out.State.Signers = signers - out.State.NumApprovalsThreshold = threshold - out.State.StartEpoch = startEpoch - out.State.UnlockDuration = unlockDuration - out.State.InitialBalance = initialBalance - - em, err := adt2.MakeEmptyMap(store).Root() - if err != nil { - return nil, err - } - - out.State.PendingTxns = em - - return &out, nil -} - type state2 struct { msig2.State store adt.Store @@ -111,7 +92,3 @@ func (s *state2) decodeTransaction(val *cbg.Deferred) (Transaction, error) { } return tx, nil } - -func (s *state2) GetState() interface{} { - return &s.State -} diff --git a/chain/actors/builtin/multisig/v3.go b/chain/actors/builtin/multisig/v3.go index c4a2791b705..8834e455348 100644 --- a/chain/actors/builtin/multisig/v3.go +++ b/chain/actors/builtin/multisig/v3.go @@ -30,25 +30,6 @@ func load3(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make3(store adt.Store, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) { - out := state3{store: store} - out.State = msig3.State{} - out.State.Signers = signers - out.State.NumApprovalsThreshold = threshold - out.State.StartEpoch = startEpoch - out.State.UnlockDuration = unlockDuration - out.State.InitialBalance = initialBalance - - em, err := adt3.StoreEmptyMap(store, builtin3.DefaultHamtBitwidth) - if err != nil { - return nil, err - } - - out.State.PendingTxns = em - - return &out, nil -} - type state3 struct { msig3.State store adt.Store @@ -113,7 +94,3 @@ func (s *state3) decodeTransaction(val *cbg.Deferred) (Transaction, error) { } return tx, nil } - -func (s *state3) GetState() interface{} { - return &s.State -} diff --git a/chain/actors/builtin/multisig/v4.go b/chain/actors/builtin/multisig/v4.go index a35a890f870..9f9dc75730f 100644 --- a/chain/actors/builtin/multisig/v4.go +++ b/chain/actors/builtin/multisig/v4.go @@ -30,25 +30,6 @@ func load4(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make4(store adt.Store, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) { - out := state4{store: store} - out.State = msig4.State{} - out.State.Signers = signers - out.State.NumApprovalsThreshold = threshold - out.State.StartEpoch = startEpoch - out.State.UnlockDuration = unlockDuration - out.State.InitialBalance = initialBalance - - em, err := adt4.StoreEmptyMap(store, builtin4.DefaultHamtBitwidth) - if err != nil { - return nil, err - } - - out.State.PendingTxns = em - - return &out, nil -} - type state4 struct { msig4.State store adt.Store @@ -113,7 +94,3 @@ func (s *state4) decodeTransaction(val *cbg.Deferred) (Transaction, error) { } return tx, nil } - -func (s *state4) GetState() interface{} { - return &s.State -} diff --git a/chain/actors/builtin/paych/actor.go.template b/chain/actors/builtin/paych/actor.go.template index 7699e76b631..3f68a5cfaab 100644 --- a/chain/actors/builtin/paych/actor.go.template +++ b/chain/actors/builtin/paych/actor.go.template @@ -42,27 +42,6 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version) (State, error) { - switch av { -{{range .versions}} - case actors.Version{{.}}: - return make{{.}}(store) -{{end}} -} - return nil, xerrors.Errorf("unknown actor version %d", av) -} - -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { -{{range .versions}} - case actors.Version{{.}}: - return builtin{{.}}.PaymentChannelActorCodeID, nil -{{end}} - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - // State is an abstract version of payment channel state that works across // versions type State interface { @@ -83,8 +62,6 @@ type State interface { // Iterate lane states ForEachLaneState(cb func(idx uint64, dl LaneState) error) error - - GetState() interface{} } // LaneState is an abstract copy of the state of a single lane diff --git a/chain/actors/builtin/paych/message.go.template b/chain/actors/builtin/paych/message.go.template index cb111d9104e..4a5ea2331e5 100644 --- a/chain/actors/builtin/paych/message.go.template +++ b/chain/actors/builtin/paych/message.go.template @@ -21,7 +21,7 @@ func (m message{{.v}}) Create(to address.Address, initialAmount abi.TokenAmount) return nil, aerr } enc, aerr := actors.SerializeParams(&init{{.v}}.ExecParams{ - CodeCID: builtin{{.v}}.PaymentChannelActorCodeID, + CodeCID: builtin{{.v}}.PaymentChannelActorCodeID, ConstructorParams: params, }) if aerr != nil { @@ -29,9 +29,9 @@ func (m message{{.v}}) Create(to address.Address, initialAmount abi.TokenAmount) } return &types.Message{ - To: init_.Address, - From: m.from, - Value: initialAmount, + To: init_.Address, + From: m.from, + Value: initialAmount, Method: builtin{{.v}}.MethodsInit.Exec, Params: enc, }, nil @@ -39,7 +39,7 @@ func (m message{{.v}}) Create(to address.Address, initialAmount abi.TokenAmount) func (m message{{.v}}) Update(paych address.Address, sv *SignedVoucher, secret []byte) (*types.Message, error) { params, aerr := actors.SerializeParams(&paych{{.v}}.UpdateChannelStateParams{ - Sv: *sv, + Sv: *sv, Secret: secret, }) if aerr != nil { @@ -47,9 +47,9 @@ func (m message{{.v}}) Update(paych address.Address, sv *SignedVoucher, secret [ } return &types.Message{ - To: paych, - From: m.from, - Value: abi.NewTokenAmount(0), + To: paych, + From: m.from, + Value: abi.NewTokenAmount(0), Method: builtin{{.v}}.MethodsPaych.UpdateChannelState, Params: params, }, nil @@ -57,18 +57,18 @@ func (m message{{.v}}) Update(paych address.Address, sv *SignedVoucher, secret [ func (m message{{.v}}) Settle(paych address.Address) (*types.Message, error) { return &types.Message{ - To: paych, - From: m.from, - Value: abi.NewTokenAmount(0), + To: paych, + From: m.from, + Value: abi.NewTokenAmount(0), Method: builtin{{.v}}.MethodsPaych.Settle, }, nil } func (m message{{.v}}) Collect(paych address.Address) (*types.Message, error) { return &types.Message{ - To: paych, - From: m.from, - Value: abi.NewTokenAmount(0), + To: paych, + From: m.from, + Value: abi.NewTokenAmount(0), Method: builtin{{.v}}.MethodsPaych.Collect, }, nil } diff --git a/chain/actors/builtin/paych/mock/mock.go b/chain/actors/builtin/paych/mock/mock.go index 1ecfa113070..3b82511ffa0 100644 --- a/chain/actors/builtin/paych/mock/mock.go +++ b/chain/actors/builtin/paych/mock/mock.go @@ -17,10 +17,6 @@ type mockState struct { lanes map[uint64]paych.LaneState } -func (ms *mockState) GetState() interface{} { - panic("implement me") -} - type mockLaneState struct { redeemed big.Int nonce uint64 diff --git a/chain/actors/builtin/paych/mock/temp b/chain/actors/builtin/paych/mock/temp deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/chain/actors/builtin/paych/paych.go b/chain/actors/builtin/paych/paych.go index 63638cda13d..30e4408d8fe 100644 --- a/chain/actors/builtin/paych/paych.go +++ b/chain/actors/builtin/paych/paych.go @@ -68,45 +68,6 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version) (State, error) { - switch av { - - case actors.Version0: - return make0(store) - - case actors.Version2: - return make2(store) - - case actors.Version3: - return make3(store) - - case actors.Version4: - return make4(store) - - } - return nil, xerrors.Errorf("unknown actor version %d", av) -} - -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { - - case actors.Version0: - return builtin0.PaymentChannelActorCodeID, nil - - case actors.Version2: - return builtin2.PaymentChannelActorCodeID, nil - - case actors.Version3: - return builtin3.PaymentChannelActorCodeID, nil - - case actors.Version4: - return builtin4.PaymentChannelActorCodeID, nil - - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - // State is an abstract version of payment channel state that works across // versions type State interface { @@ -127,8 +88,6 @@ type State interface { // Iterate lane states ForEachLaneState(cb func(idx uint64, dl LaneState) error) error - - GetState() interface{} } // LaneState is an abstract copy of the state of a single lane diff --git a/chain/actors/builtin/paych/state.go.template b/chain/actors/builtin/paych/state.go.template index 3e41f5be5f6..b4b575a3e61 100644 --- a/chain/actors/builtin/paych/state.go.template +++ b/chain/actors/builtin/paych/state.go.template @@ -24,12 +24,6 @@ func load{{.v}}(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make{{.v}}(store adt.Store) (State, error) { - out := state{{.v}}{store: store} - out.State = paych{{.v}}.State{} - return &out, nil -} - type state{{.v}} struct { paych{{.v}}.State store adt.Store @@ -80,10 +74,6 @@ func (s *state{{.v}}) LaneCount() (uint64, error) { return lsamt.Length(), nil } -func (s *state{{.v}}) GetState() interface{} { - return &s.State -} - // Iterate lane states func (s *state{{.v}}) ForEachLaneState(cb func(idx uint64, dl LaneState) error) error { // Get the lane state from the chain diff --git a/chain/actors/builtin/paych/temp b/chain/actors/builtin/paych/temp deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/chain/actors/builtin/paych/v0.go b/chain/actors/builtin/paych/v0.go index e9bc30e3d18..8e0e3434e07 100644 --- a/chain/actors/builtin/paych/v0.go +++ b/chain/actors/builtin/paych/v0.go @@ -24,12 +24,6 @@ func load0(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make0(store adt.Store) (State, error) { - out := state0{store: store} - out.State = paych0.State{} - return &out, nil -} - type state0 struct { paych0.State store adt.Store @@ -80,10 +74,6 @@ func (s *state0) LaneCount() (uint64, error) { return lsamt.Length(), nil } -func (s *state0) GetState() interface{} { - return &s.State -} - // Iterate lane states func (s *state0) ForEachLaneState(cb func(idx uint64, dl LaneState) error) error { // Get the lane state from the chain diff --git a/chain/actors/builtin/paych/v2.go b/chain/actors/builtin/paych/v2.go index 400305e2fb0..fbf4b9fde3b 100644 --- a/chain/actors/builtin/paych/v2.go +++ b/chain/actors/builtin/paych/v2.go @@ -24,12 +24,6 @@ func load2(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make2(store adt.Store) (State, error) { - out := state2{store: store} - out.State = paych2.State{} - return &out, nil -} - type state2 struct { paych2.State store adt.Store @@ -80,10 +74,6 @@ func (s *state2) LaneCount() (uint64, error) { return lsamt.Length(), nil } -func (s *state2) GetState() interface{} { - return &s.State -} - // Iterate lane states func (s *state2) ForEachLaneState(cb func(idx uint64, dl LaneState) error) error { // Get the lane state from the chain diff --git a/chain/actors/builtin/paych/v3.go b/chain/actors/builtin/paych/v3.go index 1d7c2f94b06..14bb4cb6146 100644 --- a/chain/actors/builtin/paych/v3.go +++ b/chain/actors/builtin/paych/v3.go @@ -24,12 +24,6 @@ func load3(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make3(store adt.Store) (State, error) { - out := state3{store: store} - out.State = paych3.State{} - return &out, nil -} - type state3 struct { paych3.State store adt.Store @@ -80,10 +74,6 @@ func (s *state3) LaneCount() (uint64, error) { return lsamt.Length(), nil } -func (s *state3) GetState() interface{} { - return &s.State -} - // Iterate lane states func (s *state3) ForEachLaneState(cb func(idx uint64, dl LaneState) error) error { // Get the lane state from the chain diff --git a/chain/actors/builtin/paych/v4.go b/chain/actors/builtin/paych/v4.go index b7d1e52a5b8..cf37eea5c19 100644 --- a/chain/actors/builtin/paych/v4.go +++ b/chain/actors/builtin/paych/v4.go @@ -24,12 +24,6 @@ func load4(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make4(store adt.Store) (State, error) { - out := state4{store: store} - out.State = paych4.State{} - return &out, nil -} - type state4 struct { paych4.State store adt.Store @@ -80,10 +74,6 @@ func (s *state4) LaneCount() (uint64, error) { return lsamt.Length(), nil } -func (s *state4) GetState() interface{} { - return &s.State -} - // Iterate lane states func (s *state4) ForEachLaneState(cb func(idx uint64, dl LaneState) error) error { // Get the lane state from the chain diff --git a/chain/actors/builtin/power/actor.go.template b/chain/actors/builtin/power/actor.go.template index 7ff3d038737..82f791e5805 100644 --- a/chain/actors/builtin/power/actor.go.template +++ b/chain/actors/builtin/power/actor.go.template @@ -3,7 +3,6 @@ package power import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/big" - "github.com/filecoin-project/lotus/chain/actors" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" @@ -41,27 +40,6 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version) (State, error) { - switch av { -{{range .versions}} - case actors.Version{{.}}: - return make{{.}}(store) -{{end}} -} - return nil, xerrors.Errorf("unknown actor version %d", av) -} - -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { -{{range .versions}} - case actors.Version{{.}}: - return builtin{{.}}.StoragePowerActorCodeID, nil -{{end}} - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - type State interface { cbor.Marshaler @@ -69,7 +47,6 @@ type State interface { TotalPower() (Claim, error) TotalCommitted() (Claim, error) TotalPowerSmoothed() (builtin.FilterEstimate, error) - GetState() interface{} // MinerCounts returns the number of miners. Participating is the number // with power above the minimum miner threshold. @@ -80,12 +57,6 @@ type State interface { ForEachClaim(func(miner address.Address, claim Claim) error) error ClaimsChanged(State) (bool, error) - // Testing or genesis setup only - SetTotalQualityAdjPower(abi.StoragePower) error - SetTotalRawBytePower(abi.StoragePower) error - SetThisEpochQualityAdjPower(abi.StoragePower) error - SetThisEpochRawBytePower(abi.StoragePower) error - // Diff helpers. Used by Diff* functions internally. claims() (adt.Map, error) decodeClaim(*cbg.Deferred) (Claim, error) @@ -101,7 +72,7 @@ type Claim struct { func AddClaims(a Claim, b Claim) Claim { return Claim{ - RawBytePower: big.Add(a.RawBytePower, b.RawBytePower), + RawBytePower: big.Add(a.RawBytePower, b.RawBytePower), QualityAdjPower: big.Add(a.QualityAdjPower, b.QualityAdjPower), } } diff --git a/chain/actors/builtin/power/power.go b/chain/actors/builtin/power/power.go index 69ed6cf89d8..bf530a21a60 100644 --- a/chain/actors/builtin/power/power.go +++ b/chain/actors/builtin/power/power.go @@ -3,7 +3,6 @@ package power import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/big" - "github.com/filecoin-project/lotus/chain/actors" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" @@ -67,45 +66,6 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version) (State, error) { - switch av { - - case actors.Version0: - return make0(store) - - case actors.Version2: - return make2(store) - - case actors.Version3: - return make3(store) - - case actors.Version4: - return make4(store) - - } - return nil, xerrors.Errorf("unknown actor version %d", av) -} - -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { - - case actors.Version0: - return builtin0.StoragePowerActorCodeID, nil - - case actors.Version2: - return builtin2.StoragePowerActorCodeID, nil - - case actors.Version3: - return builtin3.StoragePowerActorCodeID, nil - - case actors.Version4: - return builtin4.StoragePowerActorCodeID, nil - - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - type State interface { cbor.Marshaler @@ -113,7 +73,6 @@ type State interface { TotalPower() (Claim, error) TotalCommitted() (Claim, error) TotalPowerSmoothed() (builtin.FilterEstimate, error) - GetState() interface{} // MinerCounts returns the number of miners. Participating is the number // with power above the minimum miner threshold. @@ -124,12 +83,6 @@ type State interface { ForEachClaim(func(miner address.Address, claim Claim) error) error ClaimsChanged(State) (bool, error) - // Testing or genesis setup only - SetTotalQualityAdjPower(abi.StoragePower) error - SetTotalRawBytePower(abi.StoragePower) error - SetThisEpochQualityAdjPower(abi.StoragePower) error - SetThisEpochRawBytePower(abi.StoragePower) error - // Diff helpers. Used by Diff* functions internally. claims() (adt.Map, error) decodeClaim(*cbg.Deferred) (Claim, error) diff --git a/chain/actors/builtin/power/state.go.template b/chain/actors/builtin/power/state.go.template index d0abba3fafc..4cb904a1df7 100644 --- a/chain/actors/builtin/power/state.go.template +++ b/chain/actors/builtin/power/state.go.template @@ -29,32 +29,6 @@ func load{{.v}}(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make{{.v}}(store adt.Store) (State, error) { - out := state{{.v}}{store: store} - {{if (le .v 2)}} - em, err := adt{{.v}}.MakeEmptyMap(store).Root() - if err != nil { - return nil, err - } - - emm, err := adt{{.v}}.MakeEmptyMultimap(store).Root() - if err != nil { - return nil, err - } - - out.State = *power{{.v}}.ConstructState(em, emm) - {{else}} - s, err := power{{.v}}.ConstructState(store) - if err != nil { - return nil, err - } - - out.State = *s - {{end}} - - return &out, nil -} - type state{{.v}} struct { power{{.v}}.State store adt.Store @@ -66,7 +40,7 @@ func (s *state{{.v}}) TotalLocked() (abi.TokenAmount, error) { func (s *state{{.v}}) TotalPower() (Claim, error) { return Claim{ - RawBytePower: s.TotalRawBytePower, + RawBytePower: s.TotalRawBytePower, QualityAdjPower: s.TotalQualityAdjPower, }, nil } @@ -74,7 +48,7 @@ func (s *state{{.v}}) TotalPower() (Claim, error) { // Committed power to the network. Includes miners below the minimum threshold. func (s *state{{.v}}) TotalCommitted() (Claim, error) { return Claim{ - RawBytePower: s.TotalBytesCommitted, + RawBytePower: s.TotalBytesCommitted, QualityAdjPower: s.TotalQABytesCommitted, }, nil } @@ -90,7 +64,7 @@ func (s *state{{.v}}) MinerPower(addr address.Address) (Claim, bool, error) { return Claim{}, false, err } return Claim{ - RawBytePower: claim.RawBytePower, + RawBytePower: claim.RawBytePower, QualityAdjPower: claim.QualityAdjPower, }, ok, nil } @@ -142,7 +116,7 @@ func (s *state{{.v}}) ForEachClaim(cb func(miner address.Address, claim Claim) e return err } return cb(a, Claim{ - RawBytePower: claim.RawBytePower, + RawBytePower: claim.RawBytePower, QualityAdjPower: claim.QualityAdjPower, }) }) @@ -157,30 +131,6 @@ func (s *state{{.v}}) ClaimsChanged(other State) (bool, error) { return !s.State.Claims.Equals(other{{.v}}.State.Claims), nil } -func (s *state{{.v}}) SetTotalQualityAdjPower(p abi.StoragePower) error { - s.State.TotalQualityAdjPower = p - return nil -} - -func (s *state{{.v}}) SetTotalRawBytePower(p abi.StoragePower) error { - s.State.TotalRawBytePower = p - return nil -} - -func (s *state{{.v}}) SetThisEpochQualityAdjPower(p abi.StoragePower) error { - s.State.ThisEpochQualityAdjPower = p - return nil -} - -func (s *state{{.v}}) SetThisEpochRawBytePower(p abi.StoragePower) error { - s.State.ThisEpochRawBytePower = p - return nil -} - -func (s *state{{.v}}) GetState() interface{} { - return &s.State -} - func (s *state{{.v}}) claims() (adt.Map, error) { return adt{{.v}}.AsMap(s.store, s.Claims{{if (ge .v 3)}}, builtin{{.v}}.DefaultHamtBitwidth{{end}}) } @@ -195,7 +145,7 @@ func (s *state{{.v}}) decodeClaim(val *cbg.Deferred) (Claim, error) { func fromV{{.v}}Claim(v{{.v}} power{{.v}}.Claim) Claim { return Claim{ - RawBytePower: v{{.v}}.RawBytePower, + RawBytePower: v{{.v}}.RawBytePower, QualityAdjPower: v{{.v}}.QualityAdjPower, } } diff --git a/chain/actors/builtin/power/temp b/chain/actors/builtin/power/temp deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/chain/actors/builtin/power/v0.go b/chain/actors/builtin/power/v0.go index 465d16c5c35..91fad8c57f3 100644 --- a/chain/actors/builtin/power/v0.go +++ b/chain/actors/builtin/power/v0.go @@ -26,24 +26,6 @@ func load0(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make0(store adt.Store) (State, error) { - out := state0{store: store} - - em, err := adt0.MakeEmptyMap(store).Root() - if err != nil { - return nil, err - } - - emm, err := adt0.MakeEmptyMultimap(store).Root() - if err != nil { - return nil, err - } - - out.State = *power0.ConstructState(em, emm) - - return &out, nil -} - type state0 struct { power0.State store adt.Store @@ -146,30 +128,6 @@ func (s *state0) ClaimsChanged(other State) (bool, error) { return !s.State.Claims.Equals(other0.State.Claims), nil } -func (s *state0) SetTotalQualityAdjPower(p abi.StoragePower) error { - s.State.TotalQualityAdjPower = p - return nil -} - -func (s *state0) SetTotalRawBytePower(p abi.StoragePower) error { - s.State.TotalRawBytePower = p - return nil -} - -func (s *state0) SetThisEpochQualityAdjPower(p abi.StoragePower) error { - s.State.ThisEpochQualityAdjPower = p - return nil -} - -func (s *state0) SetThisEpochRawBytePower(p abi.StoragePower) error { - s.State.ThisEpochRawBytePower = p - return nil -} - -func (s *state0) GetState() interface{} { - return &s.State -} - func (s *state0) claims() (adt.Map, error) { return adt0.AsMap(s.store, s.Claims) } diff --git a/chain/actors/builtin/power/v2.go b/chain/actors/builtin/power/v2.go index 606534cef26..313160a7869 100644 --- a/chain/actors/builtin/power/v2.go +++ b/chain/actors/builtin/power/v2.go @@ -26,24 +26,6 @@ func load2(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make2(store adt.Store) (State, error) { - out := state2{store: store} - - em, err := adt2.MakeEmptyMap(store).Root() - if err != nil { - return nil, err - } - - emm, err := adt2.MakeEmptyMultimap(store).Root() - if err != nil { - return nil, err - } - - out.State = *power2.ConstructState(em, emm) - - return &out, nil -} - type state2 struct { power2.State store adt.Store @@ -146,30 +128,6 @@ func (s *state2) ClaimsChanged(other State) (bool, error) { return !s.State.Claims.Equals(other2.State.Claims), nil } -func (s *state2) SetTotalQualityAdjPower(p abi.StoragePower) error { - s.State.TotalQualityAdjPower = p - return nil -} - -func (s *state2) SetTotalRawBytePower(p abi.StoragePower) error { - s.State.TotalRawBytePower = p - return nil -} - -func (s *state2) SetThisEpochQualityAdjPower(p abi.StoragePower) error { - s.State.ThisEpochQualityAdjPower = p - return nil -} - -func (s *state2) SetThisEpochRawBytePower(p abi.StoragePower) error { - s.State.ThisEpochRawBytePower = p - return nil -} - -func (s *state2) GetState() interface{} { - return &s.State -} - func (s *state2) claims() (adt.Map, error) { return adt2.AsMap(s.store, s.Claims) } diff --git a/chain/actors/builtin/power/v3.go b/chain/actors/builtin/power/v3.go index 3dec3c63ef6..2ef1e28086e 100644 --- a/chain/actors/builtin/power/v3.go +++ b/chain/actors/builtin/power/v3.go @@ -28,19 +28,6 @@ func load3(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make3(store adt.Store) (State, error) { - out := state3{store: store} - - s, err := power3.ConstructState(store) - if err != nil { - return nil, err - } - - out.State = *s - - return &out, nil -} - type state3 struct { power3.State store adt.Store @@ -143,30 +130,6 @@ func (s *state3) ClaimsChanged(other State) (bool, error) { return !s.State.Claims.Equals(other3.State.Claims), nil } -func (s *state3) SetTotalQualityAdjPower(p abi.StoragePower) error { - s.State.TotalQualityAdjPower = p - return nil -} - -func (s *state3) SetTotalRawBytePower(p abi.StoragePower) error { - s.State.TotalRawBytePower = p - return nil -} - -func (s *state3) SetThisEpochQualityAdjPower(p abi.StoragePower) error { - s.State.ThisEpochQualityAdjPower = p - return nil -} - -func (s *state3) SetThisEpochRawBytePower(p abi.StoragePower) error { - s.State.ThisEpochRawBytePower = p - return nil -} - -func (s *state3) GetState() interface{} { - return &s.State -} - func (s *state3) claims() (adt.Map, error) { return adt3.AsMap(s.store, s.Claims, builtin3.DefaultHamtBitwidth) } diff --git a/chain/actors/builtin/power/v4.go b/chain/actors/builtin/power/v4.go index b73eedf5a82..686550456d3 100644 --- a/chain/actors/builtin/power/v4.go +++ b/chain/actors/builtin/power/v4.go @@ -28,19 +28,6 @@ func load4(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make4(store adt.Store) (State, error) { - out := state4{store: store} - - s, err := power4.ConstructState(store) - if err != nil { - return nil, err - } - - out.State = *s - - return &out, nil -} - type state4 struct { power4.State store adt.Store @@ -143,30 +130,6 @@ func (s *state4) ClaimsChanged(other State) (bool, error) { return !s.State.Claims.Equals(other4.State.Claims), nil } -func (s *state4) SetTotalQualityAdjPower(p abi.StoragePower) error { - s.State.TotalQualityAdjPower = p - return nil -} - -func (s *state4) SetTotalRawBytePower(p abi.StoragePower) error { - s.State.TotalRawBytePower = p - return nil -} - -func (s *state4) SetThisEpochQualityAdjPower(p abi.StoragePower) error { - s.State.ThisEpochQualityAdjPower = p - return nil -} - -func (s *state4) SetThisEpochRawBytePower(p abi.StoragePower) error { - s.State.ThisEpochRawBytePower = p - return nil -} - -func (s *state4) GetState() interface{} { - return &s.State -} - func (s *state4) claims() (adt.Map, error) { return adt4.AsMap(s.store, s.Claims, builtin4.DefaultHamtBitwidth) } diff --git a/chain/actors/builtin/reward/actor.go.template b/chain/actors/builtin/reward/actor.go.template index 89cdddaeceb..81437d26fe6 100644 --- a/chain/actors/builtin/reward/actor.go.template +++ b/chain/actors/builtin/reward/actor.go.template @@ -4,7 +4,6 @@ import ( "github.com/filecoin-project/go-state-types/abi" reward0 "github.com/filecoin-project/specs-actors/actors/builtin/reward" "github.com/ipfs/go-cid" - "github.com/filecoin-project/lotus/chain/actors" "golang.org/x/xerrors" "github.com/filecoin-project/go-state-types/cbor" @@ -39,27 +38,6 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version, currRealizedPower abi.StoragePower) (State, error) { - switch av { -{{range .versions}} - case actors.Version{{.}}: - return make{{.}}(store, currRealizedPower) -{{end}} -} - return nil, xerrors.Errorf("unknown actor version %d", av) -} - -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { -{{range .versions}} - case actors.Version{{.}}: - return builtin{{.}}.RewardActorCodeID, nil -{{end}} - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - type State interface { cbor.Marshaler @@ -77,7 +55,6 @@ type State interface { InitialPledgeForPower(abi.StoragePower, abi.TokenAmount, *builtin.FilterEstimate, abi.TokenAmount) (abi.TokenAmount, error) PreCommitDepositForPower(builtin.FilterEstimate, abi.StoragePower) (abi.TokenAmount, error) - GetState() interface{} } type AwardBlockRewardParams = reward0.AwardBlockRewardParams diff --git a/chain/actors/builtin/reward/reward.go b/chain/actors/builtin/reward/reward.go index c325cc7b6a0..1037cf7412c 100644 --- a/chain/actors/builtin/reward/reward.go +++ b/chain/actors/builtin/reward/reward.go @@ -2,7 +2,6 @@ package reward import ( "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/lotus/chain/actors" reward0 "github.com/filecoin-project/specs-actors/actors/builtin/reward" "github.com/ipfs/go-cid" "golang.org/x/xerrors" @@ -65,45 +64,6 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version, currRealizedPower abi.StoragePower) (State, error) { - switch av { - - case actors.Version0: - return make0(store, currRealizedPower) - - case actors.Version2: - return make2(store, currRealizedPower) - - case actors.Version3: - return make3(store, currRealizedPower) - - case actors.Version4: - return make4(store, currRealizedPower) - - } - return nil, xerrors.Errorf("unknown actor version %d", av) -} - -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { - - case actors.Version0: - return builtin0.RewardActorCodeID, nil - - case actors.Version2: - return builtin2.RewardActorCodeID, nil - - case actors.Version3: - return builtin3.RewardActorCodeID, nil - - case actors.Version4: - return builtin4.RewardActorCodeID, nil - - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - type State interface { cbor.Marshaler @@ -121,7 +81,6 @@ type State interface { InitialPledgeForPower(abi.StoragePower, abi.TokenAmount, *builtin.FilterEstimate, abi.TokenAmount) (abi.TokenAmount, error) PreCommitDepositForPower(builtin.FilterEstimate, abi.StoragePower) (abi.TokenAmount, error) - GetState() interface{} } type AwardBlockRewardParams = reward0.AwardBlockRewardParams diff --git a/chain/actors/builtin/reward/state.go.template b/chain/actors/builtin/reward/state.go.template index 67bfd5c85bf..1758d1413b1 100644 --- a/chain/actors/builtin/reward/state.go.template +++ b/chain/actors/builtin/reward/state.go.template @@ -23,12 +23,6 @@ func load{{.v}}(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make{{.v}}(store adt.Store, currRealizedPower abi.StoragePower) (State, error) { - out := state{{.v}}{store: store} - out.State = *reward{{.v}}.ConstructState(currRealizedPower) - return &out, nil -} - type state{{.v}} struct { reward{{.v}}.State store adt.Store @@ -107,7 +101,3 @@ func (s *state{{.v}}) PreCommitDepositForPower(networkQAPower builtin.FilterEsti }, sectorWeight), nil } - -func (s *state{{.v}}) GetState() interface{} { - return &s.State -} \ No newline at end of file diff --git a/chain/actors/builtin/reward/temp b/chain/actors/builtin/reward/temp deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/chain/actors/builtin/reward/v0.go b/chain/actors/builtin/reward/v0.go index cd098c151e8..fe053cc16f6 100644 --- a/chain/actors/builtin/reward/v0.go +++ b/chain/actors/builtin/reward/v0.go @@ -23,12 +23,6 @@ func load0(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make0(store adt.Store, currRealizedPower abi.StoragePower) (State, error) { - out := state0{store: store} - out.State = *reward0.ConstructState(currRealizedPower) - return &out, nil -} - type state0 struct { reward0.State store adt.Store @@ -89,7 +83,3 @@ func (s *state0) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate, }, sectorWeight), nil } - -func (s *state0) GetState() interface{} { - return &s.State -} diff --git a/chain/actors/builtin/reward/v2.go b/chain/actors/builtin/reward/v2.go index 08e9a7bc39a..90621e4678e 100644 --- a/chain/actors/builtin/reward/v2.go +++ b/chain/actors/builtin/reward/v2.go @@ -23,12 +23,6 @@ func load2(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make2(store adt.Store, currRealizedPower abi.StoragePower) (State, error) { - out := state2{store: store} - out.State = *reward2.ConstructState(currRealizedPower) - return &out, nil -} - type state2 struct { reward2.State store adt.Store @@ -92,7 +86,3 @@ func (s *state2) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate, }, sectorWeight), nil } - -func (s *state2) GetState() interface{} { - return &s.State -} diff --git a/chain/actors/builtin/reward/v3.go b/chain/actors/builtin/reward/v3.go index fd9fa56e27e..926cc085b5d 100644 --- a/chain/actors/builtin/reward/v3.go +++ b/chain/actors/builtin/reward/v3.go @@ -23,12 +23,6 @@ func load3(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make3(store adt.Store, currRealizedPower abi.StoragePower) (State, error) { - out := state3{store: store} - out.State = *reward3.ConstructState(currRealizedPower) - return &out, nil -} - type state3 struct { reward3.State store adt.Store @@ -92,7 +86,3 @@ func (s *state3) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate, }, sectorWeight), nil } - -func (s *state3) GetState() interface{} { - return &s.State -} diff --git a/chain/actors/builtin/reward/v4.go b/chain/actors/builtin/reward/v4.go index 310ca04e8df..f034b0018c7 100644 --- a/chain/actors/builtin/reward/v4.go +++ b/chain/actors/builtin/reward/v4.go @@ -23,12 +23,6 @@ func load4(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make4(store adt.Store, currRealizedPower abi.StoragePower) (State, error) { - out := state4{store: store} - out.State = *reward4.ConstructState(currRealizedPower) - return &out, nil -} - type state4 struct { reward4.State store adt.Store @@ -92,7 +86,3 @@ func (s *state4) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate, }, sectorWeight), nil } - -func (s *state4) GetState() interface{} { - return &s.State -} diff --git a/chain/actors/builtin/system/actor.go.template b/chain/actors/builtin/system/actor.go.template deleted file mode 100644 index 9253199709c..00000000000 --- a/chain/actors/builtin/system/actor.go.template +++ /dev/null @@ -1,41 +0,0 @@ -package system - -import ( - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors" - "golang.org/x/xerrors" - "github.com/ipfs/go-cid" - -{{range .versions}} - builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" -{{end}} -) - -var ( - Address = builtin{{.latestVersion}}.SystemActorAddr -) - -func MakeState(store adt.Store, av actors.Version) (State, error) { - switch av { -{{range .versions}} - case actors.Version{{.}}: - return make{{.}}(store) -{{end}} -} - return nil, xerrors.Errorf("unknown actor version %d", av) -} - -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { -{{range .versions}} - case actors.Version{{.}}: - return builtin{{.}}.SystemActorCodeID, nil -{{end}} - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - -type State interface { - GetState() interface{} -} diff --git a/chain/actors/builtin/system/state.go.template b/chain/actors/builtin/system/state.go.template deleted file mode 100644 index fa644f8c755..00000000000 --- a/chain/actors/builtin/system/state.go.template +++ /dev/null @@ -1,35 +0,0 @@ -package system - -import ( - "github.com/ipfs/go-cid" - - "github.com/filecoin-project/lotus/chain/actors/adt" - - system{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/system" -) - -var _ State = (*state{{.v}})(nil) - -func load{{.v}}(store adt.Store, root cid.Cid) (State, error) { - out := state{{.v}}{store: store} - err := store.Get(store.Context(), root, &out) - if err != nil { - return nil, err - } - return &out, nil -} - -func make{{.v}}(store adt.Store) (State, error) { - out := state{{.v}}{store: store} - out.State = system{{.v}}.State{} - return &out, nil -} - -type state{{.v}} struct { - system{{.v}}.State - store adt.Store -} - -func (s *state{{.v}}) GetState() interface{} { - return &s.State -} \ No newline at end of file diff --git a/chain/actors/builtin/system/system.go b/chain/actors/builtin/system/system.go deleted file mode 100644 index b4ced850f0e..00000000000 --- a/chain/actors/builtin/system/system.go +++ /dev/null @@ -1,63 +0,0 @@ -package system - -import ( - "github.com/filecoin-project/lotus/chain/actors" - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/ipfs/go-cid" - "golang.org/x/xerrors" - - builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" - - builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" - - builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin" - - builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" -) - -var ( - Address = builtin4.SystemActorAddr -) - -func MakeState(store adt.Store, av actors.Version) (State, error) { - switch av { - - case actors.Version0: - return make0(store) - - case actors.Version2: - return make2(store) - - case actors.Version3: - return make3(store) - - case actors.Version4: - return make4(store) - - } - return nil, xerrors.Errorf("unknown actor version %d", av) -} - -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { - - case actors.Version0: - return builtin0.SystemActorCodeID, nil - - case actors.Version2: - return builtin2.SystemActorCodeID, nil - - case actors.Version3: - return builtin3.SystemActorCodeID, nil - - case actors.Version4: - return builtin4.SystemActorCodeID, nil - - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - -type State interface { - GetState() interface{} -} diff --git a/chain/actors/builtin/system/temp b/chain/actors/builtin/system/temp deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/chain/actors/builtin/system/v0.go b/chain/actors/builtin/system/v0.go deleted file mode 100644 index 64c6f53d3cf..00000000000 --- a/chain/actors/builtin/system/v0.go +++ /dev/null @@ -1,35 +0,0 @@ -package system - -import ( - "github.com/ipfs/go-cid" - - "github.com/filecoin-project/lotus/chain/actors/adt" - - system0 "github.com/filecoin-project/specs-actors/actors/builtin/system" -) - -var _ State = (*state0)(nil) - -func load0(store adt.Store, root cid.Cid) (State, error) { - out := state0{store: store} - err := store.Get(store.Context(), root, &out) - if err != nil { - return nil, err - } - return &out, nil -} - -func make0(store adt.Store) (State, error) { - out := state0{store: store} - out.State = system0.State{} - return &out, nil -} - -type state0 struct { - system0.State - store adt.Store -} - -func (s *state0) GetState() interface{} { - return &s.State -} diff --git a/chain/actors/builtin/system/v2.go b/chain/actors/builtin/system/v2.go deleted file mode 100644 index eb540891cc3..00000000000 --- a/chain/actors/builtin/system/v2.go +++ /dev/null @@ -1,35 +0,0 @@ -package system - -import ( - "github.com/ipfs/go-cid" - - "github.com/filecoin-project/lotus/chain/actors/adt" - - system2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/system" -) - -var _ State = (*state2)(nil) - -func load2(store adt.Store, root cid.Cid) (State, error) { - out := state2{store: store} - err := store.Get(store.Context(), root, &out) - if err != nil { - return nil, err - } - return &out, nil -} - -func make2(store adt.Store) (State, error) { - out := state2{store: store} - out.State = system2.State{} - return &out, nil -} - -type state2 struct { - system2.State - store adt.Store -} - -func (s *state2) GetState() interface{} { - return &s.State -} diff --git a/chain/actors/builtin/system/v3.go b/chain/actors/builtin/system/v3.go deleted file mode 100644 index 5b04e189ee6..00000000000 --- a/chain/actors/builtin/system/v3.go +++ /dev/null @@ -1,35 +0,0 @@ -package system - -import ( - "github.com/ipfs/go-cid" - - "github.com/filecoin-project/lotus/chain/actors/adt" - - system3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/system" -) - -var _ State = (*state3)(nil) - -func load3(store adt.Store, root cid.Cid) (State, error) { - out := state3{store: store} - err := store.Get(store.Context(), root, &out) - if err != nil { - return nil, err - } - return &out, nil -} - -func make3(store adt.Store) (State, error) { - out := state3{store: store} - out.State = system3.State{} - return &out, nil -} - -type state3 struct { - system3.State - store adt.Store -} - -func (s *state3) GetState() interface{} { - return &s.State -} diff --git a/chain/actors/builtin/system/v4.go b/chain/actors/builtin/system/v4.go deleted file mode 100644 index b6c92497884..00000000000 --- a/chain/actors/builtin/system/v4.go +++ /dev/null @@ -1,35 +0,0 @@ -package system - -import ( - "github.com/ipfs/go-cid" - - "github.com/filecoin-project/lotus/chain/actors/adt" - - system4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/system" -) - -var _ State = (*state4)(nil) - -func load4(store adt.Store, root cid.Cid) (State, error) { - out := state4{store: store} - err := store.Get(store.Context(), root, &out) - if err != nil { - return nil, err - } - return &out, nil -} - -func make4(store adt.Store) (State, error) { - out := state4{store: store} - out.State = system4.State{} - return &out, nil -} - -type state4 struct { - system4.State - store adt.Store -} - -func (s *state4) GetState() interface{} { - return &s.State -} diff --git a/chain/actors/builtin/temp b/chain/actors/builtin/temp deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/chain/actors/builtin/verifreg/actor.go.template b/chain/actors/builtin/verifreg/actor.go.template index 9ea8e155aec..22e809ccf05 100644 --- a/chain/actors/builtin/verifreg/actor.go.template +++ b/chain/actors/builtin/verifreg/actor.go.template @@ -14,7 +14,6 @@ import ( "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin" - "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/types" ) @@ -41,28 +40,6 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version, rootKeyAddress address.Address) (State, error) { - switch av { -{{range .versions}} - case actors.Version{{.}}: - return make{{.}}(store, rootKeyAddress) -{{end}} -} - return nil, xerrors.Errorf("unknown actor version %d", av) -} - -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { -{{range .versions}} - case actors.Version{{.}}: - return builtin{{.}}.VerifiedRegistryActorCodeID, nil -{{end}} - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - - type State interface { cbor.Marshaler @@ -71,5 +48,4 @@ type State interface { 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 - GetState() interface{} } diff --git a/chain/actors/builtin/verifreg/state.go.template b/chain/actors/builtin/verifreg/state.go.template index 96bebe25fd8..244d20932d9 100644 --- a/chain/actors/builtin/verifreg/state.go.template +++ b/chain/actors/builtin/verifreg/state.go.template @@ -9,7 +9,7 @@ import ( "github.com/filecoin-project/lotus/chain/actors/adt" {{if (ge .v 3)}} builtin{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin" -{{end}} verifreg{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/verifreg" +{{end}} verifreg{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/verifreg" adt{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/util/adt" ) @@ -24,26 +24,6 @@ func load{{.v}}(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make{{.v}}(store adt.Store, rootKeyAddress address.Address) (State, error) { - out := state{{.v}}{store: store} - {{if (le .v 2)}} - em, err := adt{{.v}}.MakeEmptyMap(store).Root() - if err != nil { - return nil, err - } - - out.State = *verifreg{{.v}}.ConstructState(em, rootKeyAddress) - {{else}} - s, err := verifreg{{.v}}.ConstructState(store, rootKeyAddress) - if err != nil { - return nil, err - } - - out.State = *s - {{end}} - return &out, nil -} - type state{{.v}} struct { verifreg{{.v}}.State store adt.Store @@ -76,7 +56,3 @@ func (s *state{{.v}}) verifiedClients() (adt.Map, error) { func (s *state{{.v}}) verifiers() (adt.Map, error) { return adt{{.v}}.AsMap(s.store, s.Verifiers{{if (ge .v 3)}}, builtin{{.v}}.DefaultHamtBitwidth{{end}}) } - -func (s *state{{.v}}) GetState() interface{} { - return &s.State -} \ No newline at end of file diff --git a/chain/actors/builtin/verifreg/temp b/chain/actors/builtin/verifreg/temp deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/chain/actors/builtin/verifreg/v0.go b/chain/actors/builtin/verifreg/v0.go index e70b0e3c92d..0dc4696f43c 100644 --- a/chain/actors/builtin/verifreg/v0.go +++ b/chain/actors/builtin/verifreg/v0.go @@ -23,19 +23,6 @@ func load0(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make0(store adt.Store, rootKeyAddress address.Address) (State, error) { - out := state0{store: store} - - em, err := adt0.MakeEmptyMap(store).Root() - if err != nil { - return nil, err - } - - out.State = *verifreg0.ConstructState(em, rootKeyAddress) - - return &out, nil -} - type state0 struct { verifreg0.State store adt.Store @@ -68,7 +55,3 @@ func (s *state0) verifiedClients() (adt.Map, error) { func (s *state0) verifiers() (adt.Map, error) { return adt0.AsMap(s.store, s.Verifiers) } - -func (s *state0) GetState() interface{} { - return &s.State -} diff --git a/chain/actors/builtin/verifreg/v2.go b/chain/actors/builtin/verifreg/v2.go index 0bcbe02121d..a5ef84532d3 100644 --- a/chain/actors/builtin/verifreg/v2.go +++ b/chain/actors/builtin/verifreg/v2.go @@ -23,19 +23,6 @@ func load2(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make2(store adt.Store, rootKeyAddress address.Address) (State, error) { - out := state2{store: store} - - em, err := adt2.MakeEmptyMap(store).Root() - if err != nil { - return nil, err - } - - out.State = *verifreg2.ConstructState(em, rootKeyAddress) - - return &out, nil -} - type state2 struct { verifreg2.State store adt.Store @@ -68,7 +55,3 @@ func (s *state2) verifiedClients() (adt.Map, error) { func (s *state2) verifiers() (adt.Map, error) { return adt2.AsMap(s.store, s.Verifiers) } - -func (s *state2) GetState() interface{} { - return &s.State -} diff --git a/chain/actors/builtin/verifreg/v3.go b/chain/actors/builtin/verifreg/v3.go index 32003ca3a30..fb0c46d0c5c 100644 --- a/chain/actors/builtin/verifreg/v3.go +++ b/chain/actors/builtin/verifreg/v3.go @@ -24,19 +24,6 @@ func load3(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make3(store adt.Store, rootKeyAddress address.Address) (State, error) { - out := state3{store: store} - - s, err := verifreg3.ConstructState(store, rootKeyAddress) - if err != nil { - return nil, err - } - - out.State = *s - - return &out, nil -} - type state3 struct { verifreg3.State store adt.Store @@ -69,7 +56,3 @@ func (s *state3) verifiedClients() (adt.Map, error) { func (s *state3) verifiers() (adt.Map, error) { return adt3.AsMap(s.store, s.Verifiers, builtin3.DefaultHamtBitwidth) } - -func (s *state3) GetState() interface{} { - return &s.State -} diff --git a/chain/actors/builtin/verifreg/v4.go b/chain/actors/builtin/verifreg/v4.go index b752e747bb3..2419ef7588d 100644 --- a/chain/actors/builtin/verifreg/v4.go +++ b/chain/actors/builtin/verifreg/v4.go @@ -24,19 +24,6 @@ func load4(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make4(store adt.Store, rootKeyAddress address.Address) (State, error) { - out := state4{store: store} - - s, err := verifreg4.ConstructState(store, rootKeyAddress) - if err != nil { - return nil, err - } - - out.State = *s - - return &out, nil -} - type state4 struct { verifreg4.State store adt.Store @@ -69,7 +56,3 @@ func (s *state4) verifiedClients() (adt.Map, error) { func (s *state4) verifiers() (adt.Map, error) { return adt4.AsMap(s.store, s.Verifiers, builtin4.DefaultHamtBitwidth) } - -func (s *state4) GetState() interface{} { - return &s.State -} diff --git a/chain/actors/builtin/verifreg/verifreg.go b/chain/actors/builtin/verifreg/verifreg.go index 618907554ca..32f50a4ae32 100644 --- a/chain/actors/builtin/verifreg/verifreg.go +++ b/chain/actors/builtin/verifreg/verifreg.go @@ -17,7 +17,6 @@ import ( builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" - "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/types" @@ -67,45 +66,6 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version, rootKeyAddress address.Address) (State, error) { - switch av { - - case actors.Version0: - return make0(store, rootKeyAddress) - - case actors.Version2: - return make2(store, rootKeyAddress) - - case actors.Version3: - return make3(store, rootKeyAddress) - - case actors.Version4: - return make4(store, rootKeyAddress) - - } - return nil, xerrors.Errorf("unknown actor version %d", av) -} - -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { - - case actors.Version0: - return builtin0.VerifiedRegistryActorCodeID, nil - - case actors.Version2: - return builtin2.VerifiedRegistryActorCodeID, nil - - case actors.Version3: - return builtin3.VerifiedRegistryActorCodeID, nil - - case actors.Version4: - return builtin4.VerifiedRegistryActorCodeID, nil - - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - type State interface { cbor.Marshaler @@ -114,5 +74,4 @@ type State interface { 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 - GetState() interface{} } diff --git a/chain/actors/policy/policy.go.template b/chain/actors/policy/policy.go.template index a1a47852b77..d395d713259 100644 --- a/chain/actors/policy/policy.go.template +++ b/chain/actors/policy/policy.go.template @@ -8,20 +8,20 @@ import ( "github.com/filecoin-project/lotus/chain/actors" {{range .versions}} - {{if (ge . 2)}} builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" {{end}} + {{if (ge . 2)}} builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" {{end}} market{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin/market" miner{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin/miner" verifreg{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin/verifreg" {{if (eq . 0)}} power{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin/power" {{end}} - {{end}} + {{end}} - paych{{.latestVersion}} "github.com/filecoin-project/specs-actors{{import .latestVersion}}actors/builtin/paych" + paych{{.latestVersion}} "github.com/filecoin-project/specs-actors{{import .latestVersion}}actors/builtin/paych" ) const ( - ChainFinality = miner{{.latestVersion}}.ChainFinality - SealRandomnessLookback = ChainFinality - PaychSettleDelay = paych{{.latestVersion}}.SettleDelay + ChainFinality = miner{{.latestVersion}}.ChainFinality + SealRandomnessLookback = ChainFinality + PaychSettleDelay = paych{{.latestVersion}}.SettleDelay MaxPreCommitRandomnessLookback = builtin{{.latestVersion}}.EpochsInDay + SealRandomnessLookback ) @@ -29,13 +29,13 @@ const ( // This should only be used for testing. func SetSupportedProofTypes(types ...abi.RegisteredSealProof) { {{range .versions}} - {{if (eq . 0)}} - miner{{.}}.SupportedProofTypes = make(map[abi.RegisteredSealProof]struct{}, len(types)) - {{else}} - miner{{.}}.PreCommitSealProofTypesV0 = make(map[abi.RegisteredSealProof]struct{}, len(types)) - miner{{.}}.PreCommitSealProofTypesV7 = make(map[abi.RegisteredSealProof]struct{}, len(types)*2) - miner{{.}}.PreCommitSealProofTypesV8 = make(map[abi.RegisteredSealProof]struct{}, len(types)) - {{end}} + {{if (eq . 0)}} + miner{{.}}.SupportedProofTypes = make(map[abi.RegisteredSealProof]struct{}, len(types)) + {{else}} + miner{{.}}.PreCommitSealProofTypesV0 = make(map[abi.RegisteredSealProof]struct{}, len(types)) + miner{{.}}.PreCommitSealProofTypesV7 = make(map[abi.RegisteredSealProof]struct{}, len(types)*2) + miner{{.}}.PreCommitSealProofTypesV8 = make(map[abi.RegisteredSealProof]struct{}, len(types)) + {{end}} {{end}} AddSupportedProofTypes(types...) @@ -51,15 +51,15 @@ func AddSupportedProofTypes(types ...abi.RegisteredSealProof) { // Set for all miner versions. {{range .versions}} - {{if (eq . 0)}} - miner{{.}}.SupportedProofTypes[t] = struct{}{} - {{else}} - miner{{.}}.PreCommitSealProofTypesV0[t] = struct{}{} - miner{{.}}.PreCommitSealProofTypesV7[t] = struct{}{} - miner{{.}}.PreCommitSealProofTypesV7[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{} - miner{{.}}.PreCommitSealProofTypesV8[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{} - {{end}} - {{end}} + {{if (eq . 0)}} + miner{{.}}.SupportedProofTypes[t] = struct{}{} + {{else}} + miner{{.}}.PreCommitSealProofTypesV0[t] = struct{}{} + miner{{.}}.PreCommitSealProofTypesV7[t] = struct{}{} + miner{{.}}.PreCommitSealProofTypesV7[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{} + miner{{.}}.PreCommitSealProofTypesV8[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{} + {{end}} + {{end}} } } @@ -67,9 +67,9 @@ func AddSupportedProofTypes(types ...abi.RegisteredSealProof) { // actors versions. Use for testing. func SetPreCommitChallengeDelay(delay abi.ChainEpoch) { // Set for all miner versions. - {{range .versions}} - miner{{.}}.PreCommitChallengeDelay = delay - {{end}} + {{range .versions}} + miner{{.}}.PreCommitChallengeDelay = delay + {{end}} } // TODO: this function shouldn't really exist. Instead, the API should expose the precommit delay. @@ -81,42 +81,42 @@ func GetPreCommitChallengeDelay() abi.ChainEpoch { // meet for leader election, across all actor versions. This should only be used // for testing. func SetConsensusMinerMinPower(p abi.StoragePower) { - {{range .versions}} - {{if (eq . 0)}} - power{{.}}.ConsensusMinerMinPower = p - {{else if (eq . 2)}} - for _, policy := range builtin{{.}}.SealProofPolicies { - policy.ConsensusMinerMinPower = p - } - {{else}} - for _, policy := range builtin{{.}}.PoStProofPolicies { - policy.ConsensusMinerMinPower = p - } - {{end}} - {{end}} + {{range .versions}} + {{if (eq . 0)}} + power{{.}}.ConsensusMinerMinPower = p + {{else if (eq . 2)}} + for _, policy := range builtin{{.}}.SealProofPolicies { + policy.ConsensusMinerMinPower = p + } + {{else}} + for _, policy := range builtin{{.}}.PoStProofPolicies { + policy.ConsensusMinerMinPower = p + } + {{end}} + {{end}} } // SetMinVerifiedDealSize sets the minimum size of a verified deal. This should // only be used for testing. func SetMinVerifiedDealSize(size abi.StoragePower) { - {{range .versions}} - verifreg{{.}}.MinVerifiedDealSize = size - {{end}} + {{range .versions}} + verifreg{{.}}.MinVerifiedDealSize = size + {{end}} } func GetMaxProveCommitDuration(ver actors.Version, t abi.RegisteredSealProof) abi.ChainEpoch { switch ver { {{range .versions}} - case actors.Version{{.}}: - {{if (eq . 0)}} - return miner{{.}}.MaxSealDuration[t] - {{else}} - return miner{{.}}.MaxProveCommitDuration[t] - {{end}} - {{end}} - default: - panic("unsupported actors version") - } + case actors.Version{{.}}: + {{if (eq . 0)}} + return miner{{.}}.MaxSealDuration[t] + {{else}} + return miner{{.}}.MaxProveCommitDuration[t] + {{end}} + {{end}} + default: + panic("unsupported actors version") + } } func DealProviderCollateralBounds( @@ -125,14 +125,14 @@ func DealProviderCollateralBounds( circulatingFil abi.TokenAmount, nwVer network.Version, ) (min, max abi.TokenAmount) { switch actors.VersionForNetwork(nwVer) { - {{range .versions}} - case actors.Version{{.}}: - {{if (eq . 0)}} - return market{{.}}.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil, nwVer) - {{else}} - return market{{.}}.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) - {{end}} - {{end}} + {{range .versions}} + case actors.Version{{.}}: + {{if (eq . 0)}} + return market{{.}}.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil, nwVer) + {{else}} + return market{{.}}.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) + {{end}} + {{end}} default: panic("unsupported actors version") } @@ -145,15 +145,15 @@ func DealDurationBounds(pieceSize abi.PaddedPieceSize) (min, max abi.ChainEpoch) // Sets the challenge window and scales the proving period to match (such that // there are always 48 challenge windows in a proving period). func SetWPoStChallengeWindow(period abi.ChainEpoch) { - {{range .versions}} - miner{{.}}.WPoStChallengeWindow = period - miner{{.}}.WPoStProvingPeriod = period * abi.ChainEpoch(miner{{.}}.WPoStPeriodDeadlines) - {{if (ge . 3)}} - // by default, this is 2x finality which is 30 periods. - // scale it if we're scaling the challenge period. - miner{{.}}.WPoStDisputeWindow = period * 30 - {{end}} - {{end}} + {{range .versions}} + miner{{.}}.WPoStChallengeWindow = period + miner{{.}}.WPoStProvingPeriod = period * abi.ChainEpoch(miner{{.}}.WPoStPeriodDeadlines) + {{if (ge . 3)}} + // by default, this is 2x finality which is 30 periods. + // scale it if we're scaling the challenge period. + miner{{.}}.WPoStDisputeWindow = period * 30 + {{end}} + {{end}} } func GetWinningPoStSectorSetLookback(nwVer network.Version) abi.ChainEpoch { @@ -161,7 +161,7 @@ func GetWinningPoStSectorSetLookback(nwVer network.Version) abi.ChainEpoch { return 10 } - // NOTE: if this ever changes, adjust it in a (*Miner).mineOne() logline as well + // NOTE: if this ever changes, adjust it in a (*Miner).mineOne() logline as well return ChainFinality } @@ -207,10 +207,10 @@ func GetSectorMaxLifetime(proof abi.RegisteredSealProof, nwVer network.Version) func GetAddressedSectorsMax(nwVer network.Version) int { switch actors.VersionForNetwork(nwVer) { - {{range .versions}} - case actors.Version{{.}}: - return miner{{.}}.AddressedSectorsMax - {{end}} + {{range .versions}} + case actors.Version{{.}}: + return miner{{.}}.AddressedSectorsMax + {{end}} default: panic("unsupported network version") } @@ -218,15 +218,15 @@ func GetAddressedSectorsMax(nwVer network.Version) int { func GetDeclarationsMax(nwVer network.Version) int { switch actors.VersionForNetwork(nwVer) { - {{range .versions}} - case actors.Version{{.}}: - {{if (eq . 0)}} - // TODO: Should we instead panic here since the concept doesn't exist yet? - return miner{{.}}.AddressedPartitionsMax - {{else}} - return miner{{.}}.DeclarationsMax - {{end}} - {{end}} + {{range .versions}} + case actors.Version{{.}}: + {{if (eq . 0)}} + // TODO: Should we instead panic here since the concept doesn't exist yet? + return miner{{.}}.AddressedPartitionsMax + {{else}} + return miner{{.}}.DeclarationsMax + {{end}} + {{end}} default: panic("unsupported network version") } diff --git a/chain/actors/policy/temp b/chain/actors/policy/temp deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/chain/actors/temp b/chain/actors/temp deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/chain/actors/version.go b/chain/actors/version.go index a8b4c62b238..bd7b708bdcd 100644 --- a/chain/actors/version.go +++ b/chain/actors/version.go @@ -8,10 +8,6 @@ import ( type Version int -var LatestVersion = 4 - -var Versions = []int{0, 2, 3, LatestVersion} - const ( Version0 Version = 0 Version2 Version = 2 diff --git a/chain/gen/gen.go b/chain/gen/gen.go index 5c33ac4d729..d06c755fa34 100644 --- a/chain/gen/gen.go +++ b/chain/gen/gen.go @@ -9,8 +9,6 @@ import ( "sync/atomic" "time" - "github.com/filecoin-project/go-state-types/network" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" @@ -199,7 +197,6 @@ func NewGeneratorWithSectors(numSectors int) (*ChainGen, error) { sys := vm.Syscalls(&genFakeVerifier{}) tpl := genesis.Template{ - NetworkVersion: network.Version0, Accounts: []genesis.Actor{ { Type: genesis.TAccount, diff --git a/chain/gen/genesis/f00_system.go b/chain/gen/genesis/f00_system.go index d1dd203b63f..015dfac4a99 100644 --- a/chain/gen/genesis/f00_system.go +++ b/chain/gen/genesis/f00_system.go @@ -3,36 +3,27 @@ package genesis import ( "context" - "github.com/filecoin-project/lotus/chain/actors" - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin/system" + "github.com/filecoin-project/specs-actors/actors/builtin/system" + "github.com/filecoin-project/specs-actors/actors/builtin" cbor "github.com/ipfs/go-ipld-cbor" bstore "github.com/filecoin-project/lotus/blockstore" "github.com/filecoin-project/lotus/chain/types" ) -func SetupSystemActor(ctx context.Context, bs bstore.Blockstore, av actors.Version) (*types.Actor, error) { +func SetupSystemActor(bs bstore.Blockstore) (*types.Actor, error) { + var st system.State cst := cbor.NewCborStore(bs) - st, err := system.MakeState(adt.WrapStore(ctx, cst), av) - if err != nil { - return nil, err - } - - statecid, err := cst.Put(ctx, st.GetState()) - if err != nil { - return nil, err - } - actcid, err := system.GetActorCodeID(av) + statecid, err := cst.Put(context.TODO(), &st) if err != nil { return nil, err } act := &types.Actor{ - Code: actcid, + Code: builtin.SystemActorCodeID, Head: statecid, } diff --git a/chain/gen/genesis/f01_init.go b/chain/gen/genesis/f01_init.go index 88d40922116..718eb44807c 100644 --- a/chain/gen/genesis/f01_init.go +++ b/chain/gen/genesis/f01_init.go @@ -5,15 +5,13 @@ import ( "encoding/json" "fmt" - init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init" - - "github.com/filecoin-project/lotus/chain/actors" - "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/util/adt" + init_ "github.com/filecoin-project/specs-actors/actors/builtin/init" cbor "github.com/ipfs/go-ipld-cbor" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" @@ -23,25 +21,17 @@ import ( "github.com/filecoin-project/lotus/genesis" ) -func SetupInitActor(ctx context.Context, bs bstore.Blockstore, netname string, initialActors []genesis.Actor, rootVerifier genesis.Actor, remainder genesis.Actor, av actors.Version) (int64, *types.Actor, map[address.Address]address.Address, error) { +func SetupInitActor(bs bstore.Blockstore, netname string, initialActors []genesis.Actor, rootVerifier genesis.Actor, remainder genesis.Actor) (int64, *types.Actor, map[address.Address]address.Address, error) { if len(initialActors) > MaxAccounts { return 0, nil, nil, xerrors.New("too many initial actors") } - cst := cbor.NewCborStore(bs) - ist, err := init_.MakeState(adt.WrapStore(ctx, cst), av, netname) - if err != nil { - return 0, nil, nil, err - } + var ias init_.State + ias.NextID = MinerStart + ias.NetworkName = netname - if err = ist.SetNextID(MinerStart); err != nil { - return 0, nil, nil, err - } - - amap, err := ist.AddressMap() - if err != nil { - return 0, nil, nil, err - } + store := adt.WrapStore(context.TODO(), cbor.NewCborStore(bs)) + amap := adt.MakeEmptyMap(store) keyToId := map[address.Address]address.Address{} counter := int64(AccountStart) @@ -165,23 +155,15 @@ func SetupInitActor(ctx context.Context, bs bstore.Blockstore, netname string, i if err != nil { return 0, nil, nil, err } + ias.AddressMap = amapaddr - if err = ist.SetAddressMap(amapaddr); err != nil { - return 0, nil, nil, err - } - - statecid, err := cst.Put(ctx, ist.GetState()) - if err != nil { - return 0, nil, nil, err - } - - actcid, err := init_.GetActorCodeID(av) + statecid, err := store.Put(store.Context(), &ias) if err != nil { return 0, nil, nil, err } act := &types.Actor{ - Code: actcid, + Code: builtin.InitActorCodeID, Head: statecid, } diff --git a/chain/gen/genesis/f02_reward.go b/chain/gen/genesis/f02_reward.go index c8f479722f1..e218da6fe53 100644 --- a/chain/gen/genesis/f02_reward.go +++ b/chain/gen/genesis/f02_reward.go @@ -3,12 +3,10 @@ package genesis import ( "context" - "github.com/filecoin-project/lotus/chain/actors" - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin/reward" - "github.com/filecoin-project/go-state-types/big" + "github.com/filecoin-project/specs-actors/actors/builtin" + reward0 "github.com/filecoin-project/specs-actors/actors/builtin/reward" cbor "github.com/ipfs/go-ipld-cbor" bstore "github.com/filecoin-project/lotus/blockstore" @@ -16,28 +14,19 @@ import ( "github.com/filecoin-project/lotus/chain/types" ) -func SetupRewardActor(ctx context.Context, bs bstore.Blockstore, qaPower big.Int, av actors.Version) (*types.Actor, error) { +func SetupRewardActor(bs bstore.Blockstore, qaPower big.Int) (*types.Actor, error) { cst := cbor.NewCborStore(bs) - rst, err := reward.MakeState(adt.WrapStore(ctx, cst), av, qaPower) - if err != nil { - return nil, err - } - statecid, err := cst.Put(ctx, rst.GetState()) - if err != nil { - return nil, err - } + st := reward0.ConstructState(qaPower) - actcid, err := reward.GetActorCodeID(av) + hcid, err := cst.Put(context.TODO(), st) if err != nil { return nil, err } - act := &types.Actor{ - Code: actcid, + return &types.Actor{ + Code: builtin.RewardActorCodeID, Balance: types.BigInt{Int: build.InitialRewardBalance}, - Head: statecid, - } - - return act, nil + Head: hcid, + }, nil } diff --git a/chain/gen/genesis/f03_cron.go b/chain/gen/genesis/f03_cron.go index c6fd2422a4a..dd43a59a4ec 100644 --- a/chain/gen/genesis/f03_cron.go +++ b/chain/gen/genesis/f03_cron.go @@ -3,37 +3,27 @@ package genesis import ( "context" - "github.com/filecoin-project/lotus/chain/actors" - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin/cron" - + "github.com/filecoin-project/specs-actors/actors/builtin" + "github.com/filecoin-project/specs-actors/actors/builtin/cron" cbor "github.com/ipfs/go-ipld-cbor" bstore "github.com/filecoin-project/lotus/blockstore" "github.com/filecoin-project/lotus/chain/types" ) -func SetupCronActor(ctx context.Context, bs bstore.Blockstore, av actors.Version) (*types.Actor, error) { +func SetupCronActor(bs bstore.Blockstore) (*types.Actor, error) { cst := cbor.NewCborStore(bs) - st, err := cron.MakeState(adt.WrapStore(ctx, cbor.NewCborStore(bs)), av) - if err != nil { - return nil, err - } - - statecid, err := cst.Put(ctx, st.GetState()) - if err != nil { - return nil, err - } + cas := cron.ConstructState(cron.BuiltInEntries()) - actcid, err := cron.GetActorCodeID(av) + stcid, err := cst.Put(context.TODO(), cas) if err != nil { return nil, err } - act := &types.Actor{ - Code: actcid, - Head: statecid, - } - - return act, nil + return &types.Actor{ + Code: builtin.CronActorCodeID, + Head: stcid, + Nonce: 0, + Balance: types.NewInt(0), + }, nil } diff --git a/chain/gen/genesis/f04_power.go b/chain/gen/genesis/f04_power.go index 6fe4d75c09d..ed349c18bc6 100644 --- a/chain/gen/genesis/f04_power.go +++ b/chain/gen/genesis/f04_power.go @@ -3,39 +3,44 @@ package genesis import ( "context" - "github.com/filecoin-project/lotus/chain/actors/builtin/power" - - "github.com/filecoin-project/lotus/chain/actors" + "github.com/filecoin-project/specs-actors/actors/builtin" "github.com/filecoin-project/specs-actors/actors/util/adt" + power0 "github.com/filecoin-project/specs-actors/actors/builtin/power" cbor "github.com/ipfs/go-ipld-cbor" bstore "github.com/filecoin-project/lotus/blockstore" "github.com/filecoin-project/lotus/chain/types" ) -func SetupStoragePowerActor(ctx context.Context, bs bstore.Blockstore, av actors.Version) (*types.Actor, error) { - - cst := cbor.NewCborStore(bs) - pst, err := power.MakeState(adt.WrapStore(ctx, cbor.NewCborStore(bs)), av) +func SetupStoragePowerActor(bs bstore.Blockstore) (*types.Actor, error) { + store := adt.WrapStore(context.TODO(), cbor.NewCborStore(bs)) + emptyMap, err := adt.MakeEmptyMap(store).Root() if err != nil { return nil, err } - statecid, err := cst.Put(ctx, pst.GetState()) + multiMap, err := adt.AsMultimap(store, emptyMap) if err != nil { return nil, err } - actcid, err := power.GetActorCodeID(av) + emptyMultiMap, err := multiMap.Root() if err != nil { return nil, err } - act := &types.Actor{ - Code: actcid, - Head: statecid, + sms := power0.ConstructState(emptyMap, emptyMultiMap) + + stcid, err := store.Put(store.Context(), sms) + if err != nil { + return nil, err } - return act, nil + return &types.Actor{ + Code: builtin.StoragePowerActorCodeID, + Head: stcid, + Nonce: 0, + Balance: types.NewInt(0), + }, nil } diff --git a/chain/gen/genesis/f05_market.go b/chain/gen/genesis/f05_market.go index 5c39ef38f11..f7ac26f434f 100644 --- a/chain/gen/genesis/f05_market.go +++ b/chain/gen/genesis/f05_market.go @@ -3,36 +3,38 @@ package genesis import ( "context" - "github.com/filecoin-project/lotus/chain/actors" - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin/market" - + "github.com/filecoin-project/specs-actors/actors/builtin" + "github.com/filecoin-project/specs-actors/actors/builtin/market" + "github.com/filecoin-project/specs-actors/actors/util/adt" cbor "github.com/ipfs/go-ipld-cbor" bstore "github.com/filecoin-project/lotus/blockstore" "github.com/filecoin-project/lotus/chain/types" ) -func SetupStorageMarketActor(ctx context.Context, bs bstore.Blockstore, av actors.Version) (*types.Actor, error) { - cst := cbor.NewCborStore(bs) - mst, err := market.MakeState(adt.WrapStore(ctx, cbor.NewCborStore(bs)), av) +func SetupStorageMarketActor(bs bstore.Blockstore) (*types.Actor, error) { + store := adt.WrapStore(context.TODO(), cbor.NewCborStore(bs)) + + a, err := adt.MakeEmptyArray(store).Root() if err != nil { return nil, err } - - statecid, err := cst.Put(ctx, mst.GetState()) + h, err := adt.MakeEmptyMap(store).Root() if err != nil { return nil, err } - actcid, err := market.GetActorCodeID(av) + sms := market.ConstructState(a, h, h) + + stcid, err := store.Put(store.Context(), sms) if err != nil { return nil, err } act := &types.Actor{ - Code: actcid, - Head: statecid, + Code: builtin.StorageMarketActorCodeID, + Head: stcid, + Balance: types.NewInt(0), } return act, nil diff --git a/chain/gen/genesis/f06_vreg.go b/chain/gen/genesis/f06_vreg.go index d8f5ee2a0fc..1ba8abede57 100644 --- a/chain/gen/genesis/f06_vreg.go +++ b/chain/gen/genesis/f06_vreg.go @@ -3,13 +3,11 @@ package genesis import ( "context" - "github.com/filecoin-project/lotus/chain/actors/builtin/verifreg" - - "github.com/filecoin-project/lotus/chain/actors" - "github.com/filecoin-project/go-address" cbor "github.com/ipfs/go-ipld-cbor" + "github.com/filecoin-project/specs-actors/actors/builtin" + verifreg0 "github.com/filecoin-project/specs-actors/actors/builtin/verifreg" "github.com/filecoin-project/specs-actors/actors/util/adt" bstore "github.com/filecoin-project/lotus/blockstore" @@ -28,26 +26,25 @@ func init() { RootVerifierID = idk } -func SetupVerifiedRegistryActor(ctx context.Context, bs bstore.Blockstore, av actors.Version) (*types.Actor, error) { - cst := cbor.NewCborStore(bs) - vst, err := verifreg.MakeState(adt.WrapStore(ctx, cbor.NewCborStore(bs)), av, RootVerifierID) - if err != nil { - return nil, err - } +func SetupVerifiedRegistryActor(bs bstore.Blockstore) (*types.Actor, error) { + store := adt.WrapStore(context.TODO(), cbor.NewCborStore(bs)) - statecid, err := cst.Put(ctx, vst.GetState()) + h, err := adt.MakeEmptyMap(store).Root() if err != nil { return nil, err } - actcid, err := verifreg.GetActorCodeID(av) + sms := verifreg0.ConstructState(h, RootVerifierID) + + stcid, err := store.Put(store.Context(), sms) if err != nil { return nil, err } act := &types.Actor{ - Code: actcid, - Head: statecid, + Code: builtin.VerifiedRegistryActorCodeID, + Head: stcid, + Balance: types.NewInt(0), } return act, nil diff --git a/chain/gen/genesis/genesis.go b/chain/gen/genesis/genesis.go index 94badbbfb0b..4b86db5501e 100644 --- a/chain/gen/genesis/genesis.go +++ b/chain/gen/genesis/genesis.go @@ -6,32 +6,6 @@ import ( "encoding/json" "fmt" - builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" - verifreg0 "github.com/filecoin-project/specs-actors/actors/builtin/verifreg" - adt0 "github.com/filecoin-project/specs-actors/actors/util/adt" - - "github.com/filecoin-project/go-state-types/network" - - "github.com/filecoin-project/lotus/chain/actors/builtin/multisig" - - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin/account" - - "github.com/filecoin-project/lotus/chain/actors" - - "github.com/filecoin-project/lotus/chain/actors/builtin/verifreg" - - "github.com/filecoin-project/lotus/chain/actors/builtin/market" - - "github.com/filecoin-project/lotus/chain/actors/builtin/power" - - "github.com/filecoin-project/lotus/chain/actors/builtin/cron" - - init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init" - "github.com/filecoin-project/lotus/chain/actors/builtin/reward" - - "github.com/filecoin-project/lotus/chain/actors/builtin/system" - "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/journal" @@ -47,6 +21,11 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/crypto" + builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" + account0 "github.com/filecoin-project/specs-actors/actors/builtin/account" + multisig0 "github.com/filecoin-project/specs-actors/actors/builtin/multisig" + verifreg0 "github.com/filecoin-project/specs-actors/actors/builtin/verifreg" + adt0 "github.com/filecoin-project/specs-actors/actors/util/adt" bstore "github.com/filecoin-project/lotus/blockstore" "github.com/filecoin-project/lotus/build" @@ -139,92 +118,94 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge return nil, nil, xerrors.Errorf("putting empty object: %w", err) } - sv, err := state.VersionForNetwork(template.NetworkVersion) - if err != nil { - return nil, nil, xerrors.Errorf("getting state tree version: %w", err) - } - - state, err := state.NewStateTree(cst, sv) + state, err := state.NewStateTree(cst, types.StateTreeVersion0) if err != nil { return nil, nil, xerrors.Errorf("making new state tree: %w", err) } - av := actors.VersionForNetwork(template.NetworkVersion) - // Create system actor - sysact, err := SetupSystemActor(ctx, bs, av) + sysact, err := SetupSystemActor(bs) if err != nil { - return nil, nil, xerrors.Errorf("setup system actor: %w", err) + return nil, nil, xerrors.Errorf("setup init actor: %w", err) } - if err := state.SetActor(system.Address, sysact); err != nil { - return nil, nil, xerrors.Errorf("set system actor: %w", err) + if err := state.SetActor(builtin0.SystemActorAddr, sysact); err != nil { + return nil, nil, xerrors.Errorf("set init actor: %w", err) } // Create init actor - idStart, initact, keyIDs, err := SetupInitActor(ctx, bs, template.NetworkName, template.Accounts, template.VerifregRootKey, template.RemainderAccount, av) + idStart, initact, keyIDs, err := SetupInitActor(bs, template.NetworkName, template.Accounts, template.VerifregRootKey, template.RemainderAccount) if err != nil { return nil, nil, xerrors.Errorf("setup init actor: %w", err) } - if err := state.SetActor(init_.Address, initact); err != nil { + if err := state.SetActor(builtin0.InitActorAddr, initact); err != nil { return nil, nil, xerrors.Errorf("set init actor: %w", err) } // Setup reward - // RewardActor's state is overwritten by SetupStorageMiners, but needs to exist for miner creation messages - rewact, err := SetupRewardActor(ctx, bs, big.Zero(), av) + // RewardActor's state is overrwritten by SetupStorageMiners + rewact, err := SetupRewardActor(bs, big.Zero()) if err != nil { - return nil, nil, xerrors.Errorf("setup reward actor: %w", err) + return nil, nil, xerrors.Errorf("setup init actor: %w", err) } - err = state.SetActor(reward.Address, rewact) + err = state.SetActor(builtin0.RewardActorAddr, rewact) if err != nil { - return nil, nil, xerrors.Errorf("set reward actor: %w", err) + return nil, nil, xerrors.Errorf("set network account actor: %w", err) } // Setup cron - cronact, err := SetupCronActor(ctx, bs, av) + cronact, err := SetupCronActor(bs) if err != nil { return nil, nil, xerrors.Errorf("setup cron actor: %w", err) } - if err := state.SetActor(cron.Address, cronact); err != nil { + if err := state.SetActor(builtin0.CronActorAddr, cronact); err != nil { return nil, nil, xerrors.Errorf("set cron actor: %w", err) } // Create empty power actor - spact, err := SetupStoragePowerActor(ctx, bs, av) + spact, err := SetupStoragePowerActor(bs) if err != nil { - return nil, nil, xerrors.Errorf("setup storage power actor: %w", err) + return nil, nil, xerrors.Errorf("setup storage market actor: %w", err) } - if err := state.SetActor(power.Address, spact); err != nil { - return nil, nil, xerrors.Errorf("set storage power actor: %w", err) + if err := state.SetActor(builtin0.StoragePowerActorAddr, spact); err != nil { + return nil, nil, xerrors.Errorf("set storage market actor: %w", err) } // Create empty market actor - marketact, err := SetupStorageMarketActor(ctx, bs, av) + marketact, err := SetupStorageMarketActor(bs) if err != nil { return nil, nil, xerrors.Errorf("setup storage market actor: %w", err) } - if err := state.SetActor(market.Address, marketact); err != nil { - return nil, nil, xerrors.Errorf("set storage market actor: %w", err) + if err := state.SetActor(builtin0.StorageMarketActorAddr, marketact); err != nil { + return nil, nil, xerrors.Errorf("set market actor: %w", err) } // Create verified registry - verifact, err := SetupVerifiedRegistryActor(ctx, bs, av) + verifact, err := SetupVerifiedRegistryActor(bs) if err != nil { - return nil, nil, xerrors.Errorf("setup verified registry market actor: %w", err) + return nil, nil, xerrors.Errorf("setup storage market actor: %w", err) } - if err := state.SetActor(verifreg.Address, verifact); err != nil { - return nil, nil, xerrors.Errorf("set verified registry actor: %w", err) + if err := state.SetActor(builtin0.VerifiedRegistryActorAddr, verifact); err != nil { + return nil, nil, xerrors.Errorf("set market actor: %w", err) } - bact, err := makeAccountActor(ctx, cst, av, builtin.BurntFundsActorAddr, big.Zero()) + burntRoot, err := cst.Put(ctx, &account0.State{ + Address: builtin0.BurntFundsActorAddr, + }) if err != nil { - return nil, nil, xerrors.Errorf("setup burnt funds actor state: %w", err) + return nil, nil, xerrors.Errorf("failed to setup burnt funds actor state: %w", err) } - if err := state.SetActor(builtin.BurntFundsActorAddr, bact); err != nil { - return nil, nil, xerrors.Errorf("set burnt funds actor: %w", err) + + // Setup burnt-funds + err = state.SetActor(builtin0.BurntFundsActorAddr, &types.Actor{ + Code: builtin0.AccountActorCodeID, + Balance: types.NewInt(0), + Head: burntRoot, + }) + if err != nil { + return nil, nil, xerrors.Errorf("set burnt funds account actor: %w", err) } // Create accounts @@ -232,7 +213,7 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge switch info.Type { case genesis.TAccount: - if err := createAccountActor(ctx, cst, state, info, keyIDs, av); err != nil { + if err := createAccountActor(ctx, cst, state, info, keyIDs); err != nil { return nil, nil, xerrors.Errorf("failed to create account actor: %w", err) } @@ -244,7 +225,7 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge } idStart++ - if err := createMultisigAccount(ctx, cst, state, ida, info, keyIDs, av); err != nil { + if err := createMultisigAccount(ctx, bs, cst, state, ida, info, keyIDs); err != nil { return nil, nil, err } default: @@ -259,21 +240,26 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge if err := json.Unmarshal(template.VerifregRootKey.Meta, &ainfo); err != nil { return nil, nil, xerrors.Errorf("unmarshaling account meta: %w", err) } + st, err := cst.Put(ctx, &account0.State{Address: ainfo.Owner}) + if err != nil { + return nil, nil, err + } _, ok := keyIDs[ainfo.Owner] if ok { return nil, nil, fmt.Errorf("rootkey account has already been declared, cannot be assigned 80: %s", ainfo.Owner) } - vact, err := makeAccountActor(ctx, cst, av, ainfo.Owner, template.VerifregRootKey.Balance) + err = state.SetActor(builtin.RootVerifierAddress, &types.Actor{ + Code: builtin0.AccountActorCodeID, + Balance: template.VerifregRootKey.Balance, + Head: st, + }) if err != nil { - return nil, nil, xerrors.Errorf("setup verifreg rootkey account state: %w", err) - } - if err = state.SetActor(builtin.RootVerifierAddress, vact); err != nil { - return nil, nil, xerrors.Errorf("set verifreg rootkey account actor: %w", err) + return nil, nil, xerrors.Errorf("setting verifreg rootkey account: %w", err) } case genesis.TMultisig: - if err = createMultisigAccount(ctx, cst, state, builtin.RootVerifierAddress, template.VerifregRootKey, keyIDs, av); err != nil { + if err = createMultisigAccount(ctx, bs, cst, state, builtin.RootVerifierAddress, template.VerifregRootKey, keyIDs); err != nil { return nil, nil, xerrors.Errorf("failed to set up verified registry signer: %w", err) } default: @@ -302,13 +288,18 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge return nil, nil, err } - verifierAct, err := makeAccountActor(ctx, cst, av, verifierAd, big.Zero()) + verifierState, err := cst.Put(ctx, &account0.State{Address: verifierAd}) if err != nil { - return nil, nil, xerrors.Errorf("setup first verifier state: %w", err) + return nil, nil, err } - if err = state.SetActor(verifierId, verifierAct); err != nil { - return nil, nil, xerrors.Errorf("set first verifier actor: %w", err) + err = state.SetActor(verifierId, &types.Actor{ + Code: builtin0.AccountActorCodeID, + Balance: types.NewInt(0), + Head: verifierState, + }) + if err != nil { + return nil, nil, xerrors.Errorf("setting account from actmap: %w", err) } totalFilAllocated := big.Zero() @@ -346,13 +337,13 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge } keyIDs[ainfo.Owner] = builtin.ReserveAddress - err = createAccountActor(ctx, cst, state, template.RemainderAccount, keyIDs, av) + err = createAccountActor(ctx, cst, state, template.RemainderAccount, keyIDs) if err != nil { return nil, nil, xerrors.Errorf("creating remainder acct: %w", err) } case genesis.TMultisig: - if err = createMultisigAccount(ctx, cst, state, builtin.ReserveAddress, template.RemainderAccount, keyIDs, av); err != nil { + if err = createMultisigAccount(ctx, bs, cst, state, builtin.ReserveAddress, template.RemainderAccount, keyIDs); err != nil { return nil, nil, xerrors.Errorf("failed to set up remainder: %w", err) } default: @@ -362,38 +353,12 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge return state, keyIDs, nil } -func makeAccountActor(ctx context.Context, cst cbor.IpldStore, av actors.Version, addr address.Address, bal types.BigInt) (*types.Actor, error) { - ast, err := account.MakeState(adt.WrapStore(ctx, cst), av, addr) - if err != nil { - return nil, err - } - - statecid, err := cst.Put(ctx, ast.GetState()) - if err != nil { - return nil, err - } - - actcid, err := account.GetActorCodeID(av) - if err != nil { - return nil, err - } - - act := &types.Actor{ - Code: actcid, - Head: statecid, - Balance: bal, - } - - return act, nil -} - -func createAccountActor(ctx context.Context, cst cbor.IpldStore, state *state.StateTree, info genesis.Actor, keyIDs map[address.Address]address.Address, av actors.Version) error { +func createAccountActor(ctx context.Context, cst cbor.IpldStore, state *state.StateTree, info genesis.Actor, keyIDs map[address.Address]address.Address) error { var ainfo genesis.AccountMeta if err := json.Unmarshal(info.Meta, &ainfo); err != nil { return xerrors.Errorf("unmarshaling account meta: %w", err) } - - aa, err := makeAccountActor(ctx, cst, av, ainfo.Owner, info.Balance) + st, err := cst.Put(ctx, &account0.State{Address: ainfo.Owner}) if err != nil { return err } @@ -403,14 +368,18 @@ func createAccountActor(ctx context.Context, cst cbor.IpldStore, state *state.St return fmt.Errorf("no registered ID for account actor: %s", ainfo.Owner) } - err = state.SetActor(ida, aa) + err = state.SetActor(ida, &types.Actor{ + Code: builtin0.AccountActorCodeID, + Balance: info.Balance, + Head: st, + }) if err != nil { return xerrors.Errorf("setting account from actmap: %w", err) } return nil } -func createMultisigAccount(ctx context.Context, cst cbor.IpldStore, state *state.StateTree, ida address.Address, info genesis.Actor, keyIDs map[address.Address]address.Address, av actors.Version) error { +func createMultisigAccount(ctx context.Context, bs bstore.Blockstore, cst cbor.IpldStore, state *state.StateTree, ida address.Address, info genesis.Actor, keyIDs map[address.Address]address.Address) error { if info.Type != genesis.TMultisig { return fmt.Errorf("can only call createMultisigAccount with multisig Actor info") } @@ -418,6 +387,10 @@ func createMultisigAccount(ctx context.Context, cst cbor.IpldStore, state *state if err := json.Unmarshal(info.Meta, &ainfo); err != nil { return xerrors.Errorf("unmarshaling account meta: %w", err) } + pending, err := adt0.MakeEmptyMap(adt0.WrapStore(ctx, cst)).Root() + if err != nil { + return xerrors.Errorf("failed to create empty map: %v", err) + } var signers []address.Address @@ -434,45 +407,44 @@ func createMultisigAccount(ctx context.Context, cst cbor.IpldStore, state *state continue } - aa, err := makeAccountActor(ctx, cst, av, e, big.Zero()) + st, err := cst.Put(ctx, &account0.State{Address: e}) if err != nil { return err } - - if err = state.SetActor(idAddress, aa); err != nil { + err = state.SetActor(idAddress, &types.Actor{ + Code: builtin0.AccountActorCodeID, + Balance: types.NewInt(0), + Head: st, + }) + if err != nil { return xerrors.Errorf("setting account from actmap: %w", err) } signers = append(signers, idAddress) } - mst, err := multisig.MakeState(adt.WrapStore(ctx, cst), av, signers, uint64(ainfo.Threshold), abi.ChainEpoch(ainfo.VestingStart), abi.ChainEpoch(ainfo.VestingDuration), info.Balance) - if err != nil { - return err - } - - statecid, err := cst.Put(ctx, mst.GetState()) - if err != nil { - return err - } - - actcid, err := multisig.GetActorCodeID(av) + st, err := cst.Put(ctx, &multisig0.State{ + Signers: signers, + NumApprovalsThreshold: uint64(ainfo.Threshold), + StartEpoch: abi.ChainEpoch(ainfo.VestingStart), + UnlockDuration: abi.ChainEpoch(ainfo.VestingDuration), + PendingTxns: pending, + InitialBalance: info.Balance, + }) if err != nil { return err } - err = state.SetActor(ida, &types.Actor{ - Code: actcid, + Code: builtin0.MultisigActorCodeID, Balance: info.Balance, - Head: statecid, + Head: st, }) if err != nil { return xerrors.Errorf("setting account from actmap: %w", err) } - return nil } -func VerifyPreSealedData(ctx context.Context, cs *store.ChainStore, stateroot cid.Cid, template genesis.Template, keyIDs map[address.Address]address.Address, nv network.Version) (cid.Cid, error) { +func VerifyPreSealedData(ctx context.Context, cs *store.ChainStore, stateroot cid.Cid, template genesis.Template, keyIDs map[address.Address]address.Address) (cid.Cid, error) { verifNeeds := make(map[address.Address]abi.PaddedPieceSize) var sum abi.PaddedPieceSize @@ -483,10 +455,8 @@ func VerifyPreSealedData(ctx context.Context, cs *store.ChainStore, stateroot ci Bstore: cs.StateBlockstore(), Syscalls: mkFakedSigSyscalls(cs.VMSys()), CircSupplyCalc: nil, - NtwkVersion: func(_ context.Context, _ abi.ChainEpoch) network.Version { - return nv - }, - BaseFee: types.NewInt(0), + NtwkVersion: genesisNetworkVersion, + BaseFee: types.NewInt(0), } vm, err := vm.NewVM(ctx, &vmopt) if err != nil { @@ -515,8 +485,7 @@ func VerifyPreSealedData(ctx context.Context, cs *store.ChainStore, stateroot ci return cid.Undef, err } - // Note: This is brittle, if the methodNum / param changes, it could break things - _, err = doExecValue(ctx, vm, verifreg.Address, verifregRoot, types.NewInt(0), builtin0.MethodsVerifiedRegistry.AddVerifier, mustEnc(&verifreg0.AddVerifierParams{ + _, err = doExecValue(ctx, vm, builtin0.VerifiedRegistryActorAddr, verifregRoot, types.NewInt(0), builtin0.MethodsVerifiedRegistry.AddVerifier, mustEnc(&verifreg0.AddVerifierParams{ Address: verifier, Allowance: abi.NewStoragePower(int64(sum)), // eh, close enough @@ -527,8 +496,7 @@ func VerifyPreSealedData(ctx context.Context, cs *store.ChainStore, stateroot ci } for c, amt := range verifNeeds { - // Note: This is brittle, if the methodNum / param changes, it could break things - _, err := doExecValue(ctx, vm, verifreg.Address, verifier, types.NewInt(0), builtin0.MethodsVerifiedRegistry.AddVerifiedClient, mustEnc(&verifreg0.AddVerifiedClientParams{ + _, err := doExecValue(ctx, vm, builtin0.VerifiedRegistryActorAddr, verifier, types.NewInt(0), builtin0.MethodsVerifiedRegistry.AddVerifiedClient, mustEnc(&verifreg0.AddVerifiedClientParams{ Address: c, Allowance: abi.NewStoragePower(int64(amt)), })) @@ -563,17 +531,17 @@ func MakeGenesisBlock(ctx context.Context, j journal.Journal, bs bstore.Blocksto cs := store.NewChainStore(bs, bs, datastore.NewMapDatastore(), sys, j) // Verify PreSealed Data - stateroot, err = VerifyPreSealedData(ctx, cs, stateroot, template, keyIDs, template.NetworkVersion) + stateroot, err = VerifyPreSealedData(ctx, cs, stateroot, template, keyIDs) if err != nil { return nil, xerrors.Errorf("failed to verify presealed data: %w", err) } - stateroot, err = SetupStorageMiners(ctx, cs, stateroot, template.Miners, template.NetworkVersion) + stateroot, err = SetupStorageMiners(ctx, cs, stateroot, template.Miners) if err != nil { 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 := adt0.MakeEmptyArray(store).Root() if err != nil { return nil, xerrors.Errorf("amt build failed: %w", err) @@ -622,7 +590,7 @@ func MakeGenesisBlock(ctx context.Context, j journal.Journal, bs bstore.Blocksto } b := &types.BlockHeader{ - Miner: system.Address, + Miner: builtin0.SystemActorAddr, Ticket: genesisticket, Parents: []cid.Cid{filecoinGenesisCid}, Height: 0, diff --git a/chain/gen/genesis/miners.go b/chain/gen/genesis/miners.go index 17349b2703f..297543886dd 100644 --- a/chain/gen/genesis/miners.go +++ b/chain/gen/genesis/miners.go @@ -6,22 +6,6 @@ import ( "fmt" "math/rand" - power4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/power" - - reward4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/reward" - - market4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/market" - - "github.com/filecoin-project/lotus/chain/actors" - - "github.com/filecoin-project/lotus/chain/actors/builtin" - - "github.com/filecoin-project/lotus/chain/actors/policy" - - "github.com/filecoin-project/lotus/chain/actors/adt" - - "github.com/filecoin-project/go-state-types/network" - market0 "github.com/filecoin-project/specs-actors/actors/builtin/market" "github.com/filecoin-project/lotus/chain/actors/builtin/power" @@ -77,12 +61,7 @@ func mkFakedSigSyscalls(base vm.SyscallBuilder) vm.SyscallBuilder { } } -// Note: Much of this is brittle, if the methodNum / param / return changes, it will break things -func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid, miners []genesis.Miner, nv network.Version) (cid.Cid, error) { - - cst := cbor.NewCborStore(cs.StateBlockstore()) - av := actors.VersionForNetwork(nv) - +func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid, miners []genesis.Miner) (cid.Cid, error) { csc := func(context.Context, abi.ChainEpoch, *state.StateTree) (abi.TokenAmount, error) { return big.Zero(), nil } @@ -94,10 +73,8 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid Bstore: cs.StateBlockstore(), Syscalls: mkFakedSigSyscalls(cs.VMSys()), CircSupplyCalc: csc, - NtwkVersion: func(_ context.Context, _ abi.ChainEpoch) network.Version { - return nv - }, - BaseFee: types.NewInt(0), + NtwkVersion: genesisNetworkVersion, + BaseFee: types.NewInt(0), } vm, err := vm.NewVM(ctx, vmopt) @@ -117,13 +94,12 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid dealIDs []abi.DealID }, len(miners)) - maxPeriods := policy.GetMaxSectorExpirationExtension() / miner.WPoStProvingPeriod for i, m := range miners { // Create miner through power actor i := i m := m - spt, err := miner.SealProofTypeFromSectorSize(m.SectorSize, nv) + spt, err := miner.SealProofTypeFromSectorSize(m.SectorSize, GenesisNetworkVersion) if err != nil { return cid.Undef, err } @@ -137,7 +113,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid } params := mustEnc(constructorParams) - rval, err := doExecValue(ctx, vm, power.Address, m.Owner, m.PowerBalance, power.Methods.CreateMiner, params) + rval, err := doExecValue(ctx, vm, power.Address, m.Owner, m.PowerBalance, builtin0.MethodsPower.CreateMiner, params) if err != nil { return cid.Undef, xerrors.Errorf("failed to create genesis miner: %w", err) } @@ -153,34 +129,23 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid } minerInfos[i].maddr = ma.IDAddress - _, err = vm.Flush(ctx) - if err != nil { - return cid.Undef, xerrors.Errorf("flushing vm: %w", err) - } - - mact, err := vm.StateTree().GetActor(minerInfos[i].maddr) - if err != nil { - return cid.Undef, xerrors.Errorf("getting newly created miner actor: %w", err) - } + // TODO: ActorUpgrade + err = vm.MutateState(ctx, minerInfos[i].maddr, func(cst cbor.IpldStore, st *miner0.State) error { + maxPeriods := miner0.MaxSectorExpirationExtension / miner0.WPoStProvingPeriod + minerInfos[i].presealExp = (maxPeriods-1)*miner0.WPoStProvingPeriod + st.ProvingPeriodStart - 1 - mst, err := miner.Load(adt.WrapStore(ctx, cst), mact) - if err != nil { - return cid.Undef, xerrors.Errorf("getting newly created miner state: %w", err) - } - - pps, err := mst.GetProvingPeriodStart() + return nil + }) if err != nil { - return cid.Undef, xerrors.Errorf("getting newly created miner proving period start: %w", err) + return cid.Undef, xerrors.Errorf("mutating state: %w", err) } - - minerInfos[i].presealExp = (maxPeriods-1)*miner0.WPoStProvingPeriod + pps - 1 } // Add market funds if m.MarketBalance.GreaterThan(big.Zero()) { params := mustEnc(&minerInfos[i].maddr) - _, err := doExecValue(ctx, vm, market.Address, m.Worker, m.MarketBalance, market.Methods.AddBalance, params) + _, err := doExecValue(ctx, vm, market.Address, m.Worker, m.MarketBalance, builtin0.MethodsMarket.AddBalance, params) if err != nil { return cid.Undef, xerrors.Errorf("failed to create genesis miner (add balance): %w", err) } @@ -238,66 +203,35 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid for pi := range m.Sectors { rawPow = types.BigAdd(rawPow, types.NewInt(uint64(m.SectorSize))) - dweight, vdweight, err := dealWeight(ctx, vm, minerInfos[i].maddr, []abi.DealID{minerInfos[i].dealIDs[pi]}, 0, minerInfos[i].presealExp, av) + dweight, err := dealWeight(ctx, vm, minerInfos[i].maddr, []abi.DealID{minerInfos[i].dealIDs[pi]}, 0, minerInfos[i].presealExp) if err != nil { return cid.Undef, xerrors.Errorf("getting deal weight: %w", err) } - sectorWeight := builtin.QAPowerForWeight(m.SectorSize, minerInfos[i].presealExp, dweight, vdweight) + sectorWeight := miner0.QAPowerForWeight(m.SectorSize, minerInfos[i].presealExp, dweight.DealWeight, dweight.VerifiedDealWeight) qaPow = types.BigAdd(qaPow, sectorWeight) } } - _, err = vm.Flush(ctx) - if err != nil { - return cid.Undef, xerrors.Errorf("flushing vm: %w", err) - } + err = vm.MutateState(ctx, power.Address, func(cst cbor.IpldStore, st *power0.State) error { + st.TotalQualityAdjPower = qaPow + st.TotalRawBytePower = rawPow - pact, err := vm.StateTree().GetActor(power.Address) + st.ThisEpochQualityAdjPower = qaPow + st.ThisEpochRawBytePower = rawPow + return nil + }) if err != nil { - return cid.Undef, xerrors.Errorf("getting power actor: %w", err) + return cid.Undef, xerrors.Errorf("mutating state: %w", err) } - pst, err := power.Load(adt.WrapStore(ctx, cst), pact) + err = vm.MutateState(ctx, reward.Address, func(sct cbor.IpldStore, st *reward0.State) error { + *st = *reward0.ConstructState(qaPow) + return nil + }) if err != nil { - return cid.Undef, xerrors.Errorf("getting power state: %w", err) - } - - if err = pst.SetTotalQualityAdjPower(qaPow); err != nil { - return cid.Undef, xerrors.Errorf("setting TotalQualityAdjPower in power state: %w", err) - } - - if err = pst.SetTotalRawBytePower(rawPow); err != nil { - return cid.Undef, xerrors.Errorf("setting TotalRawBytePower in power state: %w", err) - } - - if err = pst.SetThisEpochQualityAdjPower(qaPow); err != nil { - return cid.Undef, xerrors.Errorf("setting ThisEpochQualityAdjPower in power state: %w", err) - } - - if err = pst.SetThisEpochRawBytePower(rawPow); err != nil { - return cid.Undef, xerrors.Errorf("setting ThisEpochRawBytePower in power state: %w", err) - } - - pcid, err := cst.Put(ctx, pst.GetState()) - if err != nil { - return cid.Undef, xerrors.Errorf("putting power state: %w", err) - } - - pact.Head = pcid - - if err = vm.StateTree().SetActor(power.Address, pact); err != nil { - return cid.Undef, xerrors.Errorf("setting power state: %w", err) - } - - rewact, err := SetupRewardActor(ctx, cs.StateBlockstore(), big.Zero(), actors.VersionForNetwork(nv)) - if err != nil { - return cid.Undef, xerrors.Errorf("setup reward actor: %w", err) - } - - if err = vm.StateTree().SetActor(reward.Address, rewact); err != nil { - return cid.Undef, xerrors.Errorf("set reward actor: %w", err) + return cid.Undef, xerrors.Errorf("mutating state: %w", err) } } @@ -314,55 +248,24 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid Expiration: minerInfos[i].presealExp, // TODO: Allow setting externally! } - dweight, vdweight, err := dealWeight(ctx, vm, minerInfos[i].maddr, params.DealIDs, 0, minerInfos[i].presealExp, av) + dweight, err := dealWeight(ctx, vm, minerInfos[i].maddr, params.DealIDs, 0, minerInfos[i].presealExp) if err != nil { return cid.Undef, xerrors.Errorf("getting deal weight: %w", err) } - sectorWeight := builtin.QAPowerForWeight(m.SectorSize, minerInfos[i].presealExp, dweight, vdweight) + sectorWeight := miner0.QAPowerForWeight(m.SectorSize, minerInfos[i].presealExp, dweight.DealWeight, dweight.VerifiedDealWeight) // we've added fake power for this sector above, remove it now - - _, err = vm.Flush(ctx) - if err != nil { - return cid.Undef, xerrors.Errorf("flushing vm: %w", err) - } - - pact, err := vm.StateTree().GetActor(power.Address) - if err != nil { - return cid.Undef, xerrors.Errorf("getting power actor: %w", err) - } - - pst, err := power.Load(adt.WrapStore(ctx, cst), pact) - if err != nil { - return cid.Undef, xerrors.Errorf("getting power state: %w", err) - } - - pc, err := pst.TotalPower() - if err != nil { - return cid.Undef, xerrors.Errorf("getting total power: %w", err) - } - - if err = pst.SetTotalRawBytePower(types.BigSub(pc.RawBytePower, types.NewInt(uint64(m.SectorSize)))); err != nil { - return cid.Undef, xerrors.Errorf("setting TotalRawBytePower in power state: %w", err) - } - - if err = pst.SetTotalQualityAdjPower(types.BigSub(pc.QualityAdjPower, sectorWeight)); err != nil { - return cid.Undef, xerrors.Errorf("setting TotalQualityAdjPower in power state: %w", err) - } - - pcid, err := cst.Put(ctx, pst.GetState()) + err = vm.MutateState(ctx, power.Address, func(cst cbor.IpldStore, st *power0.State) error { + st.TotalQualityAdjPower = types.BigSub(st.TotalQualityAdjPower, sectorWeight) //nolint:scopelint + st.TotalRawBytePower = types.BigSub(st.TotalRawBytePower, types.NewInt(uint64(m.SectorSize))) + return nil + }) if err != nil { - return cid.Undef, xerrors.Errorf("putting power state: %w", err) + return cid.Undef, xerrors.Errorf("removing fake power: %w", err) } - pact.Head = pcid - - if err = vm.StateTree().SetActor(power.Address, pact); err != nil { - return cid.Undef, xerrors.Errorf("setting power state: %w", err) - } - - baselinePower, rewardSmoothed, err := currentEpochBlockReward(ctx, vm, minerInfos[i].maddr, av) + epochReward, err := currentEpochBlockReward(ctx, vm, minerInfos[i].maddr) if err != nil { return cid.Undef, xerrors.Errorf("getting current epoch reward: %w", err) } @@ -372,13 +275,13 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid return cid.Undef, xerrors.Errorf("getting current total power: %w", err) } - pcd := miner0.PreCommitDepositForPower(&rewardSmoothed, tpow.QualityAdjPowerSmoothed, sectorWeight) + pcd := miner0.PreCommitDepositForPower(epochReward.ThisEpochRewardSmoothed, tpow.QualityAdjPowerSmoothed, sectorWeight) pledge := miner0.InitialPledgeForPower( sectorWeight, - baselinePower, + epochReward.ThisEpochBaselinePower, tpow.PledgeCollateral, - &rewardSmoothed, + epochReward.ThisEpochRewardSmoothed, tpow.QualityAdjPowerSmoothed, circSupply(ctx, vm, minerInfos[i].maddr), ) @@ -386,7 +289,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid pledge = big.Add(pcd, pledge) fmt.Println(types.FIL(pledge)) - _, err = doExecValue(ctx, vm, minerInfos[i].maddr, m.Worker, pledge, miner.Methods.PreCommitSector, mustEnc(params)) + _, err = doExecValue(ctx, vm, minerInfos[i].maddr, m.Worker, pledge, builtin0.MethodsMiner.PreCommitSector, mustEnc(params)) if err != nil { return cid.Undef, xerrors.Errorf("failed to confirm presealed sectors: %w", err) } @@ -396,84 +299,28 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid Sectors: []abi.SectorNumber{preseal.SectorID}, } - _, err = doExecValue(ctx, vm, minerInfos[i].maddr, power.Address, big.Zero(), miner.Methods.ConfirmSectorProofsValid, mustEnc(confirmParams)) + _, err = doExecValue(ctx, vm, minerInfos[i].maddr, power.Address, big.Zero(), builtin0.MethodsMiner.ConfirmSectorProofsValid, mustEnc(confirmParams)) if err != nil { return cid.Undef, xerrors.Errorf("failed to confirm presealed sectors: %w", err) } - - if av > actors.Version2 { - // post v2, we need to explicitly Claim this power since ConfirmSectorProofsValid doesn't do it anymore - claimParams := &power4.UpdateClaimedPowerParams{ - RawByteDelta: types.NewInt(uint64(m.SectorSize)), - QualityAdjustedDelta: sectorWeight, - } - - _, err = doExecValue(ctx, vm, power.Address, minerInfos[i].maddr, big.Zero(), power.Methods.UpdateClaimedPower, mustEnc(claimParams)) - if err != nil { - return cid.Undef, xerrors.Errorf("failed to confirm presealed sectors: %w", err) - } - - _, err = vm.Flush(ctx) - if err != nil { - return cid.Undef, xerrors.Errorf("flushing vm: %w", err) - } - - mact, err := vm.StateTree().GetActor(minerInfos[i].maddr) - if err != nil { - return cid.Undef, xerrors.Errorf("getting miner actor: %w", err) - } - - mst, err := miner.Load(adt.WrapStore(ctx, cst), mact) - if err != nil { - return cid.Undef, xerrors.Errorf("getting miner state: %w", err) - } - - if err = mst.EraseAllUnproven(); err != nil { - return cid.Undef, xerrors.Errorf("failed to erase unproven sectors: %w", err) - } - - mcid, err := cst.Put(ctx, mst.GetState()) - if err != nil { - return cid.Undef, xerrors.Errorf("putting miner state: %w", err) - } - - mact.Head = mcid - - if err = vm.StateTree().SetActor(minerInfos[i].maddr, mact); err != nil { - return cid.Undef, xerrors.Errorf("setting miner state: %w", err) - } - } } } } // Sanity-check total network power - _, err = vm.Flush(ctx) - if err != nil { - return cid.Undef, xerrors.Errorf("flushing vm: %w", err) - } - - pact, err := vm.StateTree().GetActor(power.Address) - if err != nil { - return cid.Undef, xerrors.Errorf("getting power actor: %w", err) - } + err = vm.MutateState(ctx, power.Address, func(cst cbor.IpldStore, st *power0.State) error { + if !st.TotalRawBytePower.Equals(rawPow) { + return xerrors.Errorf("st.TotalRawBytePower doesn't match previously calculated rawPow") + } - pst, err := power.Load(adt.WrapStore(ctx, cst), pact) - if err != nil { - return cid.Undef, xerrors.Errorf("getting power state: %w", err) - } + if !st.TotalQualityAdjPower.Equals(qaPow) { + return xerrors.Errorf("st.TotalQualityAdjPower doesn't match previously calculated qaPow") + } - pc, err := pst.TotalPower() + return nil + }) if err != nil { - return cid.Undef, xerrors.Errorf("getting total power: %w", err) - } - - if !pc.RawBytePower.Equals(rawPow) { - return cid.Undef, xerrors.Errorf("TotalRawBytePower (%s) doesn't match previously calculated rawPow (%s)", pc.RawBytePower, rawPow) - } - - if !pc.QualityAdjPower.Equals(qaPow) { - return cid.Undef, xerrors.Errorf("QualityAdjPower (%s) doesn't match previously calculated qaPow (%s)", pc.QualityAdjPower, qaPow) + return cid.Undef, xerrors.Errorf("mutating state: %w", err) } // TODO: Should we re-ConstructState for the reward actor using rawPow as currRealizedPower here? @@ -513,79 +360,43 @@ func currentTotalPower(ctx context.Context, vm *vm.VM, maddr address.Address) (* return &pwr, nil } -func dealWeight(ctx context.Context, vm *vm.VM, maddr address.Address, dealIDs []abi.DealID, sectorStart, sectorExpiry abi.ChainEpoch, av actors.Version) (abi.DealWeight, abi.DealWeight, error) { - // TODO: This hack should move to market actor wrapper - if av <= actors.Version2 { - params := &market0.VerifyDealsForActivationParams{ - DealIDs: dealIDs, - SectorStart: sectorStart, - SectorExpiry: sectorExpiry, - } - - var dealWeights market0.VerifyDealsForActivationReturn - ret, err := doExecValue(ctx, vm, - market.Address, - maddr, - abi.NewTokenAmount(0), - builtin0.MethodsMarket.VerifyDealsForActivation, - mustEnc(params), - ) - if err != nil { - return big.Zero(), big.Zero(), err - } - if err := dealWeights.UnmarshalCBOR(bytes.NewReader(ret)); err != nil { - return big.Zero(), big.Zero(), err - } - - return dealWeights.DealWeight, dealWeights.VerifiedDealWeight, nil - } - params := &market4.VerifyDealsForActivationParams{Sectors: []market4.SectorDeals{{ - SectorExpiry: sectorExpiry, +func dealWeight(ctx context.Context, vm *vm.VM, maddr address.Address, dealIDs []abi.DealID, sectorStart, sectorExpiry abi.ChainEpoch) (market0.VerifyDealsForActivationReturn, error) { + params := &market.VerifyDealsForActivationParams{ DealIDs: dealIDs, - }}} + SectorStart: sectorStart, + SectorExpiry: sectorExpiry, + } - var dealWeights market4.VerifyDealsForActivationReturn + var dealWeights market0.VerifyDealsForActivationReturn ret, err := doExecValue(ctx, vm, market.Address, maddr, abi.NewTokenAmount(0), - market.Methods.VerifyDealsForActivation, + builtin0.MethodsMarket.VerifyDealsForActivation, mustEnc(params), ) if err != nil { - return big.Zero(), big.Zero(), err + return market0.VerifyDealsForActivationReturn{}, err } if err := dealWeights.UnmarshalCBOR(bytes.NewReader(ret)); err != nil { - return big.Zero(), big.Zero(), err + return market0.VerifyDealsForActivationReturn{}, err } - return dealWeights.Sectors[0].DealWeight, dealWeights.Sectors[0].VerifiedDealWeight, nil + return dealWeights, nil } -func currentEpochBlockReward(ctx context.Context, vm *vm.VM, maddr address.Address, av actors.Version) (abi.StoragePower, builtin.FilterEstimate, error) { - rwret, err := doExecValue(ctx, vm, reward.Address, maddr, big.Zero(), reward.Methods.ThisEpochReward, nil) +func currentEpochBlockReward(ctx context.Context, vm *vm.VM, maddr address.Address) (*reward0.ThisEpochRewardReturn, error) { + rwret, err := doExecValue(ctx, vm, reward.Address, maddr, big.Zero(), builtin0.MethodsReward.ThisEpochReward, nil) if err != nil { - return big.Zero(), builtin.FilterEstimate{}, err - } - - // TODO: This hack should move to reward actor wrapper - if av <= actors.Version2 { - var epochReward reward0.ThisEpochRewardReturn - - if err := epochReward.UnmarshalCBOR(bytes.NewReader(rwret)); err != nil { - return big.Zero(), builtin.FilterEstimate{}, err - } - - return epochReward.ThisEpochBaselinePower, *epochReward.ThisEpochRewardSmoothed, nil + return nil, err } - var epochReward reward4.ThisEpochRewardReturn - + var epochReward reward0.ThisEpochRewardReturn if err := epochReward.UnmarshalCBOR(bytes.NewReader(rwret)); err != nil { - return big.Zero(), builtin.FilterEstimate{}, err + return nil, err } - return epochReward.ThisEpochBaselinePower, builtin.FilterEstimate(epochReward.ThisEpochRewardSmoothed), nil + return &epochReward, nil } func circSupply(ctx context.Context, vmi *vm.VM, maddr address.Address) abi.TokenAmount { diff --git a/chain/gen/genesis/util.go b/chain/gen/genesis/util.go index 67a4e9579a7..54cc30cc168 100644 --- a/chain/gen/genesis/util.go +++ b/chain/gen/genesis/util.go @@ -3,6 +3,9 @@ package genesis import ( "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-state-types/abi" cbg "github.com/whyrusleeping/cbor-gen" @@ -46,3 +49,29 @@ func doExecValue(ctx context.Context, vm *vm.VM, to, from address.Address, value return ret.Return, nil } + +// TODO: Get from build +// TODO: make a list/schedule of these. +var GenesisNetworkVersion = func() network.Version { + // returns the version _before_ the first upgrade. + if build.UpgradeBreezeHeight >= 0 { + return network.Version0 + } + if build.UpgradeSmokeHeight >= 0 { + return network.Version1 + } + if build.UpgradeIgnitionHeight >= 0 { + return network.Version2 + } + if build.UpgradeActorsV2Height >= 0 { + return network.Version3 + } + if build.UpgradeLiftoffHeight >= 0 { + return network.Version3 + } + return build.ActorUpgradeNetworkVersion - 1 // genesis requires actors v0. +}() + +func genesisNetworkVersion(context.Context, abi.ChainEpoch) network.Version { // TODO: Get from build/ + return GenesisNetworkVersion // TODO: Get from build/ +} // TODO: Get from build/ diff --git a/chain/state/statetree.go b/chain/state/statetree.go index a31ec2396ca..2a7b436b8bd 100644 --- a/chain/state/statetree.go +++ b/chain/state/statetree.go @@ -14,6 +14,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/network" + "github.com/filecoin-project/lotus/chain/actors" init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init" cbg "github.com/whyrusleeping/cbor-gen" @@ -141,19 +142,11 @@ func (ss *stateSnaps) deleteActor(addr address.Address) { // VersionForNetwork returns the state tree version for the given network // version. -func VersionForNetwork(ver network.Version) (types.StateTreeVersion, error) { - switch ver { - case network.Version0, network.Version1, network.Version2, network.Version3: - return types.StateTreeVersion0, nil - case network.Version4, network.Version5, network.Version6, network.Version7, network.Version8, network.Version9: - return types.StateTreeVersion1, nil - case network.Version10, network.Version11: - return types.StateTreeVersion2, nil - case network.Version12: - return types.StateTreeVersion3, nil - default: - panic(fmt.Sprintf("unsupported network version %d", ver)) +func VersionForNetwork(ver network.Version) types.StateTreeVersion { + if actors.VersionForNetwork(ver) == actors.Version0 { + return types.StateTreeVersion0 } + return types.StateTreeVersion1 } func NewStateTree(cst cbor.IpldStore, ver types.StateTreeVersion) (*StateTree, error) { diff --git a/chain/state/statetree_test.go b/chain/state/statetree_test.go index 9177af31219..91674337b88 100644 --- a/chain/state/statetree_test.go +++ b/chain/state/statetree_test.go @@ -5,12 +5,11 @@ import ( "fmt" "testing" - "github.com/filecoin-project/go-state-types/network" - "github.com/ipfs/go-cid" cbor "github.com/ipfs/go-ipld-cbor" address "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/network" builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" "github.com/filecoin-project/lotus/build" @@ -46,12 +45,7 @@ func BenchmarkStateTreeSet(b *testing.B) { func BenchmarkStateTreeSetFlush(b *testing.B) { cst := cbor.NewMemCborStore() - sv, err := VersionForNetwork(build.NewestNetworkVersion) - if err != nil { - b.Fatal(err) - } - - st, err := NewStateTree(cst, sv) + st, err := NewStateTree(cst, VersionForNetwork(build.NewestNetworkVersion)) if err != nil { b.Fatal(err) } @@ -81,12 +75,7 @@ func BenchmarkStateTreeSetFlush(b *testing.B) { func TestResolveCache(t *testing.T) { cst := cbor.NewMemCborStore() - sv, err := VersionForNetwork(build.NewestNetworkVersion) - if err != nil { - t.Fatal(err) - } - - st, err := NewStateTree(cst, sv) + st, err := NewStateTree(cst, VersionForNetwork(build.NewestNetworkVersion)) if err != nil { t.Fatal(err) } @@ -183,12 +172,7 @@ func TestResolveCache(t *testing.T) { func BenchmarkStateTree10kGetActor(b *testing.B) { cst := cbor.NewMemCborStore() - sv, err := VersionForNetwork(build.NewestNetworkVersion) - if err != nil { - b.Fatal(err) - } - - st, err := NewStateTree(cst, sv) + st, err := NewStateTree(cst, VersionForNetwork(build.NewestNetworkVersion)) if err != nil { b.Fatal(err) } @@ -230,12 +214,7 @@ func BenchmarkStateTree10kGetActor(b *testing.B) { func TestSetCache(t *testing.T) { cst := cbor.NewMemCborStore() - sv, err := VersionForNetwork(build.NewestNetworkVersion) - if err != nil { - t.Fatal(err) - } - - st, err := NewStateTree(cst, sv) + st, err := NewStateTree(cst, VersionForNetwork(build.NewestNetworkVersion)) if err != nil { t.Fatal(err) } @@ -272,13 +251,7 @@ func TestSetCache(t *testing.T) { func TestSnapshots(t *testing.T) { ctx := context.Background() cst := cbor.NewMemCborStore() - - sv, err := VersionForNetwork(build.NewestNetworkVersion) - if err != nil { - t.Fatal(err) - } - - st, err := NewStateTree(cst, sv) + st, err := NewStateTree(cst, VersionForNetwork(build.NewestNetworkVersion)) if err != nil { t.Fatal(err) } @@ -361,15 +334,8 @@ func assertNotHas(t *testing.T, st *StateTree, addr address.Address) { func TestStateTreeConsistency(t *testing.T) { cst := cbor.NewMemCborStore() - // TODO: ActorUpgrade: this test tests pre actors v2 - - sv, err := VersionForNetwork(network.Version3) - if err != nil { - t.Fatal(err) - } - - st, err := NewStateTree(cst, sv) + st, err := NewStateTree(cst, VersionForNetwork(network.Version3)) if err != nil { t.Fatal(err) } diff --git a/chain/vm/vm.go b/chain/vm/vm.go index f488c78649c..afc74e744f1 100644 --- a/chain/vm/vm.go +++ b/chain/vm/vm.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "fmt" + "reflect" "sync/atomic" "time" @@ -202,8 +203,7 @@ type ( ) type VM struct { - cstate *state.StateTree - // TODO: Is base actually used? Can we delete it? + cstate *state.StateTree base cid.Cid cst *cbor.BasicIpldStore buf *blockstore.BufferedBlockstore @@ -662,6 +662,37 @@ func (vm *VM) Flush(ctx context.Context) (cid.Cid, error) { return root, nil } +// MutateState usage: MutateState(ctx, idAddr, func(cst cbor.IpldStore, st *ActorStateType) error {...}) +func (vm *VM) MutateState(ctx context.Context, addr address.Address, fn interface{}) error { + act, err := vm.cstate.GetActor(addr) + if err != nil { + return xerrors.Errorf("actor not found: %w", err) + } + + st := reflect.New(reflect.TypeOf(fn).In(1).Elem()) + if err := vm.cst.Get(ctx, act.Head, st.Interface()); err != nil { + return xerrors.Errorf("read actor head: %w", err) + } + + out := reflect.ValueOf(fn).Call([]reflect.Value{reflect.ValueOf(vm.cst), st}) + if !out[0].IsNil() && out[0].Interface().(error) != nil { + return out[0].Interface().(error) + } + + head, err := vm.cst.Put(ctx, st.Interface()) + if err != nil { + return xerrors.Errorf("put new actor head: %w", err) + } + + act.Head = head + + if err := vm.cstate.SetActor(addr, act); err != nil { + return xerrors.Errorf("set actor: %w", err) + } + + return nil +} + func linksForObj(blk block.Block, cb func(cid.Cid)) error { switch blk.Cid().Prefix().Codec { case cid.DagCBOR: diff --git a/cmd/lotus-seed/genesis.go b/cmd/lotus-seed/genesis.go index 87493c58a3b..d5f1d5ad6ba 100644 --- a/cmd/lotus-seed/genesis.go +++ b/cmd/lotus-seed/genesis.go @@ -9,8 +9,6 @@ import ( "strconv" "strings" - "github.com/filecoin-project/go-state-types/network" - "github.com/filecoin-project/lotus/blockstore" "github.com/filecoin-project/lotus/chain/vm" "github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper" @@ -41,7 +39,6 @@ var genesisCmd = &cli.Command{ genesisAddMsigsCmd, genesisSetVRKCmd, genesisSetRemainderCmd, - genesisSetActorVersionCmd, genesisCarCmd, }, } @@ -59,7 +56,6 @@ var genesisNewCmd = &cli.Command{ return xerrors.New("seed genesis new [genesis.json]") } out := genesis.Template{ - NetworkVersion: network.Version0, Accounts: []genesis.Actor{}, Miners: []genesis.Miner{}, VerifregRootKey: gen.DefaultVerifregRootkeyActor, @@ -507,53 +503,6 @@ var genesisSetRemainderCmd = &cli.Command{ }, } -var genesisSetActorVersionCmd = &cli.Command{ - Name: "set-network-version", - Usage: "Set the version that this network will start from", - ArgsUsage: " ", - Action: func(cctx *cli.Context) error { - if cctx.Args().Len() != 2 { - return fmt.Errorf("must specify genesis file and network version (e.g. '0'") - } - - genf, err := homedir.Expand(cctx.Args().First()) - if err != nil { - return err - } - - var template genesis.Template - b, err := ioutil.ReadFile(genf) - if err != nil { - return xerrors.Errorf("read genesis template: %w", err) - } - - if err := json.Unmarshal(b, &template); err != nil { - return xerrors.Errorf("unmarshal genesis template: %w", err) - } - - nv, err := strconv.ParseUint(cctx.Args().Get(1), 10, 64) - if err != nil { - return xerrors.Errorf("parsing network version: %w", err) - } - - if nv > uint64(build.NewestNetworkVersion) { - return xerrors.Errorf("invalid network version: %d", nv) - } - - template.NetworkVersion = network.Version(nv) - - b, err = json.MarshalIndent(&template, "", " ") - if err != nil { - return err - } - - if err := ioutil.WriteFile(genf, b, 0644); err != nil { - return err - } - return nil - }, -} - var genesisCarCmd = &cli.Command{ Name: "car", Description: "write genesis car file", diff --git a/cmd/lotus-seed/main.go b/cmd/lotus-seed/main.go index c923971257e..c4e62b4194d 100644 --- a/cmd/lotus-seed/main.go +++ b/cmd/lotus-seed/main.go @@ -94,11 +94,6 @@ var preSealCmd = &cli.Command{ Name: "fake-sectors", Value: false, }, - &cli.IntFlag{ - Name: "network-version", - Value: 0, - Usage: "specify network version", - }, }, Action: func(c *cli.Context) error { sdir := c.String("sector-dir") @@ -134,7 +129,7 @@ var preSealCmd = &cli.Command{ } sectorSize := abi.SectorSize(sectorSizeInt) - spt, err := miner.SealProofTypeFromSectorSize(sectorSize, network.Version(c.Uint64("network-version"))) + spt, err := miner.SealProofTypeFromSectorSize(sectorSize, network.Version0) if err != nil { return err } diff --git a/documentation/en/api-v0-methods.md b/documentation/en/api-v0-methods.md index a8b760f8a36..0372c0dab3b 100644 --- a/documentation/en/api-v0-methods.md +++ b/documentation/en/api-v0-methods.md @@ -4551,7 +4551,7 @@ Inputs: ] ``` -Response: `12` +Response: `11` ### StateReadState StateReadState returns the indicated actor's state. diff --git a/documentation/en/api-v1-unstable-methods.md b/documentation/en/api-v1-unstable-methods.md index be326b3e8a6..bf282745aa6 100644 --- a/documentation/en/api-v1-unstable-methods.md +++ b/documentation/en/api-v1-unstable-methods.md @@ -4772,7 +4772,7 @@ Inputs: ] ``` -Response: `12` +Response: `11` ### StateReadState StateReadState returns the indicated actor's state. diff --git a/genesis/types.go b/genesis/types.go index d4c04113a0c..db8d32a3bd7 100644 --- a/genesis/types.go +++ b/genesis/types.go @@ -3,8 +3,6 @@ package genesis import ( "encoding/json" - "github.com/filecoin-project/go-state-types/network" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/ipfs/go-cid" @@ -77,9 +75,8 @@ type Actor struct { } type Template struct { - NetworkVersion network.Version - Accounts []Actor - Miners []Miner + Accounts []Actor + Miners []Miner NetworkName string Timestamp uint64 `json:",omitempty"` diff --git a/node/test/builder.go b/node/test/builder.go index bd180ee4151..7e26966a807 100644 --- a/node/test/builder.go +++ b/node/test/builder.go @@ -12,8 +12,6 @@ import ( "testing" "time" - "github.com/filecoin-project/go-state-types/network" - "github.com/gorilla/mux" "golang.org/x/xerrors" @@ -279,7 +277,6 @@ func mockBuilderOpts(t *testing.T, fullOpts []test.FullNodeOpts, storage []test. genms = append(genms, *genm) } templ := &genesis.Template{ - NetworkVersion: network.Version0, Accounts: genaccs, Miners: genms, NetworkName: "test", @@ -443,7 +440,6 @@ func mockSbBuilderOpts(t *testing.T, fullOpts []test.FullNodeOpts, storage []tes genms = append(genms, *genm) } templ := &genesis.Template{ - NetworkVersion: network.Version0, Accounts: genaccs, Miners: genms, NetworkName: "test",