diff --git a/api/types.go b/api/types.go index 93ed4083f..baf52aa82 100644 --- a/api/types.go +++ b/api/types.go @@ -349,6 +349,7 @@ type ForkUpgradeParams struct { UpgradeLightningHeight abi.ChainEpoch UpgradeThunderHeight abi.ChainEpoch UpgradeWatermelonHeight abi.ChainEpoch + UpgradePineappleHeight abi.ChainEpoch } type NonceMapType map[address.Address]uint64 diff --git a/build/actors/v13.tar.zst b/build/actors/v13.tar.zst new file mode 100644 index 000000000..1e3220f6b Binary files /dev/null and b/build/actors/v13.tar.zst differ diff --git a/build/builtin_actors_gen.go b/build/builtin_actors_gen.go index 11c70f9ec..64e622c96 100644 --- a/build/builtin_actors_gen.go +++ b/build/builtin_actors_gen.go @@ -94,9 +94,32 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "system": MustParseCid("bafk2bzacedtuh7cht3fud7fb4avl4g2zbz57lc4ohiaufpaex6dkmdokn5rgo"), "verifiedregistry": MustParseCid("bafk2bzaceb37hxeuoo5rgf6ansrdl2ykm5v5zp6kireubn4orcopr67jbxv6k"), }, +}, { + Network: "butterflynet", + Version: 12, + + ManifestCid: MustParseCid("bafy2bzacectxvbk77ntedhztd6sszp2btrtvsmy7lp2ypnrk6yl74zb34t2cq"), + Actors: map[string]cid.Cid{ + "account": MustParseCid("bafk2bzacebp7anjdtg2sohyt6lromx4xs7nujtwdfcsffnptphaayabx7ysxs"), + "cron": MustParseCid("bafk2bzacecu2y3awtemmglpkroiglulc2fj3gpdn6eazdqr6avcautiaighrg"), + "datacap": MustParseCid("bafk2bzacebbh5aynu3v3fluqqrcdsphleodoig42xkid2ccwdnff3avhbdop4"), + "eam": MustParseCid("bafk2bzacebzwt4v4hqoltiblhliwrnttxpr2dggbu3wsrvq4pwzisp7idu5w4"), + "ethaccount": MustParseCid("bafk2bzaceb5f6vgjkl7ic6ry5sjspqm2iij6qlcdovwi3haodb7wn37pgebii"), + "evm": MustParseCid("bafk2bzacebygt6zh6p52rkg2ugehm4k5yuu6f56i2pu6ywrmjez4n4zsje4p4"), + "init": MustParseCid("bafk2bzaceagyf3pwsthod7klfi25ow2zf2i5isfrrgr5ua3lvkgfojalrdbhw"), + "multisig": MustParseCid("bafk2bzacedgfo5mw2zqjwi37lah27sfxj4cw2abylgtxf3ucep4dyhgnppmqe"), + "paymentchannel": MustParseCid("bafk2bzacebm37tgu52cgzmiln6iip6etfmq73fd3qqz2j5gxlhtvachs7kw4c"), + "placeholder": MustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"), + "reward": MustParseCid("bafk2bzacedebvitdsztwebi44t5es4ls3p3hor252igzawr3s6uznmbvzh2ou"), + "storagemarket": MustParseCid("bafk2bzaceb2tdeqtt2eqpzeb3gezuchb7g7uzbd52bgvcdt6bg3ckq7oisb74"), + "storageminer": MustParseCid("bafk2bzaceb62clldtod2jimnri5k2koxttf6vqtlsvkjhnwduzs7sgsoakglw"), + "storagepower": MustParseCid("bafk2bzacedxvlj5xmhytdjrjqyonz37duvxb2ioyzk75c27yypkqalxuh3xh6"), + "system": MustParseCid("bafk2bzacec3vwj2chzaram3iqupkbfiein5h2l5qiltlrngbju2vg5umelclm"), + "verifiedregistry": MustParseCid("bafk2bzacedv2irkql7nil3w5v3ohqq3e54w62pxeoppjmaktzokolaaoh5ksu"), + }, }, { Network: "butterflynet", - Version: 12, + Version: 13, BundleGitTag: "v12.0.0", ManifestCid: MustParseCid("bafy2bzacectxvbk77ntedhztd6sszp2btrtvsmy7lp2ypnrk6yl74zb34t2cq"), Actors: map[string]cid.Cid{ @@ -200,9 +223,32 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "system": MustParseCid("bafk2bzacedqvik2n3phnj3cni3h2k5mtvz43nyq7mdmv7k7euejysvajywdug"), "verifiedregistry": MustParseCid("bafk2bzaceceoo5jlom2zweh7kpye2vkj33wgqnkjshlsw2neemqkfg5g2rmvg"), }, +}, { + Network: "calibrationnet", + Version: 12, + + ManifestCid: MustParseCid("bafy2bzacednzb3pkrfnbfhmoqtb3bc6dgvxszpqklf3qcc7qzcage4ewzxsca"), + Actors: map[string]cid.Cid{ + "account": MustParseCid("bafk2bzacechwwxdqvggkdylm37zldjsra2ivkdzwp7fee56bzxbzs544wv6u6"), + "cron": MustParseCid("bafk2bzacec4gdxxkqwxqqodsv6ug5dmdbqdfqwyqfek3yhxc2wweh5psxaeq6"), + "datacap": MustParseCid("bafk2bzacecq5ppfskxgv3iea3jarsix6jdduuhwsn4fbvngtbmzelzmlygorm"), + "eam": MustParseCid("bafk2bzacecb6cnwftvavpph4p34zs4psuy5xvbrhf7vszkva4npw6mw3c42xe"), + "ethaccount": MustParseCid("bafk2bzaceajmc3y3sedsqymfla3dzzqzmbu5kmr2iskm26ga2u34ll5fpztfw"), + "evm": MustParseCid("bafk2bzaced4sozr7m6rzcgpobzeiupghthfw6afumysu3oz6bxxirv74uo3vw"), + "init": MustParseCid("bafk2bzaceaewh7b6zl2egclm7fqzx2lsqr57i75lb6cj43ndoa4mal3k5ld3m"), + "multisig": MustParseCid("bafk2bzacednkwcpw5yzxjceoaliajgupzj6iqxe7ks2ll3unspbprbo5f2now"), + "paymentchannel": MustParseCid("bafk2bzacebaxhk4itfiuvbftg7kz5zxugqnvdgerobitjq4vl6q4orcwk6wqg"), + "placeholder": MustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"), + "reward": MustParseCid("bafk2bzacedra77pcglf7vdca2itcaa4vd6xrxynxmgfgdjdxqxfwqyhtoxehy"), + "storagemarket": MustParseCid("bafk2bzacea7g46y7xxu2zjq2h75x6mmx3utz2uxnlvnwi6tzpsvulna3bmiva"), + "storageminer": MustParseCid("bafk2bzaceb7qzqsi5uyxe4o5iuasi47l2hnznvmqr2eu4pl3qscvarjqlnuxo"), + "storagepower": MustParseCid("bafk2bzacedd3ka44k7d46ckbinjhv3diyuu2epgbyvhqqyjkc64qlrg3wlgzi"), + "system": MustParseCid("bafk2bzacecioupndtcnyw6iq2hbrxag3aufvczlv5nobnfbkbywqzcyfaa376"), + "verifiedregistry": MustParseCid("bafk2bzaceavldupmf7bimeeacs67z5xdfdlfca6p7sn6bev3mt5ggepfqvhqo"), + }, }, { Network: "calibrationnet", - Version: 12, + Version: 13, BundleGitTag: "v12.0.0", ManifestCid: MustParseCid("bafy2bzacednzb3pkrfnbfhmoqtb3bc6dgvxszpqklf3qcc7qzcage4ewzxsca"), Actors: map[string]cid.Cid{ @@ -315,9 +361,32 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "system": MustParseCid("bafk2bzacebxfzeom3d7ahcz2n2nlwp7ncv767bdbbrisugks4l6v7lcu2tmyg"), "verifiedregistry": MustParseCid("bafk2bzacedaws3or3twy45ltcxucgvqijsje4x675ph6vup2w35smlfneamno"), }, +}, { + Network: "caterpillarnet", + Version: 12, + + ManifestCid: MustParseCid("bafy2bzacebxiub6qsy67asvl5cx33x5vjbuqinalmf3xtnbmokxmmklzdkvei"), + Actors: map[string]cid.Cid{ + "account": MustParseCid("bafk2bzacecereuhejfvodut5357cai4lmhsyr7uenhcxvmw6jpmhe6auuly32"), + "cron": MustParseCid("bafk2bzacebo2whgy6jla4jsf5j4ovlqm2e4eepedlpw5wadas33yxmunis4b4"), + "datacap": MustParseCid("bafk2bzacecjjncl7ftgj4mrzxxfxld74pt3pyfrxmcru7a5auab25b3aoixm6"), + "eam": MustParseCid("bafk2bzacebyvawfzoxy7k4yxrj5nd3amg4rcopmnslxdwpzumfhsz5ezk4sws"), + "ethaccount": MustParseCid("bafk2bzaceaccs76uc6osvb2iy6w2pumqei3wdjtxq7rgtsotobncmqoi7kzcg"), + "evm": MustParseCid("bafk2bzaceawxgjzjkhbqwj36wzxeqbtngdh6y2tp4wsi27k7tbg2ujhw5rsjg"), + "init": MustParseCid("bafk2bzacedws5od7o6ktqyo2hudmipxuubsv2lwxz45xxjn2zguze72t6zoik"), + "multisig": MustParseCid("bafk2bzacecb4wk6n4lrmml3tssn6cszd4dc7ttux3kzjatrawhg4o6ovrng6w"), + "paymentchannel": MustParseCid("bafk2bzacea3eb556mkjvosfbqfbyfg6dgu52rfnuctwzjy3b2bh2azredxzbo"), + "placeholder": MustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"), + "reward": MustParseCid("bafk2bzaceb2x5zgkrho373l3ippp6krs7brugssg6hj2tib22xmqjzdm2o25a"), + "storagemarket": MustParseCid("bafk2bzaced5j6drzmsebpxbf2dtptrc5tyidlbftdljqxavxqb57s2qpbvdek"), + "storageminer": MustParseCid("bafk2bzaceckgusfenkczxolfczvnygnuhxbou5to2skwwngbkihla7hgdv4yy"), + "storagepower": MustParseCid("bafk2bzaceagp6ilkltsltwii66nz6a4zen4qtfk7rdkvdv3gzq7fbv4ivox3u"), + "system": MustParseCid("bafk2bzacedye5j5uxox7knb6zlnhseaadztyav76mjbyk5qslhhbpiy5cdtt2"), + "verifiedregistry": MustParseCid("bafk2bzacecduww5pirr7dvaijjijw4gf6ygf7vipgxh4scvv6vseo46gueb46"), + }, }, { Network: "caterpillarnet", - Version: 12, + Version: 13, BundleGitTag: "v12.0.0", ManifestCid: MustParseCid("bafy2bzacebxiub6qsy67asvl5cx33x5vjbuqinalmf3xtnbmokxmmklzdkvei"), Actors: map[string]cid.Cid{ @@ -421,9 +490,32 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "system": MustParseCid("bafk2bzacedpyoncjbl4oxkjm5e77ngvpy2xfajjc4myfsv2vltvzxioattlu2"), "verifiedregistry": MustParseCid("bafk2bzacebdqi5tr5pjnem5nylg2zbqcugvi7oxi35bhnrfudx4y4ufhlit2k"), }, +}, { + Network: "devnet", + Version: 12, + + ManifestCid: MustParseCid("bafy2bzaceasjdukhhyjbegpli247vbf5h64f7uvxhhebdihuqsj2mwisdwa6o"), + Actors: map[string]cid.Cid{ + "account": MustParseCid("bafk2bzacedki4apynvdxxuoigmqkgaktgy2erjftoxqxqaklnelgveyaqknfu"), + "cron": MustParseCid("bafk2bzacebjpczf7qtcisy3zdp3sqoohxe75tgupmdo5dr26vh7orzrsjn3b2"), + "datacap": MustParseCid("bafk2bzacecz4esatk7gizdc7yvl6soigkelhix7izbc75q6eqtb7gjzavpcqc"), + "eam": MustParseCid("bafk2bzacebhtpd5mxfyovi7fgsfj62nhtmh4t5guob4sgq73ymgsk7473ltig"), + "ethaccount": MustParseCid("bafk2bzacebvdbbw5ag4qnxd7cif5mtakrw4wzv63diwl7awta5plaidfay4vg"), + "evm": MustParseCid("bafk2bzacebb7vrhprnshn52bzfmypjdpcrcfecapk232a6gapk3kghu2mp67q"), + "init": MustParseCid("bafk2bzaceaw4iouukgqxmwukfpt3sakdvsu75ftjvw47swnwtdftz5oszbt4w"), + "multisig": MustParseCid("bafk2bzaceahyjwf6re4mnuwhopglo3qzh6aboluboncpijm7vuiz3u4bkazho"), + "paymentchannel": MustParseCid("bafk2bzaceaupjw3djghaqw3g3hd4tw7uuas3njkszgzx2fhmgqh5eh4e6q2by"), + "placeholder": MustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"), + "reward": MustParseCid("bafk2bzacebzso6xkjxdscbpncw7el2d4hap6lfkgwqzrbc76lzp33vkwk6obc"), + "storagemarket": MustParseCid("bafk2bzacebzg74vyk3gzbhnz4zviwvxblyar574mtd6ayognmsvlkriejmunu"), + "storageminer": MustParseCid("bafk2bzacecs262232b3awcrilyzpdketeayyqzzwgoavtxilgjvayrz55ovk4"), + "storagepower": MustParseCid("bafk2bzacebbtj2m2ajawfuzxqz5nmdep7xevjo2qfjqa5tx3vr5m6qojolya4"), + "system": MustParseCid("bafk2bzacecnau5wddulbsvwn75tc3w75jrlvkybgrlxs4ngonqab6xq3eowvg"), + "verifiedregistry": MustParseCid("bafk2bzacec37mddea65nvh4htsagtryfa3sq6i67utcupslyhzbhjhoy6hopa"), + }, }, { Network: "devnet", - Version: 12, + Version: 13, BundleGitTag: "v12.0.0", ManifestCid: MustParseCid("bafy2bzaceasjdukhhyjbegpli247vbf5h64f7uvxhhebdihuqsj2mwisdwa6o"), Actors: map[string]cid.Cid{ @@ -550,9 +642,32 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "system": MustParseCid("bafk2bzaced7npe5mt5nh72jxr2igi2sofoa7gedt4w6kueeke7i3xxugqpjfm"), "verifiedregistry": MustParseCid("bafk2bzacedej3dnr62g2je2abmyjg3xqv4otvh6e26du5fcrhvw7zgcaaez3a"), }, +}, { + Network: "mainnet", + Version: 12, + + ManifestCid: MustParseCid("bafy2bzaceapkgfggvxyllnmuogtwasmsv5qi2qzhc2aybockd6kag2g5lzaio"), + Actors: map[string]cid.Cid{ + "account": MustParseCid("bafk2bzaceboftg75mdiba7xbo2i3uvgtca4brhnr3u5ptihonixgpnrvhpxoa"), + "cron": MustParseCid("bafk2bzacechxjkfe2cehx4s7skj3wzfpzf7zolds64khrrrs66bhazsemktls"), + "datacap": MustParseCid("bafk2bzacebpiwb2ml4qbnnaayxumtk43ryhc63exdgnhivy3hwgmzemawsmpq"), + "eam": MustParseCid("bafk2bzaceb3elj4hfbbjp7g5bptc7su7mptszl4nlqfedilxvstjo5ungm6oe"), + "ethaccount": MustParseCid("bafk2bzaceb4gkau2vgsijcxpfuq33bd7w3efr2rrhxrwiacjmns2ntdiamswq"), + "evm": MustParseCid("bafk2bzacecmnyfiwb52tkbwmm2dsd7ysi3nvuxl3lmspy7pl26wxj4zj7w4wi"), + "init": MustParseCid("bafk2bzacebllyegx5r6lggf6ymyetbp7amacwpuxakhtjvjtvoy2bfkzk3vms"), + "multisig": MustParseCid("bafk2bzacecw5lyp3n3t67xdwrmo36h4z7afc3lobmmr6wg55w6yjzg5jhmh42"), + "paymentchannel": MustParseCid("bafk2bzacectv4cm47bnhga5febf3lo3fq47g72kmmp2xd5s6tcxz7hiqdywa4"), + "placeholder": MustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"), + "reward": MustParseCid("bafk2bzacealqnxn5lwzwexd6reav4dppypquklx2ujlnvaxiqk2tzstyvkp5u"), + "storagemarket": MustParseCid("bafk2bzacedylkg5am446lcuih4voyzdn4yjeqfsxfzh5b6mcuhx4mok5ph5c4"), + "storageminer": MustParseCid("bafk2bzacedo75pabe4i2l3hvhtsjmijrcytd2y76xwe573uku25fi7sugqld6"), + "storagepower": MustParseCid("bafk2bzacecsij5tpfzjpfuckxvccv2p3bdqjklkrfyyoei6lx5dyj5j4fvjm6"), + "system": MustParseCid("bafk2bzacebfqrja2hip7esf4eafxjmu6xcogoqu5xxtgdg7xa5szgvvdguchu"), + "verifiedregistry": MustParseCid("bafk2bzacedudgflxc75c77c6zkmfyq4u2xuk7k6xw6dfdccarjrvxx453b77q"), + }, }, { Network: "mainnet", - Version: 12, + Version: 13, BundleGitTag: "v12.0.0", ManifestCid: MustParseCid("bafy2bzaceapkgfggvxyllnmuogtwasmsv5qi2qzhc2aybockd6kag2g5lzaio"), Actors: map[string]cid.Cid{ @@ -656,9 +771,32 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "system": MustParseCid("bafk2bzaceaatvscbnkv36ixhtt2zel4er5oskxevgumh5gegqkv7uzah36f24"), "verifiedregistry": MustParseCid("bafk2bzacebp2r56wxadvfzpfbmqwfi3dlnwpmoc5u4tau2hfftbkuafkhye64"), }, +}, { + Network: "testing", + Version: 12, + + ManifestCid: MustParseCid("bafy2bzaceaaxd6ytavsek5bi5soqo7qamezuqfyfjy42es2clpbzu3pwzcmye"), + Actors: map[string]cid.Cid{ + "account": MustParseCid("bafk2bzacea74qqkfvacykmq5emzqblh4f4nmxdkiyixxpzs7kkcfnbfa7cb6m"), + "cron": MustParseCid("bafk2bzacecotbu7k6awdzfzakf7g5iaas6gswtunjnnb2xm2klqoshjgb4imy"), + "datacap": MustParseCid("bafk2bzaceduhmqcyailiwdupt2ottfzh5hcrjoyeyiaipf3idk3mu7y3uz2mc"), + "eam": MustParseCid("bafk2bzaceb2yzzw6dcmcmhnt3mqnm4kah66f23pc4escnto3vwa552t6ctr7i"), + "ethaccount": MustParseCid("bafk2bzacebwkvvbmttkcjjlicp4ineozc52i5sc6d46pcoq6lzzs2p5i2youa"), + "evm": MustParseCid("bafk2bzacedetwacs6wmoksxwjlbpp4442uav7fd3pagadejm2cph7ucym7eck"), + "init": MustParseCid("bafk2bzacedhpoycn4sz7dragmbo5yqjspqriydxhplqdeguaqck2hmq5hgwqg"), + "multisig": MustParseCid("bafk2bzaceacc3m23yvnpzoeekstqtr2acutfv4zvsgncorjdrsucymjohzxs4"), + "paymentchannel": MustParseCid("bafk2bzaceac6i76vfexefqf6qgebkhkf2cb4g664d5nmfh2dric5spgykevd2"), + "placeholder": MustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"), + "reward": MustParseCid("bafk2bzaceaajyncjxcrl7wbb6ukzkueyqz4uyekxpmtn4mpndkf7ksmggopzq"), + "storagemarket": MustParseCid("bafk2bzaced6cexdcinwjhtfvuxgkxukiejp3goylaxtvhqfd24rs5z7g2z7dm"), + "storageminer": MustParseCid("bafk2bzacecvkbsjhufq2zr2dojohukdnql3gkqzdkmtp2hxvn5kczxp3tu6ko"), + "storagepower": MustParseCid("bafk2bzacedexrf5qplrrl5xzijfrthjdqwodfs5e6zj5kpztc7qnywbqdyiii"), + "system": MustParseCid("bafk2bzacecp4roanbxq3bflftlkipsoqqxio5etjjnzxus5pcu7lq43fnxb34"), + "verifiedregistry": MustParseCid("bafk2bzaceandytrgcnuvizfi47sijbqh6c243vjtzlzumexm6kjv7s7hye45g"), + }, }, { Network: "testing", - Version: 12, + Version: 13, BundleGitTag: "v12.0.0", ManifestCid: MustParseCid("bafy2bzaceaaxd6ytavsek5bi5soqo7qamezuqfyfjy42es2clpbzu3pwzcmye"), Actors: map[string]cid.Cid{ @@ -762,9 +900,32 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "system": MustParseCid("bafk2bzaceaatvscbnkv36ixhtt2zel4er5oskxevgumh5gegqkv7uzah36f24"), "verifiedregistry": MustParseCid("bafk2bzacebp2r56wxadvfzpfbmqwfi3dlnwpmoc5u4tau2hfftbkuafkhye64"), }, +}, { + Network: "testing-fake-proofs", + Version: 12, + + ManifestCid: MustParseCid("bafy2bzacecver4l5d6jiuzubhrtcxjjfdx6jnxbmyp4bselol2atgkhz3e3um"), + Actors: map[string]cid.Cid{ + "account": MustParseCid("bafk2bzacea74qqkfvacykmq5emzqblh4f4nmxdkiyixxpzs7kkcfnbfa7cb6m"), + "cron": MustParseCid("bafk2bzacecotbu7k6awdzfzakf7g5iaas6gswtunjnnb2xm2klqoshjgb4imy"), + "datacap": MustParseCid("bafk2bzaceduhmqcyailiwdupt2ottfzh5hcrjoyeyiaipf3idk3mu7y3uz2mc"), + "eam": MustParseCid("bafk2bzaceb2yzzw6dcmcmhnt3mqnm4kah66f23pc4escnto3vwa552t6ctr7i"), + "ethaccount": MustParseCid("bafk2bzacebwkvvbmttkcjjlicp4ineozc52i5sc6d46pcoq6lzzs2p5i2youa"), + "evm": MustParseCid("bafk2bzacedetwacs6wmoksxwjlbpp4442uav7fd3pagadejm2cph7ucym7eck"), + "init": MustParseCid("bafk2bzacedhpoycn4sz7dragmbo5yqjspqriydxhplqdeguaqck2hmq5hgwqg"), + "multisig": MustParseCid("bafk2bzaceacc3m23yvnpzoeekstqtr2acutfv4zvsgncorjdrsucymjohzxs4"), + "paymentchannel": MustParseCid("bafk2bzaceac6i76vfexefqf6qgebkhkf2cb4g664d5nmfh2dric5spgykevd2"), + "placeholder": MustParseCid("bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro"), + "reward": MustParseCid("bafk2bzaceaajyncjxcrl7wbb6ukzkueyqz4uyekxpmtn4mpndkf7ksmggopzq"), + "storagemarket": MustParseCid("bafk2bzaced6cexdcinwjhtfvuxgkxukiejp3goylaxtvhqfd24rs5z7g2z7dm"), + "storageminer": MustParseCid("bafk2bzacedapzgrbc2rsmuqex76ftt2b62q6opi56gh2dr2oyyzuwin62rweg"), + "storagepower": MustParseCid("bafk2bzacecdwijcbbryinjtm27pdinqqkyzoskri24pwsvsadwcq2alkkjpnc"), + "system": MustParseCid("bafk2bzacecp4roanbxq3bflftlkipsoqqxio5etjjnzxus5pcu7lq43fnxb34"), + "verifiedregistry": MustParseCid("bafk2bzaceandytrgcnuvizfi47sijbqh6c243vjtzlzumexm6kjv7s7hye45g"), + }, }, { Network: "testing-fake-proofs", - Version: 12, + Version: 13, BundleGitTag: "v12.0.0", ManifestCid: MustParseCid("bafy2bzacecver4l5d6jiuzubhrtcxjjfdx6jnxbmyp4bselol2atgkhz3e3um"), Actors: map[string]cid.Cid{ diff --git a/build/openrpc/full.json.gz b/build/openrpc/full.json.gz index dbfbbe1f0..24ab403a3 100644 Binary files a/build/openrpc/full.json.gz and b/build/openrpc/full.json.gz differ diff --git a/build/openrpc/gateway.json.gz b/build/openrpc/gateway.json.gz index bde1ec8f4..d3287b108 100644 Binary files a/build/openrpc/gateway.json.gz and b/build/openrpc/gateway.json.gz differ diff --git a/build/openrpc/miner.json.gz b/build/openrpc/miner.json.gz index b5eb84c2f..8527396a1 100644 Binary files a/build/openrpc/miner.json.gz and b/build/openrpc/miner.json.gz differ diff --git a/build/params_2k.go b/build/params_2k.go index 4826d421d..1b47ee401 100644 --- a/build/params_2k.go +++ b/build/params_2k.go @@ -23,7 +23,7 @@ var NetworkBundle = "devnet" var BundleOverrides map[actorstypes.Version]string var ActorDebugging = true -const GenesisNetworkVersion = network.Version20 +const GenesisNetworkVersion = network.Version21 var UpgradeBreezeHeight = abi.ChainEpoch(-1) @@ -65,7 +65,9 @@ var UpgradeLightningHeight = abi.ChainEpoch(-22) var UpgradeThunderHeight = abi.ChainEpoch(-23) -var UpgradeWatermelonHeight = abi.ChainEpoch(200) +var UpgradeWatermelonHeight = abi.ChainEpoch(-24) + +var UpgradePineappleHeight = abi.ChainEpoch(200) // This fix upgrade only ran on calibrationnet const UpgradeWatermelonFixHeight = -100 @@ -129,6 +131,7 @@ func init() { UpgradeLightningHeight = getUpgradeHeight("LOTUS_LIGHTNING_HEIGHT", UpgradeLightningHeight) UpgradeThunderHeight = getUpgradeHeight("LOTUS_THUNDER_HEIGHT", UpgradeThunderHeight) UpgradeWatermelonHeight = getUpgradeHeight("LOTUS_WATERMELON_HEIGHT", UpgradeWatermelonHeight) + UpgradePineappleHeight = getUpgradeHeight("LOTUS_PINEAPPLE_HEIGHT", UpgradePineappleHeight) BuildType |= Build2k diff --git a/build/params_butterfly.go b/build/params_butterfly.go index 864518df5..b354e6665 100644 --- a/build/params_butterfly.go +++ b/build/params_butterfly.go @@ -54,8 +54,10 @@ const UpgradeSharkHeight = -20 const UpgradeHyggeHeight = -21 const UpgradeLightningHeight = -22 const UpgradeThunderHeight = -23 +const UpgradeWatermelonHeight = -24 -const UpgradeWatermelonHeight = 400 +// ?????? +const UpgradePineappleHeight = 999999999999999 // This fix upgrade only ran on calibrationnet const UpgradeWatermelonFixHeight = -100 diff --git a/build/params_calibnet.go b/build/params_calibnet.go index c22eef2fe..09453e9c2 100644 --- a/build/params_calibnet.go +++ b/build/params_calibnet.go @@ -88,6 +88,9 @@ const UpgradeWatermelonFixHeight = 1070494 // 2023-11-21T13:00:00Z const UpgradeWatermelonFix2Height = 1108174 +// ?????? +const UpgradePineappleHeight = 999999999999999 + var SupportedProofTypes = []abi.RegisteredSealProof{ abi.RegisteredSealProof_StackedDrg32GiBV1, abi.RegisteredSealProof_StackedDrg64GiBV1, diff --git a/build/params_interop.go b/build/params_interop.go index 9fd0d0ff8..af4a4ab85 100644 --- a/build/params_interop.go +++ b/build/params_interop.go @@ -53,8 +53,9 @@ var UpgradeSharkHeight = abi.ChainEpoch(-20) var UpgradeHyggeHeight = abi.ChainEpoch(-21) var UpgradeLightningHeight = abi.ChainEpoch(-22) var UpgradeThunderHeight = abi.ChainEpoch(-23) +var UpgradeWatermelonHeight = abi.ChainEpoch(-24) -const UpgradeWatermelonHeight = 50 +const UpgradePineappleHeight = 50 // This fix upgrade only ran on calibrationnet const UpgradeWatermelonFixHeight = -1 diff --git a/build/params_mainnet.go b/build/params_mainnet.go index 8176c4e6d..58c32b549 100644 --- a/build/params_mainnet.go +++ b/build/params_mainnet.go @@ -96,7 +96,10 @@ const UpgradeLightningHeight = 2809800 const UpgradeThunderHeight = UpgradeLightningHeight + 2880*21 // 2023-12-12T13:30:00Z -var UpgradeWatermelonHeight = abi.ChainEpoch(3469380) +const UpgradeWatermelonHeight = 3469380 + +// ?????? +var UpgradePineappleHeight = abi.ChainEpoch(999999999999999) // This fix upgrade only ran on calibrationnet const UpgradeWatermelonFixHeight = -1 @@ -119,8 +122,8 @@ func init() { SetAddressNetwork(address.Mainnet) } - if os.Getenv("LOTUS_DISABLE_WATERMELON") == "1" { - UpgradeWatermelonHeight = math.MaxInt64 + if os.Getenv("LOTUS_DISABLE_PINEAPPLE") == "1" { + UpgradePineappleHeight = math.MaxInt64 } // NOTE: DO NOT change this unless you REALLY know what you're doing. This is not consensus critical, however, diff --git a/build/params_shared_vals.go b/build/params_shared_vals.go index 1d15c2fe8..8a3f65501 100644 --- a/build/params_shared_vals.go +++ b/build/params_shared_vals.go @@ -30,7 +30,7 @@ const AllowableClockDriftSecs = uint64(1) /* inline-gen template const TestNetworkVersion = network.Version{{.latestNetworkVersion}} /* inline-gen start */ -const TestNetworkVersion = network.Version21 +const TestNetworkVersion = network.Version22 /* inline-gen end */ diff --git a/build/params_testground.go b/build/params_testground.go index 05249e7e2..8184d3239 100644 --- a/build/params_testground.go +++ b/build/params_testground.go @@ -112,6 +112,7 @@ var ( UpgradeWatermelonHeight abi.ChainEpoch = -23 UpgradeWatermelonFixHeight abi.ChainEpoch = -24 UpgradeWatermelonFix2Height abi.ChainEpoch = -25 + UpgradePineappleHeight abi.ChainEpoch = -26 DrandSchedule = map[abi.ChainEpoch]DrandEnum{ 0: DrandMainnet, diff --git a/chain/actors/builtin/account/account.go b/chain/actors/builtin/account/account.go index dcb60f801..0f7ac2093 100644 --- a/chain/actors/builtin/account/account.go +++ b/chain/actors/builtin/account/account.go @@ -6,7 +6,7 @@ import ( "github.com/filecoin-project/go-address" actorstypes "github.com/filecoin-project/go-state-types/actors" - builtin12 "github.com/filecoin-project/go-state-types/builtin" + builtin13 "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/go-state-types/cbor" "github.com/filecoin-project/go-state-types/manifest" builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" @@ -22,7 +22,7 @@ import ( "github.com/filecoin-project/lotus/chain/types" ) -var Methods = builtin12.MethodsAccount +var Methods = builtin13.MethodsAccount func Load(store adt.Store, act *types.Actor) (State, error) { if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { @@ -47,6 +47,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actorstypes.Version12: return load12(store, act.Head) + case actorstypes.Version13: + return load13(store, act.Head) + } } @@ -117,6 +120,9 @@ func MakeState(store adt.Store, av actorstypes.Version, addr address.Address) (S case actorstypes.Version12: return make12(store, addr) + case actorstypes.Version13: + return make13(store, addr) + } return nil, xerrors.Errorf("unknown actor version %d", av) } @@ -146,5 +152,6 @@ func AllCodes() []cid.Cid { (&state10{}).Code(), (&state11{}).Code(), (&state12{}).Code(), + (&state13{}).Code(), } } diff --git a/chain/actors/builtin/account/v13.go b/chain/actors/builtin/account/v13.go new file mode 100644 index 000000000..f2f3b6f66 --- /dev/null +++ b/chain/actors/builtin/account/v13.go @@ -0,0 +1,62 @@ +package account + +import ( + "fmt" + + "github.com/ipfs/go-cid" + + "github.com/filecoin-project/go-address" + actorstypes "github.com/filecoin-project/go-state-types/actors" + account13 "github.com/filecoin-project/go-state-types/builtin/v13/account" + "github.com/filecoin-project/go-state-types/manifest" + + "github.com/filecoin-project/lotus/chain/actors" + "github.com/filecoin-project/lotus/chain/actors/adt" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make13(store adt.Store, addr address.Address) (State, error) { + out := state13{store: store} + out.State = account13.State{Address: addr} + return &out, nil +} + +type state13 struct { + account13.State + store adt.Store +} + +func (s *state13) PubkeyAddress() (address.Address, error) { + return s.Address, nil +} + +func (s *state13) GetState() interface{} { + return &s.State +} + +func (s *state13) ActorKey() string { + return manifest.AccountKey +} + +func (s *state13) ActorVersion() actorstypes.Version { + return actorstypes.Version13 +} + +func (s *state13) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/cron/cron.go b/chain/actors/builtin/cron/cron.go index 17b291788..0c69cfca8 100644 --- a/chain/actors/builtin/cron/cron.go +++ b/chain/actors/builtin/cron/cron.go @@ -5,7 +5,7 @@ import ( "golang.org/x/xerrors" actorstypes "github.com/filecoin-project/go-state-types/actors" - builtin12 "github.com/filecoin-project/go-state-types/builtin" + builtin13 "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/go-state-types/manifest" builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" @@ -43,6 +43,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actorstypes.Version12: return load12(store, act.Head) + case actorstypes.Version13: + return load13(store, act.Head) + } } @@ -113,13 +116,16 @@ func MakeState(store adt.Store, av actorstypes.Version) (State, error) { case actorstypes.Version12: return make12(store) + case actorstypes.Version13: + return make13(store) + } return nil, xerrors.Errorf("unknown actor version %d", av) } var ( - Address = builtin12.CronActorAddr - Methods = builtin12.MethodsCron + Address = builtin13.CronActorAddr + Methods = builtin13.MethodsCron ) type State interface { @@ -144,5 +150,6 @@ func AllCodes() []cid.Cid { (&state10{}).Code(), (&state11{}).Code(), (&state12{}).Code(), + (&state13{}).Code(), } } diff --git a/chain/actors/builtin/cron/v13.go b/chain/actors/builtin/cron/v13.go new file mode 100644 index 000000000..d2ba03378 --- /dev/null +++ b/chain/actors/builtin/cron/v13.go @@ -0,0 +1,57 @@ +package cron + +import ( + "fmt" + + "github.com/ipfs/go-cid" + + actorstypes "github.com/filecoin-project/go-state-types/actors" + cron13 "github.com/filecoin-project/go-state-types/builtin/v13/cron" + "github.com/filecoin-project/go-state-types/manifest" + + "github.com/filecoin-project/lotus/chain/actors" + "github.com/filecoin-project/lotus/chain/actors/adt" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make13(store adt.Store) (State, error) { + out := state13{store: store} + out.State = *cron13.ConstructState(cron13.BuiltInEntries()) + return &out, nil +} + +type state13 struct { + cron13.State + store adt.Store +} + +func (s *state13) GetState() interface{} { + return &s.State +} + +func (s *state13) ActorKey() string { + return manifest.CronKey +} + +func (s *state13) ActorVersion() actorstypes.Version { + return actorstypes.Version13 +} + +func (s *state13) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/datacap/datacap.go b/chain/actors/builtin/datacap/datacap.go index 0c8f04bbf..7f5ee6c0b 100644 --- a/chain/actors/builtin/datacap/datacap.go +++ b/chain/actors/builtin/datacap/datacap.go @@ -7,7 +7,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" actorstypes "github.com/filecoin-project/go-state-types/actors" - builtin12 "github.com/filecoin-project/go-state-types/builtin" + builtin13 "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/go-state-types/cbor" "github.com/filecoin-project/go-state-types/manifest" @@ -17,8 +17,8 @@ import ( ) var ( - Address = builtin12.DatacapActorAddr - Methods = builtin12.MethodsDatacap + Address = builtin13.DatacapActorAddr + Methods = builtin13.MethodsDatacap ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -41,6 +41,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actorstypes.Version12: return load12(store, act.Head) + case actorstypes.Version13: + return load13(store, act.Head) + } } @@ -62,6 +65,9 @@ func MakeState(store adt.Store, av actorstypes.Version, governor address.Address case actorstypes.Version12: return make12(store, governor, bitwidth) + case actorstypes.Version13: + return make13(store, governor, bitwidth) + default: return nil, xerrors.Errorf("datacap actor only valid for actors v9 and above, got %d", av) } @@ -86,5 +92,6 @@ func AllCodes() []cid.Cid { (&state10{}).Code(), (&state11{}).Code(), (&state12{}).Code(), + (&state13{}).Code(), } } diff --git a/chain/actors/builtin/datacap/v13.go b/chain/actors/builtin/datacap/v13.go new file mode 100644 index 000000000..3baf374a4 --- /dev/null +++ b/chain/actors/builtin/datacap/v13.go @@ -0,0 +1,82 @@ +package datacap + +import ( + "fmt" + + "github.com/ipfs/go-cid" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" + datacap13 "github.com/filecoin-project/go-state-types/builtin/v13/datacap" + adt13 "github.com/filecoin-project/go-state-types/builtin/v13/util/adt" + "github.com/filecoin-project/go-state-types/manifest" + + "github.com/filecoin-project/lotus/chain/actors" + "github.com/filecoin-project/lotus/chain/actors/adt" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make13(store adt.Store, governor address.Address, bitwidth uint64) (State, error) { + out := state13{store: store} + s, err := datacap13.ConstructState(store, governor, bitwidth) + if err != nil { + return nil, err + } + + out.State = *s + + return &out, nil +} + +type state13 struct { + datacap13.State + store adt.Store +} + +func (s *state13) Governor() (address.Address, error) { + return s.State.Governor, nil +} + +func (s *state13) GetState() interface{} { + return &s.State +} + +func (s *state13) ForEachClient(cb func(addr address.Address, dcap abi.StoragePower) error) error { + return forEachClient(s.store, actors.Version13, s.verifiedClients, cb) +} + +func (s *state13) verifiedClients() (adt.Map, error) { + return adt13.AsMap(s.store, s.Token.Balances, int(s.Token.HamtBitWidth)) +} + +func (s *state13) VerifiedClientDataCap(addr address.Address) (bool, abi.StoragePower, error) { + return getDataCap(s.store, actors.Version13, s.verifiedClients, addr) +} + +func (s *state13) ActorKey() string { + return manifest.DatacapKey +} + +func (s *state13) ActorVersion() actorstypes.Version { + return actorstypes.Version13 +} + +func (s *state13) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/evm/evm.go b/chain/actors/builtin/evm/evm.go index 98f860cac..d77b1a1a4 100644 --- a/chain/actors/builtin/evm/evm.go +++ b/chain/actors/builtin/evm/evm.go @@ -5,7 +5,7 @@ import ( "golang.org/x/xerrors" actorstypes "github.com/filecoin-project/go-state-types/actors" - builtin12 "github.com/filecoin-project/go-state-types/builtin" + builtin13 "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/go-state-types/cbor" "github.com/filecoin-project/go-state-types/manifest" @@ -14,7 +14,7 @@ import ( "github.com/filecoin-project/lotus/chain/types" ) -var Methods = builtin12.MethodsEVM +var Methods = builtin13.MethodsEVM func Load(store adt.Store, act *types.Actor) (State, error) { if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { @@ -33,6 +33,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actorstypes.Version12: return load12(store, act.Head) + case actorstypes.Version13: + return load13(store, act.Head) + } } @@ -51,6 +54,9 @@ func MakeState(store adt.Store, av actorstypes.Version, bytecode cid.Cid) (State case actorstypes.Version12: return make12(store, bytecode) + case actorstypes.Version13: + return make13(store, bytecode) + default: return nil, xerrors.Errorf("evm actor only valid for actors v10 and above, got %d", av) } diff --git a/chain/actors/builtin/evm/v13.go b/chain/actors/builtin/evm/v13.go new file mode 100644 index 000000000..180c9f38a --- /dev/null +++ b/chain/actors/builtin/evm/v13.go @@ -0,0 +1,72 @@ +package evm + +import ( + "github.com/ipfs/go-cid" + + "github.com/filecoin-project/go-state-types/abi" + evm13 "github.com/filecoin-project/go-state-types/builtin/v13/evm" + + "github.com/filecoin-project/lotus/chain/actors/adt" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make13(store adt.Store, bytecode cid.Cid) (State, error) { + out := state13{store: store} + s, err := evm13.ConstructState(store, bytecode) + if err != nil { + return nil, err + } + + out.State = *s + + return &out, nil +} + +type state13 struct { + evm13.State + store adt.Store +} + +func (s *state13) Nonce() (uint64, error) { + return s.State.Nonce, nil +} + +func (s *state13) IsAlive() (bool, error) { + return s.State.Tombstone == nil, nil +} + +func (s *state13) GetState() interface{} { + return &s.State +} + +func (s *state13) GetBytecodeCID() (cid.Cid, error) { + return s.State.Bytecode, nil +} + +func (s *state13) GetBytecodeHash() ([32]byte, error) { + return s.State.BytecodeHash, nil +} + +func (s *state13) GetBytecode() ([]byte, error) { + bc, err := s.GetBytecodeCID() + if err != nil { + return nil, err + } + + var byteCode abi.CborBytesTransparent + if err := s.store.Get(s.store.Context(), bc, &byteCode); err != nil { + return nil, err + } + + return byteCode, nil +} diff --git a/chain/actors/builtin/init/init.go b/chain/actors/builtin/init/init.go index 41a763ecf..de1c6274e 100644 --- a/chain/actors/builtin/init/init.go +++ b/chain/actors/builtin/init/init.go @@ -7,7 +7,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" actorstypes "github.com/filecoin-project/go-state-types/actors" - builtin12 "github.com/filecoin-project/go-state-types/builtin" + builtin13 "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/go-state-types/cbor" "github.com/filecoin-project/go-state-types/manifest" builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" @@ -25,8 +25,8 @@ import ( ) var ( - Address = builtin12.InitActorAddr - Methods = builtin12.MethodsInit + Address = builtin13.InitActorAddr + Methods = builtin13.MethodsInit ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -52,6 +52,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actorstypes.Version12: return load12(store, act.Head) + case actorstypes.Version13: + return load13(store, act.Head) + } } @@ -122,6 +125,9 @@ func MakeState(store adt.Store, av actorstypes.Version, networkName string) (Sta case actorstypes.Version12: return make12(store, networkName) + case actorstypes.Version13: + return make13(store, networkName) + } return nil, xerrors.Errorf("unknown actor version %d", av) } @@ -174,5 +180,6 @@ func AllCodes() []cid.Cid { (&state10{}).Code(), (&state11{}).Code(), (&state12{}).Code(), + (&state13{}).Code(), } } diff --git a/chain/actors/builtin/init/v13.go b/chain/actors/builtin/init/v13.go new file mode 100644 index 000000000..227ce769f --- /dev/null +++ b/chain/actors/builtin/init/v13.go @@ -0,0 +1,147 @@ +package init + +import ( + "crypto/sha256" + "fmt" + + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + "golang.org/x/xerrors" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" + builtin13 "github.com/filecoin-project/go-state-types/builtin" + init13 "github.com/filecoin-project/go-state-types/builtin/v13/init" + adt13 "github.com/filecoin-project/go-state-types/builtin/v13/util/adt" + "github.com/filecoin-project/go-state-types/manifest" + + "github.com/filecoin-project/lotus/chain/actors" + "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/node/modules/dtypes" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make13(store adt.Store, networkName string) (State, error) { + out := state13{store: store} + + s, err := init13.ConstructState(store, networkName) + if err != nil { + return nil, err + } + + out.State = *s + + return &out, nil +} + +type state13 struct { + init13.State + store adt.Store +} + +func (s *state13) ResolveAddress(address address.Address) (address.Address, bool, error) { + return s.State.ResolveAddress(s.store, address) +} + +func (s *state13) MapAddressToNewID(address address.Address) (address.Address, error) { + return s.State.MapAddressToNewID(s.store, address) +} + +func (s *state13) ForEachActor(cb func(id abi.ActorID, address address.Address) error) error { + addrs, err := adt13.AsMap(s.store, s.State.AddressMap, builtin13.DefaultHamtBitwidth) + if err != nil { + return err + } + var actorID cbg.CborInt + return addrs.ForEach(&actorID, func(key string) error { + addr, err := address.NewFromBytes([]byte(key)) + if err != nil { + return err + } + return cb(abi.ActorID(actorID), addr) + }) +} + +func (s *state13) NetworkName() (dtypes.NetworkName, error) { + return dtypes.NetworkName(s.State.NetworkName), nil +} + +func (s *state13) SetNetworkName(name string) error { + s.State.NetworkName = name + return nil +} + +func (s *state13) SetNextID(id abi.ActorID) error { + s.State.NextID = id + return nil +} + +func (s *state13) Remove(addrs ...address.Address) (err error) { + m, err := adt13.AsMap(s.store, s.State.AddressMap, builtin13.DefaultHamtBitwidth) + if err != nil { + return err + } + for _, addr := range addrs { + if err = m.Delete(abi.AddrKey(addr)); err != nil { + return xerrors.Errorf("failed to delete entry for address: %s; err: %w", addr, err) + } + } + amr, err := m.Root() + if err != nil { + return xerrors.Errorf("failed to get address map root: %w", err) + } + s.State.AddressMap = amr + return nil +} + +func (s *state13) SetAddressMap(mcid cid.Cid) error { + s.State.AddressMap = mcid + return nil +} + +func (s *state13) GetState() interface{} { + return &s.State +} + +func (s *state13) AddressMap() (adt.Map, error) { + return adt13.AsMap(s.store, s.State.AddressMap, builtin13.DefaultHamtBitwidth) +} + +func (s *state13) AddressMapBitWidth() int { + return builtin13.DefaultHamtBitwidth +} + +func (s *state13) AddressMapHashFunction() func(input []byte) []byte { + return func(input []byte) []byte { + res := sha256.Sum256(input) + return res[:] + } +} + +func (s *state13) ActorKey() string { + return manifest.InitKey +} + +func (s *state13) ActorVersion() actorstypes.Version { + return actorstypes.Version13 +} + +func (s *state13) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/market/market.go b/chain/actors/builtin/market/market.go index 39473d560..95b4f5f19 100644 --- a/chain/actors/builtin/market/market.go +++ b/chain/actors/builtin/market/market.go @@ -58,6 +58,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actorstypes.Version12: return load12(store, act.Head) + case actorstypes.Version13: + return load13(store, act.Head) + } } @@ -128,6 +131,9 @@ func MakeState(store adt.Store, av actorstypes.Version) (State, error) { case actorstypes.Version12: return make12(store) + case actorstypes.Version13: + return make13(store) + } return nil, xerrors.Errorf("unknown actor version %d", av) } @@ -226,6 +232,9 @@ func DecodePublishStorageDealsReturn(b []byte, nv network.Version) (PublishStora case actorstypes.Version12: return decodePublishStorageDealsReturn12(b) + case actorstypes.Version13: + return decodePublishStorageDealsReturn13(b) + } return nil, xerrors.Errorf("unknown actor version %d", av) } @@ -313,5 +322,6 @@ func AllCodes() []cid.Cid { (&state10{}).Code(), (&state11{}).Code(), (&state12{}).Code(), + (&state13{}).Code(), } } diff --git a/chain/actors/builtin/market/v13.go b/chain/actors/builtin/market/v13.go new file mode 100644 index 000000000..23b58cc09 --- /dev/null +++ b/chain/actors/builtin/market/v13.go @@ -0,0 +1,377 @@ +package market + +import ( + "bytes" + "fmt" + + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + "golang.org/x/xerrors" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-bitfield" + rlepluslazy "github.com/filecoin-project/go-bitfield/rle" + "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/filecoin-project/go-state-types/builtin" + market13 "github.com/filecoin-project/go-state-types/builtin/v13/market" + adt13 "github.com/filecoin-project/go-state-types/builtin/v13/util/adt" + markettypes "github.com/filecoin-project/go-state-types/builtin/v9/market" + "github.com/filecoin-project/go-state-types/manifest" + + "github.com/filecoin-project/lotus/chain/actors" + "github.com/filecoin-project/lotus/chain/actors/adt" + verifregtypes "github.com/filecoin-project/lotus/chain/actors/builtin/verifreg" + "github.com/filecoin-project/lotus/chain/types" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make13(store adt.Store) (State, error) { + out := state13{store: store} + + s, err := market13.ConstructState(store) + if err != nil { + return nil, err + } + + out.State = *s + + return &out, nil +} + +type state13 struct { + market13.State + store adt.Store +} + +func (s *state13) TotalLocked() (abi.TokenAmount, error) { + fml := types.BigAdd(s.TotalClientLockedCollateral, s.TotalProviderLockedCollateral) + fml = types.BigAdd(fml, s.TotalClientStorageFee) + return fml, nil +} + +func (s *state13) BalancesChanged(otherState State) (bool, error) { + otherState13, ok := otherState.(*state13) + if !ok { + // there's no way to compare different versions of the state, so let's + // just say that means the state of balances has changed + return true, nil + } + return !s.State.EscrowTable.Equals(otherState13.State.EscrowTable) || !s.State.LockedTable.Equals(otherState13.State.LockedTable), nil +} + +func (s *state13) StatesChanged(otherState State) (bool, error) { + otherState13, ok := otherState.(*state13) + if !ok { + // there's no way to compare different versions of the state, so let's + // just say that means the state of balances has changed + return true, nil + } + return !s.State.States.Equals(otherState13.State.States), nil +} + +func (s *state13) States() (DealStates, error) { + stateArray, err := adt13.AsArray(s.store, s.State.States, market13.StatesAmtBitwidth) + if err != nil { + return nil, err + } + return &dealStates13{stateArray}, nil +} + +func (s *state13) ProposalsChanged(otherState State) (bool, error) { + otherState13, ok := otherState.(*state13) + if !ok { + // there's no way to compare different versions of the state, so let's + // just say that means the state of balances has changed + return true, nil + } + return !s.State.Proposals.Equals(otherState13.State.Proposals), nil +} + +func (s *state13) Proposals() (DealProposals, error) { + proposalArray, err := adt13.AsArray(s.store, s.State.Proposals, market13.ProposalsAmtBitwidth) + if err != nil { + return nil, err + } + return &dealProposals13{proposalArray}, nil +} + +func (s *state13) EscrowTable() (BalanceTable, error) { + bt, err := adt13.AsBalanceTable(s.store, s.State.EscrowTable) + if err != nil { + return nil, err + } + return &balanceTable13{bt}, nil +} + +func (s *state13) LockedTable() (BalanceTable, error) { + bt, err := adt13.AsBalanceTable(s.store, s.State.LockedTable) + if err != nil { + return nil, err + } + return &balanceTable13{bt}, nil +} + +func (s *state13) VerifyDealsForActivation( + minerAddr address.Address, deals []abi.DealID, currEpoch, sectorExpiry abi.ChainEpoch, +) (weight, verifiedWeight abi.DealWeight, err error) { + w, vw, _, err := market13.ValidateDealsForActivation(&s.State, s.store, deals, minerAddr, sectorExpiry, currEpoch) + return w, vw, err +} + +func (s *state13) NextID() (abi.DealID, error) { + return s.State.NextID, nil +} + +type balanceTable13 struct { + *adt13.BalanceTable +} + +func (bt *balanceTable13) ForEach(cb func(address.Address, abi.TokenAmount) error) error { + asMap := (*adt13.Map)(bt.BalanceTable) + var ta abi.TokenAmount + return asMap.ForEach(&ta, func(key string) error { + a, err := address.NewFromBytes([]byte(key)) + if err != nil { + return err + } + return cb(a, ta) + }) +} + +type dealStates13 struct { + adt.Array +} + +func (s *dealStates13) Get(dealID abi.DealID) (*DealState, bool, error) { + var deal13 market13.DealState + found, err := s.Array.Get(uint64(dealID), &deal13) + if err != nil { + return nil, false, err + } + if !found { + return nil, false, nil + } + deal := fromV13DealState(deal13) + return &deal, true, nil +} + +func (s *dealStates13) ForEach(cb func(dealID abi.DealID, ds DealState) error) error { + var ds13 market13.DealState + return s.Array.ForEach(&ds13, func(idx int64) error { + return cb(abi.DealID(idx), fromV13DealState(ds13)) + }) +} + +func (s *dealStates13) decode(val *cbg.Deferred) (*DealState, error) { + var ds13 market13.DealState + if err := ds13.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { + return nil, err + } + ds := fromV13DealState(ds13) + return &ds, nil +} + +func (s *dealStates13) array() adt.Array { + return s.Array +} + +func fromV13DealState(v13 market13.DealState) DealState { + ret := DealState{ + SectorStartEpoch: v13.SectorStartEpoch, + LastUpdatedEpoch: v13.LastUpdatedEpoch, + SlashEpoch: v13.SlashEpoch, + VerifiedClaim: 0, + } + + ret.VerifiedClaim = verifregtypes.AllocationId(v13.VerifiedClaim) + + return ret +} + +type dealProposals13 struct { + adt.Array +} + +func (s *dealProposals13) Get(dealID abi.DealID) (*DealProposal, bool, error) { + var proposal13 market13.DealProposal + found, err := s.Array.Get(uint64(dealID), &proposal13) + if err != nil { + return nil, false, err + } + if !found { + return nil, false, nil + } + + proposal, err := fromV13DealProposal(proposal13) + if err != nil { + return nil, true, xerrors.Errorf("decoding proposal: %w", err) + } + + return &proposal, true, nil +} + +func (s *dealProposals13) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error { + var dp13 market13.DealProposal + return s.Array.ForEach(&dp13, func(idx int64) error { + dp, err := fromV13DealProposal(dp13) + if err != nil { + return xerrors.Errorf("decoding proposal: %w", err) + } + + return cb(abi.DealID(idx), dp) + }) +} + +func (s *dealProposals13) decode(val *cbg.Deferred) (*DealProposal, error) { + var dp13 market13.DealProposal + if err := dp13.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { + return nil, err + } + + dp, err := fromV13DealProposal(dp13) + if err != nil { + return nil, err + } + + return &dp, nil +} + +func (s *dealProposals13) array() adt.Array { + return s.Array +} + +func fromV13DealProposal(v13 market13.DealProposal) (DealProposal, error) { + + label, err := fromV13Label(v13.Label) + + if err != nil { + return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err) + } + + return DealProposal{ + PieceCID: v13.PieceCID, + PieceSize: v13.PieceSize, + VerifiedDeal: v13.VerifiedDeal, + Client: v13.Client, + Provider: v13.Provider, + + Label: label, + + StartEpoch: v13.StartEpoch, + EndEpoch: v13.EndEpoch, + StoragePricePerEpoch: v13.StoragePricePerEpoch, + + ProviderCollateral: v13.ProviderCollateral, + ClientCollateral: v13.ClientCollateral, + }, nil +} + +func fromV13Label(v13 market13.DealLabel) (DealLabel, error) { + if v13.IsString() { + str, err := v13.ToString() + if err != nil { + return markettypes.EmptyDealLabel, xerrors.Errorf("failed to convert string label to string: %w", err) + } + return markettypes.NewLabelFromString(str) + } + + bs, err := v13.ToBytes() + if err != nil { + return markettypes.EmptyDealLabel, xerrors.Errorf("failed to convert bytes label to bytes: %w", err) + } + return markettypes.NewLabelFromBytes(bs) +} + +func (s *state13) GetState() interface{} { + return &s.State +} + +var _ PublishStorageDealsReturn = (*publishStorageDealsReturn13)(nil) + +func decodePublishStorageDealsReturn13(b []byte) (PublishStorageDealsReturn, error) { + var retval market13.PublishStorageDealsReturn + if err := retval.UnmarshalCBOR(bytes.NewReader(b)); err != nil { + return nil, xerrors.Errorf("failed to unmarshal PublishStorageDealsReturn: %w", err) + } + + return &publishStorageDealsReturn13{retval}, nil +} + +type publishStorageDealsReturn13 struct { + market13.PublishStorageDealsReturn +} + +func (r *publishStorageDealsReturn13) IsDealValid(index uint64) (bool, int, error) { + + set, err := r.ValidDeals.IsSet(index) + if err != nil || !set { + return false, -1, err + } + maskBf, err := bitfield.NewFromIter(&rlepluslazy.RunSliceIterator{ + Runs: []rlepluslazy.Run{rlepluslazy.Run{Val: true, Len: index}}}) + if err != nil { + return false, -1, err + } + before, err := bitfield.IntersectBitField(maskBf, r.ValidDeals) + if err != nil { + return false, -1, err + } + outIdx, err := before.Count() + if err != nil { + return false, -1, err + } + return set, int(outIdx), nil + +} + +func (r *publishStorageDealsReturn13) DealIDs() ([]abi.DealID, error) { + return r.IDs, nil +} + +func (s *state13) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes.AllocationId, error) { + + allocations, err := adt13.AsMap(s.store, s.PendingDealAllocationIds, builtin.DefaultHamtBitwidth) + if err != nil { + return verifregtypes.NoAllocationID, xerrors.Errorf("failed to load allocation id for %d: %w", dealId, err) + } + + var allocationId cbg.CborInt + found, err := allocations.Get(abi.UIntKey(uint64(dealId)), &allocationId) + if err != nil { + return verifregtypes.NoAllocationID, xerrors.Errorf("failed to load allocation id for %d: %w", dealId, err) + } + if !found { + return verifregtypes.NoAllocationID, nil + } + + return verifregtypes.AllocationId(allocationId), nil + +} + +func (s *state13) ActorKey() string { + return manifest.MarketKey +} + +func (s *state13) ActorVersion() actorstypes.Version { + return actorstypes.Version13 +} + +func (s *state13) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/miner/miner.go b/chain/actors/builtin/miner/miner.go index 1637cdade..0ec287f30 100644 --- a/chain/actors/builtin/miner/miner.go +++ b/chain/actors/builtin/miner/miner.go @@ -51,6 +51,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actorstypes.Version12: return load12(store, act.Head) + case actorstypes.Version13: + return load13(store, act.Head) + } } @@ -121,6 +124,9 @@ func MakeState(store adt.Store, av actors.Version) (State, error) { case actors.Version12: return make12(store) + case actors.Version13: + return make13(store) + } return nil, xerrors.Errorf("unknown actor version %d", av) } @@ -374,5 +380,6 @@ func AllCodes() []cid.Cid { (&state10{}).Code(), (&state11{}).Code(), (&state12{}).Code(), + (&state13{}).Code(), } } diff --git a/chain/actors/builtin/miner/v13.go b/chain/actors/builtin/miner/v13.go new file mode 100644 index 000000000..bbd95f818 --- /dev/null +++ b/chain/actors/builtin/miner/v13.go @@ -0,0 +1,591 @@ +package miner + +import ( + "bytes" + "errors" + "fmt" + + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + "golang.org/x/xerrors" + + "github.com/filecoin-project/go-bitfield" + rle "github.com/filecoin-project/go-bitfield/rle" + "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" + builtin13 "github.com/filecoin-project/go-state-types/builtin" + miner13 "github.com/filecoin-project/go-state-types/builtin/v13/miner" + adt13 "github.com/filecoin-project/go-state-types/builtin/v13/util/adt" + "github.com/filecoin-project/go-state-types/dline" + "github.com/filecoin-project/go-state-types/manifest" + + "github.com/filecoin-project/lotus/chain/actors" + "github.com/filecoin-project/lotus/chain/actors/adt" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make13(store adt.Store) (State, error) { + out := state13{store: store} + out.State = miner13.State{} + return &out, nil +} + +type state13 struct { + miner13.State + store adt.Store +} + +type deadline13 struct { + miner13.Deadline + store adt.Store +} + +type partition13 struct { + miner13.Partition + store adt.Store +} + +func (s *state13) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmount, err error) { + defer func() { + if r := recover(); r != nil { + err = xerrors.Errorf("failed to get available balance: %w", r) + available = abi.NewTokenAmount(0) + } + }() + // this panics if the miner doesn't have enough funds to cover their locked pledge + available, err = s.GetAvailableBalance(bal) + return available, err +} + +func (s *state13) VestedFunds(epoch abi.ChainEpoch) (abi.TokenAmount, error) { + return s.CheckVestedFunds(s.store, epoch) +} + +func (s *state13) LockedFunds() (LockedFunds, error) { + return LockedFunds{ + VestingFunds: s.State.LockedFunds, + InitialPledgeRequirement: s.State.InitialPledge, + PreCommitDeposits: s.State.PreCommitDeposits, + }, nil +} + +func (s *state13) FeeDebt() (abi.TokenAmount, error) { + return s.State.FeeDebt, nil +} + +func (s *state13) InitialPledge() (abi.TokenAmount, error) { + return s.State.InitialPledge, nil +} + +func (s *state13) PreCommitDeposits() (abi.TokenAmount, error) { + return s.State.PreCommitDeposits, nil +} + +// Returns nil, nil if sector is not found +func (s *state13) GetSector(num abi.SectorNumber) (*SectorOnChainInfo, error) { + info, ok, err := s.State.GetSector(s.store, num) + if !ok || err != nil { + return nil, err + } + + ret := fromV13SectorOnChainInfo(*info) + return &ret, nil +} + +func (s *state13) FindSector(num abi.SectorNumber) (*SectorLocation, error) { + dlIdx, partIdx, err := s.State.FindSector(s.store, num) + if err != nil { + return nil, err + } + return &SectorLocation{ + Deadline: dlIdx, + Partition: partIdx, + }, nil +} + +func (s *state13) NumLiveSectors() (uint64, error) { + dls, err := s.State.LoadDeadlines(s.store) + if err != nil { + return 0, err + } + var total uint64 + if err := dls.ForEach(s.store, func(dlIdx uint64, dl *miner13.Deadline) error { + total += dl.LiveSectors + return nil + }); err != nil { + return 0, err + } + return total, nil +} + +// GetSectorExpiration returns the effective expiration of the given sector. +// +// If the sector does not expire early, the Early expiration field is 0. +func (s *state13) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, error) { + dls, err := s.State.LoadDeadlines(s.store) + if err != nil { + return nil, err + } + // NOTE: this can be optimized significantly. + // 1. If the sector is non-faulty, it will expire on-time (can be + // learned from the sector info). + // 2. If it's faulty, it will expire early within the first 42 entries + // of the expiration queue. + + stopErr := errors.New("stop") + out := SectorExpiration{} + err = dls.ForEach(s.store, func(dlIdx uint64, dl *miner13.Deadline) error { + partitions, err := dl.PartitionsArray(s.store) + if err != nil { + return err + } + quant := s.State.QuantSpecForDeadline(dlIdx) + var part miner13.Partition + return partitions.ForEach(&part, func(partIdx int64) error { + if found, err := part.Sectors.IsSet(uint64(num)); err != nil { + return err + } else if !found { + return nil + } + if found, err := part.Terminated.IsSet(uint64(num)); err != nil { + return err + } else if found { + // already terminated + return stopErr + } + + q, err := miner13.LoadExpirationQueue(s.store, part.ExpirationsEpochs, quant, miner13.PartitionExpirationAmtBitwidth) + if err != nil { + return err + } + var exp miner13.ExpirationSet + return q.ForEach(&exp, func(epoch int64) error { + if early, err := exp.EarlySectors.IsSet(uint64(num)); err != nil { + return err + } else if early { + out.Early = abi.ChainEpoch(epoch) + return nil + } + if onTime, err := exp.OnTimeSectors.IsSet(uint64(num)); err != nil { + return err + } else if onTime { + out.OnTime = abi.ChainEpoch(epoch) + return stopErr + } + return nil + }) + }) + }) + if err == stopErr { + err = nil + } + if err != nil { + return nil, err + } + if out.Early == 0 && out.OnTime == 0 { + return nil, xerrors.Errorf("failed to find sector %d", num) + } + return &out, nil +} + +func (s *state13) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) { + info, ok, err := s.State.GetPrecommittedSector(s.store, num) + if !ok || err != nil { + return nil, err + } + + ret := fromV13SectorPreCommitOnChainInfo(*info) + + return &ret, nil +} + +func (s *state13) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error { + precommitted, err := adt13.AsMap(s.store, s.State.PreCommittedSectors, builtin13.DefaultHamtBitwidth) + if err != nil { + return err + } + + var info miner13.SectorPreCommitOnChainInfo + if err := precommitted.ForEach(&info, func(_ string) error { + return cb(fromV13SectorPreCommitOnChainInfo(info)) + }); err != nil { + return err + } + + return nil +} + +func (s *state13) LoadSectors(snos *bitfield.BitField) ([]*SectorOnChainInfo, error) { + sectors, err := miner13.LoadSectors(s.store, s.State.Sectors) + if err != nil { + return nil, err + } + + // If no sector numbers are specified, load all. + if snos == nil { + infos := make([]*SectorOnChainInfo, 0, sectors.Length()) + var info13 miner13.SectorOnChainInfo + if err := sectors.ForEach(&info13, func(_ int64) error { + info := fromV13SectorOnChainInfo(info13) + infos = append(infos, &info) + return nil + }); err != nil { + return nil, err + } + return infos, nil + } + + // Otherwise, load selected. + infos13, err := sectors.Load(*snos) + if err != nil { + return nil, err + } + infos := make([]*SectorOnChainInfo, len(infos13)) + for i, info13 := range infos13 { + info := fromV13SectorOnChainInfo(*info13) + infos[i] = &info + } + return infos, nil +} + +func (s *state13) loadAllocatedSectorNumbers() (bitfield.BitField, error) { + var allocatedSectors bitfield.BitField + err := s.store.Get(s.store.Context(), s.State.AllocatedSectors, &allocatedSectors) + return allocatedSectors, err +} + +func (s *state13) IsAllocated(num abi.SectorNumber) (bool, error) { + allocatedSectors, err := s.loadAllocatedSectorNumbers() + if err != nil { + return false, err + } + + return allocatedSectors.IsSet(uint64(num)) +} + +func (s *state13) GetProvingPeriodStart() (abi.ChainEpoch, error) { + return s.State.ProvingPeriodStart, nil +} + +func (s *state13) UnallocatedSectorNumbers(count int) ([]abi.SectorNumber, error) { + allocatedSectors, err := s.loadAllocatedSectorNumbers() + if err != nil { + return nil, err + } + + allocatedRuns, err := allocatedSectors.RunIterator() + if err != nil { + return nil, err + } + + unallocatedRuns, err := rle.Subtract( + &rle.RunSliceIterator{Runs: []rle.Run{{Val: true, Len: abi.MaxSectorNumber}}}, + allocatedRuns, + ) + if err != nil { + return nil, err + } + + iter, err := rle.BitsFromRuns(unallocatedRuns) + if err != nil { + return nil, err + } + + sectors := make([]abi.SectorNumber, 0, count) + for iter.HasNext() && len(sectors) < count { + nextNo, err := iter.Next() + if err != nil { + return nil, err + } + sectors = append(sectors, abi.SectorNumber(nextNo)) + } + + return sectors, nil +} + +func (s *state13) GetAllocatedSectors() (*bitfield.BitField, error) { + var allocatedSectors bitfield.BitField + if err := s.store.Get(s.store.Context(), s.State.AllocatedSectors, &allocatedSectors); err != nil { + return nil, err + } + + return &allocatedSectors, nil +} + +func (s *state13) LoadDeadline(idx uint64) (Deadline, error) { + dls, err := s.State.LoadDeadlines(s.store) + if err != nil { + return nil, err + } + dl, err := dls.LoadDeadline(s.store, idx) + if err != nil { + return nil, err + } + return &deadline13{*dl, s.store}, nil +} + +func (s *state13) ForEachDeadline(cb func(uint64, Deadline) error) error { + dls, err := s.State.LoadDeadlines(s.store) + if err != nil { + return err + } + return dls.ForEach(s.store, func(i uint64, dl *miner13.Deadline) error { + return cb(i, &deadline13{*dl, s.store}) + }) +} + +func (s *state13) NumDeadlines() (uint64, error) { + return miner13.WPoStPeriodDeadlines, nil +} + +func (s *state13) DeadlinesChanged(other State) (bool, error) { + other13, ok := other.(*state13) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + + return !s.State.Deadlines.Equals(other13.Deadlines), nil +} + +func (s *state13) MinerInfoChanged(other State) (bool, error) { + other0, ok := other.(*state13) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + return !s.State.Info.Equals(other0.State.Info), nil +} + +func (s *state13) Info() (MinerInfo, error) { + info, err := s.State.GetInfo(s.store) + if err != nil { + return MinerInfo{}, err + } + + mi := MinerInfo{ + Owner: info.Owner, + Worker: info.Worker, + ControlAddresses: info.ControlAddresses, + + PendingWorkerKey: (*WorkerKeyChange)(info.PendingWorkerKey), + + PeerId: info.PeerId, + Multiaddrs: info.Multiaddrs, + WindowPoStProofType: info.WindowPoStProofType, + SectorSize: info.SectorSize, + WindowPoStPartitionSectors: info.WindowPoStPartitionSectors, + ConsensusFaultElapsed: info.ConsensusFaultElapsed, + + Beneficiary: info.Beneficiary, + BeneficiaryTerm: BeneficiaryTerm(info.BeneficiaryTerm), + PendingBeneficiaryTerm: (*PendingBeneficiaryChange)(info.PendingBeneficiaryTerm), + } + + return mi, nil +} + +func (s *state13) DeadlineInfo(epoch abi.ChainEpoch) (*dline.Info, error) { + return s.State.RecordedDeadlineInfo(epoch), nil +} + +func (s *state13) DeadlineCronActive() (bool, error) { + return s.State.DeadlineCronActive, nil +} + +func (s *state13) sectors() (adt.Array, error) { + return adt13.AsArray(s.store, s.Sectors, miner13.SectorsAmtBitwidth) +} + +func (s *state13) decodeSectorOnChainInfo(val *cbg.Deferred) (SectorOnChainInfo, error) { + var si miner13.SectorOnChainInfo + err := si.UnmarshalCBOR(bytes.NewReader(val.Raw)) + if err != nil { + return SectorOnChainInfo{}, err + } + + return fromV13SectorOnChainInfo(si), nil +} + +func (s *state13) precommits() (adt.Map, error) { + return adt13.AsMap(s.store, s.PreCommittedSectors, builtin13.DefaultHamtBitwidth) +} + +func (s *state13) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) { + var sp miner13.SectorPreCommitOnChainInfo + err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw)) + if err != nil { + return SectorPreCommitOnChainInfo{}, err + } + + return fromV13SectorPreCommitOnChainInfo(sp), nil +} + +func (s *state13) EraseAllUnproven() error { + + dls, err := s.State.LoadDeadlines(s.store) + if err != nil { + return err + } + + err = dls.ForEach(s.store, func(dindx uint64, dl *miner13.Deadline) error { + ps, err := dl.PartitionsArray(s.store) + if err != nil { + return err + } + + var part miner13.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) + }) + if err != nil { + return err + } + + return s.State.SaveDeadlines(s.store, dls) + +} + +func (d *deadline13) LoadPartition(idx uint64) (Partition, error) { + p, err := d.Deadline.LoadPartition(d.store, idx) + if err != nil { + return nil, err + } + return &partition13{*p, d.store}, nil +} + +func (d *deadline13) ForEachPartition(cb func(uint64, Partition) error) error { + ps, err := d.Deadline.PartitionsArray(d.store) + if err != nil { + return err + } + var part miner13.Partition + return ps.ForEach(&part, func(i int64) error { + return cb(uint64(i), &partition13{part, d.store}) + }) +} + +func (d *deadline13) PartitionsChanged(other Deadline) (bool, error) { + other13, ok := other.(*deadline13) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + + return !d.Deadline.Partitions.Equals(other13.Deadline.Partitions), nil +} + +func (d *deadline13) PartitionsPoSted() (bitfield.BitField, error) { + return d.Deadline.PartitionsPoSted, nil +} + +func (d *deadline13) DisputableProofCount() (uint64, error) { + + ops, err := d.OptimisticProofsSnapshotArray(d.store) + if err != nil { + return 0, err + } + + return ops.Length(), nil + +} + +func (p *partition13) AllSectors() (bitfield.BitField, error) { + return p.Partition.Sectors, nil +} + +func (p *partition13) FaultySectors() (bitfield.BitField, error) { + return p.Partition.Faults, nil +} + +func (p *partition13) RecoveringSectors() (bitfield.BitField, error) { + return p.Partition.Recoveries, nil +} + +func (p *partition13) UnprovenSectors() (bitfield.BitField, error) { + return p.Partition.Unproven, nil +} + +func fromV13SectorOnChainInfo(v13 miner13.SectorOnChainInfo) SectorOnChainInfo { + info := SectorOnChainInfo{ + SectorNumber: v13.SectorNumber, + SealProof: v13.SealProof, + SealedCID: v13.SealedCID, + DealIDs: v13.DealIDs, + Activation: v13.Activation, + Expiration: v13.Expiration, + DealWeight: v13.DealWeight, + VerifiedDealWeight: v13.VerifiedDealWeight, + InitialPledge: v13.InitialPledge, + ExpectedDayReward: v13.ExpectedDayReward, + ExpectedStoragePledge: v13.ExpectedStoragePledge, + + SectorKeyCID: v13.SectorKeyCID, + } + return info +} + +func fromV13SectorPreCommitOnChainInfo(v13 miner13.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo { + ret := SectorPreCommitOnChainInfo{ + Info: SectorPreCommitInfo{ + SealProof: v13.Info.SealProof, + SectorNumber: v13.Info.SectorNumber, + SealedCID: v13.Info.SealedCID, + SealRandEpoch: v13.Info.SealRandEpoch, + DealIDs: v13.Info.DealIDs, + Expiration: v13.Info.Expiration, + UnsealedCid: nil, + }, + PreCommitDeposit: v13.PreCommitDeposit, + PreCommitEpoch: v13.PreCommitEpoch, + } + + ret.Info.UnsealedCid = v13.Info.UnsealedCid + + return ret +} + +func (s *state13) GetState() interface{} { + return &s.State +} + +func (s *state13) ActorKey() string { + return manifest.MinerKey +} + +func (s *state13) ActorVersion() actorstypes.Version { + return actorstypes.Version13 +} + +func (s *state13) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/multisig/message10.go b/chain/actors/builtin/multisig/message10.go index 8f7bb5a6f..59dd4dde0 100644 --- a/chain/actors/builtin/multisig/message10.go +++ b/chain/actors/builtin/multisig/message10.go @@ -8,7 +8,7 @@ import ( actorstypes "github.com/filecoin-project/go-state-types/actors" builtintypes "github.com/filecoin-project/go-state-types/builtin" multisig10 "github.com/filecoin-project/go-state-types/builtin/v10/multisig" - init12 "github.com/filecoin-project/go-state-types/builtin/v12/init" + init13 "github.com/filecoin-project/go-state-types/builtin/v13/init" "github.com/filecoin-project/go-state-types/manifest" "github.com/filecoin-project/lotus/chain/actors" @@ -57,7 +57,7 @@ func (m message10) Create( } // new actors are created by invoking 'exec' on the init actor with the constructor params - execParams := &init12.ExecParams{ + execParams := &init13.ExecParams{ CodeCID: code, ConstructorParams: enc, } diff --git a/chain/actors/builtin/multisig/message11.go b/chain/actors/builtin/multisig/message11.go index 4c7520d5d..89bee0255 100644 --- a/chain/actors/builtin/multisig/message11.go +++ b/chain/actors/builtin/multisig/message11.go @@ -8,7 +8,7 @@ import ( actorstypes "github.com/filecoin-project/go-state-types/actors" builtintypes "github.com/filecoin-project/go-state-types/builtin" multisig11 "github.com/filecoin-project/go-state-types/builtin/v11/multisig" - init12 "github.com/filecoin-project/go-state-types/builtin/v12/init" + init13 "github.com/filecoin-project/go-state-types/builtin/v13/init" "github.com/filecoin-project/go-state-types/manifest" "github.com/filecoin-project/lotus/chain/actors" @@ -57,7 +57,7 @@ func (m message11) Create( } // new actors are created by invoking 'exec' on the init actor with the constructor params - execParams := &init12.ExecParams{ + execParams := &init13.ExecParams{ CodeCID: code, ConstructorParams: enc, } diff --git a/chain/actors/builtin/multisig/message12.go b/chain/actors/builtin/multisig/message12.go index 43658c04b..326026c93 100644 --- a/chain/actors/builtin/multisig/message12.go +++ b/chain/actors/builtin/multisig/message12.go @@ -7,8 +7,8 @@ import ( "github.com/filecoin-project/go-state-types/abi" actorstypes "github.com/filecoin-project/go-state-types/actors" builtintypes "github.com/filecoin-project/go-state-types/builtin" - init12 "github.com/filecoin-project/go-state-types/builtin/v12/init" multisig12 "github.com/filecoin-project/go-state-types/builtin/v12/multisig" + init13 "github.com/filecoin-project/go-state-types/builtin/v13/init" "github.com/filecoin-project/go-state-types/manifest" "github.com/filecoin-project/lotus/chain/actors" @@ -57,7 +57,7 @@ func (m message12) Create( } // new actors are created by invoking 'exec' on the init actor with the constructor params - execParams := &init12.ExecParams{ + execParams := &init13.ExecParams{ CodeCID: code, ConstructorParams: enc, } diff --git a/chain/actors/builtin/multisig/message13.go b/chain/actors/builtin/multisig/message13.go new file mode 100644 index 000000000..94a9cbfbf --- /dev/null +++ b/chain/actors/builtin/multisig/message13.go @@ -0,0 +1,77 @@ +package multisig + +import ( + "golang.org/x/xerrors" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" + builtintypes "github.com/filecoin-project/go-state-types/builtin" + init13 "github.com/filecoin-project/go-state-types/builtin/v13/init" + multisig13 "github.com/filecoin-project/go-state-types/builtin/v13/multisig" + "github.com/filecoin-project/go-state-types/manifest" + + "github.com/filecoin-project/lotus/chain/actors" + init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init" + "github.com/filecoin-project/lotus/chain/types" +) + +type message13 struct{ message0 } + +func (m message13) Create( + signers []address.Address, threshold uint64, + unlockStart, unlockDuration abi.ChainEpoch, + initialAmount abi.TokenAmount, +) (*types.Message, error) { + + lenAddrs := uint64(len(signers)) + + if lenAddrs < threshold { + return nil, xerrors.Errorf("cannot require signing of more addresses than provided for multisig") + } + + if threshold == 0 { + threshold = lenAddrs + } + + if m.from == address.Undef { + return nil, xerrors.Errorf("must provide source address") + } + + // Set up constructor parameters for multisig + msigParams := &multisig13.ConstructorParams{ + Signers: signers, + NumApprovalsThreshold: threshold, + UnlockDuration: unlockDuration, + StartEpoch: unlockStart, + } + + enc, actErr := actors.SerializeParams(msigParams) + if actErr != nil { + return nil, actErr + } + + code, ok := actors.GetActorCodeID(actorstypes.Version13, manifest.MultisigKey) + if !ok { + return nil, xerrors.Errorf("failed to get multisig code ID") + } + + // new actors are created by invoking 'exec' on the init actor with the constructor params + execParams := &init13.ExecParams{ + CodeCID: code, + ConstructorParams: enc, + } + + enc, actErr = actors.SerializeParams(execParams) + if actErr != nil { + return nil, actErr + } + + return &types.Message{ + To: init_.Address, + From: m.from, + Method: builtintypes.MethodsInit.Exec, + Params: enc, + Value: initialAmount, + }, nil +} diff --git a/chain/actors/builtin/multisig/message8.go b/chain/actors/builtin/multisig/message8.go index 390c94691..5d79fe6c5 100644 --- a/chain/actors/builtin/multisig/message8.go +++ b/chain/actors/builtin/multisig/message8.go @@ -7,7 +7,7 @@ import ( "github.com/filecoin-project/go-state-types/abi" actorstypes "github.com/filecoin-project/go-state-types/actors" builtintypes "github.com/filecoin-project/go-state-types/builtin" - init12 "github.com/filecoin-project/go-state-types/builtin/v12/init" + init13 "github.com/filecoin-project/go-state-types/builtin/v13/init" multisig8 "github.com/filecoin-project/go-state-types/builtin/v8/multisig" "github.com/filecoin-project/go-state-types/manifest" @@ -57,7 +57,7 @@ func (m message8) Create( } // new actors are created by invoking 'exec' on the init actor with the constructor params - execParams := &init12.ExecParams{ + execParams := &init13.ExecParams{ CodeCID: code, ConstructorParams: enc, } diff --git a/chain/actors/builtin/multisig/message9.go b/chain/actors/builtin/multisig/message9.go index 907bec7d5..9003b7e38 100644 --- a/chain/actors/builtin/multisig/message9.go +++ b/chain/actors/builtin/multisig/message9.go @@ -7,7 +7,7 @@ import ( "github.com/filecoin-project/go-state-types/abi" actorstypes "github.com/filecoin-project/go-state-types/actors" builtintypes "github.com/filecoin-project/go-state-types/builtin" - init12 "github.com/filecoin-project/go-state-types/builtin/v12/init" + init13 "github.com/filecoin-project/go-state-types/builtin/v13/init" multisig9 "github.com/filecoin-project/go-state-types/builtin/v9/multisig" "github.com/filecoin-project/go-state-types/manifest" @@ -57,7 +57,7 @@ func (m message9) Create( } // new actors are created by invoking 'exec' on the init actor with the constructor params - execParams := &init12.ExecParams{ + execParams := &init13.ExecParams{ CodeCID: code, ConstructorParams: enc, } diff --git a/chain/actors/builtin/multisig/multisig.go b/chain/actors/builtin/multisig/multisig.go index 71a3b7b22..08da9bd2d 100644 --- a/chain/actors/builtin/multisig/multisig.go +++ b/chain/actors/builtin/multisig/multisig.go @@ -12,7 +12,7 @@ import ( "github.com/filecoin-project/go-state-types/abi" actorstypes "github.com/filecoin-project/go-state-types/actors" builtintypes "github.com/filecoin-project/go-state-types/builtin" - msig12 "github.com/filecoin-project/go-state-types/builtin/v12/multisig" + msig13 "github.com/filecoin-project/go-state-types/builtin/v13/multisig" "github.com/filecoin-project/go-state-types/cbor" "github.com/filecoin-project/go-state-types/manifest" builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" @@ -51,6 +51,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actorstypes.Version12: return load12(store, act.Head) + case actorstypes.Version13: + return load13(store, act.Head) + } } @@ -121,6 +124,9 @@ func MakeState(store adt.Store, av actorstypes.Version, signers []address.Addres case actorstypes.Version12: return make12(store, signers, threshold, startEpoch, unlockDuration, initialBalance) + case actorstypes.Version13: + return make13(store, signers, threshold, startEpoch, unlockDuration, initialBalance) + } return nil, xerrors.Errorf("unknown actor version %d", av) } @@ -147,7 +153,7 @@ type State interface { GetState() interface{} } -type Transaction = msig12.Transaction +type Transaction = msig13.Transaction var Methods = builtintypes.MethodsMultisig @@ -189,6 +195,9 @@ func Message(version actorstypes.Version, from address.Address) MessageBuilder { case actorstypes.Version12: return message12{message0{from}} + + case actorstypes.Version13: + return message13{message0{from}} default: panic(fmt.Sprintf("unsupported actors version: %d", version)) } @@ -212,13 +221,13 @@ type MessageBuilder interface { } // this type is the same between v0 and v2 -type ProposalHashData = msig12.ProposalHashData -type ProposeReturn = msig12.ProposeReturn -type ProposeParams = msig12.ProposeParams -type ApproveReturn = msig12.ApproveReturn +type ProposalHashData = msig13.ProposalHashData +type ProposeReturn = msig13.ProposeReturn +type ProposeParams = msig13.ProposeParams +type ApproveReturn = msig13.ApproveReturn func txnParams(id uint64, data *ProposalHashData) ([]byte, error) { - params := msig12.TxnIDParams{ID: msig12.TxnID(id)} + params := msig13.TxnIDParams{ID: msig13.TxnID(id)} if data != nil { if data.Requester.Protocol() != address.ID { return nil, xerrors.Errorf("proposer address must be an ID address, was %s", data.Requester) @@ -254,5 +263,6 @@ func AllCodes() []cid.Cid { (&state10{}).Code(), (&state11{}).Code(), (&state12{}).Code(), + (&state13{}).Code(), } } diff --git a/chain/actors/builtin/multisig/v13.go b/chain/actors/builtin/multisig/v13.go new file mode 100644 index 000000000..57dd66976 --- /dev/null +++ b/chain/actors/builtin/multisig/v13.go @@ -0,0 +1,138 @@ +package multisig + +import ( + "bytes" + "encoding/binary" + "fmt" + + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + "golang.org/x/xerrors" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" + builtin13 "github.com/filecoin-project/go-state-types/builtin" + msig13 "github.com/filecoin-project/go-state-types/builtin/v13/multisig" + adt13 "github.com/filecoin-project/go-state-types/builtin/v13/util/adt" + "github.com/filecoin-project/go-state-types/manifest" + + "github.com/filecoin-project/lotus/chain/actors" + "github.com/filecoin-project/lotus/chain/actors/adt" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make13(store adt.Store, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) { + out := state13{store: store} + out.State = msig13.State{} + out.State.Signers = signers + out.State.NumApprovalsThreshold = threshold + out.State.StartEpoch = startEpoch + out.State.UnlockDuration = unlockDuration + out.State.InitialBalance = initialBalance + + em, err := adt13.StoreEmptyMap(store, builtin13.DefaultHamtBitwidth) + if err != nil { + return nil, err + } + + out.State.PendingTxns = em + + return &out, nil +} + +type state13 struct { + msig13.State + store adt.Store +} + +func (s *state13) LockedBalance(currEpoch abi.ChainEpoch) (abi.TokenAmount, error) { + return s.State.AmountLocked(currEpoch - s.State.StartEpoch), nil +} + +func (s *state13) StartEpoch() (abi.ChainEpoch, error) { + return s.State.StartEpoch, nil +} + +func (s *state13) UnlockDuration() (abi.ChainEpoch, error) { + return s.State.UnlockDuration, nil +} + +func (s *state13) InitialBalance() (abi.TokenAmount, error) { + return s.State.InitialBalance, nil +} + +func (s *state13) Threshold() (uint64, error) { + return s.State.NumApprovalsThreshold, nil +} + +func (s *state13) Signers() ([]address.Address, error) { + return s.State.Signers, nil +} + +func (s *state13) ForEachPendingTxn(cb func(id int64, txn Transaction) error) error { + arr, err := adt13.AsMap(s.store, s.State.PendingTxns, builtin13.DefaultHamtBitwidth) + if err != nil { + return err + } + var out msig13.Transaction + return arr.ForEach(&out, func(key string) error { + txid, n := binary.Varint([]byte(key)) + if n <= 0 { + return xerrors.Errorf("invalid pending transaction key: %v", key) + } + return cb(txid, (Transaction)(out)) //nolint:unconvert + }) +} + +func (s *state13) PendingTxnChanged(other State) (bool, error) { + other13, ok := other.(*state13) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + return !s.State.PendingTxns.Equals(other13.PendingTxns), nil +} + +func (s *state13) transactions() (adt.Map, error) { + return adt13.AsMap(s.store, s.PendingTxns, builtin13.DefaultHamtBitwidth) +} + +func (s *state13) decodeTransaction(val *cbg.Deferred) (Transaction, error) { + var tx msig13.Transaction + if err := tx.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { + return Transaction{}, err + } + return Transaction(tx), nil +} + +func (s *state13) GetState() interface{} { + return &s.State +} + +func (s *state13) ActorKey() string { + return manifest.MultisigKey +} + +func (s *state13) ActorVersion() actorstypes.Version { + return actorstypes.Version13 +} + +func (s *state13) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/paych/message13.go b/chain/actors/builtin/paych/message13.go new file mode 100644 index 000000000..1614ec608 --- /dev/null +++ b/chain/actors/builtin/paych/message13.go @@ -0,0 +1,109 @@ +package paych + +import ( + "golang.org/x/xerrors" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" + builtin13 "github.com/filecoin-project/go-state-types/builtin" + init13 "github.com/filecoin-project/go-state-types/builtin/v13/init" + paych13 "github.com/filecoin-project/go-state-types/builtin/v13/paych" + paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych" + + "github.com/filecoin-project/lotus/chain/actors" + init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init" + "github.com/filecoin-project/lotus/chain/types" +) + +type message13 struct{ from address.Address } + +func (m message13) Create(to address.Address, initialAmount abi.TokenAmount) (*types.Message, error) { + + actorCodeID, ok := actors.GetActorCodeID(actorstypes.Version13, "paymentchannel") + if !ok { + return nil, xerrors.Errorf("error getting actor paymentchannel code id for actor version %d", 13) + } + + params, aerr := actors.SerializeParams(&paych13.ConstructorParams{From: m.from, To: to}) + if aerr != nil { + return nil, aerr + } + enc, aerr := actors.SerializeParams(&init13.ExecParams{ + CodeCID: actorCodeID, + ConstructorParams: params, + }) + if aerr != nil { + return nil, aerr + } + + return &types.Message{ + To: init_.Address, + From: m.from, + Value: initialAmount, + Method: builtin13.MethodsInit.Exec, + Params: enc, + }, nil +} + +func (m message13) Update(paych address.Address, sv *paychtypes.SignedVoucher, secret []byte) (*types.Message, error) { + params, aerr := actors.SerializeParams(&paych13.UpdateChannelStateParams{ + + Sv: toV13SignedVoucher(*sv), + + Secret: secret, + }) + if aerr != nil { + return nil, aerr + } + + return &types.Message{ + To: paych, + From: m.from, + Value: abi.NewTokenAmount(0), + Method: builtin13.MethodsPaych.UpdateChannelState, + Params: params, + }, nil +} + +func toV13SignedVoucher(sv paychtypes.SignedVoucher) paych13.SignedVoucher { + merges := make([]paych13.Merge, len(sv.Merges)) + for i := range sv.Merges { + merges[i] = paych13.Merge{ + Lane: sv.Merges[i].Lane, + Nonce: sv.Merges[i].Nonce, + } + } + + return paych13.SignedVoucher{ + ChannelAddr: sv.ChannelAddr, + TimeLockMin: sv.TimeLockMin, + TimeLockMax: sv.TimeLockMax, + SecretHash: sv.SecretHash, + Extra: (*paych13.ModVerifyParams)(sv.Extra), + Lane: sv.Lane, + Nonce: sv.Nonce, + Amount: sv.Amount, + MinSettleHeight: sv.MinSettleHeight, + Merges: merges, + Signature: sv.Signature, + } +} + +func (m message13) Settle(paych address.Address) (*types.Message, error) { + return &types.Message{ + To: paych, + From: m.from, + Value: abi.NewTokenAmount(0), + Method: builtin13.MethodsPaych.Settle, + }, nil +} + +func (m message13) Collect(paych address.Address) (*types.Message, error) { + return &types.Message{ + To: paych, + From: m.from, + Value: abi.NewTokenAmount(0), + Method: builtin13.MethodsPaych.Collect, + }, nil +} diff --git a/chain/actors/builtin/paych/paych.go b/chain/actors/builtin/paych/paych.go index fc8908cb4..2b5c78edf 100644 --- a/chain/actors/builtin/paych/paych.go +++ b/chain/actors/builtin/paych/paych.go @@ -53,6 +53,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actorstypes.Version12: return load12(store, act.Head) + case actorstypes.Version13: + return load13(store, act.Head) + } } @@ -173,6 +176,9 @@ func Message(version actorstypes.Version, from address.Address) MessageBuilder { case actorstypes.Version12: return message12{from} + case actorstypes.Version13: + return message13{from} + default: panic(fmt.Sprintf("unsupported actors version: %d", version)) } @@ -215,5 +221,6 @@ func AllCodes() []cid.Cid { (&state10{}).Code(), (&state11{}).Code(), (&state12{}).Code(), + (&state13{}).Code(), } } diff --git a/chain/actors/builtin/paych/v13.go b/chain/actors/builtin/paych/v13.go new file mode 100644 index 000000000..c5a10c571 --- /dev/null +++ b/chain/actors/builtin/paych/v13.go @@ -0,0 +1,135 @@ +package paych + +import ( + "fmt" + + "github.com/ipfs/go-cid" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/filecoin-project/go-state-types/big" + paych13 "github.com/filecoin-project/go-state-types/builtin/v13/paych" + adt13 "github.com/filecoin-project/go-state-types/builtin/v13/util/adt" + "github.com/filecoin-project/go-state-types/manifest" + + "github.com/filecoin-project/lotus/chain/actors" + "github.com/filecoin-project/lotus/chain/actors/adt" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make13(store adt.Store) (State, error) { + out := state13{store: store} + out.State = paych13.State{} + return &out, nil +} + +type state13 struct { + paych13.State + store adt.Store + lsAmt *adt13.Array +} + +// Channel owner, who has funded the actor +func (s *state13) From() (address.Address, error) { + return s.State.From, nil +} + +// Recipient of payouts from channel +func (s *state13) To() (address.Address, error) { + return s.State.To, nil +} + +// Height at which the channel can be `Collected` +func (s *state13) SettlingAt() (abi.ChainEpoch, error) { + return s.State.SettlingAt, nil +} + +// Amount successfully redeemed through the payment channel, paid out on `Collect()` +func (s *state13) ToSend() (abi.TokenAmount, error) { + return s.State.ToSend, nil +} + +func (s *state13) getOrLoadLsAmt() (*adt13.Array, error) { + if s.lsAmt != nil { + return s.lsAmt, nil + } + + // Get the lane state from the chain + lsamt, err := adt13.AsArray(s.store, s.State.LaneStates, paych13.LaneStatesAmtBitwidth) + if err != nil { + return nil, err + } + + s.lsAmt = lsamt + return lsamt, nil +} + +// Get total number of lanes +func (s *state13) LaneCount() (uint64, error) { + lsamt, err := s.getOrLoadLsAmt() + if err != nil { + return 0, err + } + return lsamt.Length(), nil +} + +func (s *state13) GetState() interface{} { + return &s.State +} + +// Iterate lane states +func (s *state13) ForEachLaneState(cb func(idx uint64, dl LaneState) error) error { + // Get the lane state from the chain + lsamt, err := s.getOrLoadLsAmt() + if err != nil { + return err + } + + // Note: we use a map instead of an array to store laneStates because the + // client sets the lane ID (the index) and potentially they could use a + // very large index. + var ls paych13.LaneState + return lsamt.ForEach(&ls, func(i int64) error { + return cb(uint64(i), &laneState13{ls}) + }) +} + +type laneState13 struct { + paych13.LaneState +} + +func (ls *laneState13) Redeemed() (big.Int, error) { + return ls.LaneState.Redeemed, nil +} + +func (ls *laneState13) Nonce() (uint64, error) { + return ls.LaneState.Nonce, nil +} + +func (s *state13) ActorKey() string { + return manifest.PaychKey +} + +func (s *state13) ActorVersion() actorstypes.Version { + return actorstypes.Version13 +} + +func (s *state13) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/power/power.go b/chain/actors/builtin/power/power.go index 9b64ded38..e263e3f87 100644 --- a/chain/actors/builtin/power/power.go +++ b/chain/actors/builtin/power/power.go @@ -9,7 +9,7 @@ import ( "github.com/filecoin-project/go-state-types/abi" actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" - builtin12 "github.com/filecoin-project/go-state-types/builtin" + builtin13 "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/go-state-types/cbor" "github.com/filecoin-project/go-state-types/manifest" builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" @@ -27,8 +27,8 @@ import ( ) var ( - Address = builtin12.StoragePowerActorAddr - Methods = builtin12.MethodsPower + Address = builtin13.StoragePowerActorAddr + Methods = builtin13.MethodsPower ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -54,6 +54,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actorstypes.Version12: return load12(store, act.Head) + case actorstypes.Version13: + return load13(store, act.Head) + } } @@ -124,6 +127,9 @@ func MakeState(store adt.Store, av actorstypes.Version) (State, error) { case actorstypes.Version12: return make12(store) + case actorstypes.Version13: + return make13(store) + } return nil, xerrors.Errorf("unknown actor version %d", av) } @@ -190,5 +196,6 @@ func AllCodes() []cid.Cid { (&state10{}).Code(), (&state11{}).Code(), (&state12{}).Code(), + (&state13{}).Code(), } } diff --git a/chain/actors/builtin/power/v13.go b/chain/actors/builtin/power/v13.go new file mode 100644 index 000000000..4cf761b16 --- /dev/null +++ b/chain/actors/builtin/power/v13.go @@ -0,0 +1,207 @@ +package power + +import ( + "bytes" + "fmt" + + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" + builtin13 "github.com/filecoin-project/go-state-types/builtin" + power13 "github.com/filecoin-project/go-state-types/builtin/v13/power" + adt13 "github.com/filecoin-project/go-state-types/builtin/v13/util/adt" + "github.com/filecoin-project/go-state-types/manifest" + + "github.com/filecoin-project/lotus/chain/actors" + "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/chain/actors/builtin" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make13(store adt.Store) (State, error) { + out := state13{store: store} + + s, err := power13.ConstructState(store) + if err != nil { + return nil, err + } + + out.State = *s + + return &out, nil +} + +type state13 struct { + power13.State + store adt.Store +} + +func (s *state13) TotalLocked() (abi.TokenAmount, error) { + return s.TotalPledgeCollateral, nil +} + +func (s *state13) TotalPower() (Claim, error) { + return Claim{ + RawBytePower: s.TotalRawBytePower, + QualityAdjPower: s.TotalQualityAdjPower, + }, nil +} + +// Committed power to the network. Includes miners below the minimum threshold. +func (s *state13) TotalCommitted() (Claim, error) { + return Claim{ + RawBytePower: s.TotalBytesCommitted, + QualityAdjPower: s.TotalQABytesCommitted, + }, nil +} + +func (s *state13) MinerPower(addr address.Address) (Claim, bool, error) { + claims, err := s.claims() + if err != nil { + return Claim{}, false, err + } + var claim power13.Claim + ok, err := claims.Get(abi.AddrKey(addr), &claim) + if err != nil { + return Claim{}, false, err + } + return Claim{ + RawBytePower: claim.RawBytePower, + QualityAdjPower: claim.QualityAdjPower, + }, ok, nil +} + +func (s *state13) MinerNominalPowerMeetsConsensusMinimum(a address.Address) (bool, error) { + return s.State.MinerNominalPowerMeetsConsensusMinimum(s.store, a) +} + +func (s *state13) TotalPowerSmoothed() (builtin.FilterEstimate, error) { + return builtin.FilterEstimate(s.State.ThisEpochQAPowerSmoothed), nil +} + +func (s *state13) MinerCounts() (uint64, uint64, error) { + return uint64(s.State.MinerAboveMinPowerCount), uint64(s.State.MinerCount), nil +} + +func (s *state13) ListAllMiners() ([]address.Address, error) { + claims, err := s.claims() + if err != nil { + return nil, err + } + + var miners []address.Address + err = claims.ForEach(nil, func(k string) error { + a, err := address.NewFromBytes([]byte(k)) + if err != nil { + return err + } + miners = append(miners, a) + return nil + }) + if err != nil { + return nil, err + } + + return miners, nil +} + +func (s *state13) ForEachClaim(cb func(miner address.Address, claim Claim) error) error { + claims, err := s.claims() + if err != nil { + return err + } + + var claim power13.Claim + return claims.ForEach(&claim, func(k string) error { + a, err := address.NewFromBytes([]byte(k)) + if err != nil { + return err + } + return cb(a, Claim{ + RawBytePower: claim.RawBytePower, + QualityAdjPower: claim.QualityAdjPower, + }) + }) +} + +func (s *state13) ClaimsChanged(other State) (bool, error) { + other13, ok := other.(*state13) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + return !s.State.Claims.Equals(other13.State.Claims), nil +} + +func (s *state13) SetTotalQualityAdjPower(p abi.StoragePower) error { + s.State.TotalQualityAdjPower = p + return nil +} + +func (s *state13) SetTotalRawBytePower(p abi.StoragePower) error { + s.State.TotalRawBytePower = p + return nil +} + +func (s *state13) SetThisEpochQualityAdjPower(p abi.StoragePower) error { + s.State.ThisEpochQualityAdjPower = p + return nil +} + +func (s *state13) SetThisEpochRawBytePower(p abi.StoragePower) error { + s.State.ThisEpochRawBytePower = p + return nil +} + +func (s *state13) GetState() interface{} { + return &s.State +} + +func (s *state13) claims() (adt.Map, error) { + return adt13.AsMap(s.store, s.Claims, builtin13.DefaultHamtBitwidth) +} + +func (s *state13) decodeClaim(val *cbg.Deferred) (Claim, error) { + var ci power13.Claim + if err := ci.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { + return Claim{}, err + } + return fromV13Claim(ci), nil +} + +func fromV13Claim(v13 power13.Claim) Claim { + return Claim{ + RawBytePower: v13.RawBytePower, + QualityAdjPower: v13.QualityAdjPower, + } +} + +func (s *state13) ActorKey() string { + return manifest.PowerKey +} + +func (s *state13) ActorVersion() actorstypes.Version { + return actorstypes.Version13 +} + +func (s *state13) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/registry.go b/chain/actors/builtin/registry.go index 6ba5fef03..93768580b 100644 --- a/chain/actors/builtin/registry.go +++ b/chain/actors/builtin/registry.go @@ -58,6 +58,22 @@ import ( reward12 "github.com/filecoin-project/go-state-types/builtin/v12/reward" system12 "github.com/filecoin-project/go-state-types/builtin/v12/system" verifreg12 "github.com/filecoin-project/go-state-types/builtin/v12/verifreg" + account13 "github.com/filecoin-project/go-state-types/builtin/v13/account" + cron13 "github.com/filecoin-project/go-state-types/builtin/v13/cron" + datacap13 "github.com/filecoin-project/go-state-types/builtin/v13/datacap" + eam13 "github.com/filecoin-project/go-state-types/builtin/v13/eam" + ethaccount13 "github.com/filecoin-project/go-state-types/builtin/v13/ethaccount" + evm13 "github.com/filecoin-project/go-state-types/builtin/v13/evm" + _init13 "github.com/filecoin-project/go-state-types/builtin/v13/init" + market13 "github.com/filecoin-project/go-state-types/builtin/v13/market" + miner13 "github.com/filecoin-project/go-state-types/builtin/v13/miner" + multisig13 "github.com/filecoin-project/go-state-types/builtin/v13/multisig" + paych13 "github.com/filecoin-project/go-state-types/builtin/v13/paych" + placeholder13 "github.com/filecoin-project/go-state-types/builtin/v13/placeholder" + power13 "github.com/filecoin-project/go-state-types/builtin/v13/power" + reward13 "github.com/filecoin-project/go-state-types/builtin/v13/reward" + system13 "github.com/filecoin-project/go-state-types/builtin/v13/system" + verifreg13 "github.com/filecoin-project/go-state-types/builtin/v13/verifreg" account8 "github.com/filecoin-project/go-state-types/builtin/v8/account" cron8 "github.com/filecoin-project/go-state-types/builtin/v8/cron" _init8 "github.com/filecoin-project/go-state-types/builtin/v8/init" @@ -617,6 +633,110 @@ func MakeRegistry(av actorstypes.Version) []RegistryEntry { } } + case actorstypes.Version13: + for key, codeID := range codeIDs { + switch key { + case manifest.AccountKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: account13.Methods, + state: new(account13.State), + }) + case manifest.CronKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: cron13.Methods, + state: new(cron13.State), + }) + case manifest.InitKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: _init13.Methods, + state: new(_init13.State), + }) + case manifest.MarketKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: market13.Methods, + state: new(market13.State), + }) + case manifest.MinerKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: miner13.Methods, + state: new(miner13.State), + }) + case manifest.MultisigKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: multisig13.Methods, + state: new(multisig13.State), + }) + case manifest.PaychKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: paych13.Methods, + state: new(paych13.State), + }) + case manifest.PowerKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: power13.Methods, + state: new(power13.State), + }) + case manifest.RewardKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: reward13.Methods, + state: new(reward13.State), + }) + case manifest.SystemKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: system13.Methods, + state: new(system13.State), + }) + case manifest.VerifregKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: verifreg13.Methods, + state: new(verifreg13.State), + }) + case manifest.DatacapKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: datacap13.Methods, + state: new(datacap13.State), + }) + + case manifest.EvmKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: evm13.Methods, + state: new(evm13.State), + }) + case manifest.EamKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: eam13.Methods, + state: nil, + }) + case manifest.PlaceholderKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: placeholder13.Methods, + state: nil, + }) + case manifest.EthAccountKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: ethaccount13.Methods, + state: nil, + }) + + } + } + default: panic("expected version v8 and up only, use specs-actors for v0-7") } diff --git a/chain/actors/builtin/reward/reward.go b/chain/actors/builtin/reward/reward.go index 3c6463645..a6c8bff5b 100644 --- a/chain/actors/builtin/reward/reward.go +++ b/chain/actors/builtin/reward/reward.go @@ -6,7 +6,7 @@ import ( "github.com/filecoin-project/go-state-types/abi" actorstypes "github.com/filecoin-project/go-state-types/actors" - builtin12 "github.com/filecoin-project/go-state-types/builtin" + builtin13 "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/go-state-types/cbor" "github.com/filecoin-project/go-state-types/manifest" builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" @@ -25,8 +25,8 @@ import ( ) var ( - Address = builtin12.RewardActorAddr - Methods = builtin12.MethodsReward + Address = builtin13.RewardActorAddr + Methods = builtin13.MethodsReward ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -52,6 +52,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actorstypes.Version12: return load12(store, act.Head) + case actorstypes.Version13: + return load13(store, act.Head) + } } @@ -122,6 +125,9 @@ func MakeState(store adt.Store, av actorstypes.Version, currRealizedPower abi.St case actorstypes.Version12: return make12(store, currRealizedPower) + case actorstypes.Version13: + return make13(store, currRealizedPower) + } return nil, xerrors.Errorf("unknown actor version %d", av) } @@ -166,5 +172,6 @@ func AllCodes() []cid.Cid { (&state10{}).Code(), (&state11{}).Code(), (&state12{}).Code(), + (&state13{}).Code(), } } diff --git a/chain/actors/builtin/reward/v13.go b/chain/actors/builtin/reward/v13.go new file mode 100644 index 000000000..e8d343cab --- /dev/null +++ b/chain/actors/builtin/reward/v13.go @@ -0,0 +1,120 @@ +package reward + +import ( + "fmt" + + "github.com/ipfs/go-cid" + + "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" + miner13 "github.com/filecoin-project/go-state-types/builtin/v13/miner" + reward13 "github.com/filecoin-project/go-state-types/builtin/v13/reward" + smoothing13 "github.com/filecoin-project/go-state-types/builtin/v13/util/smoothing" + "github.com/filecoin-project/go-state-types/manifest" + + "github.com/filecoin-project/lotus/chain/actors" + "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/chain/actors/builtin" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make13(store adt.Store, currRealizedPower abi.StoragePower) (State, error) { + out := state13{store: store} + out.State = *reward13.ConstructState(currRealizedPower) + return &out, nil +} + +type state13 struct { + reward13.State + store adt.Store +} + +func (s *state13) ThisEpochReward() (abi.TokenAmount, error) { + return s.State.ThisEpochReward, nil +} + +func (s *state13) ThisEpochRewardSmoothed() (builtin.FilterEstimate, error) { + + return builtin.FilterEstimate{ + PositionEstimate: s.State.ThisEpochRewardSmoothed.PositionEstimate, + VelocityEstimate: s.State.ThisEpochRewardSmoothed.VelocityEstimate, + }, nil + +} + +func (s *state13) ThisEpochBaselinePower() (abi.StoragePower, error) { + return s.State.ThisEpochBaselinePower, nil +} + +func (s *state13) TotalStoragePowerReward() (abi.TokenAmount, error) { + return s.State.TotalStoragePowerReward, nil +} + +func (s *state13) EffectiveBaselinePower() (abi.StoragePower, error) { + return s.State.EffectiveBaselinePower, nil +} + +func (s *state13) EffectiveNetworkTime() (abi.ChainEpoch, error) { + return s.State.EffectiveNetworkTime, nil +} + +func (s *state13) CumsumBaseline() (reward13.Spacetime, error) { + return s.State.CumsumBaseline, nil +} + +func (s *state13) CumsumRealized() (reward13.Spacetime, error) { + return s.State.CumsumRealized, nil +} + +func (s *state13) InitialPledgeForPower(qaPower abi.StoragePower, networkTotalPledge abi.TokenAmount, networkQAPower *builtin.FilterEstimate, circSupply abi.TokenAmount) (abi.TokenAmount, error) { + return miner13.InitialPledgeForPower( + qaPower, + s.State.ThisEpochBaselinePower, + s.State.ThisEpochRewardSmoothed, + smoothing13.FilterEstimate{ + PositionEstimate: networkQAPower.PositionEstimate, + VelocityEstimate: networkQAPower.VelocityEstimate, + }, + circSupply, + ), nil +} + +func (s *state13) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate, sectorWeight abi.StoragePower) (abi.TokenAmount, error) { + return miner13.PreCommitDepositForPower(s.State.ThisEpochRewardSmoothed, + smoothing13.FilterEstimate{ + PositionEstimate: networkQAPower.PositionEstimate, + VelocityEstimate: networkQAPower.VelocityEstimate, + }, + sectorWeight), nil +} + +func (s *state13) GetState() interface{} { + return &s.State +} + +func (s *state13) ActorKey() string { + return manifest.RewardKey +} + +func (s *state13) ActorVersion() actorstypes.Version { + return actorstypes.Version13 +} + +func (s *state13) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/system/system.go b/chain/actors/builtin/system/system.go index 2a2b703bb..1526a1fc0 100644 --- a/chain/actors/builtin/system/system.go +++ b/chain/actors/builtin/system/system.go @@ -5,7 +5,7 @@ import ( "golang.org/x/xerrors" actorstypes "github.com/filecoin-project/go-state-types/actors" - builtin12 "github.com/filecoin-project/go-state-types/builtin" + builtin13 "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/go-state-types/manifest" builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" @@ -21,7 +21,7 @@ import ( ) var ( - Address = builtin12.SystemActorAddr + Address = builtin13.SystemActorAddr ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -47,6 +47,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actorstypes.Version12: return load12(store, act.Head) + case actorstypes.Version13: + return load13(store, act.Head) + } } @@ -117,6 +120,9 @@ func MakeState(store adt.Store, av actorstypes.Version, builtinActors cid.Cid) ( case actorstypes.Version12: return make12(store, builtinActors) + case actorstypes.Version13: + return make13(store, builtinActors) + } return nil, xerrors.Errorf("unknown actor version %d", av) } @@ -145,5 +151,6 @@ func AllCodes() []cid.Cid { (&state10{}).Code(), (&state11{}).Code(), (&state12{}).Code(), + (&state13{}).Code(), } } diff --git a/chain/actors/builtin/system/v13.go b/chain/actors/builtin/system/v13.go new file mode 100644 index 000000000..8facf0033 --- /dev/null +++ b/chain/actors/builtin/system/v13.go @@ -0,0 +1,72 @@ +package system + +import ( + "fmt" + + "github.com/ipfs/go-cid" + + actorstypes "github.com/filecoin-project/go-state-types/actors" + system13 "github.com/filecoin-project/go-state-types/builtin/v13/system" + "github.com/filecoin-project/go-state-types/manifest" + + "github.com/filecoin-project/lotus/chain/actors" + "github.com/filecoin-project/lotus/chain/actors/adt" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make13(store adt.Store, builtinActors cid.Cid) (State, error) { + out := state13{store: store} + out.State = system13.State{ + BuiltinActors: builtinActors, + } + return &out, nil +} + +type state13 struct { + system13.State + store adt.Store +} + +func (s *state13) GetState() interface{} { + return &s.State +} + +func (s *state13) GetBuiltinActors() cid.Cid { + + return s.State.BuiltinActors + +} + +func (s *state13) SetBuiltinActors(c cid.Cid) error { + + s.State.BuiltinActors = c + return nil + +} + +func (s *state13) ActorKey() string { + return manifest.SystemKey +} + +func (s *state13) ActorVersion() actorstypes.Version { + return actorstypes.Version13 +} + +func (s *state13) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/verifreg/v13.go b/chain/actors/builtin/verifreg/v13.go new file mode 100644 index 000000000..977f22137 --- /dev/null +++ b/chain/actors/builtin/verifreg/v13.go @@ -0,0 +1,170 @@ +package verifreg + +import ( + "fmt" + + "github.com/ipfs/go-cid" + "golang.org/x/xerrors" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/filecoin-project/go-state-types/big" + builtin13 "github.com/filecoin-project/go-state-types/builtin" + adt13 "github.com/filecoin-project/go-state-types/builtin/v13/util/adt" + verifreg13 "github.com/filecoin-project/go-state-types/builtin/v13/verifreg" + verifreg9 "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" + "github.com/filecoin-project/go-state-types/manifest" + + "github.com/filecoin-project/lotus/chain/actors" + "github.com/filecoin-project/lotus/chain/actors/adt" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make13(store adt.Store, rootKeyAddress address.Address) (State, error) { + out := state13{store: store} + + s, err := verifreg13.ConstructState(store, rootKeyAddress) + if err != nil { + return nil, err + } + + out.State = *s + + return &out, nil +} + +type state13 struct { + verifreg13.State + store adt.Store +} + +func (s *state13) RootKey() (address.Address, error) { + return s.State.RootKey, nil +} + +func (s *state13) VerifiedClientDataCap(addr address.Address) (bool, abi.StoragePower, error) { + + return false, big.Zero(), xerrors.Errorf("unsupported in actors v13") + +} + +func (s *state13) VerifierDataCap(addr address.Address) (bool, abi.StoragePower, error) { + return getDataCap(s.store, actors.Version13, s.verifiers, addr) +} + +func (s *state13) RemoveDataCapProposalID(verifier address.Address, client address.Address) (bool, uint64, error) { + return getRemoveDataCapProposalID(s.store, actors.Version13, s.removeDataCapProposalIDs, verifier, client) +} + +func (s *state13) ForEachVerifier(cb func(addr address.Address, dcap abi.StoragePower) error) error { + return forEachCap(s.store, actors.Version13, s.verifiers, cb) +} + +func (s *state13) ForEachClient(cb func(addr address.Address, dcap abi.StoragePower) error) error { + + return xerrors.Errorf("unsupported in actors v13") + +} + +func (s *state13) verifiedClients() (adt.Map, error) { + + return nil, xerrors.Errorf("unsupported in actors v13") + +} + +func (s *state13) verifiers() (adt.Map, error) { + return adt13.AsMap(s.store, s.Verifiers, builtin13.DefaultHamtBitwidth) +} + +func (s *state13) removeDataCapProposalIDs() (adt.Map, error) { + return adt13.AsMap(s.store, s.RemoveDataCapProposalIDs, builtin13.DefaultHamtBitwidth) +} + +func (s *state13) GetState() interface{} { + return &s.State +} + +func (s *state13) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*Allocation, bool, error) { + + alloc, ok, err := s.FindAllocation(s.store, clientIdAddr, verifreg13.AllocationId(allocationId)) + return (*Allocation)(alloc), ok, err +} + +func (s *state13) GetAllocations(clientIdAddr address.Address) (map[AllocationId]Allocation, error) { + + v13Map, err := s.LoadAllocationsToMap(s.store, clientIdAddr) + + retMap := make(map[AllocationId]Allocation, len(v13Map)) + for k, v := range v13Map { + retMap[AllocationId(k)] = Allocation(v) + } + + return retMap, err + +} + +func (s *state13) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*Claim, bool, error) { + + claim, ok, err := s.FindClaim(s.store, providerIdAddr, verifreg13.ClaimId(claimId)) + return (*Claim)(claim), ok, err + +} + +func (s *state13) GetClaims(providerIdAddr address.Address) (map[ClaimId]Claim, error) { + + v13Map, err := s.LoadClaimsToMap(s.store, providerIdAddr) + + retMap := make(map[ClaimId]Claim, len(v13Map)) + for k, v := range v13Map { + retMap[ClaimId(k)] = Claim(v) + } + + return retMap, err + +} + +func (s *state13) GetClaimIdsBySector(providerIdAddr address.Address) (map[abi.SectorNumber][]ClaimId, error) { + + v13Map, err := s.LoadClaimsToMap(s.store, providerIdAddr) + + retMap := make(map[abi.SectorNumber][]ClaimId) + for k, v := range v13Map { + claims, ok := retMap[v.Sector] + if !ok { + retMap[v.Sector] = []ClaimId{ClaimId(k)} + } else { + retMap[v.Sector] = append(claims, ClaimId(k)) + } + } + + return retMap, err + +} + +func (s *state13) ActorKey() string { + return manifest.VerifregKey +} + +func (s *state13) ActorVersion() actorstypes.Version { + return actorstypes.Version13 +} + +func (s *state13) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/verifreg/verifreg.go b/chain/actors/builtin/verifreg/verifreg.go index de906f521..4c1e66eb5 100644 --- a/chain/actors/builtin/verifreg/verifreg.go +++ b/chain/actors/builtin/verifreg/verifreg.go @@ -7,7 +7,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" actorstypes "github.com/filecoin-project/go-state-types/actors" - builtin12 "github.com/filecoin-project/go-state-types/builtin" + builtin13 "github.com/filecoin-project/go-state-types/builtin" verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" "github.com/filecoin-project/go-state-types/cbor" "github.com/filecoin-project/go-state-types/manifest" @@ -25,8 +25,8 @@ import ( ) var ( - Address = builtin12.VerifiedRegistryActorAddr - Methods = builtin12.MethodsVerifiedRegistry + Address = builtin13.VerifiedRegistryActorAddr + Methods = builtin13.MethodsVerifiedRegistry ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -52,6 +52,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actorstypes.Version12: return load12(store, act.Head) + case actorstypes.Version13: + return load13(store, act.Head) + } } @@ -122,6 +125,9 @@ func MakeState(store adt.Store, av actorstypes.Version, rootKeyAddress address.A case actorstypes.Version12: return make12(store, rootKeyAddress) + case actorstypes.Version13: + return make13(store, rootKeyAddress) + } return nil, xerrors.Errorf("unknown actor version %d", av) } @@ -161,6 +167,7 @@ func AllCodes() []cid.Cid { (&state10{}).Code(), (&state11{}).Code(), (&state12{}).Code(), + (&state13{}).Code(), } } diff --git a/chain/actors/policy/policy.go b/chain/actors/policy/policy.go index 6d2b41154..b8d23903c 100644 --- a/chain/actors/policy/policy.go +++ b/chain/actors/policy/policy.go @@ -9,6 +9,7 @@ import ( builtin10 "github.com/filecoin-project/go-state-types/builtin" builtin11 "github.com/filecoin-project/go-state-types/builtin" builtin12 "github.com/filecoin-project/go-state-types/builtin" + builtin13 "github.com/filecoin-project/go-state-types/builtin" builtin8 "github.com/filecoin-project/go-state-types/builtin" builtin9 "github.com/filecoin-project/go-state-types/builtin" market10 "github.com/filecoin-project/go-state-types/builtin/v10/market" @@ -19,8 +20,11 @@ import ( verifreg11 "github.com/filecoin-project/go-state-types/builtin/v11/verifreg" market12 "github.com/filecoin-project/go-state-types/builtin/v12/market" miner12 "github.com/filecoin-project/go-state-types/builtin/v12/miner" - paych12 "github.com/filecoin-project/go-state-types/builtin/v12/paych" verifreg12 "github.com/filecoin-project/go-state-types/builtin/v12/verifreg" + market13 "github.com/filecoin-project/go-state-types/builtin/v13/market" + miner13 "github.com/filecoin-project/go-state-types/builtin/v13/miner" + paych13 "github.com/filecoin-project/go-state-types/builtin/v13/paych" + verifreg13 "github.com/filecoin-project/go-state-types/builtin/v13/verifreg" market8 "github.com/filecoin-project/go-state-types/builtin/v8/market" miner8 "github.com/filecoin-project/go-state-types/builtin/v8/miner" verifreg8 "github.com/filecoin-project/go-state-types/builtin/v8/verifreg" @@ -59,14 +63,14 @@ import ( ) const ( - ChainFinality = miner12.ChainFinality + ChainFinality = miner13.ChainFinality SealRandomnessLookback = ChainFinality - PaychSettleDelay = paych12.SettleDelay - MaxPreCommitRandomnessLookback = builtin12.EpochsInDay + SealRandomnessLookback + PaychSettleDelay = paych13.SettleDelay + MaxPreCommitRandomnessLookback = builtin13.EpochsInDay + SealRandomnessLookback ) var ( - MarketDefaultAllocationTermBuffer = market12.MarketDefaultAllocationTermBuffer + MarketDefaultAllocationTermBuffer = market13.MarketDefaultAllocationTermBuffer ) // SetSupportedProofTypes sets supported proof types, across all actor versions. @@ -181,11 +185,13 @@ func SetPreCommitChallengeDelay(delay abi.ChainEpoch) { miner12.PreCommitChallengeDelay = delay + miner13.PreCommitChallengeDelay = delay + } // TODO: this function shouldn't really exist. Instead, the API should expose the precommit delay. func GetPreCommitChallengeDelay() abi.ChainEpoch { - return miner12.PreCommitChallengeDelay + return miner13.PreCommitChallengeDelay } // SetConsensusMinerMinPower sets the minimum power of an individual miner must @@ -239,6 +245,10 @@ func SetConsensusMinerMinPower(p abi.StoragePower) { policy.ConsensusMinerMinPower = p } + for _, policy := range builtin13.PoStProofPolicies { + policy.ConsensusMinerMinPower = p + } + } // SetMinVerifiedDealSize sets the minimum size of a verified deal. This should @@ -269,6 +279,8 @@ func SetMinVerifiedDealSize(size abi.StoragePower) { verifreg12.MinVerifiedDealSize = size + verifreg13.MinVerifiedDealSize = size + } func GetMaxProveCommitDuration(ver actorstypes.Version, t abi.RegisteredSealProof) (abi.ChainEpoch, error) { @@ -322,6 +334,10 @@ func GetMaxProveCommitDuration(ver actorstypes.Version, t abi.RegisteredSealProo return miner12.MaxProveCommitDuration[t], nil + case actorstypes.Version13: + + return miner13.MaxProveCommitDuration[t], nil + default: return 0, xerrors.Errorf("unsupported actors version") } @@ -387,6 +403,11 @@ func SetProviderCollateralSupplyTarget(num, denom big.Int) { Denominator: denom, } + market13.ProviderCollateralSupplyTarget = builtin13.BigFrac{ + Numerator: num, + Denominator: denom, + } + } func DealProviderCollateralBounds( @@ -460,13 +481,18 @@ func DealProviderCollateralBounds( min, max := market12.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) return min, max, nil + case actorstypes.Version13: + + min, max := market13.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) + return min, max, nil + default: return big.Zero(), big.Zero(), xerrors.Errorf("unsupported actors version") } } func DealDurationBounds(pieceSize abi.PaddedPieceSize) (min, max abi.ChainEpoch) { - return market12.DealDurationBounds(pieceSize) + return market13.DealDurationBounds(pieceSize) } // Sets the challenge window and scales the proving period to match (such that @@ -549,6 +575,13 @@ func SetWPoStChallengeWindow(period abi.ChainEpoch) { // scale it if we're scaling the challenge period. miner12.WPoStDisputeWindow = period * 30 + miner13.WPoStChallengeWindow = period + miner13.WPoStProvingPeriod = period * abi.ChainEpoch(miner13.WPoStPeriodDeadlines) + + // by default, this is 2x finality which is 30 periods. + // scale it if we're scaling the challenge period. + miner13.WPoStDisputeWindow = period * 30 + } func GetWinningPoStSectorSetLookback(nwVer network.Version) abi.ChainEpoch { @@ -603,6 +636,9 @@ func GetMaxSectorExpirationExtension(nv network.Version) (abi.ChainEpoch, error) case actorstypes.Version12: return miner12.MaxSectorExpirationExtension, nil + case actorstypes.Version13: + return miner13.MaxSectorExpirationExtension, nil + default: return 0, xerrors.Errorf("unsupported network version") } @@ -610,11 +646,11 @@ func GetMaxSectorExpirationExtension(nv network.Version) (abi.ChainEpoch, error) } func GetMinSectorExpiration() abi.ChainEpoch { - return miner12.MinSectorExpiration + return miner13.MinSectorExpiration } func GetMaxPoStPartitions(nv network.Version, p abi.RegisteredPoStProof) (int, error) { - sectorsPerPart, err := builtin12.PoStProofWindowPoStPartitionSectors(p) + sectorsPerPart, err := builtin13.PoStProofWindowPoStPartitionSectors(p) if err != nil { return 0, err } @@ -623,7 +659,7 @@ func GetMaxPoStPartitions(nv network.Version, p abi.RegisteredPoStProof) (int, e return 0, err } - return min(miner12.PoStedPartitionsMax, int(uint64(maxSectors)/sectorsPerPart)), nil + return min(miner13.PoStedPartitionsMax, int(uint64(maxSectors)/sectorsPerPart)), nil } func GetDefaultAggregationProof() abi.RegisteredAggregationProof { @@ -635,7 +671,7 @@ func GetSectorMaxLifetime(proof abi.RegisteredSealProof, nwVer network.Version) return builtin4.SealProofPoliciesV0[proof].SectorMaxLifetime } - return builtin12.SealProofPoliciesV11[proof].SectorMaxLifetime + return builtin13.SealProofPoliciesV11[proof].SectorMaxLifetime } func GetAddressedSectorsMax(nwVer network.Version) (int, error) { @@ -681,6 +717,9 @@ func GetAddressedSectorsMax(nwVer network.Version) (int, error) { case actorstypes.Version12: return miner12.AddressedSectorsMax, nil + case actorstypes.Version13: + return miner13.AddressedSectorsMax, nil + default: return 0, xerrors.Errorf("unsupported network version") } @@ -742,6 +781,10 @@ func GetDeclarationsMax(nwVer network.Version) (int, error) { return miner12.DeclarationsMax, nil + case actorstypes.Version13: + + return miner13.DeclarationsMax, nil + default: return 0, xerrors.Errorf("unsupported network version") } @@ -802,6 +845,10 @@ func AggregateProveCommitNetworkFee(nwVer network.Version, aggregateSize int, ba return miner12.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil + case actorstypes.Version13: + + return miner13.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil + default: return big.Zero(), xerrors.Errorf("unsupported network version") } @@ -862,6 +909,10 @@ func AggregatePreCommitNetworkFee(nwVer network.Version, aggregateSize int, base return miner12.AggregatePreCommitNetworkFee(aggregateSize, baseFee), nil + case actorstypes.Version13: + + return miner13.AggregatePreCommitNetworkFee(aggregateSize, baseFee), nil + default: return big.Zero(), xerrors.Errorf("unsupported network version") } diff --git a/chain/actors/version.go b/chain/actors/version.go index 92c0da006..8d84bbc1d 100644 --- a/chain/actors/version.go +++ b/chain/actors/version.go @@ -14,9 +14,9 @@ const ({{range .actorVersions}} /* inline-gen start */ -var LatestVersion = 12 +var LatestVersion = 13 -var Versions = []int{0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} +var Versions = []int{0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13} const ( Version0 Version = 0 @@ -31,6 +31,7 @@ const ( Version10 Version = 10 Version11 Version = 11 Version12 Version = 12 + Version13 Version = 13 ) /* inline-gen end */ diff --git a/chain/consensus/compute_state.go b/chain/consensus/compute_state.go index 4b993b3e7..78369ec20 100644 --- a/chain/consensus/compute_state.go +++ b/chain/consensus/compute_state.go @@ -53,6 +53,7 @@ func NewActorRegistry() *vm.ActorRegistry { inv.Register(actorstypes.Version10, vm.ActorsVersionPredicate(actorstypes.Version10), builtin.MakeRegistry(actorstypes.Version10)) inv.Register(actorstypes.Version11, vm.ActorsVersionPredicate(actorstypes.Version11), builtin.MakeRegistry(actorstypes.Version11)) inv.Register(actorstypes.Version12, vm.ActorsVersionPredicate(actorstypes.Version12), builtin.MakeRegistry(actorstypes.Version12)) + inv.Register(actorstypes.Version13, vm.ActorsVersionPredicate(actorstypes.Version13), builtin.MakeRegistry(actorstypes.Version13)) return inv } diff --git a/chain/consensus/filcns/upgrades.go b/chain/consensus/filcns/upgrades.go index d7e0914fe..d0030efff 100644 --- a/chain/consensus/filcns/upgrades.go +++ b/chain/consensus/filcns/upgrades.go @@ -24,6 +24,7 @@ import ( nv19 "github.com/filecoin-project/go-state-types/builtin/v11/migration" system11 "github.com/filecoin-project/go-state-types/builtin/v11/system" nv21 "github.com/filecoin-project/go-state-types/builtin/v12/migration" + nv22 "github.com/filecoin-project/go-state-types/builtin/v13/migration" nv17 "github.com/filecoin-project/go-state-types/builtin/v9/migration" "github.com/filecoin-project/go-state-types/manifest" "github.com/filecoin-project/go-state-types/migration" @@ -280,12 +281,22 @@ func DefaultUpgradeSchedule() stmgr.UpgradeSchedule { Height: build.UpgradeWatermelonFixHeight, Network: network.Version21, Migration: buildUpgradeActorsV12MinerFix(calibnetv12BuggyMinerCID1, calibnetv12BuggyManifestCID2), + }, { + Height: build.UpgradeWatermelonFix2Height, + Network: network.Version21, + Migration: buildUpgradeActorsV12MinerFix(calibnetv12BuggyMinerCID2, calibnetv12CorrectManifestCID1), + }, { + Height: build.UpgradePineappleHeight, + Network: network.Version22, + Migration: UpgradeActorsV13, + PreMigrations: []stmgr.PreMigration{{ + PreMigration: PreUpgradeActorsV13, + StartWithin: 120, + DontStartWithin: 15, + StopWithin: 10, + }}, + Expensive: true, }, - { - Height: build.UpgradeWatermelonFix2Height, - Network: network.Version21, - Migration: buildUpgradeActorsV12MinerFix(calibnetv12BuggyMinerCID2, calibnetv12CorrectManifestCID1), - }, } for _, u := range updates { @@ -2146,6 +2157,108 @@ func buildUpgradeActorsV12MinerFix(oldBuggyMinerCID, newManifestCID cid.Cid) fun } } +func PreUpgradeActorsV13(ctx context.Context, sm *stmgr.StateManager, cache stmgr.MigrationCache, root cid.Cid, epoch abi.ChainEpoch, ts *types.TipSet) error { + // Use half the CPUs for pre-migration, but leave at least 3. + workerCount := MigrationMaxWorkerCount + if workerCount <= 4 { + workerCount = 1 + } else { + workerCount /= 2 + } + + lbts, lbRoot, err := stmgr.GetLookbackTipSetForRound(ctx, sm, ts, epoch) + if err != nil { + return xerrors.Errorf("error getting lookback ts for premigration: %w", err) + } + + config := migration.Config{ + MaxWorkers: uint(workerCount), + ProgressLogPeriod: time.Minute * 5, + } + + _, err = upgradeActorsV13Common(ctx, sm, cache, lbRoot, epoch, lbts, config) + return err +} + +func UpgradeActorsV13(ctx context.Context, sm *stmgr.StateManager, cache stmgr.MigrationCache, cb stmgr.ExecMonitor, + root cid.Cid, epoch abi.ChainEpoch, ts *types.TipSet) (cid.Cid, error) { + // Use all the CPUs except 2. + workerCount := MigrationMaxWorkerCount - 3 + if workerCount <= 0 { + workerCount = 1 + } + config := migration.Config{ + MaxWorkers: uint(workerCount), + JobQueueSize: 1000, + ResultQueueSize: 100, + ProgressLogPeriod: 10 * time.Second, + } + newRoot, err := upgradeActorsV13Common(ctx, sm, cache, root, epoch, ts, config) + if err != nil { + return cid.Undef, xerrors.Errorf("migrating actors v11 state: %w", err) + } + return newRoot, nil +} + +func upgradeActorsV13Common( + ctx context.Context, sm *stmgr.StateManager, cache stmgr.MigrationCache, + root cid.Cid, epoch abi.ChainEpoch, ts *types.TipSet, + config migration.Config, +) (cid.Cid, error) { + writeStore := blockstore.NewAutobatch(ctx, sm.ChainStore().StateBlockstore(), units.GiB/4) + adtStore := store.ActorStore(ctx, writeStore) + // ensure that the manifest is loaded in the blockstore + if err := bundle.LoadBundles(ctx, writeStore, actorstypes.Version13); err != nil { + return cid.Undef, xerrors.Errorf("failed to load manifest bundle: %w", err) + } + + // Load the state root. + var stateRoot types.StateRoot + if err := adtStore.Get(ctx, root, &stateRoot); err != nil { + return cid.Undef, xerrors.Errorf("failed to decode state root: %w", err) + } + + if stateRoot.Version != types.StateTreeVersion5 { + return cid.Undef, xerrors.Errorf( + "expected state root version 5 for actors v13 upgrade, got %d", + stateRoot.Version, + ) + } + + manifest, ok := actors.GetManifest(actorstypes.Version13) + if !ok { + return cid.Undef, xerrors.Errorf("no manifest CID for v13 upgrade") + } + + // Perform the migration + newHamtRoot, err := nv22.MigrateStateTree(ctx, adtStore, manifest, stateRoot.Actors, epoch, config, + migrationLogger{}, cache) + if err != nil { + return cid.Undef, xerrors.Errorf("upgrading to actors v11: %w", err) + } + + // Persist the result. + newRoot, err := adtStore.Put(ctx, &types.StateRoot{ + Version: types.StateTreeVersion5, + Actors: newHamtRoot, + Info: stateRoot.Info, + }) + if err != nil { + return cid.Undef, xerrors.Errorf("failed to persist new state root: %w", err) + } + + // Persists the new tree and shuts down the flush worker + if err := writeStore.Flush(ctx); err != nil { + return cid.Undef, xerrors.Errorf("writeStore flush failed: %w", err) + } + + if err := writeStore.Shutdown(ctx); err != nil { + return cid.Undef, xerrors.Errorf("writeStore shutdown failed: %w", err) + } + + return newRoot, nil +} + //////////////////// // Example upgrade function if upgrade requires only code changes diff --git a/chain/state/statetree.go b/chain/state/statetree.go index 61d7d500a..1a6497d04 100644 --- a/chain/state/statetree.go +++ b/chain/state/statetree.go @@ -156,7 +156,7 @@ func VersionForNetwork(ver network.Version) (types.StateTreeVersion, error) { case network.Version13, network.Version14, network.Version15, network.Version16, network.Version17: return types.StateTreeVersion4, nil - case network.Version18, network.Version19, network.Version20, network.Version21: + case network.Version18, network.Version19, network.Version20, network.Version21, network.Version22: return types.StateTreeVersion5, nil default: diff --git a/documentation/en/api-v0-methods-miner.md b/documentation/en/api-v0-methods-miner.md index 57070caed..9016d5a13 100644 --- a/documentation/en/api-v0-methods-miner.md +++ b/documentation/en/api-v0-methods-miner.md @@ -475,7 +475,7 @@ Inputs: ], "Bw==", 10101, - 21 + 22 ] ``` diff --git a/documentation/en/api-v0-methods.md b/documentation/en/api-v0-methods.md index 9110c1c3b..10b4f1f41 100644 --- a/documentation/en/api-v0-methods.md +++ b/documentation/en/api-v0-methods.md @@ -4732,7 +4732,7 @@ Perms: read Inputs: ```json [ - 21 + 22 ] ``` @@ -4747,7 +4747,7 @@ Perms: read Inputs: ```json [ - 21 + 22 ] ``` @@ -5469,7 +5469,8 @@ Response: "UpgradeHyggeHeight": 10101, "UpgradeLightningHeight": 10101, "UpgradeThunderHeight": 10101, - "UpgradeWatermelonHeight": 10101 + "UpgradeWatermelonHeight": 10101, + "UpgradePineappleHeight": 10101 }, "Eip155ChainID": 123 } @@ -6395,7 +6396,7 @@ Inputs: ] ``` -Response: `21` +Response: `22` ### 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 c2929f0f5..a43bcf1f0 100644 --- a/documentation/en/api-v1-unstable-methods.md +++ b/documentation/en/api-v1-unstable-methods.md @@ -6259,7 +6259,7 @@ Perms: read Inputs: ```json [ - 21 + 22 ] ``` @@ -6274,7 +6274,7 @@ Perms: read Inputs: ```json [ - 21 + 22 ] ``` @@ -7071,7 +7071,8 @@ Response: "UpgradeHyggeHeight": 10101, "UpgradeLightningHeight": 10101, "UpgradeThunderHeight": 10101, - "UpgradeWatermelonHeight": 10101 + "UpgradeWatermelonHeight": 10101, + "UpgradePineappleHeight": 10101 }, "Eip155ChainID": 123 } @@ -8051,7 +8052,7 @@ Inputs: ] ``` -Response: `21` +Response: `22` ### StateReadState StateReadState returns the indicated actor's state. diff --git a/gen/inlinegen-data.json b/gen/inlinegen-data.json index cf72d24fa..70c8fff61 100644 --- a/gen/inlinegen-data.json +++ b/gen/inlinegen-data.json @@ -1,7 +1,7 @@ { - "actorVersions": [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], - "latestActorsVersion": 12, + "actorVersions": [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], + "latestActorsVersion": 13, - "networkVersions": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21], - "latestNetworkVersion": 21 + "networkVersions": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22], + "latestNetworkVersion": 22 } diff --git a/go.mod b/go.mod index 51ef2d4b0..7893d053b 100644 --- a/go.mod +++ b/go.mod @@ -45,7 +45,7 @@ require ( github.com/filecoin-project/go-jsonrpc v0.3.1 github.com/filecoin-project/go-padreader v0.0.1 github.com/filecoin-project/go-paramfetch v0.0.4 - github.com/filecoin-project/go-state-types v0.12.8 + github.com/filecoin-project/go-state-types v0.12.9-0.20231205164216-231a5d9537a1 github.com/filecoin-project/go-statemachine v1.0.3 github.com/filecoin-project/go-statestore v0.2.0 github.com/filecoin-project/go-storedcounter v0.1.0 diff --git a/go.sum b/go.sum index 68b53ffc5..43eaf0207 100644 --- a/go.sum +++ b/go.sum @@ -339,8 +339,8 @@ github.com/filecoin-project/go-state-types v0.1.0/go.mod h1:ezYnPf0bNkTsDibL/psS github.com/filecoin-project/go-state-types v0.1.6/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= github.com/filecoin-project/go-state-types v0.1.10/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= github.com/filecoin-project/go-state-types v0.11.2-0.20230712101859-8f37624fa540/go.mod h1:SyNPwTsU7I22gL2r0OAPcImvLoTVfgRwdK/Y5rR1zz8= -github.com/filecoin-project/go-state-types v0.12.8 h1:W/UObdAsv+LbB9EfyLg92DSYoatzUWmlfV8FGyh30VA= -github.com/filecoin-project/go-state-types v0.12.8/go.mod h1:gR2NV0CSGSQwopxF+3In9nDh1sqvoYukLcs5vK0AHCA= +github.com/filecoin-project/go-state-types v0.12.9-0.20231205164216-231a5d9537a1 h1:XwF+/Aucg1wrYs5b/zV/m6BmKrftdGj4Ya/8iSkW0t8= +github.com/filecoin-project/go-state-types v0.12.9-0.20231205164216-231a5d9537a1/go.mod h1:gR2NV0CSGSQwopxF+3In9nDh1sqvoYukLcs5vK0AHCA= github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig= github.com/filecoin-project/go-statemachine v1.0.3 h1:N07o6alys+V1tNoSTi4WuuoeNC4erS/6jE74+NsgQuk= github.com/filecoin-project/go-statemachine v1.0.3/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54= diff --git a/itests/kit/ensemble_opts_nv.go b/itests/kit/ensemble_opts_nv.go index d5bb1930e..18b531e13 100644 --- a/itests/kit/ensemble_opts_nv.go +++ b/itests/kit/ensemble_opts_nv.go @@ -35,12 +35,12 @@ func LatestActorsAt(upgradeHeight abi.ChainEpoch) EnsembleOpt { }) /* inline-gen start */ return UpgradeSchedule(stmgr.Upgrade{ - Network: network.Version20, + Network: network.Version21, Height: -1, }, stmgr.Upgrade{ - Network: network.Version21, + Network: network.Version22, Height: upgradeHeight, - Migration: filcns.UpgradeActorsV12, + Migration: filcns.UpgradeActorsV13, }) /* inline-gen end */ } diff --git a/node/impl/full/state.go b/node/impl/full/state.go index 0e92c8e5b..03b6ef6cc 100644 --- a/node/impl/full/state.go +++ b/node/impl/full/state.go @@ -1914,6 +1914,7 @@ func (a *StateAPI) StateGetNetworkParams(ctx context.Context) (*api.NetworkParam UpgradeLightningHeight: build.UpgradeLightningHeight, UpgradeThunderHeight: build.UpgradeThunderHeight, UpgradeWatermelonHeight: build.UpgradeWatermelonHeight, + UpgradePineappleHeight: build.UpgradePineappleHeight, }, }, nil }